|
@@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDai
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectPlanDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectPlanDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO;
|
|
@@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotoperationplandev.IotOperationPla
|
|
import cn.iocoder.yudao.module.pms.message.PmsMessage;
|
|
import cn.iocoder.yudao.module.pms.message.PmsMessage;
|
|
import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillService;
|
|
import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillService;
|
|
import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
|
|
import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -33,6 +35,7 @@ import java.math.BigDecimal;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -162,9 +165,31 @@ public class IotOperationPlanJob implements JobHandler {
|
|
|
|
|
|
|
|
|
|
private void extracted(List<Long> devIdList, List<IotOpeationFillOrderDO> orderList,IotOperationPlanDO plan) {
|
|
private void extracted(List<Long> devIdList, List<IotOpeationFillOrderDO> orderList,IotOperationPlanDO plan) {
|
|
- LocalDateTime localDateTime = DateUtils.contactTime(plan.getBeginCreateTime());
|
|
|
|
- plan.setLastCreateTime(localDateTime);
|
|
|
|
|
|
+ //瑞鹰日报计划为12小时执行一次
|
|
|
|
+ //判断计划周期是否为小时,如果是,则保存上次执行时间为当前时间最近的整点
|
|
|
|
+ if ("hour".equals(plan.getPlanUnit())) {
|
|
|
|
+ // 获取当前时间
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+ // 获取当前分钟数
|
|
|
|
+ int minute = now.getMinute();
|
|
|
|
+
|
|
|
|
+ LocalDateTime localDateTime;
|
|
|
|
+ if (minute <= 30) {
|
|
|
|
+ // 如果分钟数小于等于30,取当前小时的整点
|
|
|
|
+ localDateTime = now.truncatedTo(ChronoUnit.HOURS);
|
|
|
|
+ } else {
|
|
|
|
+ // 如果分钟数大于30,取下一小时的整点
|
|
|
|
+ localDateTime = now.truncatedTo(ChronoUnit.HOURS).plusHours(1);
|
|
|
|
+ }
|
|
|
|
+ plan.setLastCreateTime(localDateTime);
|
|
|
|
+ } else {
|
|
|
|
+ LocalDateTime localDateTime = DateUtils.contactTime(plan.getBeginCreateTime());
|
|
|
|
+ plan.setLastCreateTime(localDateTime);
|
|
|
|
+ }
|
|
planMapper.updateById(plan);
|
|
planMapper.updateById(plan);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//4、根据设备ID生成子表数据
|
|
//4、根据设备ID生成子表数据
|
|
List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
|
|
List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
|
|
List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
|
|
List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
|
|
@@ -173,54 +198,93 @@ public class IotOperationPlanJob implements JobHandler {
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
//插入工单主表
|
|
//插入工单主表
|
|
iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
- Set<Long> rdIdList = new HashSet<>();
|
|
|
|
- rdIdList = deptService.getChildDeptIdListFromCache(163L);
|
|
|
|
- rdIdList.add(163L);
|
|
|
|
- Set<Long> rhIdList = new HashSet<>();
|
|
|
|
- rhIdList = deptService.getChildDeptIdListFromCache(157L);
|
|
|
|
- rhIdList.add(157L);
|
|
|
|
- boolean exist = rdIdList.contains(plan.getDeptId());
|
|
|
|
- if(!exist){
|
|
|
|
- //瑞鹰SCP项目部50010队伍临时创建
|
|
|
|
- if(plan.getDeptId()==292){
|
|
|
|
- //筛选日报工单
|
|
|
|
- List<IotOpeationFillOrderDO> virOrderList = new ArrayList<>();
|
|
|
|
- IotOpeationFillOrderDO fillDO = new IotOpeationFillOrderDO();
|
|
|
|
- fillDO.setOrderName("40006队"+"/"+LocalDate.now()+"运行记录填报");
|
|
|
|
- fillDO.setDeptId(322L);
|
|
|
|
- fillDO.setOrderStatus(0);
|
|
|
|
- fillDO.setCreateTime(LocalDateTime.now());
|
|
|
|
- fillDO.setUserName("李小虎");
|
|
|
|
- fillDO.setUserId(486);
|
|
|
|
- fillDO.setMobile(String.valueOf(17723897643L));
|
|
|
|
- virOrderList.add(fillDO);
|
|
|
|
- orderList1.addAll(virOrderList);
|
|
|
|
- iotOpeationFillOrderMapper.insertBatch(virOrderList);
|
|
|
|
- //创建日报设备
|
|
|
|
- List <IotOpeationFillDO> devList = opeationFillService.reportMethod(virOrderList);
|
|
|
|
- //插入日报设备
|
|
|
|
- iotOpeationFillMapper.insertFill(devList);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Set<Long> ryIdList = new HashSet<>();
|
|
|
|
+ if(plan.getIsReport()==1){
|
|
|
|
+
|
|
|
|
+ ryIdList = deptService.getChildDeptIdListFromCache(158L);
|
|
|
|
+ ryIdList.add(158L);
|
|
|
|
+
|
|
|
|
+ List<IotOpeationFillOrderDO> zxjOrderList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (IotOpeationFillOrderDO orderDO:orderList1) {
|
|
|
|
+ IotDeviceRunLogDO runLogDO = new IotDeviceRunLogDO();
|
|
|
|
+ runLogDO.setDeptId(orderDO.getDeptId());
|
|
|
|
+ //获取队伍类型
|
|
|
|
+ IotDeviceRunLogDO teamType = iotOpeationFillMapper.getTeamType(runLogDO);
|
|
|
|
+
|
|
|
|
+ //如果是钻井队伍,则日报工单责任人更新为技术员
|
|
|
|
+ //修井队伍不变
|
|
|
|
+ if(teamType!=null&&teamType.getPointCode().equals("zj")){
|
|
|
|
+ //获取技术员信息
|
|
|
|
+ AdminUserDO userInfo = iotOpeationFillMapper.getUserInfo(runLogDO);
|
|
|
|
+ if(userInfo!=null){
|
|
|
|
+ orderDO.setUserName(userInfo.getUsername());
|
|
|
|
+ orderDO.setUserId(new BigDecimal(userInfo.getId()).intValue());
|
|
|
|
+ orderDO.setMobile(userInfo.getMobile());
|
|
|
|
+ }
|
|
|
|
+ zxjOrderList.add(orderDO);
|
|
|
|
+ }else if(teamType!=null&&teamType.getPointCode().equals("xj")){
|
|
|
|
+ zxjOrderList.add(orderDO);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- boolean rhContain = rhIdList.contains(plan.getDeptId());
|
|
|
|
- //瑞恒日报插入
|
|
|
|
- rhReportInsert(plan, orderList1, rhContain);
|
|
|
|
- }
|
|
|
|
- //发送钉钉消息
|
|
|
|
- sendDingMessage(orderList1);
|
|
|
|
- //正常工单设备
|
|
|
|
- for (IotOpeationFillDO device:deviceList) {
|
|
|
|
- for (IotOpeationFillOrderDO order:orderList1) {
|
|
|
|
- if(device.getUserId().intValue()==order.getUserId().intValue()){
|
|
|
|
- device.setOrderId(order.getId());
|
|
|
|
|
|
+
|
|
|
|
+ // 按dept_id去重,保留第一个出现的元素
|
|
|
|
+ List<IotOpeationFillOrderDO> distinctOrderList = zxjOrderList.stream()
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
+ IotOpeationFillOrderDO::getDeptId,
|
|
|
|
+ order -> {
|
|
|
|
+ order.setId(null); // 关键:重置ID,避免与已有数据冲突
|
|
|
|
+ return order;
|
|
|
|
+ },
|
|
|
|
+ (existing, replacement) -> existing
|
|
|
|
+ ))
|
|
|
|
+ .values()
|
|
|
|
+ .stream()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //插入工单主表
|
|
|
|
+ iotOpeationFillOrderMapper.insertBatch(distinctOrderList);
|
|
|
|
+ //发送钉钉消息
|
|
|
|
+ sendDingMessage(distinctOrderList);
|
|
|
|
+
|
|
|
|
+ boolean ryContain = ryIdList.contains(plan.getDeptId());
|
|
|
|
+ //瑞鹰日报插入
|
|
|
|
+ ryReportInsert(plan,distinctOrderList,ryContain);
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ ryIdList = deptService.getChildDeptIdListFromCache(163L);
|
|
|
|
+ ryIdList.add(163L);
|
|
|
|
+ Set<Long> rhIdList = new HashSet<>();
|
|
|
|
+ rhIdList = deptService.getChildDeptIdListFromCache(157L);
|
|
|
|
+ rhIdList.add(157L);
|
|
|
|
+ boolean exist = ryIdList.contains(plan.getDeptId());
|
|
|
|
+ if(!exist){
|
|
|
|
+ boolean rhContain = rhIdList.contains(plan.getDeptId());
|
|
|
|
+ //瑞恒日报插入
|
|
|
|
+ rhReportInsert(plan, orderList1, rhContain);
|
|
|
|
+ }
|
|
|
|
+ //发送钉钉消息
|
|
|
|
+ sendDingMessage(orderList1);
|
|
|
|
+ //正常工单设备
|
|
|
|
+ for (IotOpeationFillDO device:deviceList) {
|
|
|
|
+ for (IotOpeationFillOrderDO order:orderList1) {
|
|
|
|
+ if(device.getUserId().intValue()==order.getUserId().intValue()){
|
|
|
|
+ device.setOrderId(order.getId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //插入子表
|
|
|
|
+ for (IotOpeationFillDO re:deviceList) {
|
|
|
|
+ re.setDeviceId(re.getId());
|
|
|
|
+ }
|
|
|
|
+ iotOpeationFillMapper.insertFill(deviceList);
|
|
}
|
|
}
|
|
- //插入子表
|
|
|
|
- for (IotOpeationFillDO re:deviceList) {
|
|
|
|
- re.setDeviceId(re.getId());
|
|
|
|
- }
|
|
|
|
- iotOpeationFillMapper.insertFill(deviceList);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -276,6 +340,16 @@ public class IotOperationPlanJob implements JobHandler {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private void ryReportInsert(IotOperationPlanDO plan, List<IotOpeationFillOrderDO> orderList1, boolean ryContain) {
|
|
|
|
+ if(ryContain){
|
|
|
|
+ //创建日报设备
|
|
|
|
+ List <IotOpeationFillDO> devList = opeationFillService.reportMethod(orderList1);
|
|
|
|
+ //插入日报设备
|
|
|
|
+ iotOpeationFillMapper.insertFill(devList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void rhReportInsert(IotOperationPlanDO plan, List<IotOpeationFillOrderDO> orderList1, boolean rhContain) {
|
|
private void rhReportInsert(IotOperationPlanDO plan, List<IotOpeationFillOrderDO> orderList1, boolean rhContain) {
|
|
if(rhContain){
|
|
if(rhContain){
|
|
|
|
|