|
@@ -239,7 +239,9 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
List<String> mobilizationIds = new ArrayList<>();
|
|
|
for (String sampleId : sampleIds) {
|
|
|
String mobilizationId = baseMapper.selectMobilizationRecord(sampleId);
|
|
|
- mobilizationIds.add(mobilizationId);
|
|
|
+ if (StringUtils.isNotEmpty(mobilizationId)){
|
|
|
+ mobilizationIds.add(mobilizationId);
|
|
|
+ }
|
|
|
}
|
|
|
if (mobilizationIds.size() > 0) {
|
|
|
List<TrialMaterialMobilization> trialMaterialMobilizations = trialMaterialMobilizationMapper.selectBatchIds(mobilizationIds);
|
|
@@ -319,7 +321,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
}
|
|
|
|
|
|
//重构编号
|
|
|
- this.buildNumber(dto);
|
|
|
+ //this.buildNumber(dto);
|
|
|
this.reNumberNo(trialSelfInspectionRecord, dto);
|
|
|
|
|
|
dto.setCreateTime(new Date());
|
|
@@ -334,59 +336,60 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
List<String> pKeyIds = Func.toStrList(tableIds);
|
|
|
for (String pKeyId : pKeyIds) {
|
|
|
WbsTreePrivate tab = wbsTreePrivateClient.getNodeByPrimaryKeyId(pKeyId);
|
|
|
- //复制数据
|
|
|
- List<Map<String, Object>> oneTabData = wbsTreePrivateClient.getTrialDataInfo(pKeyId, trialSelfInspectionRecord.getId());
|
|
|
- if (oneTabData.size() >= 1) {
|
|
|
- Map<String, Object> dataMap2 = oneTabData.get(0);
|
|
|
-
|
|
|
- dataMap2.remove("id");
|
|
|
- dataMap2.remove("p_key_id");
|
|
|
- dataMap2.remove("group_id");
|
|
|
-
|
|
|
- //sql组装
|
|
|
- String sqlInfo = "";
|
|
|
- sqlInfo = "INSERT INTO " + tab.getInitTableName() + " (";
|
|
|
- StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
|
|
|
- StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + pKeyId + "," + dto.getId() + ",");
|
|
|
- for (String keys : dataMap2.keySet()) {
|
|
|
- if (!(dataMap2.get(keys) + "").equals("null")) {
|
|
|
- String keysResult = keys.split("__")[0];
|
|
|
- String keysResult2 = keys.split("__")[1];
|
|
|
- keyStr.append(keysResult).append(",");
|
|
|
- Object value = dataMap2.get(keys);
|
|
|
-
|
|
|
- //替换报告单号、记录编号
|
|
|
- if (String.valueOf(value).contains("JL-")) {
|
|
|
- value = StringUtils.isNotEmpty(dto.getRecordNo()) ? dto.getRecordNo() : null;
|
|
|
- }
|
|
|
- if (String.valueOf(value).contains("BG-")) {
|
|
|
- value = StringUtils.isNotEmpty(dto.getReportNo()) ? dto.getReportNo() : null;
|
|
|
- }
|
|
|
+ if (tab != null) {
|
|
|
+ //查询字段
|
|
|
+ String sql = "select COLUMN_NAME from information_schema.`COLUMNS` WHERE table_name = '" + tab.getInitTableName() + "'";
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
+ List<Object> filed = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : maps) {
|
|
|
+ Object column_name = map.get("COLUMN_NAME");
|
|
|
+ if (!(("id").equals(column_name) || ("group_id").equals(column_name) || ("p_key_id").equals(column_name))) {
|
|
|
+ filed.add(column_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- String values = value + "_^_" + keysResult2;
|
|
|
- valStr.append("'").append(values).append("',");
|
|
|
+ //复制表数据
|
|
|
+ String querySql = "select " + org.apache.commons.lang.StringUtils.join(filed, ",") + " from " + tab.getInitTableName() + " where p_key_id=" + pKeyId + " and group_id = " + trialSelfInspectionRecord.getId();
|
|
|
+ List<Map<String, Object>> dataList = jdbcTemplate.queryForList(querySql);
|
|
|
+ if (dataList.size() >= 1) {
|
|
|
+ Map<String, Object> dataMap2 = dataList.get(0);
|
|
|
+
|
|
|
+ dataMap2.remove("id");
|
|
|
+ dataMap2.remove("p_key_id");
|
|
|
+ dataMap2.remove("group_id");
|
|
|
+
|
|
|
+ //sql组装
|
|
|
+ String sqlInfo = "";
|
|
|
+ sqlInfo = "INSERT INTO " + tab.getInitTableName() + " ( ";
|
|
|
+ StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
|
|
|
+ StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + pKeyId + "," + dto.getId() + ",");
|
|
|
+ for (String keys : dataMap2.keySet()) {
|
|
|
+ if (!(dataMap2.get(keys) + "").equals("null")) {
|
|
|
+ keyStr.append(keys).append(",");
|
|
|
+ valStr.append("'").append(dataMap2.get(keys)).append("',");
|
|
|
+ }
|
|
|
}
|
|
|
+ keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
|
|
|
+ valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
|
|
|
+ sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
+
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
}
|
|
|
- keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
|
|
|
- valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
|
|
|
- sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
- //新增
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
- }
|
|
|
|
|
|
- //复制附件文件
|
|
|
- List<TableFile> oldFiles = jdbcTemplate.query("select domain_url,name,extension,type,is_deleted,domain_pdf_url,status from m_table_file where is_deleted = 0 and tab_id = '" + pKeyId + "' and trial_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TableFile.class));
|
|
|
- List<TableFile> newFiles = new ArrayList<>();
|
|
|
- for (TableFile oldFile : oldFiles) {
|
|
|
- TableFile obj = BeanUtil.copyProperties(oldFile, TableFile.class);
|
|
|
- if (obj != null) {
|
|
|
- obj.setId(SnowFlakeUtil.getId());
|
|
|
- obj.setTabId(pKeyId + ""); //表pKeyId
|
|
|
- obj.setTrialRecordId(dto.getId()); //当前记录id
|
|
|
- newFiles.add(obj);
|
|
|
+ //复制附件文件
|
|
|
+ List<TableFile> oldFiles = jdbcTemplate.query("select domain_url,name,extension,type,is_deleted,domain_pdf_url,status from m_table_file where is_deleted = 0 and tab_id = '" + pKeyId + "' and trial_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TableFile.class));
|
|
|
+ List<TableFile> newFiles = new ArrayList<>();
|
|
|
+ for (TableFile oldFile : oldFiles) {
|
|
|
+ TableFile obj = BeanUtil.copyProperties(oldFile, TableFile.class);
|
|
|
+ if (obj != null) {
|
|
|
+ obj.setId(SnowFlakeUtil.getId());
|
|
|
+ obj.setTabId(pKeyId + ""); //表pKeyId
|
|
|
+ obj.setTrialRecordId(dto.getId()); //当前记录id
|
|
|
+ newFiles.add(obj);
|
|
|
+ }
|
|
|
}
|
|
|
+ tableFileClient.saveBatch(newFiles);
|
|
|
}
|
|
|
- tableFileClient.saveBatch(newFiles);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -530,7 +533,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
@Override
|
|
|
public String selfPrintPdf(String ids) throws FileNotFoundException {
|
|
|
List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
- List<String> listPdfUrl = recordList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
+ List<String> listPdfUrl = recordList.stream().map(TrialSelfInspectionRecord::getPdfUrl).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
if (listPdfUrl.size() > 0) {
|
|
|
//合并PDF
|
|
|
Long id = SnowFlakeUtil.getId();
|
|
@@ -553,7 +556,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
public String selfPrintNullPdf(String ids) throws Exception {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
- List<String> tabIdsAll = recordList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTableIds())).map(TrialSelfInspectionRecord::getTableIds).collect(Collectors.toList());
|
|
|
+ List<String> tabIdsAll = recordList.stream().map(TrialSelfInspectionRecord::getTableIds).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
List<String> tabIds = new ArrayList<>();
|
|
|
for (String tabId : tabIdsAll) {
|
|
|
List<String> strings = Func.toStrList(tabId);
|
|
@@ -787,7 +790,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
throw new ServiceException("操作失败!");
|
|
|
}
|
|
|
|
|
|
- // 获取excel流 和 html流
|
|
|
+ //获取excel流和html流
|
|
|
Workbook wb = new Workbook();
|
|
|
wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
//获取工作表
|