|
@@ -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;
|
|
|
+ }
|
|
|
}
|