Commit eac22587 authored by 周健威's avatar 周健威

Merge branch 'master' into feature-delay-add

parents 728cf4e0 f822922e
......@@ -10,7 +10,7 @@ ace-modules/ace-tool/src/main/resources/application-dev.yml
**/src/test
**/logs
xx-order/xx-order-server/logs/**
xx-order/xx-order-server/src/test/java/**
xx-order/xx-order-server/src/test/**
*.log
logs/**
/src/main/test/**
......
......@@ -6,21 +6,28 @@ import com.github.wxiaoqi.security.common.exception.auth.ClientTokenException;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.exception.auth.UserTokenException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import com.github.wxiaoqi.security.common.util.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static org.springframework.http.HttpStatus.NOT_EXTENDED;
......@@ -31,7 +38,8 @@ import static org.springframework.http.HttpStatus.NOT_EXTENDED;
@ResponseBody
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@Value("${spring.application.name}")
private String applicationName;
/**
* 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的
*/
......@@ -69,7 +77,15 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
if(0 == ex.getStatus()) {
response.setStatus(500);
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", ex.toString() + ":" +ex.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
......@@ -82,10 +98,39 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
logger.error(cause.getMessage(), ex);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(5000, "Server exception: " + ex.getMessage());
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", initCommonLogPrePart()+ ":" + ex.toString() + ":" + ex.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(CommonConstants.EX_OTHER_CODE, ex.getMessage());
}
public String initCommonLogPrePart() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
StringBuilder stringBuilder = new StringBuilder();
//request 获得头部
stringBuilder.append(request.getHeader("app"));
LocalDateTime startTime= LocalDateTime.now();//开始时间
stringBuilder.append("》》" +startTime.toString());
stringBuilder.append("》》" +request.getServletPath());
stringBuilder.append("》》" +applicationName + ":" + request.getServletPath());
return stringBuilder.toString();
}
}
......@@ -4,18 +4,27 @@ package com.github.wxiaoqi.security.common.handler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import com.github.wxiaoqi.security.common.util.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice("com.xxfc.platform")
@Slf4j
public class PlatformExceptionHandler {
@Value("${spring.application.name}")
private String applicationName;
@ExceptionHandler(value = {BaseException.class})
public BaseResponse baseExceptionHandler(Exception e) {
......@@ -35,11 +44,27 @@ public class PlatformExceptionHandler {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
log.error(cause.getMessage(), e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) {
log.error(ex.getMessage());
}
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
log.error("Server exception: ", e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + e.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", initCommonLogPrePart()+ ":" + e.toString() + ":" + e.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) {
log.error(ex.getMessage());
}
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
......@@ -52,4 +77,18 @@ public class PlatformExceptionHandler {
return assembleResult(error, e.getClass().getSimpleName() + ": " + e.getMessage());
}
public String initCommonLogPrePart() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
StringBuilder stringBuilder = new StringBuilder();
//request 获得头部
stringBuilder.append(request.getHeader("app"));
LocalDateTime startTime= LocalDateTime.now();//开始时间
stringBuilder.append("》》" +startTime.toString());
stringBuilder.append("》》" +request.getServletPath());
stringBuilder.append("》》" +applicationName + ":" + request.getServletPath());
return stringBuilder.toString();
}
}
......@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.common.log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -36,7 +33,7 @@ public class XxLogInterceptor{
CommonLogService commonLogService;
//触发条件为:com.xxfc.platform包下面所有controller
@Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..*)")
@Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..* || com.github.wxiaoqi.security.admin.rest..* || com.github.wxiaoqi.security.admin.rest..*)")
public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
......@@ -60,6 +57,7 @@ public class XxLogInterceptor{
try{
//###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数
log.info("接口调用返回:{}", xxLogEntity.toString());
//###################下面代码为方法执行后#####################
if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
......
package com.github.wxiaoqi.security.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URLDecoder;
@Slf4j
public class HttpRequestUtil {
/**
* post请求
* @param url url地址
* @return
*/
public static String httpPost(String url){
//post请求返回结果
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost method = new HttpPost(url);
String str = "";
try {
HttpResponse result = httpClient.execute(method);
url = URLDecoder.decode(url, "UTF-8");
/**请求发送成功,并得到响应**/
if (result.getStatusLine().getStatusCode() == 200) {
try {
/**读取服务器返回过来的json字符串数据**/
str = EntityUtils.toString(result.getEntity(),"UTF-8");
} catch (Exception e) {
log.error("post请求提交失败:" + url, e);
}
}
} catch (IOException e) {
log.error("post请求提交失败:" + url, e);
}
return str;
}
/**
* 发送get请求
* @param url 路径
* @return
*/
public static String httpGet(String url){
//get请求返回结果
String strResult = null;
try {
DefaultHttpClient client = new DefaultHttpClient();
//发送get请求
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
/**请求发送成功,并得到响应**/
if (response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
/**读取服务器返回过来的json字符串数据**/
strResult = EntityUtils.toString(response.getEntity(),"UTF-8");
} else {
log.error("get请求提交失败:" + url);
}
} catch (IOException e) {
log.error("get请求提交失败:" + url, e);
}
return strResult;
}
}
package com.github.wxiaoqi.security.common.util;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpUtils {
//设置编码格式
String ContentType= "application/x-www-form-urlencoded; charset=UTF-8";
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path,
Map<String, String> querys
)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", ssf, 443));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
}
\ No newline at end of file
......@@ -36,4 +36,11 @@ public class UserMemberSaveDTO {
*/
@ApiModelProperty(value = "剩余天数")
private Integer rentFreeDays;
/**
* 剩余天数
*/
@ApiModelProperty(value = "剩余天数")
private Integer source;
}
package com.github.wxiaoqi.security.admin.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.Table;
......@@ -20,6 +17,7 @@ import java.io.Serializable;
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "base_user_member_export")
@ToString
public class BaseUserMemberExport implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
......@@ -42,5 +40,12 @@ public class BaseUserMemberExport implements Serializable {
private Integer crtId;
@Column(name = "member_name")
private String memberName;
@Column(name = "before_membe_level")
private Integer beforeMemberLevel;
@Column(name = "before_discount")
private Integer beforeDiscount;
@Column(name = "source")
private Integer source;
}
......@@ -95,4 +95,11 @@ public class AppUserDTO {
private Boolean isBindQQ;
//用户上线
private Integer parentId;
//用户上线身份id
private Integer parentPositionId;
//用户上线记录id
private Integer parentPositionTempId;
//用户分公司id
private Integer parentCompanyId;
}
......@@ -23,7 +23,10 @@ import tk.mybatis.spring.annotation.MapperScan;
*/
@EnableDiscoveryClient
@EnableCircuitBreaker
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {
"com.github.wxiaoqi.security.common.log",
"com.github.wxiaoqi.security.admin"
})
@EnableFeignClients(value = {"com.github.wxiaoqi.security","com.xxfc.platform"},defaultConfiguration = HeaderConfig.class)
@EnableScheduling
@EnableAceAuthClient
......
......@@ -334,5 +334,15 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
}
}
public AppUserPositionTemp getOne(Integer userId){
Example example = new Example(AppUserPositionTemp.class);
example.createCriteria().andEqualTo("userId", userId).andEqualTo("isDel", 0);
List<AppUserPositionTemp> list=selectByExample(example);
if (list.size()>0){
return list.get(0);
}
return null;
}
}
......@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.dto.UserRelationDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserRelationTemp;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.bo.InviteMemberBO;
......@@ -20,7 +18,6 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.github.wxiaoqi.security.admin.mapper.AppUserRelationMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
......@@ -57,6 +54,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
@Value("${admin.validTime}")
private Long validTime;
@Autowired
private AppUserPositionTempBiz positionTempBiz;
/**
* 关系绑定
* 规则A->B (B无有效上线+无有效下线)
......@@ -369,6 +369,15 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
parentId=relation.getParentId();
}
userDTO.setParentId(parentId);
if (parentId!=null&&parentId>0){
AppUserPositionTemp positionTemp= positionTempBiz.getOne(parentId);
if (positionTemp!=null){
userDTO.setParentPositionId(positionTemp.getPositionId());
userDTO.setParentPositionTempId(positionTemp.getId());
userDTO.setParentCompanyId(positionTemp.getCompanyId());
}
}
}
}
......@@ -4,18 +4,20 @@ import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.dto.BaseUserMemberVO;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberExport;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberLevelMapper;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberMapper;
......@@ -23,12 +25,14 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 用户会员表
......@@ -43,11 +47,25 @@ import java.util.List;
public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMember> {
@Autowired
AppUserDetailBiz detailBiz;
private AppUserDetailBiz detailBiz;
@Autowired
private BaseUserMemberLevelMapper BaseUserMemberLevelMapper;
private ExecutorService executorService = Executors.newCachedThreadPool();
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@Autowired
private BaseUserMemberExportBiz baseUserMemberExportBiz;
@Autowired
private HttpServletRequest request;
// @Autowired
// private TaskExecutor taskExecutor;
//
......@@ -224,7 +242,7 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
* @param userMemberDTO
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void UpdateUserMember(UserMemberDTO userMemberDTO) throws InvocationTargetException, IllegalAccessException {
public void UpdateUserMember(UserMemberDTO userMemberDTO) throws Exception {
Integer userId = userMemberDTO.getUserId();
BaseUserMember baseUserMember = new BaseUserMember();
......@@ -234,7 +252,6 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
if (totalNumber < freeDays) {
freeDays = totalNumber;
}
if (userMemberDTO.getMemberLevel() != null) {
Example exa = new Example(BaseUserMemberLevel.class);
Example.Criteria criteria = exa.createCriteria();
......@@ -254,6 +271,7 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
Integer buyCount = userMemberDTO.getBuyCount() == null ? 1 : userMemberDTO.getBuyCount();
UserMemberVo userMemberVo = getMemberInfoByUserId(userMemberDTO.getUserId());
//保存修改记录
if (userMemberVo == null) {
baseUserMember.setRentFreeDays(freeDays);
baseUserMember.setBuyCount(buyCount);
......@@ -277,6 +295,10 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
userVo1.setIsMember(1);
detailBiz.updUuserInfoById(userVo1);
}
log.info("保存修改记录");
setModifyData(userMemberVo,baseUserMember);
log.info("保存成功");
}
......@@ -286,4 +308,36 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
criteria.andIn("userId", userIds);
mapper.deleteByExample(example);
}
private void setModifyData(UserMemberVo beforeMember, BaseUserMember aftereMember) throws Exception {
log.info("保存修改会员记录={}",aftereMember);
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
executorService.submit(()->{
try {
AppUserVo qppUser = detailBiz.getUserInfoById(beforeMember.getUserId());
BaseUserMemberExport baseUserMemberExport = BaseUserMemberExport
.builder()
.username(qppUser.getUsername())
.beforeMemberLevel(beforeMember.getMemberLevel())
.memberLevel(aftereMember.getMemberLevel())
.totalNumber(aftereMember.getTotalNumber() - beforeMember.getTotalNumber())
.rentFreeDays(aftereMember.getRentFreeDays() - beforeMember.getRentFreeDays())
.beforeDiscount(beforeMember.getDiscount())
.discount(aftereMember.getDiscount())
.status(1)
.crtTime(System.currentTimeMillis())
.crtId(Integer.valueOf(infoFromToken.getId()))
.crtName(infoFromToken.getUniqueName())
.memberName(qppUser.getRealname())
.source(1)
.build();
baseUserMemberExportBiz.insertSelective(baseUserMemberExport);
System.out.println(baseUserMemberExport);
} catch (Exception e) {
e.printStackTrace();
log.error("保存修改会员记录失败"+e.getMessage());
}
log.info("保存修改会员记录成功");
});
}
}
\ No newline at end of file
......@@ -52,6 +52,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final int BORDER_NUM=250;
private BaseUserMemberExport baseUserMemberExport;
public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO, Integer userId, String name) {
......@@ -256,4 +257,9 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
public void updateUserMemberExportDataStatus(Integer id) {
mapper.updateUserMemberExportDataStatusById(id, 1);
}
@Override
public void insertSelective(BaseUserMemberExport baseUserMemberExport){
mapper.insertSelective(baseUserMemberExport);
}
}
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
......@@ -13,6 +14,7 @@ import java.util.List;
* @email nishijjo@qq.com
* @date 2019-06-11 11:06:45
*/
@Repository
public interface BaseUserMemberLevelMapper extends Mapper<BaseUserMemberLevel> {
List<BaseUserMemberLevel> selectUserMembersLevelByLevels(@Param("levels") List<Integer> levels);
......
......@@ -20,7 +20,8 @@
</update>
<select id="findExportDataPage" resultType="com.github.wxiaoqi.security.admin.dto.BaseUserMemberExportDTO">
select `id`,`member_level` as `memberLevel`,`member_name` as `memberName`,`rent_free_days` as `rentFreeDays`,`total_number` as `totalNumber`,`username`,`status`,`crt_name` as `crtName`,`crt_time`as `crtTime` from `base_user_member_export` where `is_del`=0
select `id`,`member_level` as `memberLevel`,`member_name` as `memberName`,`rent_free_days` as `rentFreeDays`,`total_number` as `totalNumber`,`username`,`status`,`crt_name` as `crtName`,`crt_time`as `crtTime` from `base_user_member_export`
where `is_del`=0 and source = 0
<if test="username != null and username != ''">
and `username`=#{username}
</if>
......
......@@ -7,7 +7,7 @@ public enum CrosstownTypeEnum {
DEPARTURE(1, "交车"),
ARRIVE(2, "还车"),
FIXED_LOSS(3, "定损"),
FIXED_LOSS_NOW(4, "定损"),
FIXED_LOSS_NOW(4, "立即定损"),
;
/**
* 编码
......
......@@ -309,16 +309,23 @@ public class BaseOrder implements Serializable {
private Integer remark;
/**
* 备注
* 上级id
*/
@ApiModelProperty(value = "上级id")
@Column(name = "parent_user_id")
private Integer parentUserId;
/**
* 备注
* 上级公司id
*/
@ApiModelProperty(value = "备注")
@ApiModelProperty(value = "上级公司id")
@Column(name = "parent_user_company_id")
private Integer parentUserCompanyId;
/**
* 上级公司员工id
*/
@ApiModelProperty(value = "上级公司员工id")
@Column(name = "parent_position_id")
private Integer parentPositionId;
}
......@@ -41,4 +41,7 @@ public class BgOrderListVo {
private Integer vehicleCode;
private Integer userId;
//员工身份
private String positionName;
}
......@@ -297,6 +297,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
orderPageVo.setIllegalReserve(illegalReserve);
orderPageVo.setItems(orderItemBiz.selectList(new OrderItem(){{
setOrderId(orderPageVo.getId());
setType(104);
}}));
return ObjectRestResponse.succ(orderPageVo);
}
......
......@@ -251,7 +251,6 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
}
Vehicle vehicle = null;
RestResponse<Vehicle> vehicleRestResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", vehicleRestResponse.getMessage());
if (vehicleRestResponse.getData() != null) {
vehicle = vehicleRestResponse.getData();
} else {
......@@ -289,17 +288,17 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleDepartureVo.setCheckMan(checkUserInfoDto.getUsername());
vehicleDepartureVo.setCheckManTel(checkUserInfoDto.getTelephone());
}
log.info("小程序订单出车: " + vehicleDepartureVo.toString());
try {
RestResponse restResponse = vehicleFeign.departureBySmall(vehicleDepartureVo);
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
log.info("小程序订单出车成功: " + restResponse.getCode() + restResponse.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(1001, e.getMessage());
}
} else if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.ARRIVE.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode()) { //还车
} else if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.ARRIVE.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode() || orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.FIXED_LOSS_NOW.getCode()) { //还车
VehicleArrivalVo vehicleArrivalVo = new VehicleArrivalVo();
vehicleArrivalVo.setVehicleId(orderRentVehicleDetail.getVehicleId());
vehicleArrivalVo.setArrivalBranchCompanyId(userDTO.getCompanyId());
......@@ -309,12 +308,13 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleArrivalVo.setRecycleManTel(checkUserInfoDto.getTelephone());
}
vehicleArrivalVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId());
log.info("小程序订单还车: " + vehicleArrivalVo.toString());
try {
RestResponse restResponse = vehicleFeign.arrivalBySmall(vehicleArrivalVo);
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
log.info("小程序订单还车成功: " + restResponse.getCode() + restResponse.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(500, e.getMessage());
}
......
......@@ -187,7 +187,7 @@ public class OrderCalculateBiz {
//返回优惠券
if(StrUtil.isNotBlank(baseOrder.getCouponTickerNos())) {
//没有租车消费金额,所以返回所有优惠券
inProgressVO.setBackCoupons(StrUtil.split(baseOrder.getCouponTickerNos(), ','));
backCouponNos.addAll(StrUtil.split(baseOrder.getCouponTickerNos(), ','));
}
//设置消费金额,添加租车以外的消费金额
......
......@@ -113,6 +113,13 @@ public class BackStageOrderController extends CommonBaseController implements Us
return ObjectRestResponse.succ(new PageDataVO<>());
}
//车辆排班表查询订单详情
if (dto.getOneNo()!=null) {
dto.setPage(1);
dto.setLimit(1);
dto.setType(1);
}
if (StringUtils.isNotBlank(dto.getPhone()) || StringUtils.isNotBlank(dto.getRealName())) {
List<AppUserLogin> appUserLoins = userFeign.getOne(dto.getPhone(), dto.getRealName());
if (CollectionUtil.isNotEmpty(appUserLoins)) {
......
......@@ -101,6 +101,8 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
//设置上级
baseOrder.setParentUserId(appUserDTO.getParentId());
baseOrder.setParentUserCompanyId(appUserDTO.getParentCompanyId());
baseOrder.setParentPositionId(appUserDTO.getParentPositionTempId());
return baseOrder;
}
......
......@@ -31,6 +31,7 @@ import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.AccompanyingItemType;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
......@@ -143,75 +144,138 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//设置订单名称
bo.getOrder().setName(bo.getVehicleModel().getName());
//是否有使用会员权益 则调用接口触发新增消费记录次数
//扣减免费天数
if(SYS_TRUE.equals(bo.getOrder().getHasMemberRight())) {
if(null == bo.getFreeDays()) {
bo.setFreeDays(0);
}
int result = userFeign.memberDays(bo.getAppUserDTO().getUserid(), bo.getFreeDays(), UserFeign.MEMBER_DAYS_LOCK);
if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
}
OrderItem vehicleModelItem = bo.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL);
BigDecimal amount = vehicleModelItem.getTotalAmount();
//如果有使用优惠券,则扣减
if(BigDecimal.ZERO.compareTo(bo.getOrder().getCouponAmount()) < 0) {
activityFeign.use(bo.getAppUserDTO().getUserid(), Convert.toList(String.class, bo.getOrder().getCouponTickerNos()), bo.getOrder().getNo(), channel, amount, ActivityFeign.TYPE_USE);
}
//分布式事务执行标记
Integer cloudTransact = 0;
//插入随声物品item
List<OrderAccompanyDTO> oads = new ArrayList<OrderAccompanyDTO>();
List<AccompanyingItemVo> accompanyingItemList = vehicleFeign.listAccompanyingItem().getData();
try{
//插入随声物品item
List<OrderAccompanyDTO> oads = new ArrayList<OrderAccompanyDTO>();
List<AccompanyingItemVo> accompanyingItemList = vehicleFeign.listAccompanyingItem().getData();
// Map<String, AccompanyingItemVo> accompanyingItemMap = vehicleFeign.listAccompanyingItem().getData()
// .parallelStream().collect(Collectors.toMap(en -> en.getId().toString(), en -> en));
if(null == bo.getAccompanyItems()) {
bo.setAccompanyItems(new ArrayList<OrderAccompanyDTO>());
}
Map<String, OrderAccompanyDTO> orderAccompanyDTOMap = bo.getAccompanyItems()
.parallelStream().collect(Collectors.toMap(en -> en.getId().toString(), en -> en));
for(AccompanyingItemVo aiv : accompanyingItemList) {
if(AccompanyingItemType.TOOL.getCode().equals(aiv.getType())
|| AccompanyingItemType.EQUIPMENT.getCode().equals(aiv.getType())) {
OrderAccompanyDTO orderAccompanyDTO = BeanUtil.toBean(aiv, OrderAccompanyDTO.class);
orderAccompanyDTO.setUnitPrice(aiv.getPrice());
orderAccompanyDTO.setNum(aiv.getNumber());
oads.add(orderAccompanyDTO);
}else {
OrderAccompanyDTO orderAccompanyDTO = orderAccompanyDTOMap.get(aiv.getId().toString());
if(null != orderAccompanyDTO) {
BeanUtil.copyProperties(aiv, orderAccompanyDTO);
if(null == bo.getAccompanyItems()) {
bo.setAccompanyItems(new ArrayList<OrderAccompanyDTO>());
}
Map<String, OrderAccompanyDTO> orderAccompanyDTOMap = bo.getAccompanyItems()
.parallelStream().collect(Collectors.toMap(en -> en.getId().toString(), en -> en));
for(AccompanyingItemVo aiv : accompanyingItemList) {
if(AccompanyingItemType.TOOL.getCode().equals(aiv.getType())
|| AccompanyingItemType.EQUIPMENT.getCode().equals(aiv.getType())) {
OrderAccompanyDTO orderAccompanyDTO = BeanUtil.toBean(aiv, OrderAccompanyDTO.class);
orderAccompanyDTO.setUnitPrice(aiv.getPrice());
orderAccompanyDTO.setNum(aiv.getNumber());
oads.add(orderAccompanyDTO);
}else {
OrderAccompanyDTO orderAccompanyDTO = orderAccompanyDTOMap.get(aiv.getId().toString());
if(null != orderAccompanyDTO) {
BeanUtil.copyProperties(aiv, orderAccompanyDTO);
orderAccompanyDTO.setUnitPrice(aiv.getPrice());
oads.add(orderAccompanyDTO);
}
}
}
}
bo.setAccompanyItems(oads);
bo.setAccompanyItems(oads);
//获取可用车辆
acquireVehicle(bo, null, null);
//获取可用车辆
acquireVehicle(bo, null, null);
cloudTransact = 1;
OrderItem accompanyItem = orderItemBiz.initOrderItem(BigDecimal.ZERO, 1, "随车物品", null, ACCOMPANY);
accompanyItem.setRealAmount(BigDecimal.ZERO);
accompanyItem.setDetail(JSONUtil.toJsonStr(bo.getAccompanyItems()));
accompanyItem.setOrderId(bo.getOrder().getId());
orderItemBiz.insertSelective(accompanyItem);
//添加随声物品项
OrderItem accompanyItem = orderItemBiz.initOrderItem(BigDecimal.ZERO, 1, "随车物品", null, ACCOMPANY);
accompanyItem.setRealAmount(BigDecimal.ZERO);
accompanyItem.setDetail(JSONUtil.toJsonStr(bo.getAccompanyItems()));
accompanyItem.setOrderId(bo.getOrder().getId());
orderItemBiz.insertSelective(accompanyItem);
//是否有使用会员权益 则调用接口触发新增消费记录次数
//扣减免费天数
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_LOCK);
cloudTransact = 2;
//设置后台系统创建人
if(StrUtil.isNotBlank(bo.getCrtUser())) {
bo.getOrder().setCrtUser(bo.getCrtUser());
OrderItem vehicleModelItem = bo.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL);
BigDecimal amount = vehicleModelItem.getTotalAmount();
//如果有使用优惠券,则扣减
if(BigDecimal.ZERO.compareTo(bo.getOrder().getCouponAmount()) < 0) {
activityFeign.use(bo.getAppUserDTO().getUserid(), Convert.toList(String.class, bo.getOrder().getCouponTickerNos()), bo.getOrder().getNo(), channel, amount, ActivityFeign.TYPE_USE);
}
cloudTransact = 3;
//设置后台系统创建人
if(StrUtil.isNotBlank(bo.getCrtUser())) {
bo.getOrder().setCrtUser(bo.getCrtUser());
}
super.handleDetail(bo);
}catch (Exception e) {
//事务补偿处理
log.error("cloudTransact : {}", cloudTransact);
RestResponse<Integer> restResponse;
try {
//判断分布式事务执行到哪里
switch (cloudTransact) {
case 1 :
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
break;
case 2 :
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
break;
case 3 :
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
//退还天数
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
//退还优惠券
for(String backCoupon : Convert.toList(String.class, bo.getOrder().getCouponTickerNos())) {
activityFeign.cancelUse(backCoupon);
}
break;
default:
break;
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
} finally {
throw e;
}
}
super.handleDetail(bo);
//发送定时取消订单(数据字典设置--5分钟)
rabbitProduct.sendDelayMessage(bo.getOrder(), autoCancelTime);
}
private void useOrBackFreeDays(RentVehicleBO bo, int memberDaysWithdraw) {
//退还天数
if (SYS_TRUE.equals(bo.getOrder().getHasMemberRight())) {
if (null == bo.getFreeDays()) {
bo.setFreeDays(0);
}
int result = userFeign.memberDays(bo.getAppUserDTO().getUserid(), bo.getFreeDays(), memberDaysWithdraw);
if (result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
}
}
private void errorRejectVehicle(RentVehicleBO bo) {
//取消车辆预定
//未支付,拒绝之前的预约
RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(bo.getBookRecordId());
log.info("下单失败,拒绝预约{}, 结果: {}", bo.getBookRecordId(), restResponse.toString());
}
@Override
public void handleCalculate(RentVehicleBO bo) {
RentVehiclePriceVO rvpv = calculatePrice(bo);
......
......@@ -241,84 +241,58 @@
</select>
<select id="getAllOrderList" parameterType="Map" resultType="com.xxfc.platform.order.pojo.bg.BgOrderListVo">
SELECT
bc1.`name` AS startCompanyName,
bc2. NAME AS endCompanyName,
v1.number_plate AS numberPlate,
v1.code AS vehicleCode,
a1. NAME AS username,
a2.username AS telephone,
a2.id As userId,
b1.id AS orderId,
b1.`no` AS orderNo,
b1.`status` as status,
b1.`name` as vehicleName,
b1.crt_time as crtTime,
o1.start_time as startTime,
o1.end_time as endTime,
b1.real_amount as realAmount,
b1.pay_way as payWay,
o1.id as detailId,
b1.pay_time as payTime
FROM
base_order b1
LEFT JOIN order_rent_vehicle_detail o1 ON b1.detail_id = o1.id
LEFT JOIN vehicle.branch_company bc1 ON bc1.id = o1.start_company_id
LEFT JOIN vehicle.branch_company bc2 ON bc2.id = o1.end_company_id
LEFT JOIN vehicle.vehicle v1 ON v1.id = o1.vehicle_id
LEFT JOIN xxfc_third_platform.id_information a1 ON b1.user_id = a1.user_login_id
LEFT JOIN ag_admin_v1.app_user_login a2 ON a2.id = b1.user_id
SELECT * from order_list_info
<where>
<if test="userIds != null and userIds.size() > 0">
and b1.user_id in
and userId in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="phone != null and phone != ''">
and a2.username like CONCAT ("%", #{phone}, "%")
and telephone like CONCAT ("%", #{phone}, "%")
</if>
<if test="realName != null and realName != ''">
and a1.name like CONCAT ("%", #{realName}, "%")
and username like CONCAT ("%", #{realName}, "%")
</if>
<if test="userId != null">
and b1.user_id = #{userId}
and userId = #{userId}
</if>
<if test="status != null">
and b1.status = #{status}
and status = #{status}
</if>
<if test="type != null">
and b1.type = #{type}
and type = #{type}
</if>
<if test="no != null and no != '' ">
and b1.no like CONCAT ("%", #{no}, "%")
and orderNo like CONCAT ("%", #{no}, "%")
</if>
<if test="plateNumber != null and plateNumber != '' ">
and v1.number_plate like CONCAT ("%", #{plateNumber}, "%")
and numberPlate like CONCAT ("%", #{plateNumber}, "%")
</if>
<if test="vehicleCode != null">
and v1.code = #{vehicleCode}
and vehicleCode = #{vehicleCode}
</if>
<if test="startTime != null">
and o1.start_time between #{startTime} and #{endTime}
and startTime between #{startTime} and #{endTime}
</if>
<if test="companyIds != null and companyIds.size > 0">
and (o1.start_company_id in
and (startCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
or
o1.end_company_id in
endCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="zoneId != null">
and (bc1.zone_id = #{zoneId} or bc2.zone_id = #{zoneId})
and (startZoneId = #{zoneId} or endZoneId = #{zoneId})
</if>
</where>
order by b1.crt_time desc
order by crtTime desc
</select>
......
......@@ -67,7 +67,7 @@ public class ServiceTest {
@Test
public void test4(){
HomePageOrderData totalOrder = statisticsBiz.getTotalOrder(null);
HomePageOrderData totalOrder = statisticsBiz.getTotalOrder(null,null);
System.out.println(totalOrder);
}
......
......@@ -99,6 +99,12 @@
<version>0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
......@@ -675,12 +675,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay>{
orderPayVo.setAmount(3);
orderPayVo.setBody("扣除租车订单费用");
orderPayVo.setSubject("租车订单交易费用");
orderPayBiz.testTradeRefund("216584713656209408", 105000, "退还违约金1050元", "2165847136562094081050");
//orderPayBiz.testTradeRefund("216584713656209408", 105000, "退还违约金1050元", "2165847136562094081050");
//orderPayBiz.fundAuthOrderUnFreeze(orderPayVo, "");
//orderPayBiz.alipayOrderRefund("20191024153859000003","2019102422001421530513773694", 2, "xxxx", "");
//orderPayBiz.tradePay("20191108195202000020", "2019110810002001710518149012", 120000,"退还押金", "退还押金");
//orderPayBiz.fundAuthCancel(orderPayVo, "");
//orderPayBiz.tradePay("20191114182254000019", "2019111410002001530505959461", 1,"扣除违约金", "扣除违约金");
orderPayBiz.fundAuthQuery("20191115092455000004");
orderPayBiz.fundAuthQuery("20191031172653000026");
}
}
......@@ -2,7 +2,7 @@ package com.xxfc.platform.universal.controller;
import com.xxfc.platform.universal.biz.MailServiceBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -13,7 +13,7 @@ public class EmailSendController {
@Autowired
MailServiceBiz mailServiceBiz;
@GetMapping(value = "/app/unauth/send")
@PostMapping(value = "/app/unauth/send")
public void senEmail(String toUser, String subject, String content) {
mailServiceBiz.run(toUser, subject, content);
}
......
......@@ -8,6 +8,8 @@ import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.universal.biz.UserMessage;
import com.xxfc.platform.universal.entity.IDCardInformation;
import com.xxfc.platform.universal.entity.IdInformation;
......@@ -16,6 +18,8 @@ import com.xxfc.platform.universal.service.PictureParsing.UserPictureParsing;
import com.xxfc.platform.universal.service.authenticationInterface.UserAuthentication;
import com.xxfc.platform.universal.utils.CertifHttpUtils;
import com.xxfc.platform.universal.utils.Validation;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.map.HashedMap;
......@@ -44,14 +48,22 @@ import java.util.*;
*/
@Service
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class CertificationService {
@Value("${certification.frequency:2}")
private Integer FREQUENCY;
@Autowired
private ConfigFeign configFeign;
@Autowired
private UserAuthentication authentication;
@Autowired
private IdInformationMapper idInformationMapper;
@Autowired
private UserFeign userFeign;
......@@ -61,8 +73,12 @@ public class CertificationService {
@Autowired
private UserPictureParsing userPictureParsing;
private String AUTHENTICATION_TYPE="100";
/**
* 一、身份证图片进行实名认证
* 一、身份证图片进行实名认证
*
* @param idInformation
* @return
*/
......@@ -75,14 +91,14 @@ public class CertificationService {
}
//判断是否有填写身份证号
if (StringUtils.isBlank(idInformation.getIdNumber())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "填写证件号");
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "填写证件号");
}
if (!Validation.isIdCard(idInformation.getIdNumber())) {
return ObjectRestResponse.createFailedResult(ResultCode.WRONG_FORMAT_OF_ID_CARD, "填写的证件格式错误");
return ObjectRestResponse.createFailedResult(ResultCode.WRONG_FORMAT_OF_ID_CARD, "证件格式错误");
}
//判断是有否填写名字
if (StringUtils.isBlank(idInformation.getName())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "填写姓名");
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "填写姓名");
}
//判断是否有正面照片
if (StringUtils.isBlank(idInformation.getFrontUrl())) {
......@@ -97,11 +113,20 @@ public class CertificationService {
//验证证件信息是否和填入的客户信息一致
String name = credentialsData.getName();
String number = credentialsData.getCode();
if (idInformation.getName().equals(name)) {
ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "姓名不一致");
if (!idInformation.getName().replaceAll(" ","").equals(name)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "姓名不一致");
}
if (!idInformation.getIdNumber().replaceAll(" ","").equals(number)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
}
if (idInformation.getIdNumber().equals(number)) {
ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
//判断是否超过认证次数
Example exa = new Example(IdInformation.class);
exa.createCriteria().andEqualTo("idNumber", number);
List<IdInformation> idInformatics = idInformationMapper.selectByExample(exa);
if (CollectionUtils.isNotEmpty(idInformatics) && idInformatics.size() >getCofig() ) {
log.error("该身份证已超过最大认证次数");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该身份证已超过最大认证次数");
}
//3.验证
boolean result = authentication.certificate(new UserMessage() {{
......@@ -150,6 +175,25 @@ public class CertificationService {
}
/**
* 获取认证次数
* @return
*/
public Integer getCofig() {
List<Cofig> cofigs = null;
try {
cofigs = configFeign.getAllByType(AUTHENTICATION_TYPE).getData();
log.info("cofigs={}",cofigs);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
if (CollectionUtils.isEmpty(cofigs)) {
return FREQUENCY;
}
return Integer.valueOf(cofigs.get(0).getParams());
}
/**
* 二、认证通过保存到数据库当中
*
......@@ -159,23 +203,12 @@ public class CertificationService {
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse<Integer> addIdInformation(IdInformation idInformation) {
log.info("----idInformation=========" + idInformation);
//保存认证信息
try {
Example exa = new Example(IdInformation.class);
Example.Criteria criteria = exa.createCriteria();
criteria.andEqualTo("idNumber", idInformation.getIdNumber());
List<IdInformation> idInformatics = idInformationMapper.selectByExample(exa);
if (CollectionUtils.isEmpty(idInformatics)) {
idInformation.setCrtTime(new Date());
idInformationMapper.insertSelective(idInformation);
} else {
log.error("该身份证已存在,不要重复认证");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该身份证已存在,不要重复认证");
}
idInformationMapper.insertSelective(idInformation);
log.info("----addIdInformation---userid===" + idInformation.getUserLoginId() + "----name====" + idInformation.getName() + "---IdNumber===" + idInformation.getIdNumber());
//认证成功后修改用户,用户认证状态
ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return ObjectRestResponse.succ(idInformation.getId());
} catch (Exception e) {
log.error(e.getMessage(), e);
......
package com.xxfc.platform.vehicle.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分公司停靠车辆统计
*/
@Table(name = "branch_company_vehicle_count")
@Data
public class BranchCompanyVehicleCount {
@Id
private Long id;
/**
* 公司名称
*/
@Column(name = "company_id")
private String companyId;
/**
* 当前停靠车辆数量
*/
@Column(name = "vehicle_num")
private Integer vehicleNum;
/**
* 统计日期
*/
@Column(name = "count_date")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd"
)
private Date countDate;
/**
* 统计年
*/
@Column(name = "count_year")
private Integer countYear;
/**
* 统计月
*/
@Column(name = "count_month")
private Integer countMonth;
/**
* 统计周
*/
@Column(name = "count_week")
private Integer countWeek;
}
\ No newline at end of file
......@@ -151,4 +151,19 @@ public class AddOrUpdateVehicleVo {
* 车辆状态
*/
private Integer travelStatus;
/**
* 终端号
*/
private String terminalNumber;
/**
* SIM卡号
*/
private String simNumber;
/**
* 通讯类型
*/
private String communicationType;
}
\ No newline at end of file
package com.xxfc.platform.vehicle.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class BranchCompanyVehicleCountVo {
//分公司ID
private Integer companyId;
//统计年
private Integer countYear;
//统计月
private Integer countMonth;
//统计周
private Integer countWeek;
//统计日期
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd"
)
private Date countDate;
//统计数量
private Integer vehicleNum;
//公司名称
private String companyName;
//周开始时间
private String weekStartDate;
//周结束时间
private String weekEndDate;
}
......@@ -2,8 +2,11 @@ package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
import java.util.Date;
@Data
public class BranchCompanyVehicleCount {
private String parkBranchCompanyName;
public class VehicleWeekCountVo {
private Integer week;
private Date dateTime;
private Integer count;
}
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
@Data
public class BranchCompanyVehicleCountDTO extends PageParam {
//开始时间 yyyy-MM-dd
private String startTime;
//结束时间
private String endTime;
private Integer companyId;
//统计类型,日月年, 1、日,2、月,3、年
private Integer type;
}
package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.Utils.OrderDateUtils;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCountMapper, BranchCompanyVehicleCount> {
@Autowired
VehicleBiz vehicleBiz;
public ObjectRestResponse add(BranchCompanyVehicleCount branchCompanyVehicleCount) {
if (branchCompanyVehicleCount == null) {
return ObjectRestResponse.paramIsEmpty();
}
BranchCompanyVehicleCount oldValue = selectOne(branchCompanyVehicleCount);
if (oldValue == null) {
insertSelectiveRe(branchCompanyVehicleCount);
}
return ObjectRestResponse.succ();
}
public ObjectRestResponse addAll(List<BranchCompanyVehicleCountVo> list) {
if (list != null && list.size() > 0) {
list.parallelStream().forEach(result -> {
BranchCompanyVehicleCount branchCompanyVehicleCount = new BranchCompanyVehicleCount();
BeanUtil.copyProperties(result, branchCompanyVehicleCount, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
add(branchCompanyVehicleCount);
});
return ObjectRestResponse.succ();
} else {
return ObjectRestResponse.paramIsEmpty();
}
}
@Scheduled(cron = "0 0 2 * * *")
public void addAll() {
addAll(vehicleBiz.getAllVehicleInfo());
}
/**
* 按天统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByDay(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.getAllCountInfo(query.getSuper()));
}
/**
* 按月统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByMonth(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.countByMonth(query.getSuper()));
}
/**
* 按周统计
* @param query
* @return
*/
public PageDataVO<BranchCompanyVehicleCountVo> countByWeek(Query query) {
return PageDataVO.pageInfo(query, () -> mapper.countByWeek(query.getSuper()));
}
public ObjectRestResponse<PageDataVO<BranchCompanyVehicleCountVo>> getAllCountInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
if (branchCompanyVehicleCountDTO == null) {
return ObjectRestResponse.paramIsEmpty();
}
Integer page = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage();
Integer limit = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit();
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
branchCompanyVehicleCountDTO.setPage(page);
branchCompanyVehicleCountDTO.setLimit(limit);
Query query = new Query(branchCompanyVehicleCountDTO);
if (type == 1) {//按天
return ObjectRestResponse.succ(countByDay(query));
}
if (type == 2) {//按周
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = countByWeek(query);
if (pageDataVO != null && pageDataVO.getData() != null && pageDataVO.getData().size() > 0) {
pageDataVO.getData().parallelStream().forEach(result -> {
String weekStartDate = OrderDateUtils.getStartDayOfWeekNo(result.getCountYear(), result.getCountWeek());
String weekEndDate = OrderDateUtils.getEndDayOfWeekNo(result.getCountYear(), result.getCountWeek());
result.setWeekStartDate(weekStartDate);
result.setWeekEndDate(weekEndDate);
});
}
return ObjectRestResponse.succ(pageDataVO);
}
if (type == 3) {//按月
return ObjectRestResponse.succ(countByMonth(query));
}
return ObjectRestResponse.succ(new PageDataVO<>());
}
}
......@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.*;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
......@@ -198,14 +199,6 @@ public class VehicleActiveService {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
}
// if (StringUtils.isBlank(arrivalVo.getRecycleMan()) || StringUtils.isBlank(arrivalVo.getRecycleManTel())) {
// throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
// ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
// }
// if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
Integer MileageRest = vehicle.getMileageLastUpdate();
Integer MileageRest1 = arrivalVo.getMileage();
if (MileageRest1 == null) {
......@@ -217,6 +210,9 @@ public class VehicleActiveService {
if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2);
} else {
throw new BaseException(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc(),
ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode());
}
// 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(MileageRest1);
......@@ -239,12 +235,11 @@ public class VehicleActiveService {
}
if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
vehicle.setStatus(VehicleStatus.NORMAL.getCode());
// if (result == 0) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
}
//2019-11-22 16:30 还原还车时修改车辆停靠分公司需求
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleMapper.updateByPrimaryKeySelective(vehicle);
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
DateTime actualArrivalDate = new DateTime(new Date());
//提前还车处理
......@@ -257,7 +252,8 @@ public class VehicleActiveService {
bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark()==null?"": bookVehicleVo.getRemark()+ " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setBookEndDate(new Date());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
try {
Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
if (!hasSuc) {
......@@ -285,6 +281,11 @@ public class VehicleActiveService {
if (vehicleBookRecord != null) {
departureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany());
}
//添加收车成功,后面有当天预定的记录时,取消当天的预定
boolean unBookStatus = unBookArrivalDateTime(vehicleBookRecord);
if (!unBookStatus) {
log.info("还车释放当天bookInfo失败!请手动修改!");
}
vehicleDepartureLogMapper.updateByPrimaryKeySelective(departureLog);
// 车辆活动日志
VehicleActiveLog activeLog = vehicleActiveLogMapper.selectLastByVehicleId(arrivalVo.getVehicleId());
......@@ -295,23 +296,6 @@ public class VehicleActiveService {
activeLog.setEndTime(new Date());
activeLog.setUpdateTime(new Date());
vehicleActiveLogMapper.updateByPrimaryKeySelective(activeLog);
//取消预定时间 bookInfo和bookRecord
// BookVehicleVO bookVehicleVo = new BookVehicleVO();
// BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo);
// bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE);
// bookVehicleVo.setBookStartDate(null);
// bookVehicleVo.setBookEndDate(null);
// bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
// bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
// try {
// Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
// if(!hasSuc){
// throw new BaseException(ResCode.VEHICLE_UNBOOK_FAIL.getDesc(), ResCode.VEHICLE_UNBOOK_FAIL.getCode());
// }
// } catch ( Exception e) {
// log.error(e.getMessage(), e);;
// }
} else {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
......@@ -322,6 +306,46 @@ public class VehicleActiveService {
vehicleDepartureLogMapper.insertSelective(vehicleDepartureLog);
}
/**
* 如果还车时,还车当天还有其他预定记录,则不释放当天的bookInfo, 如果没有其他记录,则释放当天的bookInfo
* @param vehicleBookRecord
* @return
*/
public boolean unBookArrivalDateTime(VehicleBookRecord vehicleBookRecord) {
Map<String, Object> map = new HashMap<>();
Date startDate = null;
if (vehicleBookRecord.getActualEndDate() == null) {
startDate = vehicleBookRecord.getBookEndDate();
} else {
startDate = vehicleBookRecord.getActualEndDate();
}
DateTime bookStartDate = new DateTime(startDate);
DateTime unBookEndDate = DateTime.now().withMillis(DateUtils.getEndOfDay());
map.put("startTime", bookStartDate.toString(DATE_TIME_FORMATTER));
map.put("endTime", unBookEndDate.toString(DATE_TIME_FORMATTER));
map.put("status", 1);
map.put("vehicleId", vehicleBookRecord.getVehicleId());
log.info("查询还车当天是否有其他预定记录:{}", map);
List<VehicleBookRecordVo> vehicleBookRecords = vehicleBookRecordBiz.selectAllBookRecord(map).getData();
if (vehicleBookRecords == null || vehicleBookRecords.size() <= 0) { //没有记录,取消记录
BookVehicleVO bookVehicleVO = new BookVehicleVO();
bookVehicleVO.setVehicleId(vehicleBookRecord.getVehicleId());
DateTime unBookStartDate = DateTime.now().withMillis(DateUtils.getStartOfDay());
bookVehicleVO.setUnbookStartDate(unBookStartDate.toString(DATE_TIME_FORMATTER));
bookVehicleVO.setUnbookEndDate(unBookEndDate.toString(DATE_TIME_FORMATTER));
log.info("释放还车当天bookInfo: {}", bookVehicleVO);
try {
return vehicleBiz.unbookVehicle(bookVehicleVO);
} catch (Exception e) {
log.info("还车释放当天bookInfo失败");
e.printStackTrace();
}
}
log.info("还车当天有其他预定记录,不释放当天bookInfo, {}", vehicleBookRecords);
return true;
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public void checkDateInvalid(VehicleDepartureVo arrivalVo) {
if (arrivalVo.getBookRecordId() != null) {
......
......@@ -1514,7 +1514,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
}
public List<BranchCompanyVehicleCount> getAllVehicleInfo() {
public List<BranchCompanyVehicleCountVo> getAllVehicleInfo() {
return mapper.getAllVehicleInfo();
}
......
......@@ -256,14 +256,15 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return ObjectRestResponse.createDefaultFail();
}
//出行中才修改车辆停靠分公司
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
Vehicle vehicle = vehicleBiz.selectById(vehicleBookRecord.getVehicleId());
if (vehicle != null) {
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleBiz.updateSelectiveByIdRe(vehicle);
}
}
//2019-11-22 16:30 取消修改还车地点同时修改停靠分公司需求
// VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
// if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
// Vehicle vehicle = vehicleBiz.selectById(vehicleBookRecord.getVehicleId());
// if (vehicle != null) {
// vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
// vehicleBiz.updateSelectiveByIdRe(vehicle);
// }
// }
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
......@@ -491,12 +492,17 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
public ObjectRestResponse<List<VehicleBookRecordVo>> selectAllBookRecord(Map<String, Object> param) {
return ObjectRestResponse.succ(mapper.selectAllBookRecord(param));
}
public ObjectRestResponse<List<VehicleBookRecordVo>> selectAllBookRecord(Date startTime, Date endTime, Integer status) {
Map<String, Object> map = new HashMap<>();
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("status", status);
return ObjectRestResponse.succ(mapper.selectAllBookRecord(map));
return selectAllBookRecord(map);
}
/**
......
......@@ -6,7 +6,6 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo;
......@@ -14,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -29,7 +30,11 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
@Autowired
private VehicleBiz vehicleBiz;
@Autowired
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public List getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo, List<Integer> companyList) throws Exception {
......@@ -94,8 +99,4 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
}
public List<BranchCompanyVehicleCount> getAllVehicleInfo() {
return vehicleBiz.getAllVehicleInfo();
}
}
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVehicleCount> {
List<BranchCompanyVehicleCountVo> getAllCountInfo(Map<String, Object> param);
List<BranchCompanyVehicleCountVo> countByMonth(Map<String, Object> param);
List<BranchCompanyVehicleCountVo> countByWeek(Map<String, Object> param);
}
\ No newline at end of file
......@@ -54,5 +54,5 @@ public interface VehicleMapper extends Mapper<Vehicle> {
@Select("select `id` from `vehicle` where `is_del`=0")
List<String> findExistVehicleIds();
List<BranchCompanyVehicleCount> getAllVehicleInfo();
List<BranchCompanyVehicleCountVo> getAllVehicleInfo();
}
\ No newline at end of file
......@@ -338,14 +338,15 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
bookRecordUpdateLog.setOperaterId(userDTO.getId());
bookRecordUpdateLog.setOperaterName(userDTO.getName());
bookRecordUpdateLog.setCreateTime(new Date());
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(oldValue.getId());
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
Vehicle vehicle = vehicleBiz.selectById(oldValue.getVehicleId());
if (vehicle != null) {
vehicle.setParkBranchCompanyId(oldValue.getRetCompany());
vehicleBiz.updateSelectiveByIdRe(vehicle);
}
}
//2019-11-22 16:30 取消修改还车地点同时修改停靠分公司需求
// VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(oldValue.getId());
// if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
// Vehicle vehicle = vehicleBiz.selectById(oldValue.getVehicleId());
// if (vehicle != null) {
// vehicle.setParkBranchCompanyId(oldValue.getRetCompany());
// vehicleBiz.updateSelectiveByIdRe(vehicle);
// }
// }
vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord);
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else {
......
package com.xxfc.platform.vehicle.rest.admin;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@Controller
@RequestMapping(value = "/bg-vehicle/count")
public class BranchCompanyVehicleCountController extends BaseController<BranchCompanyVehicleCountBiz> {
@Autowired
private HttpServletResponse response;
@GetMapping(value = "/getAll")
@ResponseBody
public ObjectRestResponse getAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
return baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO);
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO).getData();
if (pageDataVO != null && pageDataVO.getData() != null) {
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("companyId", "公司ID");
writer.addHeaderAlias("companyName", "公司名");
writer.addHeaderAlias("countYear", "年");
writer.addHeaderAlias("countMonth", "月");
writer.addHeaderAlias("countWeek", "周");
writer.addHeaderAlias("weekStartDate", "开始日期");
writer.addHeaderAlias("weekEndDate", "结束日期");
writer.addHeaderAlias("countDate", "日期");
writer.addHeaderAlias("vehicleNum", "数量");
writer.setColumnWidth(7, 17);
writer.setColumnWidth(5, 17);
writer.setColumnWidth(6, 17);
writer.setColumnWidth(1, 17);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(pageDataVO.getData(), true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}
}
......@@ -7,10 +7,10 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,7 +30,7 @@ import java.util.List;
public class VehicleInformationDownloadController extends BaseController<VehicleInformationDownloadBiz> {
@Autowired
UserFeign userFeign;
private UserFeign userFeign;
@Autowired
private UserAuthConfig userAuthConfig;
......@@ -39,7 +39,10 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
private VehicleBiz vehicleBiz;
@Autowired
HttpServletResponse response;
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
@Autowired
private HttpServletResponse response;
@GetMapping("/excel")
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson", required = false) String vehiclePageQueryVoJson) throws Exception {
......@@ -69,24 +72,9 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
IoUtil.close(out);
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo() throws Exception {
List<BranchCompanyVehicleCount> rows = baseBiz.getAllVehicleInfo();
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("parkBranchCompanyName", "停靠分公司");
writer.addHeaderAlias("count", "车辆数量");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
@GetMapping("/app/unauth/addAll")
public void addAll() {
branchCompanyVehicleCountBiz.addAll(vehicleBiz.getAllVehicleInfo());
}
}
package com.xxfc.platform.vehicle.util;
import org.joda.time.DateTime;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
......@@ -19,4 +21,43 @@ public class DateUtils {
public static Date localDateToDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
/**
* 获取当天的开始时间
* @return
*/
public static long getStartOfDay() {
return getStartOfDay(new Date());
}
/**
* 获取某天的开始时间
* @param date
* @return
*/
public static long getStartOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTimeAtStartOfDay();
return startOfDay.getMillis();
}
/**
* 获取当天的结束时间
* @return
*/
public static long getEndOfDay() {
return getEndOfDay(new Date());
}
/**
* 获取某天的结束时间
* @param date
* @return
*/
public static long getEndOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime endOfDay = dateTime.millisOfDay().withMaximumValue();
return endOfDay.getMillis();
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper" >
<select id="getAllCountInfo" parameterType="Map" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo">
SELECT
c.*,
b.`name` AS companyName
FROM
branch_company_vehicle_count c
LEFT JOIN branch_company b ON b.id = c.company_id
<where>
<if test = "companyId != null">
and c.company_id = #{companyId}
</if>
<if test="startTime != null and startTime != ''">
and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if>
</where>
GROUP BY c.id
ORDER BY c.company_id, c.count_date
</select>
<select id="countByMonth" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map">
SELECT c.company_id, c.count_year, c.count_month, b.`name` as companyName, sum(c.vehicle_num) as vehicle_num from branch_company_vehicle_count c
LEFT JOIN branch_company b on b.id = c.company_id
<where>
<if test = "companyId != null">
and c.company_id = #{companyId}
</if>
<if test="startTime != null and startTime != ''">
and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if>
</where>
GROUP BY c.company_id,c.count_year,c.count_month
</select>
<select id="countByWeek" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo" parameterType="Map">
SELECT c.company_id, c.count_year, c.count_week, b.`name` as companyName, sum(c.vehicle_num) as vehicle_num from branch_company_vehicle_count c
LEFT JOIN branch_company b on b.id = c.company_id
<where>
<if test = "companyId != null">
and c.company_id = #{companyId}
</if>
<if test="startTime != null and startTime != ''">
and c.count_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and c.count_date &lt;= #{endTime}
</if>
</where>
GROUP BY c.company_id,c.count_year,c.count_week
</select>
</mapper>
\ No newline at end of file
......@@ -529,20 +529,20 @@
<if test="code != null">
and v3.code = #{code}
</if>
<!--增加时间限制,未审核的小于当前时间的不显示-->
<!--增加时间限制,未审核的结束时间小于当前时间的不显示-->
<if test="flag == true and status == 1">
and book_end_date &gt;= now()
</if>
<!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示-->
<if test="flag == true and status == 2">
and ( (v4.id IS NOT NULL and DATE_ADD(v1.book_end_date,INTERVAL '2' DAY) >= now()) OR (v4.id IS NULL AND v1.book_end_date &gt;= now()))
<!--增加时间限制,已审核的未出车结束时间小于当前时间的不显示-->
<if test="flag == true and (status == 3 or status == 2)">
and v4.id IS NULL AND v1.book_end_date &gt;= now()
</if>
<if test="flag == true">
and v1.book_user != -2
</if>
</where>
group by v1.id
order by create_time DESC
order by v1.book_start_date DESC
</select>
<select id="selectAllBookRecord" resultMap="searchBookRecord" parameterType="Map">
......@@ -554,8 +554,13 @@
<if test="startTime != null and status == 2">
and v1.book_end_date between #{startTime} and #{endTime}
</if>
<if test="vehicleId != null and vehicleId != ''">
and v1.vehicle_id = #{vehicleId}
</if>
</select>
<!--获取所有已取消的预定记录-->
<select id="selectAllCancelBookRecord" resultMap="searchBookRecord" parameterType="Map">
select v1.* from vehicle_book_record v1
......
......@@ -591,18 +591,10 @@
</select>
<!--导出分公司停靠所有车辆-->
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCount">
SELECT
b1. NAME AS parkBranchCompanyName,
count(v1.id) as count
FROM
branch_company b1
LEFT JOIN vehicle v1 ON v1.park_branch_company_id = b1.id
WHERE
b1.is_del = 0
AND v1.is_del = 0
GROUP BY b1.`name`
order by b1.`name`
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo">
select b.id as companyId, DATE_FORMAT(now(),'%Y') as countYear, DATE_FORMAT(now(),'%m') as countMonth,DATE_FORMAT(now(),'%u') as countWeek,DATE_FORMAT(now(),'%Y-%m-%d') as countDate,count(*) as vehicleNum from vehicle v
LEFT JOIN branch_company b on b.id = v.park_branch_company_id
GROUP BY b.id
</select>
<select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle"
......@@ -992,7 +984,14 @@
, vbre.ret_company as to_lift_company
, vbrs.lift_company as to_return_company
from
(select vehicle_id, max(if(book_end_date &lt; #{startDateExtend}, book_end_date, null)) as max_book_end_date, min(if(book_start_date &gt; #{endDateExtend}, book_start_date, null)) as min_book_start_date from vehicle_book_record where status != 4 and status != 6 group by vehicle_id) sevbr
<!--
查询开始时间 前面的最后一条 预约记录
查询结束时间 后面的第一条 预约记录
添加比较actual_start_date 和 actual_end_date-->
(select vehicle_id
, max(if(IFNULL(actual_end_date, book_end_date) &lt; #{startDateExtend}, IFNULL(actual_end_date,book_end_date), null)) as max_book_end_date
, min(if(IFNULL(actual_start_date, book_start_date) &gt; #{endDateExtend}, IFNULL(actual_start_date, book_start_date), null)) as min_book_start_date
from vehicle_book_record where status != 4 and status != 6 group by vehicle_id) sevbr
left join vehicle_book_record vbre
on sevbr.vehicle_id = vbre.vehicle_id and sevbr.max_book_end_date = vbre.book_end_date and vbre.status != 4 and vbre.status != 6
left join vehicle_book_record vbrs
......
......@@ -4,14 +4,16 @@
<select id="findVehicleModelPage" parameterType="com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition"
resultType="com.xxfc.platform.vehicle.pojo.VehicleModelVo">
SELECT * from
(select vm.*,v.sum,v2.leasableQuantity,vpc.`name` brandName,vpc2.name numberName from vehicle_model vm left JOIN
(select model_id as mid, count(1) as sum FROM vehicle GROUP BY mid) v
on vm.id=v.mid left JOIN
(select model_id as mid2, count(1) as leasableQuantity FROM vehicle where`use_type`=1 GROUP BY model_id) v2
(select vm.*,v.sum,v2.leasableQuantity,vpc.`name` brandName,vpc2.name numberName from vehicle_model vm
left JOIN
(select model_id as mid, count(1) as sum FROM vehicle where is_del= 0 GROUP BY mid) v
on vm.id=v.mid
left JOIN
(select model_id as mid2, count(1) as leasableQuantity FROM vehicle where`use_type`=1 and is_del= 0 GROUP BY model_id) v2
on v.mid=v2.mid2
left join (SELECT id,name FROM vehicle_plat_cata where state=0) vpc on vm.brand=vpc.id
left join (SELECT id,name FROM vehicle_plat_cata where state=0) vpc2 on vm.number=vpc2.id
where isdel = 0
where vm.isdel = 0
) vmqc WHERE 1=1
<if test="isDel !=null ">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment