wangxuan 8 månader sedan
förälder
incheckning
239ae1e955

+ 3 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxPmqManagementDistributionDao.java

@@ -45,4 +45,7 @@ public interface ZhcxPmqManagementDistributionDao extends BaseMapper<ZhcxPmqMana
 
     // 第三层
     List<MachineState> getMachinesStatus(@Param("projectId")String projectId,@Param("id") String id);
+
+    // 第三层数据删除,因为派单 更改质检确认人
+    void deleteBatchIdsForDispatchTochange(@Param("resultList") List<String> resultList,@Param("nowDate") String nowDate);
 }

+ 13 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxPmqManagementLogService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxPmqManagementLogDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.rwcommon.base.R;
 
 /**
  * <p>
@@ -12,5 +13,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2024-11-22
  */
 public interface ZhcxPmqManagementLogService extends IService<ZhcxPmqManagementLogDo> {
+    /**
+     * 三单派单页面记录操作日志
+     * @param id RECORED_id
+     * @param type 操作类型
+     */
+    R logForSecondFloor(String id, String type);
 
+    /**
+     * 三单执行页面记录操作日志
+     * @param id ZHCX_PMQ_MANAGEMENT_DISTRIBUTION_DETAIL_id
+     * @param type 操作类型
+     */
+    R logFoThirdFloor(String id,String type);
 }

+ 21 - 7
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPmqManagementDistributionServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementDistributionDetailService;
+import com.rongwei.bscommon.sys.service.ZhcxPmqManagementLogService;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDetailDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDo;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDistributionDao;
@@ -43,6 +44,9 @@ public class ZhcxPmqManagementDistributionServiceImpl extends ServiceImpl<ZhcxPm
     @Autowired
     private ZhcxPmqManagementServiceImpl managementService;
 
+    @Autowired
+    private ZhcxPmqManagementLogService logService;
+
     @Override
     public R generateDistributionDetail(String pid) {
         if(StringUtils.isEmpty(pid)){
@@ -109,21 +113,29 @@ public class ZhcxPmqManagementDistributionServiceImpl extends ServiceImpl<ZhcxPm
         resultList.addAll(updateList);
         // 拿到第三层子表的id
         List<String> detailIds = resultList.stream().map(ZhcxPmqManagementDistributionDetailDo::getId).collect(Collectors.toList());
-        // 可能会涉及到改派 TODO 未写完
-        // dispatchTochange(pid,detailIds);
-        // 更新第二层的派单状态
         String nowDate = DateUtil.formatDateTime(new Date());
+        // 可能会涉及到改派
+        boolean dispatchTochange = dispatchTochange(pid, detailIds, nowDate);
+        // 操作记录
+        if(dispatchTochange){
+            logService.logForSecondFloor(pid,"派单改派");
+        }else{
+            logService.logForSecondFloor(pid,"派单");
+        }
+        // 更新第二层的派单状态
         baseMapper.updateDispatchStatus(pid,nowDate);
+        // 更新第二层的关闭状态
+        detailService.updateClosedStateInSecondFloor(pid);
         return R.ok("派单成功");
     }
 
-    private void dispatchTochange(String pid,List<String> baseList){
+    private boolean dispatchTochange(String pid,List<String> baseList,String nowDate){
         LambdaQueryWrapper<ZhcxPmqManagementDistributionDetailDo> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ZhcxPmqManagementDistributionDetailDo::getDeleted,"0")
                 .eq(ZhcxPmqManagementDistributionDetailDo::getPid,pid);
         List<ZhcxPmqManagementDistributionDetailDo> detailDos = detailService.list(queryWrapper);
         // 需要删除的数据集合
-        List<ZhcxPmqManagementDistributionDetailDo> resultList = new ArrayList<>();
+        List<String> resultList = new ArrayList<>();
         if(!detailDos.isEmpty()){
             // 证明有改派的数据,找出改派的数据然后删了
             for (ZhcxPmqManagementDistributionDetailDo detailDo : detailDos) {
@@ -131,13 +143,15 @@ public class ZhcxPmqManagementDistributionServiceImpl extends ServiceImpl<ZhcxPm
                     // 如果在confirmerids里面,
                     detailDo.setDeleted("1"); // 伪删
                     detailDo.setRemark("改派删除");
-                    resultList.add(detailDo);
+                    resultList.add(detailDo.getId());
                 }
             }
         }
         if(!resultList.isEmpty()){
-            detailService.updateBatchById(resultList);
+            baseMapper.deleteBatchIdsForDispatchTochange(resultList,nowDate);
+            return true;
         }
+        return false;
     }
 
     @Override

+ 69 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPmqManagementLogServiceImpl.java

@@ -1,11 +1,27 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.rongwei.bscommon.sys.service.ZhcxPmqManagementDistributionDetailService;
+import com.rongwei.bscommon.sys.service.ZhcxPmqManagementRecoredService;
+import com.rongwei.bscommon.sys.utils.CommonUtils;
+import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDetailDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementLogDo;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementLogDao;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommon.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+import java.util.Objects;
+
 /**
  * <p>
  * 三单管理_操作日志 服务实现类
@@ -15,6 +31,59 @@ import org.springframework.stereotype.Service;
  * @since 2024-11-22
  */
 @Service
+@Slf4j
 public class ZhcxPmqManagementLogServiceImpl extends ServiceImpl<ZhcxPmqManagementLogDao, ZhcxPmqManagementLogDo> implements ZhcxPmqManagementLogService {
 
+    @Autowired
+    private ZhcxPmqManagementDistributionDetailService detailService;
+
+    @Autowired
+    private ZhcxPmqManagementRecoredService recoredService;
+
+    @Override
+    public R logForSecondFloor(String id, String type) {
+        ZhcxPmqManagementRecoredDo recoredDo = recoredService.getById(id);
+        Date nowDate = DateUtil.parse(DateUtil.now(), "yyyy-MM-dd HH:mm:ss");
+        // 获取当前操作人
+        SysUserVo currentUser = CommonUtils.getCurrentUser();
+        if(Objects.isNull(currentUser) || StringUtils.isEmpty(currentUser.getId())){
+            return R.error("无法获取当前操作人");
+        }
+        ZhcxPmqManagementLogDo zhcxPmqManagementLogDo = new ZhcxPmqManagementLogDo();
+        zhcxPmqManagementLogDo.setId(SecurityUtil.getUUID())
+                .setOperator(currentUser.getName())
+                .setOperatorid(currentUser.getId())
+                .setOperationtype(type)
+                .setOperationtime(nowDate)
+                .setPmqmid(recoredDo.getPmqmid())
+                .setRecoredid(id);
+        this.save(zhcxPmqManagementLogDo);
+        log.info("记录日志");
+        return R.ok("记录日志");
+    }
+
+    @Override
+    public R logFoThirdFloor(String id, String type) {
+        ZhcxPmqManagementDistributionDetailDo detailDo = detailService.getById(id);
+        ZhcxPmqManagementRecoredDo recoredDo = recoredService.getById(detailDo.getPid());
+        Date nowDate = DateUtil.parse(DateUtil.now(), "yyyy-MM-dd HH:mm:ss");
+        // 获取当前操作人
+        SysUserVo currentUser = CommonUtils.getCurrentUser();
+        if(Objects.isNull(currentUser) || StringUtils.isEmpty(currentUser.getId())){
+            return R.error("无法获取当前操作人");
+        }
+        ZhcxPmqManagementLogDo zhcxPmqManagementLogDo = new ZhcxPmqManagementLogDo();
+        zhcxPmqManagementLogDo.setId(SecurityUtil.getUUID())
+                .setOperator(currentUser.getName())
+                .setOperatorid(currentUser.getId())
+                .setOperationtype(type)
+                .setOperationtime(nowDate)
+                .setPmqmid(recoredDo.getPmqmid())
+                .setRecoredid(recoredDo.getId())
+                .setDistributionid(detailDo.getDistributid())
+                .setDetailid(id);
+        this.save(zhcxPmqManagementLogDo);
+        log.info("记录日志");
+        return R.ok("记录日志");
+    }
 }

+ 13 - 1
business-common/src/main/resources/mybatis/business/ZhcxPmqManagementDistributionDao.xml

@@ -128,7 +128,7 @@
                     WHEN x.STATUS IS NULL THEN '未关闭'
                     WHEN x.STATUS = 'NA' THEN 'NA'
                     WHEN x.STATUS = '已关闭' THEN '已关闭'
-                    ELSE '关闭'
+                    ELSE '关闭'
                     END AS STATUS
                     FROM
                     INCONTROL.ZHCX_PMQ_MANAGEMENT_DISTRIBUTION_DETAIL x
@@ -150,4 +150,16 @@
         ORDER BY
             TO_NUMBER(REPLACE(n.DEVICE_NUMBER, '#', ''))
     </select>
+
+    <update id="deleteBatchIdsForDispatchTochange">
+        UPDATE
+            INCONTROL.ZHCX_PMQ_MANAGEMENT_DISTRIBUTION_DETAIL
+        SET
+            DELETED = '1',REMARK = '改派删除',MODIFYDATE = #{nowDate}
+        WHERE
+            ID IN
+           <foreach collection="resultList" item="id" open="(" close=")" separator=",">
+             #{id}
+           </foreach>
+    </update>
 </mapper>

+ 3 - 1
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxPmqManagementLogDo.java

@@ -2,6 +2,8 @@ package com.rongwei.bsentity.domain;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.rongwei.rwcommon.base.BaseDo;
+
+import java.io.Serializable;
 import java.util.Date;
 import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
@@ -20,7 +22,7 @@ import lombok.experimental.Accessors;
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @TableName("ZHCX_PMQ_MANAGEMENT_LOG")
-public class ZhcxPmqManagementLogDo extends BaseDo {
+public class ZhcxPmqManagementLogDo extends BaseDo implements Serializable {
 
     private static final long serialVersionUID=1L;
 

+ 1 - 1
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxPMQMController.java

@@ -98,7 +98,7 @@ public class ZhcxPMQMController {
     }
 
     @GetMapping("/selectManifestList2")
-    @ApiOperation("三单清单数据源")
+    @ApiOperation("三单清单数据源(第二层接口)")
     public R selectManifestList2(String projectId,String id){
         try {
             if(Objects.isNull(projectId)){return R.ok("项目id为空");}