包头bug修复

This commit is contained in:
guoshengxiong 2025-04-25 18:09:21 +08:00
parent 75a2e82efa
commit b2adcec61d
12 changed files with 604 additions and 168 deletions

View File

@ -23,26 +23,40 @@ import io.swagger.annotations.ApiModelProperty;
public class UserDevGroup implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="id")
private java.lang.Long id ;
/**装置或项目组id*/
@ApiModelProperty(value="装置或项目组id")
private java.lang.Long devGroupId ;
/**用户id*/
@ApiModelProperty(value="用户id")
private java.lang.Long userId ;
/**节点id*/
@ApiModelProperty(value="节点id")
private java.lang.String nodeId ;
/**1装置2项目组*/
@ApiModelProperty(value="1装置2项目组")
private java.lang.Integer type ;
/**创建时间*/
@ApiModelProperty(value="创建时间")
private java.util.Date createDate ;
/**更新时间*/
@ApiModelProperty(value="更新时间")
private java.util.Date updateDate ;
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private java.lang.Long id;
/**
* 装置或项目组id
*/
@ApiModelProperty(value = "装置或项目组id")
private java.lang.Long devGroupId;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id")
private java.lang.Long userId;
/**
* 节点id装置不变项目祖装置+项目组id
*/
@ApiModelProperty(value = "节点id装置不变项目祖装置+项目组id")
private java.lang.String nodeId;
/**
* 1装置2项目组
*/
@ApiModelProperty(value = "1装置2项目组")
private java.lang.Integer type;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private java.util.Date createDate;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private java.util.Date updateDate;
}

View File

@ -183,10 +183,12 @@ public class PlanFeedbackApprovalServiceImpl extends ServiceImpl<PlanFeedbackApp
Map<Long, PlanFeedback> recordIdMap = planFeedbackService.getNewestFeedbackList(approvalWorks.stream().map(PlanFeedbackApprovalWork::getRecordId).collect(Collectors.toList())).stream().collect(Collectors.toMap(PlanFeedback::getRecordId, Function.identity(), (o1, o2) -> o1));
for (PlanFeedbackApprovalWork approvalWork : approvalWorks) {
PlanFeedback planFeedback = recordIdMap.get(approvalWork.getRecordId());
planFeedback.setApprovalStatus(2);
planFeedbackService.updateById(planFeedback);
approvalWork.setFeedbackId(planFeedback.getId());
planFeedbackApprovalWorkService.updateById(approvalWork);
if (planFeedback != null) {
planFeedback.setApprovalStatus(2);
planFeedbackService.updateById(planFeedback);
approvalWork.setFeedbackId(planFeedback.getId());
planFeedbackApprovalWorkService.updateById(approvalWork);
}
}
}

View File

@ -276,6 +276,8 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
if (count > 0) {
throw new OpenAlertException("请先删除反馈数据");
}
planFeedbackApprovalWorkService.remove(new LambdaQueryWrapper<PlanFeedbackApprovalWork>()
.eq(PlanFeedbackApprovalWork::getRecordId, id));
baseMapper.deleteById(id);
}

View File

@ -6,7 +6,9 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gexin.fastjson.JSON;
import com.wflow.bean.entity.WflowModelHistorys;
import com.wflow.mapper.WflowModelHistorysMapper;
import com.wflow.mapper.WflowModelsMapper;
@ -15,6 +17,8 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.basicdata.entity.*;
import com.zhgd.xmgl.modules.basicdata.service.*;
import com.zhgd.xmgl.modules.basicdata.service.impl.DictionaryItemServiceImpl;
import com.zhgd.xmgl.modules.basicdata.service.impl.SystemUserServiceImpl;
import com.zhgd.xmgl.util.FlowUtil;
import com.zhgd.xmgl.util.MapBuilder;
import com.zhgd.xmgl.util.MessageUtil;
import io.swagger.annotations.Api;
@ -348,4 +352,36 @@ public class BaseMenuController {
}
}
// //菜单清除有下级菜单的菜单path
// @PostMapping(value = "/ttt")
// public Result ttt(@RequestBody Map<String, Object> param) {
// SystemUser bthg = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>()
// .eq(SystemUser::getAccount, "bthg"));
// Map<String, Object> objectMap = systemUserService1.doLogin(new MapBuilder<String, Object>()
// .put("md5Password", "67395ff68eeba39368d5fa079788089b")
// .put("md5Password", "67395ff68eeba39368d5fa079788089b")
// .build(), bthg);
// Optional.ofNullable(objectMap.get("menuAuthority")).map(m->((Map) m).get("menuList")).ifPresent(m->{
// com.gexin.fastjson.JSONArray array = JSON.parseArray(JSON.toJSONString(m));
// for (int i = 0; i < array.size(); i++) {
// com.gexin.fastjson.JSONObject jsonObject = array.getJSONObject(i);
// listTree(jsonObject,null);
// }
// });
// return Result.ok();
// }
//
// private void listTree(com.gexin.fastjson.JSONObject jsonObject,com.gexin.fastjson.JSONObject parent) {
// if (!FlowUtil.isEmpty(jsonObject.get("menuList"))) {
// com.gexin.fastjson.JSONArray menuList = jsonObject.getJSONArray("menuList");
// for (int i = 0; i < menuList.size(); i++) {
// com.gexin.fastjson.JSONObject jsonObject1 = menuList.getJSONObject(i);
// listTree(jsonObject1,jsonObject);
// }
// baseMenuService.update(new LambdaUpdateWrapper<BaseMenu>()
// .set(BaseMenu::getPath, "")
// .eq(BaseMenu::getMenuId, jsonObject.getString("menuId")));
// }
// }
}

View File

@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.basicdata.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
@ -18,8 +19,13 @@ import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.baotou.entity.DeviceUnit;
import com.zhgd.xmgl.modules.baotou.entity.ProjectGroup;
import com.zhgd.xmgl.modules.baotou.entity.ProjectGroupUnit;
import com.zhgd.xmgl.modules.baotou.entity.UserDevGroup;
import com.zhgd.xmgl.modules.baotou.service.IDeviceUnitService;
import com.zhgd.xmgl.modules.baotou.service.IProjectGroupService;
import com.zhgd.xmgl.modules.baotou.service.IProjectGroupUnitService;
import com.zhgd.xmgl.modules.baotou.service.IUserDevGroupService;
import com.zhgd.xmgl.modules.basicdata.entity.BaseRole;
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
@ -28,10 +34,12 @@ import com.zhgd.xmgl.modules.basicdata.service.IBaseRoleService;
import com.zhgd.xmgl.modules.basicdata.service.IDictionaryItemService;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
import com.zhgd.xmgl.modules.worker.entity.UserDevAuthority;
import com.zhgd.xmgl.modules.worker.entity.UserEnterprise;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
import com.zhgd.xmgl.modules.worker.service.impl.UserDevAuthorityServiceImpl;
import com.zhgd.xmgl.modules.worker.service.impl.UserEnterpriseServiceImpl;
import com.zhgd.xmgl.modules.xz.entity.XzProjectOrg;
@ -54,7 +62,6 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
@ -62,6 +69,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.zhgd.xmgl.util.ExcelUtils.downLoadExcel;
@ -80,6 +88,9 @@ import static com.zhgd.xmgl.util.ExcelUtils.setPullDown;
@Slf4j
@Api(tags = "账号")
public class SystemUserController {
@Lazy
@Autowired
IProjectGroupUnitService projectGroupUnitService;
@Autowired
private ISystemUserService systemUserService;
@Lazy
@ -112,6 +123,12 @@ public class SystemUserController {
@Lazy
@Autowired
private NoticeServiceImpl noticeService;
@Lazy
@Autowired
private EnterpriseInfoServiceImpl enterpriseInfoService;
@Lazy
@Autowired
private IDeviceUnitService deviceUnitService;
/**
* 添加
@ -701,6 +718,86 @@ public class SystemUserController {
return result;
}
//
// @ApiOperation(value = "导出excel", notes = "导出excel", httpMethod = "POST")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
// @ApiImplicitParam(name = "type", value = "1项目2装置", paramType = "query", required = true, dataType = "String"),
// @ApiImplicitParam(name = "leftId", value = "左边Id", paramType = "query", required = true, dataType = "String"),
// })
// @PostMapping(value = "/exportXls")
// public ModelAndView exportXls(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
// // Step.1 组装查询条件
// List<PlanMilestone2Right> pageList = planMilestone2RightService.queryList(paramMap);
// Map<String, Object> map = new HashMap<>();
// List<Map<String, Object>> listMap = new ArrayList<>();
// if (pageList.size() > 0) {
// for (PlanMilestone2Right p : pageList) {
// Map<String, Object> mp = new HashMap<>();
// mp.put("leftId", p.getLeftId());
// mp.put("leftName", p.getClassifyName());
// mp.put("projectSn", p.getProjectSn());
// mp.put("name", p.getName());
// mp.put("beginDate", DateUtil.formatDate(p.getBeginDate()));
// mp.put("endDate", p.getEndDate());
// List<String> nodeStatus = Arrays.asList("关键控制点", "重要事件的控制", "作业项目的节点");
// List<String> iss = Arrays.asList("", "");
// try {
// mp.put("nodeStatus", nodeStatus.get(p.getNodeStatus() - 1));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// mp.put("completeType", iss.get(p.getCompleteType()));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// mp.put("isImportantMilestone", iss.get(p.getIsImportantMilestone()));
// } catch (Exception e) {
// e.printStackTrace();
// }
// mp.put("createTime", p.getCreateTime());
// mp.put("updateTime", p.getUpdateTime());
// mp.put("useTimeType", Objects.equals(p.getUseTimeType(), 1) ? "开始时间" : "结束时间");
// mp.put("type", p.getType());
// listMap.add(mp);
// }
// }
// //将项目清单集合添加到map中
// map.put("listMap", listMap);
// InputStream fis = null;
// try {
// fis = new ClassPathResource("excel/总体统筹计划编制导出模板.xlsx").getInputStream();
//// fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\总体统筹计划编制导出模板.xlsx");
// File out = new File(new File(System.getProperty("user.dir").replace("file:/", "/").replace("\\", "/"), "tmp"), "系统项目组危险源辨别评价表模板.xlsx");
// if (!out.getParentFile().exists()) {
// out.getParentFile().mkdirs();
// }
// IOUtils.copy(fis, out);
// //获取模板
// TemplateExportParams params = new TemplateExportParams(out.getAbsolutePath());
// //模板视图
// ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
// //添加表格参数
// mv.addObject(TemplateExcelConstants.PARAMS, params);
// //添加模板参数
// mv.addObject(TemplateExcelConstants.MAP_DATA, map);
// return mv;
// } catch (IOException e) {
// log.error("", e);
// throw new OpenAlertException("系统错误");
// } finally {
// if (fis != null) {
// try {
// fis.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
/**
* 保存角色如果不存在
*
@ -791,86 +888,6 @@ public class SystemUserController {
}
//
// @ApiOperation(value = "导出excel", notes = "导出excel", httpMethod = "POST")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
// @ApiImplicitParam(name = "type", value = "1项目2装置", paramType = "query", required = true, dataType = "String"),
// @ApiImplicitParam(name = "leftId", value = "左边Id", paramType = "query", required = true, dataType = "String"),
// })
// @PostMapping(value = "/exportXls")
// public ModelAndView exportXls(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
// // Step.1 组装查询条件
// List<PlanMilestone2Right> pageList = planMilestone2RightService.queryList(paramMap);
// Map<String, Object> map = new HashMap<>();
// List<Map<String, Object>> listMap = new ArrayList<>();
// if (pageList.size() > 0) {
// for (PlanMilestone2Right p : pageList) {
// Map<String, Object> mp = new HashMap<>();
// mp.put("leftId", p.getLeftId());
// mp.put("leftName", p.getClassifyName());
// mp.put("projectSn", p.getProjectSn());
// mp.put("name", p.getName());
// mp.put("beginDate", DateUtil.formatDate(p.getBeginDate()));
// mp.put("endDate", p.getEndDate());
// List<String> nodeStatus = Arrays.asList("关键控制点", "重要事件的控制", "作业项目的节点");
// List<String> iss = Arrays.asList("", "");
// try {
// mp.put("nodeStatus", nodeStatus.get(p.getNodeStatus() - 1));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// mp.put("completeType", iss.get(p.getCompleteType()));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// mp.put("isImportantMilestone", iss.get(p.getIsImportantMilestone()));
// } catch (Exception e) {
// e.printStackTrace();
// }
// mp.put("createTime", p.getCreateTime());
// mp.put("updateTime", p.getUpdateTime());
// mp.put("useTimeType", Objects.equals(p.getUseTimeType(), 1) ? "开始时间" : "结束时间");
// mp.put("type", p.getType());
// listMap.add(mp);
// }
// }
// //将项目清单集合添加到map中
// map.put("listMap", listMap);
// InputStream fis = null;
// try {
// fis = new ClassPathResource("excel/总体统筹计划编制导出模板.xlsx").getInputStream();
//// fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\总体统筹计划编制导出模板.xlsx");
// File out = new File(new File(System.getProperty("user.dir").replace("file:/", "/").replace("\\", "/"), "tmp"), "系统项目组危险源辨别评价表模板.xlsx");
// if (!out.getParentFile().exists()) {
// out.getParentFile().mkdirs();
// }
// IOUtils.copy(fis, out);
// //获取模板
// TemplateExportParams params = new TemplateExportParams(out.getAbsolutePath());
// //模板视图
// ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
// //添加表格参数
// mv.addObject(TemplateExcelConstants.PARAMS, params);
// //添加模板参数
// mv.addObject(TemplateExcelConstants.MAP_DATA, map);
// return mv;
// } catch (IOException e) {
// log.error("", e);
// throw new OpenAlertException("系统错误");
// } finally {
// if (fis != null) {
// try {
// fis.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
@ApiOperation(value = "勾选导出项目子账号word", notes = "勾选导出项目子账号word", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ -895,4 +912,167 @@ public class SystemUserController {
url = Fileutils.getExportTemplateFile("excel/work/勾选导出项目子账号模板.docx").getAbsolutePath();
EasyPoiUtil.exportNewLineWord(response, map, FileUtil.file(url));
}
@ApiOperation(value = "项目子账号批量分配装置项目组和单位权限(根据项目组和装置那里的绑定关系)", notes = "项目子账号批量分配装置项目组和单位权限(根据项目组和装置那里的绑定关系)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "userIdList", value = "用户id数组", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/batchAuthSubAccount")
public Result batchAuthSubAccount(@ApiIgnore @RequestBody HashMap<String, Object> param) {
List<String> userIdList = com.gexin.fastjson.JSON.parseObject(JSON.toJSONString(param.get("userIdList")), new TypeReference<ArrayList<String>>() {
});
if (CollUtil.isEmpty(userIdList)) {
return Result.ok();
}
String projectSn = MapUtils.getString(param, "projectSn");
List<EnterpriseInfo> enterpriseInfos = BeanUtil.copyToList(enterpriseInfoService.getEnterpriseInfoList(new MapBuilder<String, Object>()
.put("projectSn", projectSn)
.build()), EnterpriseInfo.class);
Map<String, EnterpriseInfo> enterpriseNameMap = enterpriseInfos.stream().collect(Collectors.toMap(EnterpriseInfo::getEnterpriseName, Function.identity(), (o1, o2) -> o1));
Map<Long, EnterpriseInfo> enterpriseMap = enterpriseInfos.stream().collect(Collectors.toMap(EnterpriseInfo::getId, Function.identity(), (o1, o2) -> o1));
Map<Long, ProjectGroup> groupMap = projectGroupService.list(new LambdaQueryWrapper<ProjectGroup>()
.eq(ProjectGroup::getProjectSn, projectSn)).stream().collect(Collectors.toMap(ProjectGroup::getId, Function.identity(), (o1, o2) -> o1));
List<DeviceUnit> deviceUnits = deviceUnitService.queryList(new MapBuilder<String, Object>()
.put("projectSn", projectSn)
.build());
List<SystemUser> systemUserList = systemUserService.getProjectChildernSystemUserList(new MapBuilder<String, Object>()
.put("userIdList", userIdList)
.put("projectSn", projectSn)
.build());
Map<Long, List<SystemUser>> enterpriseUserMap = systemUserList.stream().collect(Collectors.groupingBy(SystemUser::getEnterpriseId));
//分配装置项目组
List<UserDevGroup> userDevGroups = new ArrayList<>();
for (DeviceUnit deviceUnit : deviceUnits) {
for (Map.Entry<Long, List<SystemUser>> entry : enterpriseUserMap.entrySet()) {
String enterpriseId = entry.getKey() + "";
List<SystemUser> users = entry.getValue();
if (users != null) {
for (SystemUser user : users) {
if (Objects.equals(user.getUserType(), "1")) {
//部门用户分配所有装置项目组和单位
addUserDevGroup(userDevGroups, deviceUnit, user);
} else if (Objects.equals(user.getUserType(), "2")) {
//项目组用户
Optional.ofNullable(enterpriseMap.get(Convert.toLong(enterpriseId))).map(EnterpriseInfo::getEnterpriseName)
.flatMap(m -> StrUtil.split(deviceUnit.getProjectGroupIds(), ",").stream().map(s -> groupMap.get(Convert.toLong(s)))
.filter(group -> group != null && group.getProjectGroupName().equals(m)).findAny()).ifPresent(projectGroup -> {
addUserDevGroupForGroup(userDevGroups, deviceUnit, user, projectGroup);
});
} else {
//项目组单位监理单位EPC/E+P+C承包商施工单位分配装置管理装置项目组
if (StrUtil.contains(deviceUnit.getSupervisingUnitIds(), enterpriseId)
|| StrUtil.contains(deviceUnit.getEpcContractorIds(), enterpriseId)
|| StrUtil.contains(deviceUnit.getConstructionUnitIds(), enterpriseId)) {
addUserDevGroup(userDevGroups, deviceUnit, user);
}
}
}
}
}
}
userDevGroupService.remove(new LambdaQueryWrapper<UserDevGroup>()
.in(UserDevGroup::getUserId, userIdList));
userDevGroupService.saveBatch(userDevGroups);
//分配单位
//部门用户分配所有装置项目组和单位
Set<Long> authAllEnterpriseIdList = new HashSet<>();
for (EnterpriseInfo enterpriseInfo : enterpriseInfos) {
authAllEnterpriseIdList.add(enterpriseInfo.getId());
}
List<UserEnterprise> userEnterprises = new ArrayList<>();
//部门用户分配所有装置项目组和单位
List<ProjectGroupUnit> projectGroupUnits = projectGroupUnitService.list(new LambdaQueryWrapper<ProjectGroupUnit>()
.eq(ProjectGroupUnit::getProjectSn, projectSn));
for (Map.Entry<Long, List<SystemUser>> entry : enterpriseUserMap.entrySet()) {
//项目组单位监理单位EPC/E+P+C承包商施工单位分配所有后代和祖级单位项目组管理
Set<Long> authEnterpriseIdList = new HashSet<>();
//项目组用户
Set<Long> authGroupEnterpriseIdList = new HashSet<>();
Long enterpriseId = entry.getKey();
authEnterpriseIdList.add(enterpriseId);
for (ProjectGroupUnit pgu : projectGroupUnits) {
Optional.ofNullable(groupMap.get(pgu.getProjectGroupId())).map(ProjectGroup::getProjectGroupName).map(enterpriseNameMap::get).map(EnterpriseInfo::getId)
.ifPresent(e -> {
authEnterpriseIdList.add(e);
authGroupEnterpriseIdList.add(e);
authGroupEnterpriseIdList.add(pgu.getSupervisingUnitId());
authGroupEnterpriseIdList.add(pgu.getEpcContractorId());
authGroupEnterpriseIdList.addAll(StrUtil.split(pgu.getConstructionUnitIds(), ",").stream().map(Convert::toLong).collect(Collectors.toList()));
});//保存项目组单位
if (Objects.equals(pgu.getSupervisingUnitId(), enterpriseId)) {
authEnterpriseIdList.add(pgu.getEpcContractorId());
authEnterpriseIdList.addAll(StrUtil.split(pgu.getConstructionUnitIds(), ",").stream().map(Convert::toLong).collect(Collectors.toList()));
}
if (Objects.equals(pgu.getEpcContractorId(), enterpriseId)) {
authEnterpriseIdList.add(pgu.getSupervisingUnitId());
authEnterpriseIdList.addAll(StrUtil.split(pgu.getConstructionUnitIds(), ",").stream().map(Convert::toLong).collect(Collectors.toList()));
}
if (StrUtil.contains(pgu.getConstructionUnitIds(), enterpriseId + "")) {
authEnterpriseIdList.add(pgu.getSupervisingUnitId());
authEnterpriseIdList.add(pgu.getEpcContractorId());
}
}
List<SystemUser> userList = entry.getValue();
if (userList != null) {
for (SystemUser user : userList) {
UserEnterprise userEnterprise = new UserEnterprise();
userEnterprise.setUserId(user.getUserId());
userEnterprise.setEnterpriseId(StrUtil.join(",",
(Objects.equals(user.getUserType(), "1") ? authAllEnterpriseIdList : (Objects.equals(user.getUserType(), "2") ? authGroupEnterpriseIdList : authEnterpriseIdList))
.stream().filter(Objects::nonNull).collect(Collectors.toList())));
userEnterprises.add(userEnterprise);
}
}
}
userEnterpriseService.remove(new LambdaQueryWrapper<UserEnterprise>()
.in(UserEnterprise::getUserId, userIdList));
userEnterpriseService.saveBatch(userEnterprises);
return Result.ok();
}
/**
* 项目组添加装置项目组权限
*/
private void addUserDevGroupForGroup(List<UserDevGroup> userDevGroups, DeviceUnit deviceUnit, SystemUser user, ProjectGroup projectGroup) {
UserDevGroup dev = new UserDevGroup();
dev.setDevGroupId(deviceUnit.getId());
dev.setUserId(user.getUserId());
dev.setNodeId(deviceUnit.getId() + "");
dev.setType(1);
userDevGroups.add(dev);
UserDevGroup group = new UserDevGroup();
group.setDevGroupId(projectGroup.getId());
group.setUserId(user.getUserId());
group.setNodeId(projectGroup.getId() + "" + deviceUnit.getId());
group.setType(2);
userDevGroups.add(group);
}
/**
* 添加装置项目组权限
*
* @param userDevGroups
* @param deviceUnit
* @param user
*/
private void addUserDevGroup(List<UserDevGroup> userDevGroups, DeviceUnit deviceUnit, SystemUser user) {
UserDevGroup dev = new UserDevGroup();
dev.setDevGroupId(deviceUnit.getId());
dev.setUserId(user.getUserId());
dev.setNodeId(deviceUnit.getId() + "");
dev.setType(1);
userDevGroups.add(dev);
if (StrUtil.isNotBlank(deviceUnit.getProjectGroupIds())) {
for (String groupId : StrUtil.split(deviceUnit.getProjectGroupIds(), ",")) {
UserDevGroup group = new UserDevGroup();
group.setDevGroupId(Long.valueOf(groupId));
group.setUserId(user.getUserId());
group.setNodeId(groupId + deviceUnit.getId() + "");
group.setType(2);
userDevGroups.add(group);
}
}
}
}

View File

@ -140,6 +140,28 @@ public class CarInfo implements Serializable {
private java.lang.String carQrCode;
@ApiModelProperty(value = "特殊工种操作证")
private java.lang.String specialWorkType;
@ApiModelProperty(value = "编号")
private java.lang.String num;
@ApiModelProperty(value = "到检日期yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date inspectionDate;
@ApiModelProperty(value = "保险终止日yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date insuranceTerminationDate;
@ApiModelProperty(value = "行驶证开始有效期yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date xszBeginDate;
@ApiModelProperty(value = "行驶证结束有效期yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date xszEndDate;
@ApiModelProperty(value = "计划入厂时间截止到yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date enterFactoryEndDate;
@TableField(exist = false)
@ApiModelProperty(value = "企业名称")
@ -164,6 +186,12 @@ public class CarInfo implements Serializable {
public String toExistString() {
return "CarInfo{" +
", enterFactoryEndDate='" + enterFactoryEndDate + '\'' +
", xszEndDate='" + xszEndDate + '\'' +
", xszBeginDate='" + xszBeginDate + '\'' +
", insuranceTerminationDate='" + insuranceTerminationDate + '\'' +
", inspectionDate='" + inspectionDate + '\'' +
", num='" + num + '\'' +
", carNumber='" + carNumber + '\'' +
", carColor='" + carColor + '\'' +
", projectSn='" + projectSn + '\'' +

View File

@ -34,6 +34,18 @@
t.car_qr_code
,
t.special_work_type
,
t.num
,
t.inspection_date
,
t.insurance_termination_date
,
t.xsz_begin_date
,
t.xsz_end_date
,
t.enter_factory_end_date
FROM car_info t
join project p on p.project_sn = t.project_sn
LEFT JOIN car_type b ON (t.car_type = b.id and t.project_sn = b.project_sn)

View File

@ -41,6 +41,7 @@ import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
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.modules.xz.service.impl.XzHikvisionSyncServiceImpl;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.*;
@ -56,9 +57,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilterInputStream;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -100,6 +100,9 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
WorkerInfoServiceImpl workerInfoService;
@Lazy
@Autowired
XzHikvisionSyncServiceImpl xzHikvisionSyncService;
@Lazy
@Autowired
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
@Autowired
private EnterpriseInfoServiceImpl enterpriseInfoService;
@ -211,14 +214,14 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
.eq(CarInfoApprovalFlow::getCarNumber, c.getCarNumber())
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
);
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("此预约时间段内,车辆已经被其他企业预约了,请修改预约时间!");
}
List<CarInfoApprovalFlow> otherFlows = flows.stream().filter(f -> f.getEnterpriseId() != null && !Objects.equals(c.getEnterpriseId(), f.getEnterpriseId())
&& (DateUtil.compare(f.getReserveStartTime(), c.getReserveStartTime()) != 0 || DateUtil.compare(f.getReserveEndTime(), c.getReserveEndTime()) != 0)).collect(Collectors.toList());
otherFlows.stream().filter(f -> DateUtil.compare(f.getReserveStartTime(), c.getReserveEndTime()) < 0 && DateUtil.compare(f.getReserveEndTime(), c.getReserveStartTime()) > 0).findAny().ifPresent(flowCar -> {
throw new OpenAlertException(StrUtil.format("车牌号:{},此预约时间段内({}到{}),车辆已经被其他企业预约了({}到{}),请修改预约时间!",
c.getCarNumber(), DateUtil.formatDateTime(c.getReserveStartTime()), DateUtil.formatDateTime(c.getReserveEndTime()),
DateUtil.formatDateTime(flowCar.getReserveStartTime()), DateUtil.formatDateTime(flowCar.getReserveEndTime())));
});
}
@Override
@ -233,11 +236,13 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
}
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public Result uploadExcelCar(File file, String projectSn) {
Result<String> result = new Result<String>();
Result<String> result = new Result<>();
StringBuilder notExistEnterprise = new StringBuilder("");
String notExistEnterpriseMsg = "";
StringBuilder existCarNumName = new StringBuilder("");
String existCarNumMsg = "";
ArrayList<String> errIdCards = new ArrayList<>();
String rtMsg = "";
StringBuilder existWorkerName = new StringBuilder("");
String existWorkerNameMsg = "";
@ -251,13 +256,13 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
if (list == null || list.size() == 0) {
throw new OpenAlertException(MessageUtil.get("excelNotDataErr"));
}
this.checkParams(list, projectSn);
this.checkParams(list);
Map<String, EnterpriseInfo> enterpriseInfoMap = projectEnterpriseService.queryPageList(new MapBuilder<String, Object>()
.put("projectSn", projectSn)
.put(Cts.PAGE_SIZE, -1)
.build()).getRecords().stream().collect(Collectors.toMap(EnterpriseInfo::getEnterpriseName, Function.identity(), (enterpriseInfo, enterpriseInfo2) -> enterpriseInfo));
Map<String, CarInfo> numMap = carInfoMapper.selectList(new LambdaQueryWrapper<CarInfo>()
.in(CarInfo::getCarNumber, list.stream().map(o -> o.get("车牌号")).collect(Collectors.toList()))
.in(CarInfo::getCarNumber, list.stream().map(o -> StrUtil.trim(o.get("*车牌号")).toUpperCase(Locale.ROOT)).collect(Collectors.toList()))
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)).stream().collect(Collectors.toMap(CarInfo::getCarNumber, Function.identity()));
Map<String, WorkerInfo> workerMap = workerInfoService.list(new LambdaQueryWrapper<WorkerInfo>()
.eq(WorkerInfo::getProjectSn, projectSn)
@ -267,33 +272,64 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
).stream().collect(Collectors.toMap(CarType::getCarTypeName, Function.identity(), (o1, o2) -> o1));
for (Map<String, String> importInfo : list) {
String carNumber = StrUtil.trim(importInfo.get("*车牌号")).toUpperCase(Locale.ROOT);
String workerName = StrUtil.trim(importInfo.get("司机姓名"));
String carModuleType = importInfo.get("*车辆类型");
CarInfo dataCar = numMap.get(importInfo.get("*车牌号"));
CarInfo dataCar = numMap.get(carNumber);
CarInfo excelCar = new CarInfo();
excelCar.setCarNumber(importInfo.get("*车牌号"));
excelCar.setCarColor(importInfo.get("*车辆颜色"));
String num = StrUtil.trim(importInfo.get("*编号"));
excelCar.setNum(num);
if (StrUtil.isNotBlank(importInfo.get("到检日期"))) {
excelCar.setInspectionDate(DateUtil.parseDate(importInfo.get("到检日期")));
}
if (StrUtil.isNotBlank(importInfo.get("保险终止日"))) {
excelCar.setInsuranceTerminationDate(DateUtil.parseDate(importInfo.get("保险终止日")));
}
String xszDate = importInfo.get("行驶证有效期");
if (StrUtil.isNotBlank(xszDate)) {
List<Date> range = DateUtils.parseDateRange(xszDate);
if (range != null) {
excelCar.setXszBeginDate(range.get(0));
excelCar.setXszEndDate(range.get(1));
}
}
if (StrUtil.isNotBlank(importInfo.get("计划入厂时间截止到"))) {
excelCar.setEnterFactoryEndDate(DateUtil.parseDate(importInfo.get("计划入厂时间截止到")));
}
excelCar.setCarNumber(carNumber);
excelCar.setCarColor(importInfo.get("车辆颜色"));
excelCar.setAddTime(new Date());
excelCar.setProjectSn(projectSn);
String readWorkerName = importInfo.get("*司机姓名");
if (!"临时车辆".equals(carModuleType)) {
WorkerInfo workerInfo = workerMap.get(readWorkerName);
WorkerInfo workerInfo = workerMap.get(workerName);
if (workerInfo == null) {
existWorkerName.append(readWorkerName);
existWorkerName.append("");
log.info("在人员管理中不存在:{}", readWorkerName);
continue;
if (workerName != null) {
existWorkerName.append(workerName);
existWorkerName.append("");
}
log.info("在人员管理中不存在:{}", workerName);
} else {
excelCar.setDriverWorkerId(String.valueOf(workerInfo.getId()));
}
excelCar.setDriverWorkerId(String.valueOf(workerInfo.getId()));
}
excelCar.setDriverWorkerName(readWorkerName);
excelCar.setDriverTelephone(importInfo.get("*司机电话"));
excelCar.setDriverWorkerName(workerName);
String driverTelephone = StrUtil.trim(importInfo.get("司机电话"));
excelCar.setDriverTelephone(driverTelephone);
excelCar.setIsBlack(Objects.equals(importInfo.get("*是否黑名单"), "") ? 1 : 0);
excelCar.setCarType(Optional.ofNullable(carTypeMap.get(importInfo.get("*车种类型"))).map(CarType::getId).orElse(null));
excelCar.setCarModuleType("固定车辆".equals(carModuleType) ? 1 : ("长期车辆".equals(carModuleType) ? 2 : 3));
excelCar.setReserveStartTime(DateUtil.parse(importInfo.get("预约开始时间")));
excelCar.setReserveEndTime(DateUtil.parse(importInfo.get("预约结束时间")));
excelCar.setEntryAndExitPermit("单次".equals(importInfo.get("允许进出次数")) ? 0 : 1);
excelCar.setEnterpriseId(Optional.ofNullable(enterpriseInfoMap.get(importInfo.get("*单位"))).map(EnterpriseInfo::getId).orElse(null));
String enterpriseName = StrUtil.trim(importInfo.get("*单位"));
Optional<Long> enterpriseIdOp = Optional.ofNullable(enterpriseInfoMap.get(enterpriseName)).map(EnterpriseInfo::getId);
if (!enterpriseIdOp.isPresent()) {
//没有企业的不保存
notExistEnterprise.append(excelCar.getCarNumber()).append("(").append(enterpriseName).append(")");
notExistEnterprise.append("");
continue;
}
excelCar.setEnterpriseId(enterpriseIdOp.get());
if (dataCar == null) {
this.addCarInfo(excelCar);
} else {
@ -308,7 +344,10 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
this.editCarInfo(excelCar);
}
}
if (!"".equals(notExistEnterprise.toString())) {
notExistEnterprise.deleteCharAt(notExistEnterprise.lastIndexOf(""));
notExistEnterpriseMsg = "车牌号为:" + notExistEnterprise + "的车辆企业不存在。";
}
if (!"".equals(existCarNumName.toString())) {
existCarNumName.deleteCharAt(existCarNumName.lastIndexOf(""));
existCarNumMsg = "车牌号为:" + existCarNumName + "的车辆已存在对应信息(车牌号等信息一致)。";
@ -317,7 +356,7 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
existWorkerName.deleteCharAt(existWorkerName.lastIndexOf(""));
existWorkerNameMsg = "司机姓名:" + existWorkerName + "在人员管理中不存在。";
}
rtMsg = StrUtil.format("导入成功。{}{}", existCarNumMsg, existWorkerNameMsg);
rtMsg = StrUtil.format("操作成功。{}{}{}", existCarNumMsg, existWorkerNameMsg, notExistEnterpriseMsg);
result.successMsg(rtMsg);
} catch (OpenAlertException e) {
log.error("error", e);
@ -335,34 +374,30 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
return result;
}
private void checkParams(List<Map<String, String>> list, String projectSn) {
private void checkParams(List<Map<String, String>> list) {
for (Map<String, String> importInfo : list) {
if (StringUtils.isBlank(importInfo.get("*编号"))) {
throw new OpenAlertException("有编号未填写");
}
if (StringUtils.isBlank(importInfo.get("*单位"))) {
throw new OpenAlertException("有单位未填写");
}
if (StringUtils.isBlank(importInfo.get("*车辆类型"))) {
throw new OpenAlertException("有车辆类型未填写");
}
if (StringUtils.isBlank(importInfo.get("*车牌号"))) {
String carNum = importInfo.get("*车牌号");
if (StringUtils.isBlank(carNum)) {
throw new OpenAlertException("有车牌号未填写");
}
if (StringUtils.isBlank(importInfo.get("*车辆颜色"))) {
throw new OpenAlertException("有车辆颜色未填写");
}
if (StringUtils.isBlank(importInfo.get("*车种类型"))) {
throw new OpenAlertException("有车种类型未填写");
}
if (StringUtils.isBlank(importInfo.get("*司机姓名"))) {
throw new OpenAlertException("有司机姓名未填写");
}
if (StringUtils.isBlank(importInfo.get("*司机电话"))) {
throw new OpenAlertException("有司机电话未填写");
}
if (StringUtils.isBlank(importInfo.get("*司机电话"))) {
throw new OpenAlertException("有司机电话未填写");
}
if (!"固定车辆".equals(importInfo.get("*车辆类型")) && DateUtil.compare(DateUtil.parse(importInfo.get("预约结束时间")), new Date()) < 0) {
throw new OpenAlertException("预约时间已失效,车辆" + importInfo.get("*车牌号") + "无法下发,请重新提交");
throw new OpenAlertException("预约时间已失效,车辆" + carNum + "无法下发,请重新提交");
}
String xszDate = importInfo.get("行驶证有效期");
if (StringUtils.isNotBlank(xszDate) && !DateUtils.validateDateRange(xszDate)) {
throw new OpenAlertException(StrUtil.format("车牌号:{}的行驶证有效期格式{}填写错误要改成“2020-10-10到2020-10-11”格式", carNum, xszDate));
}
}
}
@ -453,6 +488,11 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
carInfoMapper.updateById(carInfo);
carInfoMapper.update(null, new LambdaUpdateWrapper<CarInfo>()
.set(CarInfo::getSendSuccessStatus, 4)
.set(CarInfo::getInspectionDate, carInfo.getInspectionDate())
.set(CarInfo::getInsuranceTerminationDate, carInfo.getInsuranceTerminationDate())
.set(CarInfo::getXszBeginDate, carInfo.getXszBeginDate())
.set(CarInfo::getXszEndDate, carInfo.getXszEndDate())
.set(CarInfo::getEnterFactoryEndDate, carInfo.getEnterFactoryEndDate())
.eq(CarInfo::getId, carInfo.getId()));
if (isReservationType(old)) {
@ -628,13 +668,13 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
deleteCarInfoForHikvision(carInfo, true);
} else {
if (Objects.equals(carInfo.getCarModuleType(), CarInfoCarModuleTypeEnum.GD.getValue())) {
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(4).setOperate(2).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(5).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
xzHikvisionSyncService.addOrUpdate(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(4).setOperate(2).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
xzHikvisionSyncService.addOrUpdate(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(5).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
} else if (Objects.equals(carInfo.getCarModuleType(), CarInfoCarModuleTypeEnum.CQ.getValue()) || Objects.equals(carInfo.getCarModuleType(), CarInfoCarModuleTypeEnum.LS.getValue())) {
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
xzHikvisionSyncService.addOrUpdate(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(6).setOperate(1).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
}
if (old.getIsBlack() == 1) {
xzHikvisionSyncMapper.insert(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
xzHikvisionSyncService.addOrUpdate(new XzHikvisionSync().setProjectSn(carInfo.getProjectSn()).setType(7).setOperate(3).setWhoId(carInfo.getId()).setBigType(2).setCreateDate(getSyncTimeWithInitAndDeleteSyncIfAbsent(2, carInfo.getId())));
}
asyncHikvision.editCarInfoForHikvisionAsync(carInfo, old);
}

View File

@ -69,4 +69,6 @@ public interface IXzHikvisionSyncService extends IService<XzHikvisionSync> {
void retry(Map<String, Object> paramMap) throws Exception;
List<XzHikvisionSync> queryEqList(XzHikvisionSync sync);
void addOrUpdate(XzHikvisionSync setCreateDate);
}

View File

@ -1,5 +1,6 @@
package com.zhgd.xmgl.modules.xz.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -12,6 +13,7 @@ import com.zhgd.redis.lock.RedisRepository;
import com.zhgd.xmgl.async.AsyncHikvision;
import com.zhgd.xmgl.call.HikvisionCall;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.basicdata.entity.SystemCities;
import com.zhgd.xmgl.modules.car.entity.CarInfo;
import com.zhgd.xmgl.modules.car.mapper.CarInfoMapper;
import com.zhgd.xmgl.modules.project.entity.Project;
@ -38,6 +40,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 海康同步数据
@ -255,4 +258,27 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
.eq(sync.getOperate() != null, XzHikvisionSync::getOperate, sync.getOperate())
.eq(StringUtils.isNotBlank(sync.getDeviceSn()), XzHikvisionSync::getDeviceSn, sync.getDeviceSn()));
}
@Override
public void addOrUpdate(XzHikvisionSync sync) {
List<XzHikvisionSync> syncList = xzHikvisionSyncMapper.selectList(new LambdaQueryWrapper<XzHikvisionSync>()
.eq(XzHikvisionSync::getProjectSn, sync.getProjectSn())
.eq(XzHikvisionSync::getType, sync.getType())
.eq(XzHikvisionSync::getWhoId, sync.getWhoId())
.eq(XzHikvisionSync::getBigType, sync.getBigType())
.eq(XzHikvisionSync::getOperate, sync.getOperate())
.eq(StringUtils.isNotBlank(sync.getDeviceSn()), XzHikvisionSync::getDeviceSn, sync.getDeviceSn()));
if (CollUtil.isNotEmpty(syncList)) {
XzHikvisionSync xzHikvisionSync = syncList.get(0);
if (syncList.size() > 1) {
//删除多余的数据
this.remove(new LambdaQueryWrapper<XzHikvisionSync>()
.in(XzHikvisionSync::getId, syncList.stream().map(XzHikvisionSync::getId).filter(id -> !Objects.equals(xzHikvisionSync.getId(), id)).collect(Collectors.toList())));
}
sync.setId(xzHikvisionSync.getId());
this.updateById(sync);
} else {
this.save(sync);
}
}
}

View File

@ -4,6 +4,7 @@ package com.zhgd.xmgl.util;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -11,10 +12,7 @@ import org.apache.commons.lang3.time.DateFormatUtils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
@ -30,6 +28,111 @@ import java.util.regex.Pattern;
**/
@Slf4j
public class DateUtils {
/**
* 验证日期段格式日期格式yyyy-MM-dd yyyy/MM/dd yyyy.MM.dd yyyy年MM月dd日分割符号~
*
* @param input
* @return
*/
public static boolean validateDateRange(String input) {
if (StrUtil.isBlank(input)) {
return true;
}
return parseDateRange(input) != null;
}
/**
* 解析日期段格式日期格式yyyy-MM-dd yyyy/MM/dd yyyy.MM.dd yyyy年MM月dd日分割符号~
*
* @param input
* @return
*/
public static List<Date> parseDateRange(String input) {
input = StrUtil.trim(input);
String regex = "^\\s*" +
"(?:" +
// 标准格式yyyy-MM-dd yyyy/MM/dd yyyy.MM.dd
"(?<stdStartY>\\d{4})[-/.]?(?<stdStartM>\\d{1,2})[-/.]?(?<stdStartD>\\d{1,2})" +
"|" +
// 中文格式yyyy年MM月dd日
"(?<cnStartY>\\d{4})\\s*年\\s*(?<cnStartM>\\d{1,2})\\s*月\\s*(?<cnStartD>\\d{1,2})\\s*日" +
")" +
"\\s*" +
// 分隔符
"(?<sep>到|至|——|—|~|--+)" +
"\\s*" +
"(?:" +
// 标准格式结束日期
"(?<stdEndY>\\d{4})[-/.]?(?<stdEndM>\\d{1,2})[-/.]?(?<stdEndD>\\d{1,2})" +
"|" +
// 中文格式结束日期
"(?<cnEndY>\\d{4})\\s*年\\s*(?<cnEndM>\\d{1,2})\\s*月\\s*(?<cnEndD>\\d{1,2})\\s*日" +
")" +
"\\s*$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
try {
// 解析开始日期
int startYear, startMonth, startDay;
if (matcher.group("stdStartY") != null) {
// 标准格式
startYear = Integer.parseInt(matcher.group("stdStartY"));
startMonth = Integer.parseInt(matcher.group("stdStartM"));
startDay = Integer.parseInt(matcher.group("stdStartD"));
} else {
// 中文格式
startYear = Integer.parseInt(matcher.group("cnStartY"));
startMonth = Integer.parseInt(matcher.group("cnStartM"));
startDay = Integer.parseInt(matcher.group("cnStartD"));
}
// 解析结束日期
int endYear, endMonth, endDay;
if (matcher.group("stdEndY") != null) {
// 标准格式
endYear = Integer.parseInt(matcher.group("stdEndY"));
endMonth = Integer.parseInt(matcher.group("stdEndM"));
endDay = Integer.parseInt(matcher.group("stdEndD"));
} else {
// 中文格式
endYear = Integer.parseInt(matcher.group("cnEndY"));
endMonth = Integer.parseInt(matcher.group("cnEndM"));
endDay = Integer.parseInt(matcher.group("cnEndD"));
}
LocalDate startDate = LocalDate.of(startYear, startMonth, startDay);
LocalDate endDate = LocalDate.of(endYear, endMonth, endDay);
return Arrays.asList(Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} catch (Exception e) {
log.error("", e);
return null; // 处理无效日期
}
}
return null;
}
public static void main(String[] args) {
String[] testCases = {
"2020-10-10到2020-10-11",
"2020年10月10日——2020年10月11日",
"2020/10/10~2020/10/11",
"2020 年 1 月 5 日 至 2020 年 1 月 6 日",
"2020.12.31—2021.01.01"
};
for (String testCase : testCases) {
List<Date> dates = parseDateRange(testCase);
if (dates != null) {
System.out.printf("输入: '%s'\n开始日期: %s\n结束日期: %s\n\n", testCase, dates.get(0), dates.get(1));
} else {
System.out.printf("输入: '%s' 解析失败\n\n", testCase);
}
}
}
public static String dealDateFormat(String oldDate) {
Date date1 = null;
@ -723,13 +826,4 @@ public class DateUtils {
return from;
}
public static void main(String[] args) {
System.out.println(getBeforeDayOfWeek(new Date(), 1));
System.out.println(getBeforeDayOfWeek(new Date(), 2));
System.out.println(getBeforeDayOfWeek(new Date(), 3));
System.out.println(getBeforeDayOfWeek(new Date(), 4));
System.out.println(getBeforeDayOfWeek(new Date(), 5));
System.out.println(getBeforeDayOfWeek(new Date(), 6));
System.out.println(getBeforeDayOfWeek(new Date(), 7));
}
}