Jelajahi Sumber

运行记录1010-瑞鹰钻修井生成日报

yuanchao 5 hari lalu
induk
melakukan
4d895250a2

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java

@@ -269,6 +269,9 @@ public class IotOpeationFillController {
                 IotRyDailyReportSaveReqVO saveReqVO1 = BeanUtil.mapToBean(stringRyObjectMap, IotRyDailyReportSaveReqVO.class,false);
                 saveReqVO1.setDeptId(fillDO1.getDeptId());
                 saveReqVO1.setFillOrderCreateTime(fillList.get(0).getCreateTime().atStartOfDay());
+                if(fillDO1.getDeviceCategoryId()==228){
+                    saveReqVO1.setProjectClassification("2");
+                }
                 iotRyDailyReportService.createIotRyDailyReport(saveReqVO1);
             }
 

+ 7 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillMapper.java

@@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLo
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO;
 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.system.dal.dataobject.user.AdminUserDO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -248,4 +249,10 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     @TenantIgnore
     IotDeviceRunLogDO getDesc(IotDeviceRunLogDO runLogDO);
 
+    @TenantIgnore
+    IotDeviceRunLogDO getTeamType(IotDeviceRunLogDO runLogDO);
+
+    @TenantIgnore
+    AdminUserDO getUserInfo(IotDeviceRunLogDO runLogDO);
+
 }

+ 117 - 45
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationPlanJob.java

@@ -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.dal.dataobject.IotDeviceDO;
 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.IotOpeationFillOrderDO;
 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.service.iotopeationfill.IotOpeationFillService;
 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 lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -33,6 +35,7 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 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) {
-        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);
+
+
+
         //4、根据设备ID生成子表数据
         List<IotOpeationFillDO> deviceList = iotOpeationFillMapper.getFillDevices(devIdList);
         List<Integer> idList = deviceList.stream().map(IotOpeationFillDO::getUserId).collect(Collectors.toList());
@@ -173,54 +198,91 @@ public class IotOperationPlanJob implements JobHandler {
                 .collect(Collectors.toList());
         //插入工单主表
         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);
+
+            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 +338,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) {
         if(rhContain){
 

+ 16 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillServiceImpl.java

@@ -56,7 +56,9 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
 
     private static Long RH_CLASS_ID = 226L;
 
-    private static Long RY_CLASS_ID = 227L;
+    private static Long RY_ZJ_CLASS_ID = 227L;
+
+    private static Long RY_XJ_CLASS_ID = 228L;
 
     @Override
     public Long createIotOpeationFill(IotOpeationFillSaveReqVO createReqVO) {
@@ -342,6 +344,12 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         if(orderList.size()>0){
             //遍历工单主数据,根据dept_id查询是否为根节点
             for (IotOpeationFillOrderDO orderDO:orderList) {
+
+                IotDeviceRunLogDO runLogDO = new IotDeviceRunLogDO();
+                runLogDO.setDeptId(orderDO.getDeptId());
+                //获取队伍类型
+                IotDeviceRunLogDO teamType = iotOpeationFillMapper.getTeamType(runLogDO);
+
                 List<IotOpeationFillOrderDO> childList = iotOpeationFillMapper.childList(orderDO);
 
                 int randomNum = generateUniqueNumber();
@@ -354,8 +362,13 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
 
                     if(rhIdList.contains(orderDO.getDeptId())){
                         devOrder.setDeviceCategoryId(RH_CLASS_ID);
-                    }else if(ryIdList.contains(orderDO.getDeptId())){
-                        devOrder.setDeviceCategoryId(RY_CLASS_ID);
+                    }else if(ryIdList.contains(orderDO.getDeptId())&&teamType!=null){
+                        //队伍类型为zj则日报设备分类为钻井,否则为修井
+                        if(teamType.getPointCode().equals("zj")){
+                            devOrder.setDeviceCategoryId(RY_ZJ_CLASS_ID);
+                        }else{
+                            devOrder.setDeviceCategoryId(RY_XJ_CLASS_ID);
+                        }
                     }
 
                     devOrder.setDeptId(orderDO.getDeptId());

+ 12 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -1177,5 +1177,17 @@
     </select>
 
 
+    <select id="getTeamType" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        select type as point_code from system_dept_type where dept_id = #{deptId}
+    </select>
+
+
+    <select id="getUserInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
+            resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
+        select * from system_users where dept_id = #{deptId} and nickname = '技术员'
+    </select>
+
+
 
 </mapper>

+ 0 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOperationPlanMapper.xml

@@ -17,9 +17,6 @@
             status = 0
         and
             deleted = 0
-        and
-            is_report is null
-        or  is_report != 1
     </select>
 
     <select id="getReportPlan" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO">