wangxuan 8 ay önce
ebeveyn
işleme
77e647840e

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

@@ -29,4 +29,11 @@ public interface ZhcxPmqManagementRecoredService extends IService<ZhcxPmqManagem
      * @return map集合:sys_file表id,文件类型
      */
     R filePreview(String id);
+
+    /**
+     * 三单派单页面右边列表数据源
+     * @param id  Recored_id
+     * @return 数据
+     */
+    R getListData(String id);
 }

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

@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDistributionDao;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementDistributionDetailService;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementDistributionService;
+import com.rongwei.bscommon.sys.service.ZhcxPmqManagementService;
 import com.rongwei.bscommon.sys.utils.CommonUtils;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDetailDo;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDistributionDo;
@@ -13,6 +14,7 @@ import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementRecoredDao;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementRecoredService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.sqlServer.JuFileInfoDto;
+import com.rongwei.bsentity.dto.sqlServer.JutInfo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
@@ -28,6 +30,7 @@ import java.io.File;
 import java.sql.*;
 import java.util.*;
 import java.util.Date;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -54,6 +57,9 @@ public class ZhcxPmqManagementRecoredServiceImpl extends ServiceImpl<ZhcxPmqMana
     @Value("${nxsystem.filepath:#{null}}")
     private String nxfilepath;
 
+    @Autowired
+    private ZhcxPmqManagementService zhcxPmqManagementService;
+
     @Autowired
     private ZhcxPmqManagementDistributionService zhcxPmqManagementDistributionService;
 
@@ -223,4 +229,101 @@ public class ZhcxPmqManagementRecoredServiceImpl extends ServiceImpl<ZhcxPmqMana
         }
         return resultList;
     }
+
+    @Override
+    public R getListData(String id) {
+        ZhcxPmqManagementRecoredDo recoredDo = this.getById(id);
+        // 生成第2.5层数据结果
+        List<ZhcxPmqManagementDistributionDo> distributions = baseMapper.getDistributionsByPid(id);
+        // 拿到发单流水号和部门id
+        String deptid = recoredDo.getDeptid();
+        String seqno = String.valueOf(recoredDo.getSeqno());
+        // 触发器
+        boolean isSave = false;
+        int index = 0;
+        if(StringUtils.isNotBlank(deptid) || StringUtils.isNotBlank(seqno)){
+            Map<String, JutInfo> sqlServer = getStutasInSqlServer(deptid, seqno);
+            if(!sqlServer.isEmpty()) {
+                for (ZhcxPmqManagementDistributionDo distribution : distributions) {
+                    // 获取机号
+                    String machineno = distribution.getMachineno();
+                    if (StringUtils.isNotBlank(machineno)) {
+                        machineno = machineno.replace("#", "");
+                        log.info("三单派单右边列表拿到的sqlServer对象:{}", sqlServer.get(machineno));
+                        if (Objects.nonNull(sqlServer.get(machineno))) {
+                            // 代表在sqlserver那边已关闭
+                            distribution.setStatus("已关闭");
+                            distribution.setRemark("NX系统关闭,SqlServerId:"+sqlServer.get(machineno).getRecordID());
+                            index++;
+                            if(!StringUtils.isNotBlank(distribution.getId())){
+                                distribution.setId(SecurityUtil.getUUID());
+                                zhcxPmqManagementDistributionService.save(distribution);
+                                if(!isSave){ isSave = true;}
+                            }else {
+                                zhcxPmqManagementDistributionService.updateById(distribution);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        if(isSave){
+            // 更改派单状态/更新第二层的状态
+            recoredDo.setDispatchstatus("1");
+            if(index == distributions.size()){
+                recoredDo.setClosestatus("已关闭");
+                this.updateById(recoredDo);
+                zhcxPmqManagementDistributionDetailService.updateClosedStateInSecondFloor(id);
+            }else {
+                this.updateById(recoredDo);
+            }
+            log.info("更新关闭状态");
+        }
+        Map<String, Object> results = new HashMap<>();
+        results.put("records",distributions);
+        results.put("current",1);
+        results.put("orders",new ArrayList<String>());
+        results.put("pages",1);
+        results.put("searchCount",true);
+        results.put("size",100);
+        results.put("total",distributions.size());
+        return R.ok(results);
+    }
+
+    /**
+     * 三单派单右边列表
+     * @param deptid NX部门id
+     * @param seqno 流水号
+     * @return key:机号 v:数据 状态为已关闭
+     */
+    private Map<String,JutInfo> getStutasInSqlServer(String deptid, String seqno){
+        // 结果集合
+        List<JutInfo> result = new ArrayList<>();
+        String url ="jdbc:sqlserver://"+nxurl+":1433;databaseName="+nxdbname+";"+nxurlfix+"";
+        log.info("三单派单右边列表连接字符串" + url);
+        try(Connection connection = DriverManager.getConnection(url,nxdbuser,nxdbpw);
+            Statement statement = connection.createStatement()) {
+            String sqlStr = "SELECT 发单流水号,当前部门ID,机号,质检,质检确认日期,关闭状态,RecordID FROM [JUT753] WHERE 关闭状态 = '已关闭' AND [发单流水号] = N'"+seqno+"' AND [当前部门ID] = N'"+deptid+"' ";
+            ResultSet resultSet = statement.executeQuery(sqlStr);
+            while (resultSet.next()) {
+                JutInfo jutInfo = new JutInfo();
+                jutInfo.setSeqno(resultSet.getString(1));
+                jutInfo.setDeptid(resultSet.getString(2));
+                jutInfo.setMachineno(resultSet.getString(3));
+                jutInfo.setQuality(resultSet.getString(4));
+                jutInfo.setConfirmTime(resultSet.getString(5));
+                jutInfo.setStatus(resultSet.getString(6));
+                jutInfo.setRecordID(resultSet.getString(7));
+                result.add(jutInfo);
+            }
+        }catch(Exception e1){
+            log.error("SQLSERVER三单派单右边列表连接异常");
+            e1.printStackTrace();
+        }
+        Map<String, JutInfo> map = new HashMap<>();
+        if(!result.isEmpty()){
+            map = result.stream().collect(Collectors.toMap(JutInfo::getMachineno, info -> info));
+        }
+        return map;
+    }
 }

+ 1 - 3
business-common/src/main/resources/mybatis/business/ZhcxPmqManagementRecoredDao.xml

@@ -29,9 +29,7 @@
                     p.ID AS PROJECTID
                 FROM
                     INCONTROL.ZHCX_PROJECT_DEVICE_NUMBER n
-                        JOIN INCONTROL.ZHCX_PROJECT_MANAGE p ON
-                        p.ID = n.PID
-                            AND p.DELETED = '0'
+                JOIN INCONTROL.ZHCX_PROJECT_MANAGE p ON p.ID = n.PID AND p.DELETED = '0'
                 WHERE
                     n.DELETED = '0'
             )p ON p.PROJECTID = manage.PROJECTID

+ 34 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/sqlServer/JutInfo.java

@@ -0,0 +1,34 @@
+package com.rongwei.bsentity.dto.sqlServer;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 三单关闭记录表__sqlserver表名:
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class JutInfo {
+    // 发单流水号
+    private String seqno;
+
+    // 当前部门ID
+    private String deptid;
+
+    // 机号
+    private String machineno;
+
+    // 质检
+    private String quality;
+
+    // 质检确认日期
+    private String confirmTime;
+
+    // 关闭状态
+    private String status;
+
+    //表记录id
+    private String recordID;
+}

+ 21 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxPmqManagementRecoredController.java

@@ -44,5 +44,26 @@ public class ZhcxPmqManagementRecoredController {
             return R.error("文件预览异常");
         }
     }
+
+    /**
+     * 三单派单页面右边列表数据源
+     * @param map
+     * @return
+     */
+    @PostMapping("/getListData")
+    @ApiOperation("三单派单页面右边列表数据源")
+    public R getListData(@RequestBody Map<String,Object> map){
+        try {
+            if(Objects.isNull(map.get("querySql"))){
+                return R.error("id不能为空");
+            }
+            String id = (String) map.get("querySql");
+            log.info("三单派单页面右边列表数据源->id:{}",id);
+            return managementRecoredService.getListData(id);
+        } catch (Exception e) {
+            log.info(String.valueOf(e));
+            return R.error("三单派单页面右边列表数据源异常");
+        }
+    }
 }