|
@@ -202,107 +202,102 @@ public class IotOperationPlanJob implements JobHandler {
|
|
|
//判断是否为瑞恒特殊计划
|
|
//判断是否为瑞恒特殊计划
|
|
|
if(plan.getId()==153L){
|
|
if(plan.getId()==153L){
|
|
|
unNormalTeamInPlan(plan);
|
|
unNormalTeamInPlan(plan);
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //4、根据设备ID生成子表数据
|
|
|
|
|
- List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
|
|
|
|
|
- List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
|
|
|
|
|
- List<IotOpeationFillOrderDO> orderList1 = orderList.stream()
|
|
|
|
|
- .filter(obj -> idList.contains(obj.getUserId()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //4、根据设备ID生成子表数据
|
|
|
|
|
+ List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
|
|
|
|
|
+ List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
|
|
|
|
|
+ List<IotOpeationFillOrderDO> orderList1 = orderList.stream()
|
|
|
|
|
+ .filter(obj -> idList.contains(obj.getUserId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
- // 按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);
|
|
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
|
|
|
|
- //插入工单主表
|
|
|
|
|
- iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
|
|
|
- //瑞都
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ // 按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{
|
|
|
|
|
+
|
|
|
|
|
+ //插入工单主表
|
|
|
|
|
+ iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
|
|
|
+ //瑞都
|
|
|
|
|
+ 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);
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void sendDingMessage(List<IotOpeationFillOrderDO> orderList1) {
|
|
private void sendDingMessage(List<IotOpeationFillOrderDO> orderList1) {
|