|
@@ -1,5 +1,6 @@
|
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.rongwei.bscommon.sys.dao.*;
|
|
|
import com.rongwei.bscommon.sys.service.ZhcxPMQMService;
|
|
|
import com.rongwei.bscommon.sys.utils.ZhcxCommon;
|
|
@@ -7,18 +8,32 @@ import com.rongwei.bsentity.domain.ZhcxPmqManagementDo;
|
|
|
import com.rongwei.bsentity.domain.ZhcxPmqManagementMapDo;
|
|
|
import com.rongwei.bsentity.domain.ZhcxPmqManagementRecoredDo;
|
|
|
import com.rongwei.bsentity.domain.ZhcxPmqManagementSourceDo;
|
|
|
+import com.rongwei.bsentity.dto.sqlServer.ZhcxPmqManagementSource;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.sql.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
+
|
|
|
+ @Value("${nxsystem.url:#{null}}")
|
|
|
+ private String nxurl;
|
|
|
+ @Value("${nxsystem.dbname:#{null}}")
|
|
|
+ private String nxdbname;
|
|
|
+ @Value("${nxsystem.dbuser:#{null}}")
|
|
|
+ private String nxdbuser;
|
|
|
+ @Value("${nxsystem.dbpw:#{null}}")
|
|
|
+ private String nxdbpw;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ZhcxPMQMDao pmqmDao;
|
|
|
|
|
@@ -36,34 +51,18 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
|
|
|
@Autowired
|
|
|
private ZhcxPmqManagementSourceDao sourceDao;
|
|
|
+ @Autowired
|
|
|
+ private ZhcxPMQMDao zhcxPMQMDao;
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getPMQMData(Map<String, String> map) {
|
|
|
List<Map<String, Object>> res = new ArrayList<>();
|
|
|
Date currentDate = new Date();
|
|
|
- // 获取当前抽取的最大的下发日期
|
|
|
- List<ZhcxPmqManagementRecoredDo> tempList1 = recoredDao.getMaxDatetime();
|
|
|
- String maxTime = "2000-01-01 00:00:00";
|
|
|
- if (!tempList1.isEmpty() && tempList1.get(0) != null && tempList1.get(0).getDistributetime() != null) {
|
|
|
- maxTime = DateFormatUtils.format(tempList1.get(0).getDistributetime(), "yyyy-MM-dd HH:mm:ss");
|
|
|
- }
|
|
|
- Map<String, String> queryMap01 = new HashMap<>();
|
|
|
- queryMap01.put("maxtime", maxTime);
|
|
|
+
|
|
|
// 抽取NX系统数据
|
|
|
- List<ZhcxPmqManagementSourceDo> nxSystemData = sourceDao.getMockData(queryMap01);
|
|
|
+ List<ZhcxPmqManagementSourceDo> nxSystemData = getNxSystemData();
|
|
|
newMapData(nxSystemData);
|
|
|
|
|
|
- for (ZhcxPmqManagementSourceDo row : nxSystemData) {
|
|
|
- // 将NX系统数据写入ZHCX_PMQ_MANAGEMENT_SOURCE表
|
|
|
- ZhcxPmqManagementSourceDo saveRow = new ZhcxPmqManagementSourceDo();
|
|
|
- BeanUtils.copyProperties(row, saveRow);
|
|
|
- row.setId(SecurityUtil.getUUID());
|
|
|
- row.setDeleted("0");
|
|
|
- row.setCreatedate(currentDate);
|
|
|
- row.setModifydate(currentDate);
|
|
|
-// sourceDao.insert(row);
|
|
|
- }
|
|
|
-
|
|
|
// 获取所有用户
|
|
|
List<Map<String, Object>> allUser = pmqmDao.getAllUser();
|
|
|
|
|
@@ -177,6 +176,7 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public void updateCloseStatusSimple(String id) {
|
|
|
ZhcxPmqManagementDo row = managementDao.selectById(id);
|
|
|
Map<String, String> queryMap = new HashMap<>();
|
|
@@ -195,4 +195,59 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ZhcxPmqManagementSourceDo> getNxSystemData() {
|
|
|
+ List<Map<String, Object>> prjCodeList = zhcxPMQMDao.getAllProjectCode();
|
|
|
+ Set<String> projectCodes = prjCodeList.stream()
|
|
|
+ .filter(map -> map.containsKey("PROJECT_CODE"))
|
|
|
+ .map(map -> (String) map.get("PROJECT_CODE"))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ List<ZhcxPmqManagementRecoredDo> tempList1 = recoredDao.getMaxDatetime();
|
|
|
+ String maxTime = "2000-01-01 00:00:01";
|
|
|
+ if (!tempList1.isEmpty() && tempList1.get(0) != null && tempList1.get(0).getDistributetime() != null) {
|
|
|
+ maxTime = DateFormatUtils.format(tempList1.get(0).getDistributetime(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ }
|
|
|
+ List<ZhcxPmqManagementSourceDo> list = new ArrayList<>();
|
|
|
+ String url ="jdbc:sqlserver://"+nxurl+":1433;databaseName="+nxdbname+";encrypt=true;trustServerCertificate=true";
|
|
|
+ try(Connection connection = DriverManager.getConnection(url,nxdbuser,nxdbpw);
|
|
|
+ Statement statement = connection.createStatement()) {
|
|
|
+ String sqlStr = "SELECT * FROM JUV1841 WHERE 下发日期 > '"+maxTime+"'";
|
|
|
+ try(ResultSet resultSet = statement.executeQuery(sqlStr)) {
|
|
|
+ while (resultSet.next()) {
|
|
|
+ ZhcxPmqManagementSourceDo entity = new ZhcxPmqManagementSourceDo();
|
|
|
+ entity.setId(SecurityUtil.getUUID());
|
|
|
+ entity.setDeleted("0");
|
|
|
+ entity.setOrdertype(resultSet.getString(1));
|
|
|
+ entity.setOrderno(resultSet.getString(2));
|
|
|
+
|
|
|
+ String projectCode = resultSet.getString(3);
|
|
|
+ if (StringUtils.isNotBlank(projectCode) && projectCodes.contains(projectCode)) {
|
|
|
+ entity.setProjectno(projectCode);
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ entity.setProjectname(resultSet.getString(4));
|
|
|
+ entity.setThemepoint(resultSet.getString(5));
|
|
|
+ entity.setSeqno(resultSet.getInt(6));
|
|
|
+ entity.setCurrenttimes(resultSet.getInt(7));
|
|
|
+ entity.setTotaltimes(resultSet.getInt(8));
|
|
|
+ String dateStr = resultSet.getString(9);
|
|
|
+ if (StringUtils.isNotBlank(dateStr)) {
|
|
|
+ entity.setDistributetime(DateUtil.parse(dateStr,"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setDeptname(resultSet.getString(10));
|
|
|
+ entity.setQcname(resultSet.getString(11));
|
|
|
+ sourceDao.insert(entity);
|
|
|
+ list.add(entity);
|
|
|
+ }
|
|
|
+ } catch (Exception e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }catch(SQLException e2){
|
|
|
+ e2.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|