浏览代码

三单派单新增接口

wangxuan 6 月之前
父节点
当前提交
bcef31bfb3

+ 12 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxPmqManagementRecoredDao.java

@@ -52,4 +52,16 @@ public interface ZhcxPmqManagementRecoredDao extends BaseMapper<ZhcxPmqManagemen
      * @param id PID
      * @param id PID
      */
      */
     List<ZhcxPmqManagementDistributionDo> getDistributionsByPidSimple(@Param("id") String id);
     List<ZhcxPmqManagementDistributionDo> getDistributionsByPidSimple(@Param("id") String id);
+
+    /**
+     * 根据id删除2.5数据
+     * @param ids Distribution表的id集合
+     */
+    void deleteDistributionById(@Param("ids") List<String> ids);
+
+    /**
+     * 根据pid删除3数据
+     * @param ids Distribution_detail表的id集合
+     */
+    void deleteDistributionDetailById(@Param("ids") List<String> ids);
 }
 }

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxPmqManagementRecoredService.java

@@ -4,6 +4,7 @@ import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.ZhcxPmqManagementDistributionDTO;
 import com.rongwei.bsentity.dto.ZhcxPmqManagementDistributionDTO;
+import com.rongwei.bsentity.dto.sqlServer.DistributionDTO;
 import com.rongwei.bsentity.dto.sqlServer.RecoredDistributionDTO;
 import com.rongwei.bsentity.dto.sqlServer.RecoredDistributionDTO;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.R;
 
 
@@ -67,6 +68,12 @@ public interface ZhcxPmqManagementRecoredService extends IService<ZhcxPmqManagem
      */
      */
     R updateBatchList(List<ZhcxPmqManagementDistributionDTO> list,String status,String dispatchstatus);
     R updateBatchList(List<ZhcxPmqManagementDistributionDTO> list,String status,String dispatchstatus);
 
 
+    /**
+     * 三单派单页面批量派单弹窗处理数据接口(批量派单同一人和批量派单) 涉及到部分派单
+     * @param dto
+     * @return
+     */
+    R updateBatchList2(DistributionDTO dto);
     /**
     /**
      * 三单派单页面批量派单处理数据接口
      * 三单派单页面批量派单处理数据接口
      * @param dto 参数
      * @param dto 参数

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

@@ -4,14 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.FileUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDistributionDao;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDistributionDao;
+import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDistributionDetailDao;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.utils.CommonUtils;
 import com.rongwei.bscommon.sys.utils.CommonUtils;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDetailDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDetailDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDo;
+import com.rongwei.bsentity.domain.ZhcxPmqManagementDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementRecoredDao;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementRecoredDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.ZhcxPmqManagementDistributionDTO;
 import com.rongwei.bsentity.dto.ZhcxPmqManagementDistributionDTO;
+import com.rongwei.bsentity.dto.sqlServer.DistributionDTO;
 import com.rongwei.bsentity.dto.sqlServer.JuFileInfoDto;
 import com.rongwei.bsentity.dto.sqlServer.JuFileInfoDto;
 import com.rongwei.bsentity.dto.sqlServer.JutInfo;
 import com.rongwei.bsentity.dto.sqlServer.JutInfo;
 import com.rongwei.bsentity.dto.sqlServer.RecoredDistributionDTO;
 import com.rongwei.bsentity.dto.sqlServer.RecoredDistributionDTO;
@@ -73,6 +76,12 @@ public class ZhcxPmqManagementRecoredServiceImpl extends ServiceImpl<ZhcxPmqMana
     @Autowired
     @Autowired
     private SysFileItemService sysFileItemService;
     private SysFileItemService sysFileItemService;
 
 
+    @Autowired
+    private ZhcxPmqManagementDistributionDao distributionDao;
+
+    @Autowired
+    private ZhcxPmqManagementDistributionDetailDao detailDao;
+
     @Override
     @Override
     public R generateDistributionDetail(Map<String, Object> map) {
     public R generateDistributionDetail(Map<String, Object> map) {
         // 第二层主表id
         // 第二层主表id
@@ -584,6 +593,100 @@ public class ZhcxPmqManagementRecoredServiceImpl extends ServiceImpl<ZhcxPmqMana
         return R.ok("批量派单成功");
         return R.ok("批量派单成功");
     }
     }
 
 
+    @Override
+    public R updateBatchList2(DistributionDTO dto) {
+        String pids = dto.getList().get(0).getPid();
+        List<ZhcxPmqManagementDistributionDTO> list = dto.getList();
+        if(StringUtils.isEmpty(pids)){
+            return R.error("数据异常,请联系管理员");
+        }
+        String[] pidStr = pids.split(",");
+        // 第2.5层集合
+        List<ZhcxPmqManagementDistributionDo> resultList1 = new ArrayList<>();
+        // 第三层集合
+        List<ZhcxPmqManagementDistributionDetailDo> resultList2 = new ArrayList<>();
+        // 第一层主表ID
+        List<String> managementIds = new ArrayList<>();
+        // 第二层表数据
+        List<ZhcxPmqManagementRecoredDo> recoredList = new ArrayList<>();
+        for (String pid : pidStr) {
+            // 第二层数据
+            ZhcxPmqManagementRecoredDo recoredDo = this.getById(pid);
+            recoredList.add(recoredDo);
+            for (ZhcxPmqManagementDistributionDTO zhcxPmqManagementDistributionDTO : list) {
+                ZhcxPmqManagementDistributionDo result = new ZhcxPmqManagementDistributionDo();
+                String distributionId = SecurityUtil.getUUID();
+                // 可能是未派单,或者是部分派单的数据
+                String id = zhcxPmqManagementDistributionDTO.getId();
+                String[] ids = id.split(",");
+                if(ids.length > 0){
+                    List<String> idList = Arrays.asList(id.split(","));
+                    // 删除第2.5层 第三层数据
+                    baseMapper.deleteDistributionById(idList);
+                    baseMapper.deleteDistributionDetailById(idList);
+                }
+                // 第2.5层数据
+                result.setId(distributionId);
+                result.setPid(pid);
+                result.setProjectid(zhcxPmqManagementDistributionDTO.getProjectid());
+                result.setProjectname(zhcxPmqManagementDistributionDTO.getProjectname());
+                result.setProjectno(zhcxPmqManagementDistributionDTO.getProjectno());
+                result.setMachineid(zhcxPmqManagementDistributionDTO.getMachineid());
+                result.setMachineno(zhcxPmqManagementDistributionDTO.getMachineno());
+                result.setConfirmerid(zhcxPmqManagementDistributionDTO.getConfirmerid());
+                result.setConfirmer(zhcxPmqManagementDistributionDTO.getConfirmer());
+                // 关闭状态
+                if(!StringUtils.isEmpty(zhcxPmqManagementDistributionDTO.getStatus())) {
+                    result.setStatus(zhcxPmqManagementDistributionDTO.getStatus());
+                }
+                if(!StringUtils.isEmpty(String.valueOf(recoredDo.getSeqno()))) {
+                    result.setSerialnumber(String.valueOf(recoredDo.getSeqno()));
+                }
+                if(!StringUtils.isEmpty(zhcxPmqManagementDistributionDTO.getSupplement())) {
+                    result.setSupplement(zhcxPmqManagementDistributionDTO.getSupplement());
+                }
+                result.setRemark("批量派单");
+                resultList1.add(result);
+                // 第三层数据
+                ZhcxPmqManagementDistributionDetailDo bean = new ZhcxPmqManagementDistributionDetailDo();
+                BeanUtil.copyProperties(result,bean);
+                bean.setDistributid(distributionId);
+                bean.setId(SecurityUtil.getUUID());
+                resultList2.add(bean);
+            }
+            managementIds.add(recoredDo.getPmqmid());
+        }
+        // 保存2.5层 3层数据
+        if(!resultList1.isEmpty()){
+            zhcxPmqManagementDistributionService.saveBatch(resultList1);
+            zhcxPmqManagementDistributionDetailService.saveBatch(resultList2);
+            // 需要去更新Recored派单状态和关闭状态
+            updateRecoredStatus(recoredList,managementIds);
+        }
+        return R.ok("批量派单成功");
+    }
+
+    private void updateRecoredStatus(List<ZhcxPmqManagementRecoredDo> recoredList, List<String> managementIds) {
+        for (ZhcxPmqManagementRecoredDo recoredDo : recoredList) {
+            // 派单状态
+            String dispatchStatus = (distributionDao.selectListByPid(recoredDo.getId()).isEmpty())? "1" : "2";
+            // 关闭状态
+            ZhcxPmqManagementDo managementDo = zhcxPmqManagementService.getById(recoredDo.getPmqmid());
+            if(Objects.nonNull(managementDo.getProjectid())) {
+                String closeStatus = detailDao.getNotClosedStateInThirdFloorByPid(recoredDo.getId(), managementDo.getProjectid());
+                // 更新第二层表数据
+                recoredDo.setDispatchstatus(dispatchStatus);
+                recoredDo.setClosestatus(closeStatus);
+                this.updateById(recoredDo);
+            }
+        }
+        // 异步去更新第一层状态
+        List<String> ids = managementIds.stream().distinct().collect(Collectors.toList());
+        if(!ids.isEmpty()){
+            managementMapService.updateClosedStateInFirstFloor(ids);
+        }
+    }
+
     @Override
     @Override
     public R closedBatchList(RecoredDistributionDTO dto) {
     public R closedBatchList(RecoredDistributionDTO dto) {
         // 关闭状态
         // 关闭状态

+ 22 - 0
business-common/src/main/resources/mybatis/business/ZhcxPmqManagementRecoredDao.xml

@@ -102,4 +102,26 @@
             #{id}
             #{id}
         </foreach>
         </foreach>
     </update>
     </update>
+
+    <update id="deleteDistributionById">
+        UPDATE
+        INCONTROL.ZHCX_PMQ_MANAGEMENT_DISTRIBUTION
+        SET
+        DELETED ='1',REMARK='批量派单删除'
+        WHERE PID in
+        <foreach collection="ids" item="id" separator="," open="(" close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <update id="deleteDistributionDetailById">
+        UPDATE
+        INCONTROL.ZHCX_PMQ_MANAGEMENT_DISTRIBUTION_DETAIL
+        SET
+        DELETED ='1',REMARK='批量派单删除'
+        WHERE PID in
+        <foreach collection="ids" item="id" separator="," open="(" close=")">
+            #{id}
+        </foreach>
+    </update>
 </mapper>
 </mapper>

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

@@ -91,7 +91,7 @@ public class ZhcxPmqManagementRecoredController {
     @ApiOperation("三单派单页面批量派单弹窗处理数据接口")
     @ApiOperation("三单派单页面批量派单弹窗处理数据接口")
     public R updateBatchList(@RequestBody DistributionDTO dto){
     public R updateBatchList(@RequestBody DistributionDTO dto){
         try {
         try {
-            if(dto.getList().isEmpty()){return R.error("空数组");}
+            //if(dto.getList().isEmpty()){return R.error("空数组");}
             if(dto.getStatus().isEmpty()){return R.error("关闭状态为空");}
             if(dto.getStatus().isEmpty()){return R.error("关闭状态为空");}
             if(dto.getDispatchstatus().isEmpty()){return R.error("派单状态为空");}
             if(dto.getDispatchstatus().isEmpty()){return R.error("派单状态为空");}
             log.info("三单派单页面批量派单处理数据接口->集合大小:{}",dto.getList().size());
             log.info("三单派单页面批量派单处理数据接口->集合大小:{}",dto.getList().size());
@@ -102,6 +102,18 @@ public class ZhcxPmqManagementRecoredController {
         }
         }
     }
     }
 
 
+    @PostMapping("/updateBatchList2")
+    @ApiOperation("三单派单页面批量派单弹窗处理数据接口(批量派单同一人和批量派单)")
+    public R updateBatchList2(@RequestBody DistributionDTO dto){
+        try {
+            log.info("三单派单页面批量派单处理数据接口->集合大小:{}",dto.getList().size());
+            return managementRecoredService.updateBatchList2(dto);
+        } catch (Exception e) {
+            log.info(String.valueOf(e));
+            return R.error("三单派单批量派单失败");
+        }
+    }
+
     @PostMapping("/closedBatchList")
     @PostMapping("/closedBatchList")
     @ApiOperation("三单派单页面批量NA/批量关闭处理数据接口")
     @ApiOperation("三单派单页面批量NA/批量关闭处理数据接口")
     public R closedBatchList(@RequestBody RecoredDistributionDTO dto){
     public R closedBatchList(@RequestBody RecoredDistributionDTO dto){