车辆预约判断状态
This commit is contained in:
parent
4ceede281c
commit
c749c65561
@ -4,12 +4,12 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.XzSystemUserToCompanyProject;
|
||||
import com.zhgd.xmgl.modules.basicdata.enums.SystemUserAccountTypeEnum;
|
||||
@ -21,6 +21,7 @@ import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
||||
import com.zhgd.xmgl.modules.car.service.ICarInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.EmailUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -63,6 +64,9 @@ public class CarInfoController {
|
||||
|
||||
@Autowired
|
||||
private IXzSystemUserToCompanyProjectService xzSystemUserToCompanyProjectService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "查询", operDesc = "分页列表查询项目下车辆黑白名单")
|
||||
@ApiOperation(value = "分页列表查询项目下车辆黑白名单", notes = "分页列表查询项目下车辆黑白名单", httpMethod = "POST")
|
||||
@ -113,125 +117,141 @@ public class CarInfoController {
|
||||
@ApiOperation(value = "添加车辆黑白名单管理信息", notes = "添加车辆黑白名单管理信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/save")
|
||||
public Result<Object> save(@RequestBody Map<String, Object> map) {
|
||||
log.info("开始添加车辆" + JSONObject.parseObject(JSON.toJSONString(map)));
|
||||
Object alarmPushWorkerId = map.get("alarmPushWorkerId");
|
||||
String userId = String.valueOf(map.get("enterpriseId"));
|
||||
Object driverWorkerName = map.get("driverWorkerName");
|
||||
List<String> carType = (List<String>) map.get("carType");
|
||||
List<String> driverWorkerId = (List<String>) map.get("driverWorkerId");
|
||||
Integer carModuleType = "临时车辆".equals(MapUtils.getString(map, "carModuleType")) ? 2 : 3;
|
||||
List<String> userIds = (List<String>) map.get("userIds");
|
||||
CarInfo carInfo = new CarInfo();
|
||||
if (driverWorkerId != null) {
|
||||
carInfo.setDriverWorkerId(driverWorkerId.get(0).toString());
|
||||
}
|
||||
if (driverWorkerName != null) {
|
||||
carInfo.setDriverWorkerName(driverWorkerName.toString());
|
||||
}
|
||||
if (alarmPushWorkerId != null) {
|
||||
List<String> alarmPushWorkerIds = (List<String>) alarmPushWorkerId;
|
||||
carInfo.setAlarmPushWorkerId(alarmPushWorkerIds.get(0).toString());
|
||||
}
|
||||
if (userId != null) {
|
||||
carInfo.setCreateBy(Long.valueOf(userId));
|
||||
Long workerId = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getUserId, userId)).getWorkerId();
|
||||
carInfo.setEnterpriseId(workerInfoService.getById(workerId).getEnterpriseId());
|
||||
}
|
||||
carInfo.setCarModuleType(carModuleType);
|
||||
Integer entryAndExitPermit = "单次".equals(MapUtils.getString(map, "entryAndExitPermit")) ? 0 : 1;
|
||||
carInfo.setReserveStartTime(DateUtil.parse(map.get("reserveStartTime").toString() + ":00", DatePattern.NORM_DATETIME_FORMAT));
|
||||
carInfo.setReserveEndTime(DateUtil.parse(map.get("reserveEndTime").toString() + ":00", DatePattern.NORM_DATETIME_FORMAT));
|
||||
carInfo.setEntryAndExitPermit(entryAndExitPermit);
|
||||
carInfo.setCarNumber(String.valueOf(map.get("carNumber")));
|
||||
Object carColor = map.get("carColor");
|
||||
if (carColor != null) {
|
||||
carInfo.setCarColor(String.valueOf(carColor));
|
||||
}
|
||||
carInfo.setCarType(Long.valueOf(carType.get(0).toString()));
|
||||
carInfo.setDriverTelephone(String.valueOf(map.get("driverTelephone")));
|
||||
List<Map<String, Object>> carPhotosUrl = (List<Map<String, Object>>) map.get("carPhotosUrl");
|
||||
List<Map<String, Object>> carPhotosUrls = new ArrayList<>();
|
||||
if (carPhotosUrl != null) {
|
||||
for (Map<String, Object> file : carPhotosUrl) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
carPhotosUrls.add(teMap);
|
||||
String paramStr = JSON.toJSONString(map);
|
||||
log.info("开始添加车辆" + paramStr);
|
||||
try {
|
||||
Object alarmPushWorkerId = map.get("alarmPushWorkerId");
|
||||
String userId = String.valueOf(map.get("enterpriseId"));
|
||||
Object driverWorkerName = map.get("driverWorkerName");
|
||||
List<String> carType = (List<String>) map.get("carType");
|
||||
List<String> driverWorkerId = (List<String>) map.get("driverWorkerId");
|
||||
Integer carModuleType = "临时车辆".equals(MapUtils.getString(map, "carModuleType")) ? 2 : 3;
|
||||
List<String> userIds = (List<String>) map.get("userIds");
|
||||
CarInfo carInfo = new CarInfo();
|
||||
if (driverWorkerId != null) {
|
||||
carInfo.setDriverWorkerId(driverWorkerId.get(0).toString());
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> jsz = (List<Map<String, Object>>) map.get("jsz");
|
||||
List<Map<String, Object>> jszList = new ArrayList<>();
|
||||
if (jsz != null) {
|
||||
for (Map<String, Object> file : jsz) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
jszList.add(teMap);
|
||||
if (driverWorkerName != null) {
|
||||
carInfo.setDriverWorkerName(driverWorkerName.toString());
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> xsz = (List<Map<String, Object>>) map.get("xsz");
|
||||
List<Map<String, Object>> xszList = new ArrayList<>();
|
||||
if (xsz != null) {
|
||||
for (Map<String, Object> file : xsz) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
xszList.add(teMap);
|
||||
if (alarmPushWorkerId != null) {
|
||||
List<String> alarmPushWorkerIds = (List<String>) alarmPushWorkerId;
|
||||
carInfo.setAlarmPushWorkerId(alarmPushWorkerIds.get(0).toString());
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> jqx = (List<Map<String, Object>>) map.get("jqx");
|
||||
List<Map<String, Object>> jqxList = new ArrayList<>();
|
||||
if (jqx != null) {
|
||||
for (Map<String, Object> file : jqx) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
jqxList.add(teMap);
|
||||
if (userId != null) {
|
||||
carInfo.setCreateBy(Long.valueOf(userId));
|
||||
Long workerId = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getUserId, userId)).getWorkerId();
|
||||
carInfo.setEnterpriseId(workerInfoService.getById(workerId).getEnterpriseId());
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> otherProve = (List<Map<String, Object>>) map.get("otherProve");
|
||||
List<Map<String, Object>> otherProveList = new ArrayList<>();
|
||||
if (otherProve != null) {
|
||||
for (Map<String, Object> file : otherProve) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
otherProveList.add(teMap);
|
||||
carInfo.setCarModuleType(carModuleType);
|
||||
Integer entryAndExitPermit = "单次".equals(MapUtils.getString(map, "entryAndExitPermit")) ? 0 : 1;
|
||||
carInfo.setReserveStartTime(DateUtil.parse(map.get("reserveStartTime").toString() + ":00", DatePattern.NORM_DATETIME_FORMAT));
|
||||
carInfo.setReserveEndTime(DateUtil.parse(map.get("reserveEndTime").toString() + ":00", DatePattern.NORM_DATETIME_FORMAT));
|
||||
carInfo.setEntryAndExitPermit(entryAndExitPermit);
|
||||
carInfo.setCarNumber(String.valueOf(map.get("carNumber")));
|
||||
Object carColor = map.get("carColor");
|
||||
if (carColor != null) {
|
||||
carInfo.setCarColor(String.valueOf(carColor));
|
||||
}
|
||||
}
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
carInfo.setUserIds(userIds);
|
||||
}
|
||||
carInfo.setCarPhotosUrl(JSON.toJSONString(carPhotosUrls));
|
||||
carInfo.setJsz(JSON.toJSONString(jszList));
|
||||
carInfo.setXsz(JSON.toJSONString(xszList));
|
||||
carInfo.setJqx(JSON.toJSONString(jqxList));
|
||||
carInfo.setOtherProve(JSON.toJSONString(otherProveList));
|
||||
carInfo.setProjectSn(String.valueOf(map.get("projectSn")));
|
||||
carInfo.setIsBlack(MapUtils.getInteger(map, "isBlack"));
|
||||
Object outsideDriverIdCard = map.get("outsideDriverIdCard");
|
||||
if (outsideDriverIdCard != null) {
|
||||
carInfo.setOutsideDriverIdCard(outsideDriverIdCard.toString());
|
||||
}
|
||||
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, carInfo.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, carInfo.getCarNumber());
|
||||
CarInfo old = carInfoService.getOne(queryWrapper);
|
||||
if (old != null && Objects.equals(old.getIsBlack(), 1)) {
|
||||
List<String> collect = getUserIds(carInfo.getProjectSn(), carInfo.getUserIds());
|
||||
for (String s : collect) {
|
||||
noticeService.addUserNotice(Long.valueOf(s), "新增车辆通知", StrUtil.format("【({})车辆已被拉黑,无法再进行新增】", carInfo.getCarNumber()),
|
||||
"24");
|
||||
carInfo.setCarType(Long.valueOf(carType.get(0).toString()));
|
||||
carInfo.setDriverTelephone(String.valueOf(map.get("driverTelephone")));
|
||||
List<Map<String, Object>> carPhotosUrl = (List<Map<String, Object>>) map.get("carPhotosUrl");
|
||||
List<Map<String, Object>> carPhotosUrls = new ArrayList<>();
|
||||
if (carPhotosUrl != null) {
|
||||
for (Map<String, Object> file : carPhotosUrl) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
carPhotosUrls.add(teMap);
|
||||
}
|
||||
}
|
||||
} else if (DateUtil.compare(carInfo.getReserveEndTime(), new Date()) < 0) {
|
||||
List<String> collect = getUserIds(carInfo.getProjectSn(), carInfo.getUserIds());
|
||||
for (String s : collect) {
|
||||
noticeService.addUserNotice(Long.valueOf(s), "车辆下发道闸通知", StrUtil.format("【预约时间已过期,({})车辆无法下发】", carInfo.getCarNumber()),
|
||||
"24");
|
||||
List<Map<String, Object>> jsz = (List<Map<String, Object>>) map.get("jsz");
|
||||
List<Map<String, Object>> jszList = new ArrayList<>();
|
||||
if (jsz != null) {
|
||||
for (Map<String, Object> file : jsz) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
jszList.add(teMap);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
carInfoService.addCarInfo(carInfo);
|
||||
List<Map<String, Object>> xsz = (List<Map<String, Object>>) map.get("xsz");
|
||||
List<Map<String, Object>> xszList = new ArrayList<>();
|
||||
if (xsz != null) {
|
||||
for (Map<String, Object> file : xsz) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
xszList.add(teMap);
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> jqx = (List<Map<String, Object>>) map.get("jqx");
|
||||
List<Map<String, Object>> jqxList = new ArrayList<>();
|
||||
if (jqx != null) {
|
||||
for (Map<String, Object> file : jqx) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
jqxList.add(teMap);
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> otherProve = (List<Map<String, Object>>) map.get("otherProve");
|
||||
List<Map<String, Object>> otherProveList = new ArrayList<>();
|
||||
if (otherProve != null) {
|
||||
for (Map<String, Object> file : otherProve) {
|
||||
Map<String, Object> teMap = new HashMap<>(16);
|
||||
teMap.put("name", file.get("name"));
|
||||
teMap.put("url", file.get("url"));
|
||||
otherProveList.add(teMap);
|
||||
}
|
||||
}
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
carInfo.setUserIds(userIds);
|
||||
}
|
||||
carInfo.setCarPhotosUrl(JSON.toJSONString(carPhotosUrls));
|
||||
carInfo.setJsz(JSON.toJSONString(jszList));
|
||||
carInfo.setXsz(JSON.toJSONString(xszList));
|
||||
carInfo.setJqx(JSON.toJSONString(jqxList));
|
||||
carInfo.setOtherProve(JSON.toJSONString(otherProveList));
|
||||
carInfo.setProjectSn(String.valueOf(map.get("projectSn")));
|
||||
carInfo.setIsBlack(MapUtils.getInteger(map, "isBlack"));
|
||||
Object outsideDriverIdCard = map.get("outsideDriverIdCard");
|
||||
if (outsideDriverIdCard != null) {
|
||||
carInfo.setOutsideDriverIdCard(outsideDriverIdCard.toString());
|
||||
}
|
||||
try {
|
||||
carInfoService.validEnterpriseTime(carInfo);
|
||||
} catch (OpenAlertException e) {
|
||||
//在最后一级审批人审批的时候也需要做以上同样的判断,因为可能会出现两个不同企业的人员同时提出了有冲突预约时间的车辆入场审批申请。这时候,让审批正常通过,但是不处理这条数据,不同步到后台,只用发送通知提醒项目账号和发起人、审批人账号。
|
||||
//通知内容:车辆【辽A12345】预约失败,此预约时间段内,车辆已经被其他企业预约了!
|
||||
List<String> collect = getUserIds(carInfo.getProjectSn(), carInfo.getUserIds());
|
||||
for (String s : collect) {
|
||||
noticeService.addUserNotice(Long.valueOf(s), "新增车辆通知", StrUtil.format("车辆【{}】预约失败,此预约时间段内,车辆已经被其他企业预约了!", carInfo.getCarNumber()),
|
||||
"24");
|
||||
}
|
||||
}
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, carInfo.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, carInfo.getCarNumber());
|
||||
CarInfo old = carInfoService.getOne(queryWrapper);
|
||||
if (old != null && Objects.equals(old.getIsBlack(), 1)) {
|
||||
List<String> collect = getUserIds(carInfo.getProjectSn(), carInfo.getUserIds());
|
||||
for (String s : collect) {
|
||||
noticeService.addUserNotice(Long.valueOf(s), "新增车辆通知", StrUtil.format("【({})车辆已被拉黑,无法再进行新增】", carInfo.getCarNumber()),
|
||||
"24");
|
||||
}
|
||||
} else if (DateUtil.compare(carInfo.getReserveEndTime(), new Date()) < 0) {
|
||||
List<String> collect = getUserIds(carInfo.getProjectSn(), carInfo.getUserIds());
|
||||
for (String s : collect) {
|
||||
noticeService.addUserNotice(Long.valueOf(s), "车辆下发道闸通知", StrUtil.format("【预约时间已过期,({})车辆无法下发】", carInfo.getCarNumber()),
|
||||
"24");
|
||||
}
|
||||
} else {
|
||||
carInfoService.addCarInfo(carInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("添加车辆黑白名单管理信息", e);
|
||||
emailUtils.sendFlowEmail(paramStr, e, "添加车辆", "/xmgl/carInfo/save");
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
@ -315,7 +335,7 @@ public class CarInfoController {
|
||||
return Result.success(carInfoService.countCarModuleType(map));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "查询", operDesc = "更新车辆二维码,如果为空")
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "更新", operDesc = "更新车辆二维码,如果为空")
|
||||
@ApiOperation(value = "更新车辆二维码,如果为空", notes = "更新车辆二维码,如果为空", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
@ -326,7 +346,7 @@ public class CarInfoController {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "查询", operDesc = "批量更新车辆信息")
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "更新", operDesc = "批量更新车辆信息")
|
||||
@ApiOperation(value = "批量更新车辆信息", notes = "批量更新车辆信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
@ -336,4 +356,13 @@ public class CarInfoController {
|
||||
carInfoService.editAllCar(param);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "查询", operDesc = "审批流检验车辆状态")
|
||||
@ApiOperation(value = "审批流检验车辆状态", notes = "审批流检验车辆状态", httpMethod = "POST")
|
||||
@PostMapping(value = "/validEnterpriseStatus")
|
||||
public Result validEnterpriseStatus(@ApiIgnore @RequestParam Map<String, Object> param) {
|
||||
return Result.success(carInfoService.validEnterpriseStatus(param));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -154,4 +154,7 @@ public class CarInfo implements Serializable {
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "从审批流过来")
|
||||
private Boolean fromFlow;
|
||||
}
|
||||
|
||||
@ -18,27 +18,31 @@ import java.util.Map;
|
||||
*/
|
||||
public interface ICarInfoService extends IService<CarInfo> {
|
||||
/**
|
||||
*分页列表查询项目下车辆黑白名单
|
||||
* 分页列表查询项目下车辆黑白名单
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
IPage<CarInfo> selectCarListPage(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
*列表查询项目下车辆黑白名单
|
||||
* 列表查询项目下车辆黑白名单
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<CarInfo> selectCarList(Map<String, Object> map);
|
||||
|
||||
/**添加车辆黑白名单管理信息
|
||||
/**
|
||||
* 添加车辆黑白名单管理信息
|
||||
*
|
||||
* @param carInfo
|
||||
*/
|
||||
void addCarInfo(CarInfo carInfo);
|
||||
|
||||
/**
|
||||
*删除或更新车辆
|
||||
* 删除或更新车辆
|
||||
*
|
||||
* @param project
|
||||
* @param car
|
||||
* @param mustUpdate
|
||||
@ -46,38 +50,44 @@ public interface ICarInfoService extends IService<CarInfo> {
|
||||
void deleteOrUpdateCar(Project project, CarInfo car, boolean mustUpdate);
|
||||
|
||||
/**
|
||||
*编辑车辆黑白名单管理信息
|
||||
* 编辑车辆黑白名单管理信息
|
||||
*
|
||||
* @param carInfo
|
||||
*/
|
||||
void editCarInfo(CarInfo carInfo);
|
||||
|
||||
/**
|
||||
*删除车辆数据
|
||||
* 删除车辆数据
|
||||
*
|
||||
* @param projectSn
|
||||
*/
|
||||
void deleteProjectCarData(String projectSn);
|
||||
|
||||
/**
|
||||
*统计项目下各车辆黑白名单情况
|
||||
* 统计项目下各车辆黑白名单情况
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> selectCarTypeCount(Map<String, Object> map);
|
||||
|
||||
/**删除车辆黑白名单管理信息
|
||||
/**
|
||||
* 删除车辆黑白名单管理信息
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
void delete(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
*统计项目下各车辆类型情况
|
||||
* 统计项目下各车辆类型情况
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
CountCarModuleTypeVo countCarModuleType(Map<String, Object> map);
|
||||
|
||||
/**通过id查询车辆黑白名单管理信息
|
||||
/**
|
||||
* 通过id查询车辆黑白名单管理信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
@ -85,42 +95,62 @@ public interface ICarInfoService extends IService<CarInfo> {
|
||||
CarInfo queryById(String id);
|
||||
|
||||
/**
|
||||
*根据车牌号查询车辆信息
|
||||
* 根据车牌号查询车辆信息
|
||||
*
|
||||
* @param carNumber
|
||||
* @return
|
||||
*/
|
||||
CarInfo queryByCarNumber(String carNumber);
|
||||
|
||||
/**
|
||||
*添加车辆到海康isc
|
||||
* 添加车辆到海康isc
|
||||
*
|
||||
* @param carInfo
|
||||
* @param asyncHikvision
|
||||
*/
|
||||
void addCarInfoForHikvision(CarInfo carInfo, AsyncHikvision asyncHikvision);
|
||||
|
||||
/**
|
||||
*删除车辆到海康isc
|
||||
* 删除车辆到海康isc
|
||||
*
|
||||
* @param carInfo
|
||||
* @param isSetBlack
|
||||
*/
|
||||
void deleteCarInfoForHikvision(CarInfo carInfo, boolean isSetBlack);
|
||||
|
||||
/**编辑车辆到海康isc
|
||||
/**
|
||||
* 编辑车辆到海康isc
|
||||
*
|
||||
* @param carInfo
|
||||
* @param old
|
||||
*/
|
||||
void editCarInfoForHikvision(CarInfo carInfo, CarInfo old);
|
||||
|
||||
/**更新车辆二维码,如果为空
|
||||
/**
|
||||
* 更新车辆二维码,如果为空
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void updateCarQrCode(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
*批量更新车辆信息
|
||||
* 批量更新车辆信息
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void editAllCar(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 审批流检验车辆状态
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> validEnterpriseStatus(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 校验车辆预约时间
|
||||
*
|
||||
* @param carInfo
|
||||
*/
|
||||
void validEnterpriseTime(CarInfo carInfo);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import com.zhgd.redis.lock.redisson.DistributedLock;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.SystemUserServiceImpl;
|
||||
import com.zhgd.xmgl.modules.car.entity.*;
|
||||
import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
||||
@ -28,14 +29,13 @@ import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.impl.ProjectServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionCompareDataServiceImpl;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.PathUtil;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -44,7 +44,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zhgd.xmgl.async.AsyncHikvision.getSyncTimeWithInitAndDeleteSyncIfAbsent;
|
||||
|
||||
@ -73,6 +75,9 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
@Autowired
|
||||
ProjectServiceImpl projectService;
|
||||
@Lazy
|
||||
@Resource
|
||||
NoticeServiceImpl noticeService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
||||
@Autowired
|
||||
@ -127,8 +132,8 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
if (Objects.equals(old.getCarModuleType(), CarInfoCarModuleTypeEnum.GD.getValue())) {
|
||||
throw new OpenAlertException("该车辆已存在,请勿重复添加!");
|
||||
}
|
||||
if (!Objects.equals(old.getEnterpriseId(), c.getEnterpriseId())) {
|
||||
throw new OpenAlertException("已存在企业不一致的车辆!");
|
||||
if (!Objects.equals(c.getFromFlow(), true)) {
|
||||
this.validEnterpriseTime(c);
|
||||
}
|
||||
Date now = new Date();
|
||||
boolean isHk = projectCarCameraConfigService.isHikvisionConfig(c.getProjectSn());
|
||||
@ -168,6 +173,27 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一时间同个车牌只能一个企业,这个车辆已经被A企业录入过了,他预约的是2024年10-13号,我预约的是12-14号,时间有重叠的时候,我就不能预约了,点击保存的时候提示:“10-13号车辆已经被其他企业预约了,请修改预约时间!”,我就需要将预约时间更改为13号以后才可以预约成功。
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
@Override
|
||||
public void validEnterpriseTime(CarInfo c) {
|
||||
List<CarInfoApprovalFlow> flows = carInfoApprovalFlowMapper.selectList(new LambdaQueryWrapper<CarInfoApprovalFlow>()
|
||||
.eq(CarInfoApprovalFlow::getProjectSn, c.getProjectSn())
|
||||
.eq(CarInfoApprovalFlow::getCarNumber, c.getCarNumber())
|
||||
);
|
||||
List<CarInfoApprovalFlow> otherFlows = flows.stream().filter(f -> !Objects.equals(c.getEnterpriseId(), f.getEnterpriseId())).collect(Collectors.toList());
|
||||
boolean overlap = otherFlows.stream().anyMatch(f -> DateUtil.compare(f.getReserveStartTime(), c.getReserveEndTime()) < 0 && DateUtil.compare(f.getReserveEndTime(), c.getReserveStartTime()) > 0);
|
||||
if (overlap) {
|
||||
List<Map<String, Date>> dumplictcatePeriods = DateUtils.getTimePeriodListDumplictcatePeriod(otherFlows.stream().map(f -> (Map<String, Date>) new MapBuilder<String, Date>().put("startDate", f.getReserveStartTime()).put("endDate", f.getReserveEndTime()).build()).collect(Collectors.toList()));
|
||||
List<String> dateList = dumplictcatePeriods.stream().map(f -> DateUtil.formatDateTime(f.get("startDate")) + "到" + DateUtil.formatDateTime(f.get("endDate"))).collect(Collectors.toList());
|
||||
// throw new OpenAlertException(StrUtil.format("此预约时间段内({}),车辆已经被其他企业预约了,请修改预约时间!", StrUtil.join(",", dateList)));
|
||||
throw new OpenAlertException("此预约时间段内,车辆已经被其他企业预约了,请修改预约时间!");
|
||||
}
|
||||
}
|
||||
|
||||
private void validTime(CarInfo c) {
|
||||
if (isReservationType(c) && DateUtil.compare(c.getReserveEndTime(), new Date()) < 0) {
|
||||
throw new OpenAlertException("预约时间已失效,车辆无法下发,请重新提交");
|
||||
@ -467,4 +493,31 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> validEnterpriseStatus(Map<String, Object> param) {
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
String userId = MapUtils.getString(param, "userId");
|
||||
CarInfo carInfo = BeanUtil.toBean(param, CarInfo.class);
|
||||
WorkerInfo workerInfo = workerInfoMapper.selectById(systemUserService.getById(userId).getWorkerId());
|
||||
carInfo.setEnterpriseId(workerInfo.getEnterpriseId());
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, carInfo.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, carInfo.getCarNumber());
|
||||
CarInfo old = this.getOne(queryWrapper);
|
||||
if (old != null && Objects.equals(old.getIsBlack(), 1)) {
|
||||
map.put("success", false);
|
||||
map.put("message", "此车辆已被拉黑,无法再进行预约!");
|
||||
} else {
|
||||
try {
|
||||
this.validEnterpriseTime(carInfo);
|
||||
map.put("success", true);
|
||||
map.put("message", "success");
|
||||
} catch (OpenAlertException e) {
|
||||
map.put("success", false);
|
||||
map.put("message", e.getMessage());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +80,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/exam/courseRecord/page").permitAll()
|
||||
.antMatchers("/xmgl/carInfo/validEnterpriseStatus").permitAll()
|
||||
.antMatchers("/xmgl/enterpriseType/list").permitAll()
|
||||
.antMatchers("/xmgl/dictionaryItem/list").permitAll()
|
||||
.antMatchers("/xmgl/xzSupplierQualificationApply/**").permitAll()
|
||||
|
||||
@ -643,6 +643,47 @@ public class DateUtils {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并去重时间段
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Date>> getTimePeriodListDumplictcatePeriod(List<Map<String, Date>> periodList) {
|
||||
List<Map<String, Date>> result = new ArrayList<>();
|
||||
//列表不能为空
|
||||
if (periodList == null) {
|
||||
return null;
|
||||
}
|
||||
//对数据排序,开始时间从小到大
|
||||
Collections.sort(periodList, new Comparator<Map<String, Date>>() {
|
||||
@Override
|
||||
public int compare(Map<String, Date> u1, Map<String, Date> u2) {
|
||||
long diff = u1.get("startDate").getTime() - u2.get("startDate").getTime();
|
||||
if (diff > 0) {
|
||||
return 1;
|
||||
} else if (diff < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0; //相等为0
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (int i = 0; i < periodList.size() - 1; i++) {
|
||||
int j = i + 1;
|
||||
//判断 i的Endtime 与j 的Begintime 是否有交叉,有交叉,更新 j的Begintime 为i的Begintime, 并移除i
|
||||
if (periodList.get(i).get("endDate").after(periodList.get(j).get("startDate"))) {
|
||||
periodList.get(j).put("startDate", periodList.get(i).get("startDate"));
|
||||
periodList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
result = periodList;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> diffTimeDayList = getDiffTimeDayList("2024-01-01", "2025-01-01");
|
||||
for (String s : diffTimeDayList) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user