|
@@ -21,7 +21,6 @@ import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillServic
|
|
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;
|
|
-import org.apache.ibatis.annotations.Param;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -63,7 +62,6 @@ public class IotOperationPlanJob implements JobHandler {
|
|
private DeptService deptService;
|
|
private DeptService deptService;
|
|
@Resource
|
|
@Resource
|
|
private IotOpeationFillService opeationFillService;
|
|
private IotOpeationFillService opeationFillService;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 1、查询开启状态运行计划
|
|
* 1、查询开启状态运行计划
|
|
* 2、根据计划获取设备
|
|
* 2、根据计划获取设备
|
|
@@ -76,7 +74,6 @@ public class IotOperationPlanJob implements JobHandler {
|
|
@Override
|
|
@Override
|
|
public String execute(String param) throws Exception {
|
|
public String execute(String param) throws Exception {
|
|
TenantContextHolder.setIgnore(true);
|
|
TenantContextHolder.setIgnore(true);
|
|
- System.out.println("***********创建运行记录填报工单开始执行*********8");
|
|
|
|
|
|
|
|
|
|
|
|
//1、查询开启,非删除状态运行计划
|
|
//1、查询开启,非删除状态运行计划
|
|
@@ -226,192 +223,73 @@ public class IotOperationPlanJob implements JobHandler {
|
|
.filter(obj -> idList.contains(obj.getUserId()))
|
|
.filter(obj -> idList.contains(obj.getUserId()))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- Set<Long> idList1 = new HashSet<>();
|
|
|
|
- idList1 = deptService.getChildDeptIdListFromCache(157L);
|
|
|
|
- idList1.add(157L);
|
|
|
|
|
|
|
|
- boolean containPlan = idList1.contains(plan.getDeptId());
|
|
|
|
|
|
+ //插入工单主表
|
|
|
|
+ iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
|
|
|
|
- List<IotOpeationFillOrderDO> orderList2 = new ArrayList<>();
|
|
|
|
- List<IotOperationPlanDO> rpList = new ArrayList<>();
|
|
|
|
|
|
|
|
Set<Long> pdeptList = new HashSet<>();
|
|
Set<Long> pdeptList = new HashSet<>();
|
|
pdeptList = deptService.getChildDeptIdListFromCache(plan.getDeptId());
|
|
pdeptList = deptService.getChildDeptIdListFromCache(plan.getDeptId());
|
|
pdeptList.add(plan.getDeptId());
|
|
pdeptList.add(plan.getDeptId());
|
|
|
|
|
|
//查询日报计划
|
|
//查询日报计划
|
|
- rpList = planMapper.getReportPlan(pdeptList);
|
|
|
|
|
|
+ List<IotOperationPlanDO> rpList = planMapper.getReportPlan(pdeptList);
|
|
List<Long> rpdList = rpList.stream().map(IotOperationPlanDO::getDeptId).collect(Collectors.toList());
|
|
List<Long> rpdList = rpList.stream().map(IotOperationPlanDO::getDeptId).collect(Collectors.toList());
|
|
|
|
|
|
- if(rpdList.size()>0){
|
|
|
|
- orderList2 = orderList.stream().filter(e->rpdList.contains(e.getDeptId())).collect(Collectors.toList());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(containPlan){
|
|
|
|
|
|
|
|
|
|
+ Set<Long> idList1 = new HashSet<>();
|
|
|
|
+ idList1 = deptService.getChildDeptIdListFromCache(163L);
|
|
|
|
+ idList1.add(163L);
|
|
|
|
|
|
|
|
+ boolean exist = idList1.contains(plan.getDeptId());
|
|
|
|
|
|
|
|
+ if(!exist){
|
|
|
|
+ //1、有指定队伍插入指定队伍日报设备
|
|
|
|
+ //2、无指定队伍全部队伍插入日报设备
|
|
if(rpList.size()>0){
|
|
if(rpList.size()>0){
|
|
|
|
+ //筛选日报工单
|
|
|
|
+ List<IotOpeationFillOrderDO> virOrderList = orderList1.stream().filter(e->rpdList.contains(e.getDeptId())).collect(Collectors.toList());
|
|
|
|
|
|
- //有责任人,但设备不满足条件,而且属于瑞恒
|
|
|
|
- List<IotOpeationFillDO> pdList2 = iotOpeationFillMapper.pdList2(pdeptList);
|
|
|
|
- //有责任人,且满足条件,而且属于瑞恒
|
|
|
|
-
|
|
|
|
- //判断是否与日报计划所属部门一致
|
|
|
|
- pdList2 = pdList2.stream().filter(e->rpdList.contains(e.getDeptId())).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if(pdList2.size()>0){
|
|
|
|
- orderList2 = new ArrayList<>();
|
|
|
|
- try{
|
|
|
|
- for (IotOpeationFillDO pd:pdList2) {
|
|
|
|
-
|
|
|
|
- IotOpeationFillOrderDO fillDO = new IotOpeationFillOrderDO();
|
|
|
|
-
|
|
|
|
- fillDO.setOrderName(pd.getOrgName()+"/"+LocalDate.now()+"运行记录填报");
|
|
|
|
- fillDO.setDeptId(pd.getDeptId());
|
|
|
|
- fillDO.setOrderStatus(0);
|
|
|
|
- fillDO.setCreateTime(LocalDateTime.now());
|
|
|
|
- fillDO.setUserName(pd.getUserName());
|
|
|
|
- fillDO.setUserId(pd.getUserId());
|
|
|
|
- fillDO.setMobile(pd.getMobile());
|
|
|
|
- orderList2.add(fillDO);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- orderList1.addAll(orderList2);
|
|
|
|
-
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }else if(orderList2.size()>0){
|
|
|
|
- orderList1.addAll(orderList2);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- List<IotOpeationFillDO> pdList2 = iotOpeationFillMapper.pdList2(pdeptList);
|
|
|
|
-
|
|
|
|
- if(pdList2.size()>0){
|
|
|
|
-
|
|
|
|
- try{
|
|
|
|
- for (IotOpeationFillDO pd:pdList2) {
|
|
|
|
-
|
|
|
|
- IotOpeationFillOrderDO fillDO = new IotOpeationFillOrderDO();
|
|
|
|
-
|
|
|
|
- fillDO.setOrderName(pd.getOrgName()+"/"+LocalDate.now()+"运行记录填报");
|
|
|
|
- fillDO.setDeptId(pd.getDeptId());
|
|
|
|
- fillDO.setOrderStatus(0);
|
|
|
|
- fillDO.setCreateTime(LocalDateTime.now());
|
|
|
|
- fillDO.setUserName(pd.getUserName());
|
|
|
|
- fillDO.setUserId(pd.getUserId());
|
|
|
|
- fillDO.setMobile(pd.getMobile());
|
|
|
|
- orderList1.add(fillDO);
|
|
|
|
- }
|
|
|
|
|
|
+ if(virOrderList.size()>0){
|
|
|
|
+ //创建日报设备
|
|
|
|
+ List <IotOpeationFillDO> devList = opeationFillService.reportMethod(virOrderList);
|
|
|
|
+ //插入日报设备
|
|
|
|
+ iotOpeationFillMapper.insertFill(devList);
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- IotOpeationFillOrderDO todayTime = new IotOpeationFillOrderDO();
|
|
|
|
- todayTime.setCreateTime(localDateTime);
|
|
|
|
-
|
|
|
|
- List<String> userList = orderList1.stream().map(IotOpeationFillOrderDO::getUserName).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- List<IotOpeationFillOrderDO> allOrder = iotOpeationFillMapper.allOrder(localDateTime,userList);
|
|
|
|
|
|
|
|
- if(allOrder.size()>0){
|
|
|
|
|
|
|
|
- }else{
|
|
|
|
-
|
|
|
|
- iotOpeationFillOrderMapper.insertBatch(orderList1);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /* //发送钉钉通知
|
|
|
|
- pmsThreadPoolTaskExecutor.execute(()->{
|
|
|
|
- try{
|
|
|
|
- for (IotOpeationFillOrderDO order:orderList1) {
|
|
|
|
- pmsMessage.sendMessage(order.getId(), order.getOrderName(), PmsConstants.GENERATE_OPERATION, (long)order.getUserId(), order.getMobile());
|
|
|
|
- }
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- });*/
|
|
|
|
-
|
|
|
|
- for (IotOpeationFillDO device:deviceList) {
|
|
|
|
- System.out.println("deviceUser"+device.getUserId());
|
|
|
|
|
|
+ /*//发送钉钉通知
|
|
|
|
+ pmsThreadPoolTaskExecutor.execute(()->{
|
|
|
|
+ try{
|
|
for (IotOpeationFillOrderDO order:orderList1) {
|
|
for (IotOpeationFillOrderDO order:orderList1) {
|
|
- System.out.println("orderId"+order.getUserId());
|
|
|
|
- if(device.getUserId().intValue()==order.getUserId().intValue()){
|
|
|
|
- System.out.println("-----相等-------");
|
|
|
|
- device.setOrderId(order.getId());
|
|
|
|
- }
|
|
|
|
|
|
+ pmsMessage.sendMessage(order.getId(), order.getOrderName(), PmsConstants.GENERATE_OPERATION, (long)order.getUserId(), order.getMobile());
|
|
}
|
|
}
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ });*/
|
|
|
|
|
|
|
|
|
|
- System.out.println("***********创建运行记录填报工单执行结束*********8");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- System.out.println("*****************插入运行记录设备表***********************");
|
|
|
|
-
|
|
|
|
- for (IotOpeationFillDO re:deviceList) {
|
|
|
|
- re.setDeviceId(re.getId());
|
|
|
|
- re.setIsReport(0);
|
|
|
|
- }
|
|
|
|
- iotOpeationFillMapper.insertFill(deviceList);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<Long> oDeptList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- if(rpList.size()>0){
|
|
|
|
- oDeptList = orderList2.stream().map(IotOpeationFillOrderDO::getDeptId).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- // 先判断oDeptList是否为空,如果为空则根据业务需求设置exist的值
|
|
|
|
- boolean exist;
|
|
|
|
- if (oDeptList.isEmpty()) {
|
|
|
|
- // 当oDeptList为空时,这里可以根据实际场景设置默认值
|
|
|
|
- // 例如:空列表认为所有元素都被包含,设置为true
|
|
|
|
- exist = false;
|
|
|
|
- // 或者认为不满足,设置为false
|
|
|
|
- // exist = false;
|
|
|
|
- } else {
|
|
|
|
- exist = idList1.containsAll(oDeptList);
|
|
|
|
|
|
+ //正常工单设备
|
|
|
|
+ for (IotOpeationFillDO device:deviceList) {
|
|
|
|
+ for (IotOpeationFillOrderDO order:orderList1) {
|
|
|
|
+ if(device.getUserId().intValue()==order.getUserId().intValue()){
|
|
|
|
+ device.setOrderId(order.getId());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if(exist){
|
|
|
|
- List <IotOpeationFillDO> devList = opeationFillService.reportMethod(orderList2);
|
|
|
|
- //插入虚拟设备
|
|
|
|
- iotOpeationFillMapper.insertFill(devList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- oDeptList = orderList1.stream().map(IotOpeationFillOrderDO::getDeptId).collect(Collectors.toList());
|
|
|
|
|
|
+ //插入子表
|
|
|
|
+ for (IotOpeationFillDO re:deviceList) {
|
|
|
|
+ re.setDeviceId(re.getId());
|
|
|
|
+ }
|
|
|
|
+ iotOpeationFillMapper.insertFill(deviceList);
|
|
|
|
|
|
- // 先判断oDeptList是否为空,如果为空则根据业务需求设置exist的值
|
|
|
|
- boolean exist;
|
|
|
|
- if (oDeptList.isEmpty()) {
|
|
|
|
- // 当oDeptList为空时,这里可以根据实际场景设置默认值
|
|
|
|
- // 例如:空列表认为所有元素都被包含,设置为true
|
|
|
|
- exist = false;
|
|
|
|
- // 或者认为不满足,设置为false
|
|
|
|
- // exist = false;
|
|
|
|
- } else {
|
|
|
|
- exist = idList1.containsAll(oDeptList);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if(exist){
|
|
|
|
- List <IotOpeationFillDO> devList = opeationFillService.reportMethod(orderList1);
|
|
|
|
- //插入虚拟设备
|
|
|
|
- iotOpeationFillMapper.insertFill(devList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+}
|