Commit 8313a91b authored by libin's avatar libin

Merge remote-tracking branch 'origin/dev' into dev

parents 5787342e 72a68c9f
...@@ -2,24 +2,29 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,24 +2,29 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin; import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.constant.UserConstant; import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.feign.MQSenderFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.time.Instant; import java.time.Instant;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.Executors;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -36,6 +41,11 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -36,6 +41,11 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
private static final String WX_TYPE="wx"; private static final String WX_TYPE="wx";
private static final String QQ_TYPE="q"; private static final String QQ_TYPE="q";
@Autowired
ThirdFeign thirdFeign;
@Autowired
MQSenderFeign mqSenderFeign;
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
@Override @Override
public void insertSelective(AppUserLogin entity) { public void insertSelective(AppUserLogin entity) {
...@@ -62,6 +72,44 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -62,6 +72,44 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
super.updateSelectiveById(entity); super.updateSelectiveById(entity);
} }
public Object test() {
threadRunner();
return "success";
}
public void threadRunner() {
List<AppUserLogin> list = mapper.selectAll();
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
if(list != null && list.size() > 0) {
for(AppUserLogin appUserLogin : list) {
try {
Thread.sleep(3000);
} catch (Exception e){}
IdInformation idInformation = thirdFeign.getOneByUserId(appUserLogin.getId());
if(idInformation != null) { //实名认证
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", appUserLogin.getId());
jsonObject.put("integralRuleCode", "CRETIFICATION");
jsonObject.put("channelId", idInformation.getId());
mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
}
try {
Thread.sleep(3000);
} catch (Exception e){}
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", appUserLogin.getId());
jsonObject.put("integralRuleCode", "REGISTER");
jsonObject.put("channelId", appUserLogin.getId());
mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
}
}
}
});
}
/** /**
* 根据用户名获取用户信息 * 根据用户名获取用户信息
......
...@@ -66,6 +66,16 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -66,6 +66,16 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线"); log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
return; return;
} }
AppUserVo appUserVo=userDetailBiz.getUserInfoById(userId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在");
return;
}
appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该上线用户不存在");
return;
}
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId); AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time=System.currentTimeMillis(); Long time=System.currentTimeMillis();
if(relation==null){ if(relation==null){
...@@ -122,7 +132,6 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -122,7 +132,6 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
} }
} }
/** /**
* 小程序分享上下线绑定 * 小程序分享上下线绑定
* @param userid 当前人小程序id * @param userid 当前人小程序id
...@@ -218,9 +227,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -218,9 +227,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
//获取用户的下线总数 //获取用户的下线总数
public int getCountByParentId(Integer parentId,Long time){ public int getCountByParentId(Integer parentId,Long time){
Example example=new Example(AppUserRelation.class); if (validTime<=0){
example.createCriteria().andEqualTo("parentId",parentId).andNotEqualTo("isForever",1).andGreaterThan("bindTime",time); time= validTime;
return mapper.selectCountByExample(example); }
return mapper.countByParentId(parentId,time);
} }
@CacheClear(key="user:relation{1.userId}") @CacheClear(key="user:relation{1.userId}")
......
package com.github.wxiaoqi.security.admin.mapper; package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation; import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
...@@ -16,4 +17,7 @@ public interface AppUserRelationMapper extends Mapper<AppUserRelation> { ...@@ -16,4 +17,7 @@ public interface AppUserRelationMapper extends Mapper<AppUserRelation> {
List<AppUserRelation> selectByLeaderId(Integer leaderId); List<AppUserRelation> selectByLeaderId(Integer leaderId);
//获取有效的下级
public int countByParentId(@Param("parentId")Integer parentId,@Param("bindTime")Long bindTime);
} }
package com.github.wxiaoqi.security.admin.rest; package com.github.wxiaoqi.security.admin.rest;
import com.ace.cache.annotation.Cache;
import com.github.wxiaoqi.security.admin.biz.*; import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.entity.*; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.admin.vo.AppUserGroups; import com.github.wxiaoqi.security.admin.vo.AppUserGroups;
import com.github.wxiaoqi.security.admin.vo.AppUserInfoVo; import com.github.wxiaoqi.security.admin.vo.AppUserInfoVo;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
...@@ -14,24 +12,20 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; ...@@ -14,24 +12,20 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo; import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse; import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController; import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.feign.OrderFeign; import com.xxfc.platform.order.feign.OrderFeign;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -153,7 +147,7 @@ public class AppUserController extends CommonBaseController{ ...@@ -153,7 +147,7 @@ public class AppUserController extends CommonBaseController{
UserMemberVo memberVo=userMemberBiz.getMemberInfoByUserId(userid); UserMemberVo memberVo=userMemberBiz.getMemberInfoByUserId(userid);
if(memberVo!=null){ if(memberVo!=null){
BeanUtils.copyProperties(userDTO,memberVo); BeanUtils.copyProperties(userDTO,memberVo);
userDTO.setPayCount(orderFeign.baseOrderCount(SYS_TRUE, "4,5,6,7", null, userid).getData()); userDTO.setPayCount(orderFeign.baseOrderCount(SYS_TRUE, "4,5,6,-1", null, userid).getData());
Integer level=memberVo.getMemberLevel(); Integer level=memberVo.getMemberLevel();
BaseUserMemberLevel memberLevel=userMemberLevelBiz.getLevel(level); BaseUserMemberLevel memberLevel=userMemberLevelBiz.getLevel(level);
if (memberLevel!=null){ if (memberLevel!=null){
...@@ -285,4 +279,11 @@ public class AppUserController extends CommonBaseController{ ...@@ -285,4 +279,11 @@ public class AppUserController extends CommonBaseController{
AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code); AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code);
return ObjectRestResponse.succ(appUserInfoVo); return ObjectRestResponse.succ(appUserInfoVo);
} }
@GetMapping("/app/unauth/test")
@IgnoreUserToken
@IgnoreClientToken
public Object test() {
return appUserLoginBiz.test();
}
} }
...@@ -6,4 +6,12 @@ ...@@ -6,4 +6,12 @@
<select id="selectByLeaderId" resultType="com.github.wxiaoqi.security.admin.entity.AppUserRelation"> <select id="selectByLeaderId" resultType="com.github.wxiaoqi.security.admin.entity.AppUserRelation">
select `parent_id` as `parentId`,`user_id`as `userId`,`bind_time` as `bindTime` from `app_user_relation` where `parent_id`=#{leaderId} and `is_del`=0 order by `bind_time` DESC select `parent_id` as `parentId`,`user_id`as `userId`,`bind_time` as `bindTime` from `app_user_relation` where `parent_id`=#{leaderId} and `is_del`=0 order by `bind_time` DESC
</select> </select>
<select id="countByParentId">
select count(*) from `app_user_relation` where
`parent_id`=#{parentId} and `is_del`=0
<if test="bindTime!='' and bindTime!=null and bindTime>0">
and (is_forever=2 or bind_time>#{bindTime})
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -181,7 +181,7 @@ public class IntegralUserRecordBiz extends BaseBiz<IntegralUserRecordMapper, Int ...@@ -181,7 +181,7 @@ public class IntegralUserRecordBiz extends BaseBiz<IntegralUserRecordMapper, Int
} else { } else {
integralUserRecordDto.setStartTime(null); integralUserRecordDto.setStartTime(null);
Integer count = mapper.countByUserAndCode(integralUserRecordDto); Integer count = mapper.countByUserAndCode(integralUserRecordDto);
integralUserStatus.setIntegralStatus(count == number); integralUserStatus.setIntegralStatus(true);
} }
integralUserStatusBiz.save(integralUserStatus); integralUserStatusBiz.save(integralUserStatus);
} }
......
...@@ -38,4 +38,6 @@ public class IntegralUserRecordController { ...@@ -38,4 +38,6 @@ public class IntegralUserRecordController {
public ObjectRestResponse getListByCode(IntegralUserRecordDto integralUserRecordDto) { public ObjectRestResponse getListByCode(IntegralUserRecordDto integralUserRecordDto) {
return integralUserRecordBiz.getByUserAndTime(integralUserRecordDto); return integralUserRecordBiz.getByUserAndTime(integralUserRecordDto);
} }
} }
...@@ -41,6 +41,7 @@ import org.springframework.stereotype.Service; ...@@ -41,6 +41,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -169,7 +170,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -169,7 +170,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds())); ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds()));
} }
List<AppUserVo> list = userFeign.getByUserIds(ids).getData(); List<AppUserVo> list = userFeign.getByUserIds(ids).getData();
orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? null : list); orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? new ArrayList<>() : list);
} }
//设置保留金 //设置保留金
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
...@@ -259,7 +260,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -259,7 +260,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds())); ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds()));
} }
List<AppUserVo> list = userFeign.getByUserIds(ids).getData(); List<AppUserVo> list = userFeign.getByUserIds(ids).getData();
orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? null : list); orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? new ArrayList<>() : list);
} }
//设置保留金 //设置保留金
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
...@@ -322,6 +323,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -322,6 +323,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
//车辆预定审核通过 //车辆预定审核通过
RestResponse<Integer> result = vehicleFeign.proveVehicleBooking(orvd.getBookRecordId());
//确认免费天数 //确认免费天数
if (orvd.getFreeDays() > 0) { if (orvd.getFreeDays() > 0) {
......
package com.xxfc.platform.order.biz; package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.order.entity.DailyMembersOrderStatistics; import com.xxfc.platform.order.entity.DailyMembersOrderStatistics;
import com.xxfc.platform.order.entity.DailyTravelOrderStatistics;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper;
import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,13 +37,25 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta ...@@ -38,13 +37,25 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
public boolean memberOrderStatistics() { public boolean memberOrderStatistics() {
try { try {
List<Map<String, Object>> travelGmv = mapper.getTravelGmv(day); Map<String, Object> travelGmv = mapper.getTravelGmv(day);
if (CollectionUtils.isEmpty(travelGmv)) { if (travelGmv.isEmpty()) {
return true; return true;
} }
for (Map<String, Object> stringObjectMap : travelGmv) {
DailyMembersOrderStatistics MembersStatistics = new DailyMembersOrderStatistics();
BeanUtils.copyProperties(MembersStatistics, stringObjectMap); DailyMembersOrderStatistics MembersStatistics = new DailyMembersOrderStatistics();
BeanUtils.copyProperties(MembersStatistics, travelGmv);
String oneDay = MembersStatistics.getOneDay();
if (StringUtils.isBlank(oneDay)) {
throw new BaseException();
}
Example exa = new Example(DailyMembersOrderStatistics.class);
exa.createCriteria().andEqualTo("oneDay", oneDay);
List<DailyMembersOrderStatistics> statistics = selectByExample(exa);
if (CollectionUtils.isEmpty(statistics)) {
insertSelective(MembersStatistics); insertSelective(MembersStatistics);
} }
return true; return true;
......
...@@ -3,16 +3,21 @@ package com.xxfc.platform.order.biz; ...@@ -3,16 +3,21 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.order.entity.DailyTravelOrderStatistics; import com.xxfc.platform.order.entity.DailyTravelOrderStatistics;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 每日旅游订单统计 * 每日旅游订单统计
...@@ -20,6 +25,7 @@ import java.util.*; ...@@ -20,6 +25,7 @@ import java.util.*;
* @author Administrator * @author Administrator
*/ */
@Service @Service
@Slf4j
public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStatisticsMapper, DailyTravelOrderStatistics> { public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStatisticsMapper, DailyTravelOrderStatistics> {
@Value("${order.day}") @Value("${order.day}")
private Integer day; private Integer day;
...@@ -58,10 +64,26 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati ...@@ -58,10 +64,26 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
BeanUtil.copyProperties(object, statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(object, statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
} }
String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay();
for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) { if (StringUtils.isBlank(oneDay)) {
insertSelectiveRe(e.getValue()); throw new BaseException();
} }
Example exa= new Example(DailyTravelOrderStatistics.class);
exa.createCriteria().andEqualTo("oneDay",oneDay);
List<DailyTravelOrderStatistics> statistics= selectByExample(exa);
if (CollectionUtils.isEmpty(statistics)){
for (Map.Entry<Integer, DailyTravelOrderStatistics> entry : map.entrySet()) {
insertSelectiveRe(entry.getValue());
}
}else {
log.error("今日已统计车辆订单,请不要重复统计!");
}
//
// for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) {
// insertSelectiveRe(e.getValue());
// }
} }
} }
......
...@@ -4,19 +4,27 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,19 +4,27 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.order.entity.DailyOrderStatistics;
import com.xxfc.platform.order.entity.DailyVehicleOrderStatistics; import com.xxfc.platform.order.entity.DailyVehicleOrderStatistics;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import sun.rmi.runtime.Log;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import javax.print.attribute.standard.MediaSize;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 每日租车订单统计 * 每日租车订单统计
...@@ -24,6 +32,7 @@ import java.util.*; ...@@ -24,6 +32,7 @@ import java.util.*;
* @author Administrator * @author Administrator
*/ */
@Service @Service
@Slf4j
public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderStatisticsMapper, DailyVehicleOrderStatistics> { public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderStatisticsMapper, DailyVehicleOrderStatistics> {
private final Integer TYPE_DEFERRED = 1; private final Integer TYPE_DEFERRED = 1;
...@@ -73,8 +82,8 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta ...@@ -73,8 +82,8 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
} }
private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result) throws Exception { private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result) throws Exception {
if (CollectionUtils.isNotEmpty(result)) {
if(CollectionUtils.isNotEmpty(result)) {
Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>(); Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>();
for (DailyVehicleOrderStatistics value : result) { for (DailyVehicleOrderStatistics value : result) {
...@@ -89,11 +98,22 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta ...@@ -89,11 +98,22 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
value, value,
statistics, statistics,
CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
}
String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay();
if (StringUtils.isBlank(oneDay)) {
throw new BaseException();
} }
Example exa= new Example(DailyVehicleOrderStatistics.class);
exa.createCriteria().andEqualTo("oneDay",oneDay);
List<DailyVehicleOrderStatistics> statistics= selectByExample(exa);
for (Map.Entry<Integer, DailyVehicleOrderStatistics> entry : map.entrySet()) { if (CollectionUtils.isEmpty(statistics)){
insertSelectiveRe(entry.getValue()); for (Map.Entry<Integer, DailyVehicleOrderStatistics> entry : map.entrySet()) {
insertSelectiveRe(entry.getValue());
}
}else {
log.error("今日已统计车辆订单,请不要重复统计!");
} }
} }
......
...@@ -14,7 +14,7 @@ import java.util.Map; ...@@ -14,7 +14,7 @@ import java.util.Map;
*/ */
public interface DailyMembersOrderStatisticsMapper extends Mapper<DailyMembersOrderStatistics> { public interface DailyMembersOrderStatisticsMapper extends Mapper<DailyMembersOrderStatistics> {
List<Map<String, Object>> getTravelGmv(@Param("day") Integer day); Map<String, Object> getTravelGmv(@Param("day") Integer day);
OrderStatistics monthOrderTotal(@Param("companyId") Integer companyId); OrderStatistics monthOrderTotal(@Param("companyId") Integer companyId);
......
...@@ -35,22 +35,22 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -35,22 +35,22 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
/** /**
* 租车订单 * 租车订单
*/ */
private final Integer TYEP_VEHICLE = 1; private final Integer TYPE_VEHICLE = 1;
/** /**
* 旅游订单 * 旅游订单
*/ */
private final Integer TYEP_TOUR = 2; private final Integer TYPE_TOUR = 2;
/** /**
* 购买会员订单 * 购买会员订单
*/ */
private final Integer TYEP_MEMBER = 3; private final Integer TYPE_MEMBER = 3;
/** /**
* 月总数据 * 月总数据
*/ */
private final Integer TYEP_TOTAL = 4; private final Integer TYPE_TOTAL = 4;
@Autowired @Autowired
private DailyVehicleOrderStatisticsBiz vehicleBiz; private DailyVehicleOrderStatisticsBiz vehicleBiz;
...@@ -77,22 +77,23 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -77,22 +77,23 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
UserDTO user = userDTOObjectRestResponse.getData(); UserDTO user = userDTOObjectRestResponse.getData();
Integer companyId = user.getCompanyId(); Integer companyId = user.getCompanyId();
if (TYEP_VEHICLE.equals(type)) { if (TYPE_VEHICLE.equals(type)) {
OrderStatistics vehicle = vehicleBiz.findAll(companyId); OrderStatistics vehicle = vehicleBiz.findAll(companyId);
return ObjectRestResponse.succ(vehicle); return ObjectRestResponse.succ(vehicle);
} }
if (TYEP_TOUR.equals(type)) { if (TYPE_TOUR.equals(type)) {
OrderStatistics tour = TravelBiz.findAll(companyId); OrderStatistics tour = TravelBiz.findAll(companyId);
return ObjectRestResponse.succ(tour); return ObjectRestResponse.succ(tour);
} }
if (TYEP_MEMBER.equals(type)) { if (TYPE_MEMBER.equals(type)) {
OrderStatistics member = membersBiz.findAll(companyId); OrderStatistics member = membersBiz.findAll(companyId);
return ObjectRestResponse.succ(member); return ObjectRestResponse.succ(member);
} }
if (TYEP_TOTAL.equals(type)) { if (TYPE_TOTAL.equals(type)) {
return ObjectRestResponse.succ(baseBiz.getTotalOrder(companyId)); return ObjectRestResponse.succ(baseBiz.getTotalOrder(companyId));
} }
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "参数错误!"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "参数错误!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
daily_members_order_statistics daily_members_order_statistics
WHERE WHERE
branch_company_id =#{companyId} branch_company_id =#{companyId}
and -- and
DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),interval 1 day),'%Y-%c') -- DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),interval 1 day),'%Y-%c')
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
daily_travel_order_statistics daily_travel_order_statistics
WHERE WHERE
branch_company_id =#{branchCompanyId} branch_company_id =#{branchCompanyId}
AND -- AND
DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%c') -- DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%c')
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -139,9 +139,8 @@ ...@@ -139,9 +139,8 @@
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics"> <select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT SELECT
IFNULL(sum(gmv),0) as totalGmv, IFNULL(sum(gmv),0) as totalGmv,
IFNULL(sum(security_deposit),0) as totalSecurityDeposit, (IFNULL(sum(security_deposit),0)-IFNULL(sum(refund_security_deposit) ,0)) as totalSecurityDeposit,
IFNULL(sum(refund_security_deposit) ,0) as totalRefundSecurityDeposit, IFNULL(sum(refund_security_deposit) ,0) as totalRefundSecurityDeposit,
IFNULL(sum(compensation) ,0) as totalCompensation, IFNULL(sum(compensation) ,0) as totalCompensation,
IFNULL(sum(forfeit) ,0) as totalForfeit, IFNULL(sum(forfeit) ,0) as totalForfeit,
...@@ -151,7 +150,7 @@ ...@@ -151,7 +150,7 @@
daily_vehicle_order_statistics daily_vehicle_order_statistics
WHERE WHERE
branch_company_id =#{companyId} branch_company_id =#{companyId}
and -- and
DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),interval 1 day),'%Y-%c') -- DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),interval 1 day),'%Y-%c')
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -47,7 +47,7 @@ public class IdInformation implements Serializable { ...@@ -47,7 +47,7 @@ public class IdInformation implements Serializable {
* 用户id * 用户id
*/ */
@Column(name = "user_login_id") @Column(name = "user_login_id")
private Integer userLonginId; private Integer userLoginId;
/** /**
* *
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.vo.OrderRefundVo; import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.universal.vo.TrafficViolations; import com.xxfc.platform.universal.vo.TrafficViolations;
...@@ -74,7 +75,8 @@ public interface ThirdFeign { ...@@ -74,7 +75,8 @@ public interface ThirdFeign {
@PostMapping("/dictionary/type_code") @PostMapping("/dictionary/type_code")
public Dictionary findDictionaryByTypeAndCode(@RequestParam(value = "type") String type,@RequestParam(value = "code") String code); public Dictionary findDictionaryByTypeAndCode(@RequestParam(value = "type") String type,@RequestParam(value = "code") String code);
@GetMapping(value = "/certif/app/unauth/selectByUser")
public IdInformation getOneByUserId(@RequestParam(value = "userId")Integer userId);
/***************************************** 违章 ********************************************/ /***************************************** 违章 ********************************************/
@GetMapping("/3p/tv/getRentViolation") @GetMapping("/3p/tv/getRentViolation")
......
...@@ -12,14 +12,10 @@ import com.xxfc.platform.universal.biz.MQServiceBiZ; ...@@ -12,14 +12,10 @@ import com.xxfc.platform.universal.biz.MQServiceBiZ;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.service.CertificationService; import com.xxfc.platform.universal.service.CertificationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
...@@ -45,7 +41,6 @@ public class CertificationController { ...@@ -45,7 +41,6 @@ public class CertificationController {
private UserFeign userFeign; private UserFeign userFeign;
@Qualifier("applicationTaskExecutor") @Qualifier("applicationTaskExecutor")
@Autowired @Autowired
private TaskExecutor executor; private TaskExecutor executor;
...@@ -79,11 +74,11 @@ public class CertificationController { ...@@ -79,11 +74,11 @@ public class CertificationController {
return ObjectRestResponse.createFailedResult(ResultCode.GET_APPUSER_FAILED_CODE,"无法识别,请重新上传"); return ObjectRestResponse.createFailedResult(ResultCode.GET_APPUSER_FAILED_CODE,"无法识别,请重新上传");
} }
AppUserDTO appUserDTO = appUserDTOObjectRestResponse.getData(); AppUserDTO appUserDTO = appUserDTOObjectRestResponse.getData();
idInformation.setUserLonginId(appUserDTO.getUserid()); idInformation.setUserLoginId(appUserDTO.getUserid());
//获取用户认证信息 //获取用户认证信息
ObjectRestResponse orr = null; ObjectRestResponse orr = null;
try { try {
orr = userFeign.authentication(idInformation.getUserLonginId(), null,null, 0); orr = userFeign.authentication(idInformation.getUserLoginId(), null,null, 0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -125,4 +120,8 @@ public class CertificationController { ...@@ -125,4 +120,8 @@ public class CertificationController {
mqServiceBiZ.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString()); mqServiceBiZ.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
} }
@GetMapping(value = "/app/unauth/selectByUser")
public IdInformation getOneByUserId(Integer userId) {
return certificationService.getByUser(userId);
}
} }
...@@ -2,8 +2,6 @@ package com.xxfc.platform.universal.mapper; ...@@ -2,8 +2,6 @@ package com.xxfc.platform.universal.mapper;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
...@@ -11,6 +9,8 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -11,6 +9,8 @@ import tk.mybatis.mapper.common.Mapper;
public interface IdInformationMapper extends Mapper<IdInformation> { public interface IdInformationMapper extends Mapper<IdInformation> {
@Insert(value = "insert into id_information (user_login_id,name,id_number,certificate_type,front_url,back_url,expiration_date) " + @Insert(value = "insert into id_information (user_login_id,name,id_number,certificate_type,front_url,back_url,expiration_date) " +
"values (#{userLonginId},#{name},#{idNumber},#{certificateType},#{frontUrl},#{backUrl},#{expirationDate})") "values (#{userLoginId},#{name},#{idNumber},#{certificateType},#{frontUrl},#{backUrl},#{expirationDate})")
void addIdInformation(IdInformation idInformation); void addIdInformation(IdInformation idInformation);
IdInformation selectByUserId(Integer userLoginId);
} }
...@@ -10,7 +10,6 @@ import com.xxfc.platform.universal.entity.IdInformation; ...@@ -10,7 +10,6 @@ import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.mapper.IdInformationMapper; import com.xxfc.platform.universal.mapper.IdInformationMapper;
import com.xxfc.platform.universal.utils.CertifHttpUtils; import com.xxfc.platform.universal.utils.CertifHttpUtils;
import com.xxfc.platform.universal.utils.Validation; import com.xxfc.platform.universal.utils.Validation;
import javafx.application.Application;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.collections4.map.HashedMap;
...@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
...@@ -335,7 +333,7 @@ public class CertificationService { ...@@ -335,7 +333,7 @@ public class CertificationService {
Example exa = new Example(IdInformation.class); Example exa = new Example(IdInformation.class);
Example.Criteria criteria = exa.createCriteria(); Example.Criteria criteria = exa.createCriteria();
criteria.andEqualTo("idNumber",idInformation.getIdNumber()); criteria.andEqualTo("idNumber",idInformation.getIdNumber());
criteria.andEqualTo("userLonginId",idInformation.getUserLonginId()); criteria.andEqualTo("userLoginId",idInformation.getUserLoginId());
List<IdInformation> idInformations = idInformationMapper.selectByExample(exa); List<IdInformation> idInformations = idInformationMapper.selectByExample(exa);
if (CollectionUtils.isEmpty(idInformations)) { if (CollectionUtils.isEmpty(idInformations)) {
idInformation.setCrtTime(new Date()); idInformation.setCrtTime(new Date());
...@@ -346,22 +344,20 @@ public class CertificationService { ...@@ -346,22 +344,20 @@ public class CertificationService {
idInformation.setUpdTime(new Date()); idInformation.setUpdTime(new Date());
idInformationMapper.updateByPrimaryKeySelective(idInformation); idInformationMapper.updateByPrimaryKeySelective(idInformation);
} }
log.info("----addIdInformation---userid==="+idInformation.getUserLonginId()+"----name====" + idInformation.getName()+"---IdNumber==="+idInformation.getIdNumber()); log.info("----addIdInformation---userid==="+idInformation.getUserLoginId()+"----name====" + idInformation.getName()+"---IdNumber==="+idInformation.getIdNumber());
//认证成功后修改用户,用户认证状态 //认证成功后修改用户,用户认证状态
ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLonginId(), idInformation.getName(), idInformation.getIdNumber(), 1); ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return ObjectRestResponse.succ(idInformation.getId()); return ObjectRestResponse.succ(idInformation.getId());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus(); TransactionAspectSupport.currentTransactionStatus();
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA,"无法识别,请重新上传"); return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA,"无法识别,请重新上传");
} }
} }
public IdInformation getByUser(Integer userId) {
return idInformationMapper.selectByUserId(userId);
}
} }
......
...@@ -6,14 +6,16 @@ ...@@ -6,14 +6,16 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="idNumber" column="id_number"/> <result property="idNumber" column="id_number"/>
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="userLonginId" column="user_login_id"/> <result property="userLoginId" column="user_login_id"/>
<result property="certificateType" column="certificate_type"/> <result property="certificateType" column="certificate_type"/>
<result property="frontUrl" column="front_url"/> <result property="frontUrl" column="front_url"/>
<result property="backUrl" column="back_url"/> <result property="backUrl" column="back_url"/>
<result property="expirationDate" column="expiration_date"/> <result property="expirationDate" column="expiration_date"/>
<result property="authenticationMethods" column="authentication_methods"/> <result property="authenticationMethods" column="authentication_methods"/>
</resultMap> </resultMap>
<select id="selectByUserId" resultType="com.xxfc.platform.universal.entity.IdInformation" parameterType="java.lang.Integer">
select * from id_information where user_login_id = #{userLoginId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -29,6 +29,7 @@ public enum ResCode { ...@@ -29,6 +29,7 @@ public enum ResCode {
VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE(104003,"车辆未出车"), VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE(104003,"车辆未出车"),
VEHICLE_BOOK_RECORD_IS_NOT_EXIST(104004, "预约记录不存在"), VEHICLE_BOOK_RECORD_IS_NOT_EXIST(104004, "预约记录不存在"),
VEHICLE_UNBOOK_FAIL(104005, "取消预定失败!"),
BRANCH_COMPANY_UNEXIST(105001, "分公司信息不存在"), BRANCH_COMPANY_UNEXIST(105001, "分公司信息不存在"),
BRANCH_COMPANY_STOCK_EXISTED(105002, "分公司股权信息已存在"), BRANCH_COMPANY_STOCK_EXISTED(105002, "分公司股权信息已存在"),
......
...@@ -103,4 +103,9 @@ public class BookVehicleVO { ...@@ -103,4 +103,9 @@ public class BookVehicleVO {
private String upkeepIds; private String upkeepIds;
private String orderNo; private String orderNo;
/**
* book_record状态
*/
private Integer status;
} }
\ No newline at end of file
...@@ -14,9 +14,6 @@ public class CompanyDetail extends BranchCompany { ...@@ -14,9 +14,6 @@ public class CompanyDetail extends BranchCompany {
StringBuilder detailAddrStr = new StringBuilder(""); StringBuilder detailAddrStr = new StringBuilder("");
if(null != this.getSysRegions() && this.getSysRegions().size() > 0) { if(null != this.getSysRegions() && this.getSysRegions().size() > 0) {
for(SysRegion sysRegion : this.getSysRegions()) { for(SysRegion sysRegion : this.getSysRegions()) {
// if(0 != detailAddrStr.length()) {
//
// }
String name = sysRegion.getName() String name = sysRegion.getName()
.replace("省", "") .replace("省", "")
.replace("市", "") .replace("市", "")
...@@ -27,7 +24,9 @@ public class CompanyDetail extends BranchCompany { ...@@ -27,7 +24,9 @@ public class CompanyDetail extends BranchCompany {
} }
} }
} }
if(this.getAddrDetail().contains(detailAddrStr)) {
return this.getAddrDetail();
}
detailAddrStr.append(this.getAddrDetail()); detailAddrStr.append(this.getAddrDetail());
return detailAddrStr.toString(); return detailAddrStr.toString();
} }
......
...@@ -29,4 +29,6 @@ public class QueryVehicleWarningMsgVo { ...@@ -29,4 +29,6 @@ public class QueryVehicleWarningMsgVo {
private Integer page; private Integer page;
private Integer limit; private Integer limit;
private Integer colorType;
} }
...@@ -56,7 +56,7 @@ public class VehicleActiveService { ...@@ -56,7 +56,7 @@ public class VehicleActiveService {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) { if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
Integer MileageLift=vehicle.getMileageLastUpdate(); Integer MileageLift=vehicle.getMileageLastUpdate();
...@@ -75,8 +75,8 @@ public class VehicleActiveService { ...@@ -75,8 +75,8 @@ public class VehicleActiveService {
int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(), int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(),
VehicleStatus.NORMAL.getCode()); VehicleStatus.NORMAL.getCode());
if (result == 0) { if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
//修改预约记录状态 //修改预约记录状态
...@@ -117,10 +117,35 @@ public class VehicleActiveService { ...@@ -117,10 +117,35 @@ public class VehicleActiveService {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(), throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode()); ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
} }
}
public String getVehicleStatus(Integer status, String vehicleId) {
StringBuilder stringBuilder = new StringBuilder();
switch (status) {
case 1:
stringBuilder.append("正常运行");
break;
case 2:
stringBuilder.append("维修");
break;
case 3:
stringBuilder.append("报废");
break;
case 4:
stringBuilder.append("出车");
break;
case 5:
stringBuilder.append("保养");
break;
}
List<VehicleBookRecordVo> vehicleBookRecordVos = vehicleBookRecordBiz.selectByVehicleId(vehicleId);
if(vehicleBookRecordVos != null && vehicleBookRecordVos.size() > 0) {
stringBuilder.append("中,使用人:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUsername());
stringBuilder.append(" 使用人电话:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone());
}
return stringBuilder.toString();
} }
@Transactional @Transactional
...@@ -131,7 +156,7 @@ public class VehicleActiveService { ...@@ -131,7 +156,7 @@ public class VehicleActiveService {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) { if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
} }
Integer Mileagerest = vehicle.getMileageLastUpdate(); Integer Mileagerest = vehicle.getMileageLastUpdate();
......
...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.constant.RedisKey; ...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.constant.VehicleStatus; import com.xxfc.platform.vehicle.constant.VehicleStatus;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper; import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper;
import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper; import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper; import com.xxfc.platform.vehicle.mapper.VehicleMapper;
...@@ -314,180 +311,94 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -314,180 +311,94 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.suc(); return RestResponse.suc();
} }
/** // /**
* 申请汽车预定(内部) // * 申请汽车预定(内部)
* 检查是否可预定,修改相关预定记录状态 // * 检查是否可预定,修改相关预定记录状态
* @param userId // * @param userId
* @param bookVehicleVo // * @param bookVehicleVo
* @return // * @return
*/ // */
@Transactional // @Transactional
public VehicleBookRecord applyVehicle4Employee(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{ // public VehicleBookRecord applyVehicle4Employee(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{
//检查车辆信息是否合法 // //检查车辆信息是否合法
checkIfVehicleExists(bookVehicleVo.getVehicleId()); // checkIfVehicleExists(bookVehicleVo.getVehicleId());
//提取日期和相应的预定目标日期 // //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); // Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
//预定时间不能为空 // //预定时间不能为空
if(StringUtils.isBlank(bookVehicleVo.getBookStartDate()) || StringUtils.isBlank(bookVehicleVo.getBookEndDate())){ // if(StringUtils.isBlank(bookVehicleVo.getBookStartDate()) || StringUtils.isBlank(bookVehicleVo.getBookEndDate())){
throw new BaseException(ResultCode.DATE_TIME_IS_NULL); // throw new BaseException(ResultCode.DATE_TIME_IS_NULL);
} // }
String[] bookStartDateArray = bookVehicleVo.getBookStartDate().split(" "); // String[] bookStartDateArray = bookVehicleVo.getBookStartDate().split(" ");
String[] bookEndDateArray = bookVehicleVo.getBookEndDate().split(" "); // String[] bookEndDateArray = bookVehicleVo.getBookEndDate().split(" ");
//
DateTime startDay =DateTime.parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER); // DateTime startDay =DateTime.parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookEndDateArray[0], DEFAULT_DATE_TIME_FORMATTER); // DateTime endDay =DateTime.parse(bookEndDateArray[0], DEFAULT_DATE_TIME_FORMATTER);
//
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
}
}
//加入预定申请记录
VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName);
vehicleBookRecord.setBookStartDate(DateTime.
parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
vehicleBookRecord.setBookEndDate(DateTime.
parse(bookEndDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
vehicleBookRecord.setOrderNo(bookVehicleVo.getOrderNo());
vehicleBookRecordBiz.save(vehicleBookRecord);
// //添加预定时间记录
// //
// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate()); // //转换日期范围为列表,并检查是否合法
// for(Map.Entry<String, Integer> entry : map.entrySet()) { // fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
// VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); // if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
// vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId()); // throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
// vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); // }
// vehicleBookHourInfoDto.setBookedHour(entry.getValue()); // Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
// vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto); // //检查车辆是否可以预定
// for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
// Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
// if(Boolean.FALSE.equals(rsEach)){
// throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
// } // }
// }
//修改相关车辆预定记录 //
Boolean hasSuc = bookedVehicle(bookVehicleVo); // //加入预定申请记录
if(!hasSuc){ // VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
throw new BaseException(ResultCode.BOOKED_FAILED_CODE); // vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
} // vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
// vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
//添加随车物品 // vehicleBookRecord.setBookUser(userId);
List<Map<String,Object>> params = Lists.newArrayList(); // vehicleBookRecord.setBookUserName(userName);
if(MapUtils.isNotEmpty(bookVehicleVo.getSelectedAccItem())){ // vehicleBookRecord.setBookStartDate(DateTime.
for(Map.Entry<Integer,Integer> idAndAmount : bookVehicleVo.getSelectedAccItem().entrySet()){ // parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
Map<String,Object> row = Maps.newHashMap(); // vehicleBookRecord.setBookEndDate(DateTime.
row.put("id",idAndAmount.getKey()); // parse(bookEndDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
row.put("amount",idAndAmount.getValue()); // vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
row.put("bookRecordId",vehicleBookRecord.getId()); // vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
params.add(row); // vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
} // vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
bookRecordAccItemMapper.batchAdd(params); // vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
} // vehicleBookRecord.setOrderNo(bookVehicleVo.getOrderNo());
// vehicleBookRecordBiz.save(vehicleBookRecord);
return vehicleBookRecord; //// //添加预定时间记录
} ////
//// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
/** //// for(Map.Entry<String, Integer> entry : map.entrySet()) {
* 需要审核 //// VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
* @param userId //// vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
* @param bookVehicleVo //// vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
* @param userName //// vehicleBookHourInfoDto.setBookedHour(entry.getValue());
* @return //// vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
* @throws Exception //// }
*/ //
@Transactional // //修改相关车辆预定记录
public VehicleBookRecord applyForVehicle(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{ // Boolean hasSuc = bookedVehicle(bookVehicleVo);
log.info("预定车辆参数:userId = {}, bookVehicleVo = {},username = {}", userId, bookVehicleVo, userName); // if(!hasSuc){
//检查车辆信息是否合法 // throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
checkIfVehicleExists(bookVehicleVo.getVehicleId()); // }
//提取日期和相应的预定目标日期 //
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); // //添加随车物品
//预定时间不能为空 // List<Map<String,Object>> params = Lists.newArrayList();
if(StringUtils.isBlank(bookVehicleVo.getBookStartDate()) || StringUtils.isBlank(bookVehicleVo.getBookEndDate())){ // if(MapUtils.isNotEmpty(bookVehicleVo.getSelectedAccItem())){
throw new BaseException(ResultCode.DATE_TIME_IS_NULL); // for(Map.Entry<Integer,Integer> idAndAmount : bookVehicleVo.getSelectedAccItem().entrySet()){
} // Map<String,Object> row = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER); // row.put("id",idAndAmount.getKey());
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER); // row.put("amount",idAndAmount.getValue());
// row.put("bookRecordId",vehicleBookRecord.getId());
// params.add(row);
//转换日期范围为列表,并检查是否合法 // }
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay); // bookRecordAccItemMapper.batchAdd(params);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 // }
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH); //
} // return vehicleBookRecord;
//检查车辆是否可以预定 // }
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
}
}
//加入预定申请记录
VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) {
vehicleBookRecord = new VehicleBookRecord();
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName);
vehicleBookRecordBiz.save(vehicleBookRecord);
} else {
vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId());
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord);
}
// //添加预定时间记录
VehicleBookRecord newValue = vehicleBookRecordBiz.selectOne(vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setBookedHour(entry.getValue());
vehicleBookHourInfoDto.setBookRecordId(newValue.getId());
vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
}
//修改相关车辆预定记录
Boolean hasSuc = bookedVehicle(bookVehicleVo);
if(!hasSuc){
throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
}
//添加随车物品
List<Map<String,Object>> params = Lists.newArrayList();
if(MapUtils.isNotEmpty(bookVehicleVo.getSelectedAccItem())){
for(Map.Entry<Integer,Integer> idAndAmount : bookVehicleVo.getSelectedAccItem().entrySet()){
Map<String,Object> row = Maps.newHashMap();
row.put("id",idAndAmount.getKey());
row.put("amount",idAndAmount.getValue());
row.put("bookRecordId",vehicleBookRecord.getId());
params.add(row);
}
bookRecordAccItemMapper.batchAdd(params);
}
return vehicleBookRecord;
}
/** /**
* 不需要审核 * 不需要审核
...@@ -506,15 +417,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -506,15 +417,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER); DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法 //转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay); fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
} }
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){ for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey()); Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED); throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
} }
...@@ -527,7 +437,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -527,7 +437,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate()); vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate()); vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode()); vehicleBookRecord.setStatus(bookVehicleVo.getStatus());
vehicleBookRecord.setBookUser(userId); vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName); vehicleBookRecord.setBookUserName(userName);
vehicleBookRecordBiz.save(vehicleBookRecord); vehicleBookRecordBiz.save(vehicleBookRecord);
...@@ -539,14 +449,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -539,14 +449,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
} }
// //添加预定时间记录 // //添加预定时间记录
VehicleBookRecord newValue = vehicleBookRecordBiz.selectOne(vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String, Integer> entry : map.entrySet()) { for(Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId()); vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setBookedHour(entry.getValue()); vehicleBookHourInfoDto.setBookedHour(entry.getValue());
vehicleBookHourInfoDto.setBookRecordId(newValue.getId());
vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto); vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
} }
...@@ -574,7 +481,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -574,7 +481,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional @Transactional
public Boolean applyVehicle4EmployeePerMonth(String vehicleId, List<String> bookedDates, String yearMonth){ public Boolean applyVehicle4EmployeePerMonth(String vehicleId, List<String> bookedDates, String yearMonth, Map<String, Integer> hourInfo){
//检查车辆是否有空档 //检查车辆是否有空档
//获得当月预定记录 //获得当月预定记录
VehicleBookInfo vehicleBookInfo = getByVehicleIdAndYearMonth(vehicleId,yearMonth); VehicleBookInfo vehicleBookInfo = getByVehicleIdAndYearMonth(vehicleId,yearMonth);
...@@ -587,14 +494,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -587,14 +494,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,Integer> andOpratorParam = yearMonthAndParam.get(yearMonth); Map<String,Integer> andOpratorParam = yearMonthAndParam.get(yearMonth);
Integer andOperationFactor = andOpratorParam.get("andOperationFactor"); Integer andOperationFactor = andOpratorParam.get("andOperationFactor");
Integer andOperationRs = andOpratorParam.get("andOperationRs"); Integer andOperationRs = andOpratorParam.get("andOperationRs");
if(vehicleBookInfo!=null&&vehicleBookInfo.getBookedDate()!=null && if(vehicleBookInfo != null && vehicleBookInfo.getBookedDate() != null &&
((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){ ((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){
return Boolean.FALSE; //当天已经被预定检查小时是否也被预定
return filterHourInfoBooked(vehicleId, hourInfo);
} }
return Boolean.TRUE; return Boolean.TRUE;
} }
public boolean filterHourInfoBooked(String vehicleId, Map<String, Integer> hourInfo) {
for(Map.Entry<String, Integer> entry : hourInfo.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setVehicleId(vehicleId);
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() >0) {
if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) { // 已经被预定
log.info(entry.getKey() + "预定的时间段已经被预约!");
return Boolean.FALSE;
}
}
}
return Boolean.TRUE;
}
/** /**
* 批准预定车辆预定 * 批准预定车辆预定
* @param operatorId * @param operatorId
...@@ -616,24 +540,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -616,24 +540,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换为相应预定参数 //转换为相应预定参数
BookVehicleVO bookVehicleVo = new BookVehicleVO(); BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
// //审核通过的话,需要修改相关车辆预定记录
// if(VehicleBookRecordStatus.APPROVE.getCode().equals(rsStatus)) {
// Boolean hasSuc = bookedVehicle(bookVehicleVo);
// if(!hasSuc){
// return RestResponse.code(ResCode.VEHICLE_BOOKED_INFO_ALREADY_CHANGED.getCode());
// }
// }
// //如果拒绝预定,删除预定时间记录
// if(VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())) {
// //删除预定时间记录
// List<String> list = null;
// for( DateTime curDate = new DateTime(vehicleBookRecord.getBookStartDate());curDate.compareTo(new DateTime(vehicleBookRecord.getBookEndDate()))<=0;curDate=curDate.plusDays(1)) {
// list.add(curDate.toString(DEFAULT_DATE_TIME_FORMATTER));
// }
// vehicleBookHourInfoBiz.delete(vehicleBookRecord.getVehicleId(),list);
// }
//成功后修改预定记录状态 //成功后修改预定记录状态
Map<String,Object> updateParam = Maps.newHashMap(); Map<String,Object> updateParam = Maps.newHashMap();
updateParam.put("id",bookRecordId); updateParam.put("id",bookRecordId);
...@@ -682,12 +591,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -682,12 +591,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(null); bookVehicleVo.setBookStartDate(null);
bookVehicleVo.setBookEndDate(null); bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
//取消预定 //取消预定
Boolean hasSuc = unbookVehicle(bookVehicleVo); Boolean hasSuc = unbookVehicle(bookVehicleVo);
if(!hasSuc){ if(!hasSuc){
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc()); return RestResponse.codeAndMessage(ResCode.VEHICLE_UNBOOK_FAIL.getCode(), ResCode.VEHICLE_UNBOOK_FAIL.getDesc());
} }
//修改预定状态,写入取消人 //修改预定状态,写入取消人
Map<String,Object> updateParam = Maps.newHashMap(); Map<String,Object> updateParam = Maps.newHashMap();
...@@ -753,7 +662,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -753,7 +662,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public Boolean bookedVehicle( BookVehicleVO bookVehicleVo) throws Exception{ public Boolean bookedVehicle( BookVehicleVO bookVehicleVo) throws Exception{
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER); DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法 //转换日期范围为列表,并检查是否合法
...@@ -785,11 +693,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -785,11 +693,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicleBookInfo.setVehicle(vehicleId); vehicleBookInfo.setVehicle(vehicleId);
vehicleBookInfo.setYearMonth(yearMonth); vehicleBookInfo.setYearMonth(yearMonth);
//检查是否存在相关车辆 //检查是否存在相关车辆
Vehicle param = new Vehicle();
param.setId(vehicleId);
checkIfVehicleExists(vehicleId); checkIfVehicleExists(vehicleId);
Integer orRsOperationFactor = getBitOpratorFactor4Booked(bookedDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果 Integer orRsOperationFactor = getBitOpratorFactor4Booked(bookedDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
vehicleBookInfo.setBookedDate(orRsOperationFactor); vehicleBookInfo.setBookedDate(orRsOperationFactor);
Map<String,Object> map = new HashMap<>();
map.put("vehicle", vehicleId);
map.put("yearMonth", yearMonth);
List<VehicleBookInfo> vehicleBookInfos = vehicleBookInfoMapper.getByVehicleIdAndYearMonth(map);
if(vehicleBookInfos != null && vehicleBookInfos.size() > 0) {
if((vehicleBookInfos.get(0).getBookedDate() & orRsOperationFactor) == orRsOperationFactor) {
return Boolean.TRUE;
}
}
Integer effected = vehicleBookInfoMapper.insertIgnore(vehicleBookInfo); Integer effected = vehicleBookInfoMapper.insertIgnore(vehicleBookInfo);
if(effected == 0){//已存在则需要更新 if(effected == 0){//已存在则需要更新
Map<String,Object> params = Maps.newHashMap(); Map<String,Object> params = Maps.newHashMap();
...@@ -881,17 +796,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -881,17 +796,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//提取日期参数,改为每月一份 //提取日期参数,改为每月一份
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DEFAULT_DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DEFAULT_DATE_TIME_FORMATTER); DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法 //转换日期范围为列表,并检查是否合法
uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay); uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getUnbookStartDate(), bookVehicleVo.getUnbookEndDate());
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH);
} }
Boolean rs = Boolean.TRUE; Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){ for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = unbookVehiclePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey()); Boolean rsEach = unbookVehiclePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
rs = Boolean.FALSE; rs = Boolean.FALSE;
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//手动回滚 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//手动回滚
...@@ -900,8 +815,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -900,8 +815,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return rs; return rs;
} }
@Transactional @Transactional
public Boolean unbookVehiclePerMonth(String vehicleId, List<String> unbookDates, String yearMonth){ public Boolean unbookVehiclePerMonth(String vehicleId, List<String> unbookDates, String yearMonth, Map<String, Integer> hourInfo){
checkIfVehicleExists(vehicleId); checkIfVehicleExists(vehicleId);
Map<String,Object> params = Maps.newHashMap(); Map<String,Object> params = Maps.newHashMap();
params.put("vehicleId",vehicleId); params.put("vehicleId",vehicleId);
...@@ -921,10 +837,34 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -921,10 +837,34 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Integer andRsOperationFactor = getBitOpratorFactor4UnBooked(unbookDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果 Integer andRsOperationFactor = getBitOpratorFactor4UnBooked(unbookDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
params.put("andRsOperationFactor", params.put("andRsOperationFactor",
andRsOperationFactor); andRsOperationFactor);
Integer effected = vehicleBookInfoMapper.updateBookedInfo(params); if(hourInfo.size() == 1) { //取消当天的小时,不取消当天的预定
return effected>0?Boolean.TRUE:Boolean.FALSE; return unbookHourInfo(vehicleId, hourInfo);
} else {
Integer effected = vehicleBookInfoMapper.updateBookedInfo(params);
return unbookHourInfo(vehicleId, hourInfo);
}
} }
public boolean unbookHourInfo(String vehicleId, Map<String, Integer> hourInfo) {
for (Map.Entry<String, Integer> entry : hourInfo.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setVehicleId(vehicleId);
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
if (vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
vehicleBookHourInfos.get(0).setBookedHour((vehicleBookHourInfos.get(0).getBookedHour() & ~entry.getValue()));
int effect = vehicleBookHourInfoBiz.updateByIdRe(vehicleBookHourInfos.get(0));
if (effect < 1) {
return Boolean.FALSE;
} else {
continue;
}
} else {
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
/** /**
* 获取某月份相应预定日期查询条件 * 获取某月份相应预定日期查询条件
......
...@@ -31,7 +31,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -31,7 +31,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public static Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate) { public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null; Date startDate = null;
Date endDate = null; Date endDate = null;
...@@ -68,12 +68,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -68,12 +68,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
endPredictableHour |= 1 << (curentHour); endPredictableHour |= 1 << (curentHour);
} }
} }
if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour); } else {
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour);
}
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(endDay.getDayOfMonth() - startDay.getDayOfMonth() >1){ // if(endDay.getDayOfMonth() - startDay.getDayOfMonth() >1){ //
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
String curDateStr = curDate.toString(DATE_TIME_FORMATTER); String curDateStr = curDate.toString(DATE_TIME_FORMATTER);
...@@ -143,18 +145,9 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -143,18 +145,9 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
String result = Integer.toBinaryString(16777200); int b = 16744448;
String newString = new StringBuilder(result).reverse().toString(); Integer a = b | 31;
int i=newString.length()-result.replace("1", "").length(); System.out.println(a);
System.out.println(i);
Map<String, Integer> map = getPredictableHours("2019-07-28 00:00:00","2019-07-29 00:00:00");
for (Map.Entry<String, Integer> entry : map.entrySet()) {
log.info(entry.getKey());
log.info(entry.getValue() + "");
}
} }
} }
...@@ -299,7 +299,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -299,7 +299,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return PageDataVO.pageInfo(vehiclePageInfo); return PageDataVO.pageInfo(vehiclePageInfo);
} }
public List<VehicleBookRecordVo> selectByVehicleId(String vehicleId) {
return mapper.selectByVehicleId(vehicleId);
}
/** /**
......
...@@ -30,7 +30,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> { ...@@ -30,7 +30,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> {
public List<VehicleRecordInfoVo> getByParam(Map<String, Object> params); public List<VehicleRecordInfoVo> getByParam(Map<String, Object> params);
public List<VehicleBookRecord> getByVehicleId(String vehicleId); public List<VehicleBookRecordVo> selectByVehicleId(String vehicleId);
public List<VehicleBookRecordVo> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo); public List<VehicleBookRecordVo> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo);
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
...@@ -13,17 +14,16 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -13,17 +14,16 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.biz.VehicleBookRecordBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.biz.VehicleWarningMsgBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException; import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BookType; import com.xxfc.platform.vehicle.constant.BookType;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.Vehicle; import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo; import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord; import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
...@@ -46,6 +46,7 @@ import java.util.ArrayList; ...@@ -46,6 +46,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP; import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
...@@ -55,7 +56,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; ...@@ -55,7 +56,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
@Slf4j @Slf4j
@IgnoreClientToken @IgnoreClientToken
@Api(value="车辆管理controller",tags={"车辆管理接口"}) @Api(value="车辆管理controller",tags={"车辆管理接口"})
public class VehicleController extends BaseController<VehicleBiz> { public class VehicleController extends BaseController<VehicleBiz> implements UserRestInterface {
@Autowired @Autowired
private VehicleBookRecordBiz vehicleBookRecordBiz; private VehicleBookRecordBiz vehicleBookRecordBiz;
...@@ -78,7 +79,11 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -78,7 +79,11 @@ public class VehicleController extends BaseController<VehicleBiz> {
@Autowired @Autowired
private VehicleJobHandler vehicleJobHandler; private VehicleJobHandler vehicleJobHandler;
@Autowired
BranchCompanyBiz branchCompanyBiz;
public UserFeign getUserFeign() {
return userFeign;
}
private static Integer MAX_DRIVING_LICENSE_SIZE = 10 * 1024 * 1024;//10M private static Integer MAX_DRIVING_LICENSE_SIZE = 10 * 1024 * 1024;//10M
public static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
...@@ -213,6 +218,7 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -213,6 +218,7 @@ public class VehicleController extends BaseController<VehicleBiz> {
public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception { public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception {
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID()); Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
baseBiz.applyVehicle(operatorId, bookVehicleVo, userName); baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -228,7 +234,8 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -228,7 +234,8 @@ public class VehicleController extends BaseController<VehicleBiz> {
public RestResponse<Integer> applyForVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception { public RestResponse<Integer> applyForVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception {
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID()); Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
baseBiz.applyForVehicle(operatorId, bookVehicleVo, userName); bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -440,7 +447,8 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -440,7 +447,8 @@ public class VehicleController extends BaseController<VehicleBiz> {
BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class); BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
bookVehicleVo.setBookType(BookType.USER_RENT.getCode()); bookVehicleVo.setBookType(BookType.USER_RENT.getCode());
bookVehicleVo.setVehicleId(pageDataVO.getData().get(0).getId()); bookVehicleVo.setVehicleId(pageDataVO.getData().get(0).getId());
VehicleBookRecord vehicleBookRecord = baseBiz.applyVehicle4Employee(operatorId, bookVehicleVo, userName); bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
VehicleBookRecord vehicleBookRecord = baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return ObjectRestResponse.succ(vehicleBookRecord); return ObjectRestResponse.succ(vehicleBookRecord);
} }
...@@ -450,6 +458,34 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -450,6 +458,34 @@ public class VehicleController extends BaseController<VehicleBiz> {
@IgnoreClientToken @IgnoreClientToken
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) { public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) {
UserDTO userDTO = getAdminUserInfo();
if(userDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, "token失效");
}
List<Integer> companyList = Lists.newArrayList();
List<BranchCompany> branchCompany = branchCompanyBiz.getListByUser(userDTO);
companyList = branchCompany.stream().map(BranchCompany::getId).collect(Collectors.toList());
if(vehiclePlanDto.getParkBranchCompanyId() != null) {
if(companyList.size() > 0) {
if(companyList.contains(vehiclePlanDto.getParkBranchCompanyId())) {
companyList.clear();
companyList.add(vehiclePlanDto.getParkBranchCompanyId());
} else {
return ObjectRestResponse.succ();
}
}
}
if(vehiclePlanDto.getSubordinateBranch() != null) {
if(companyList.size() > 0) {
if(companyList.contains(vehiclePlanDto.getSubordinateBranch())) {
companyList.clear();
companyList.add(vehiclePlanDto.getSubordinateBranch());
} else {
return ObjectRestResponse.succ();
}
}
}
vehiclePlanDto.setCompanyIds(companyList);
//获取列表 //获取列表
PageDataVO<VehicleAndModelInfoVo> pageDataVO = baseBiz.getAllVehicle(vehiclePlanDto); PageDataVO<VehicleAndModelInfoVo> pageDataVO = baseBiz.getAllVehicle(vehiclePlanDto);
//获取警告信息 //获取警告信息
......
...@@ -367,11 +367,9 @@ ...@@ -367,11 +367,9 @@
</select> </select>
<select id="getByVehicleId" parameterType="java.lang.String" <select id="getByVehicleId" parameterType="java.lang.String"
resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo"> resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo">
SELECT v1.*, conv(v2.booked_hour,10,2) startHour,conv(v3.booked_hour,10,2) endHour,bc2.name retCompanyName from vehicle_book_record v1 SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
LEFT JOIN vehicle_book_hour_info v2 on v2.book_record_id = v1.id and YEAR(v2.year_month_day) = YEAR(v1.book_start_date) AND MONTH(v2.year_month_day) = MONTH(v1.book_start_date) AND DAY(v2.year_month_day) =DAY(v1.book_start_date) LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
LEFT JOIN vehicle_book_hour_info v3 on v3.book_record_id = v1.id and YEAR(v3.year_month_day) = YEAR(v1.book_end_date) AND MONTH(v3.year_month_day) = MONTH(v1.book_end_date) AND DAY(v3.year_month_day) =DAY(v1.book_end_date) where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2 and v1.book_end_date
</select> </select>
<select id="getByParam" parameterType="java.util.Map" resultMap="getVehicleMap"> <select id="getByParam" parameterType="java.util.Map" resultMap="getVehicleMap">
select v1.* from vehicle_book_record v1 select v1.* from vehicle_book_record v1
......
...@@ -380,16 +380,16 @@ ...@@ -380,16 +380,16 @@
<if test="status != null"> <if test="status != null">
and v1.status = #{status} and v1.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v1.subordinate_branch = #{subordinateBranch} and v1.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v1.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if> </if>
<if test="zoneId !=null"> <if test="zoneId !=null">
and bc2.zone_id = #{zoneId} and bc2.zone_id = #{zoneId}
</if> </if>
and is_del != 1 and is_del != 1
</where> </where>
</select> </select>
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
select v1.*,bc3.name parkCompanyName from vehicle v1 select v1.*,bc3.name parkCompanyName from vehicle v1
LEFT JOIN branch_company bc3 ON v1.park_branch_company_id = bc3.id LEFT JOIN branch_company bc3 ON v1.park_branch_company_id = bc3.id
<where> <where>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v1.number_plate = #{numberPlate} and v1.number_plate = #{numberPlate}
</if> </if>
<if test="companyIds != null and companyIds.size > 0"> <if test="companyIds != null and companyIds.size > 0">
...@@ -455,21 +455,19 @@ ...@@ -455,21 +455,19 @@
<if test="startTime != null"> <if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime} and v1.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v1.number_plate = #{numberPlate} and v1.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v1.status = #{status} and v1.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v1.subordinate_branch = #{subordinateBranch} and v1.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v1.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc1.zone_id = #{zoneId}
</if> </if>
and v1.is_del != 1
</where> </where>
GROUP BY v1.status GROUP BY v1.status
union all union all
...@@ -480,21 +478,19 @@ ...@@ -480,21 +478,19 @@
<if test="startTime != null"> <if test="startTime != null">
and v2.create_time between #{startTime} and #{endTime} and v2.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v2.number_plate = #{numberPlate} and v2.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v2.status = #{status} and v2.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v2.subordinate_branch = #{subordinateBranch} and v2.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v2.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if> </if>
and v1.is_del != 1
</where> </where>
</select> </select>
......
...@@ -44,20 +44,17 @@ ...@@ -44,20 +44,17 @@
<if test="startTime != null"> <if test="startTime != null">
and w.create_time between #{startTime} and #{endTime} and w.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v.number_plate = #{numberPlate} and v.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v.status = #{status} and v.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v.subordinate_branch = #{subordinateBranch} and v.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if> </if>
</where> </where>
</select> </select>
...@@ -76,6 +73,12 @@ ...@@ -76,6 +73,12 @@
<if test="numberPlate != null and numberPlate != '' "> <if test="numberPlate != null and numberPlate != '' ">
and number_plate = #{numberPlate} and number_plate = #{numberPlate}
</if> </if>
<if test="type != null">
and type = #{type}
</if>
<if test="colorType != null">
and color_type = #{colorType}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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