|
@@ -92,6 +92,7 @@ import java.net.URL;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -708,11 +709,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
public TransactionStatus beginTransaction(DataSourceTransactionManager transactionManager) {
|
|
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();//事务定义类
|
|
|
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
|
- TransactionStatus status = transactionManager.getTransaction(def);// 返回事务对象
|
|
|
- return status;
|
|
|
+ return transactionManager.getTransaction(def);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public R saveOrUpdateInfo(List<TableInfo> tableInfoList) {
|
|
|
|
|
@@ -1055,7 +1054,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
public R getBussPdfInfo(Long pkeyId) throws Exception {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
//String file_path = "/Users/hongchuangyanfa/Desktop/";
|
|
|
-
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
|
@@ -1386,7 +1384,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//获取试验记录id
|
|
|
List<String> recordIds = baseMapper.queryTrialRecordId(nodeId).stream().distinct().collect(Collectors.toList());
|
|
|
if (recordIds.size() > 0) {
|
|
|
- String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
+ String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where pdf_url is not null and id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
List<TrialSelfInspectionRecord> query = jdbcTemplate.query(recordInfoSql, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
|
|
|
if (query.size() > 0) {
|
|
|
//只获取已审批合格自检记录,追加试验pdf到质检后面
|
|
@@ -1425,6 +1423,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
Map<String, Object> reData = new HashMap<>();
|
|
|
WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .select(WbsTreePrivate::getInitTableName, WbsTreePrivate::getHtmlUrl, WbsTreePrivate::getPKeyId)
|
|
|
.eq(WbsTreePrivate::getPKeyId, pkeyId));
|
|
|
if (wbsTreePrivate == null) {
|
|
|
return list;
|
|
@@ -1435,12 +1434,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
//表单是否存储在
|
|
|
String tabName = wbsTreePrivate.getInitTableName();
|
|
|
- String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
+ String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
|
|
|
- if (tabList == null || tabList.size() <= 0) {
|
|
|
- throw new ServiceException("无实体表对应");
|
|
|
+ if (tabList.size() <= 0) {
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
+ //实体数据
|
|
|
String querySql = "select * from " + wbsTreePrivate.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + groupId;
|
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
|
@@ -1457,6 +1457,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
+
|
|
|
// 时间段处理
|
|
|
if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
|
|
@@ -1513,8 +1514,161 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 获取默认值
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.select("col_key", "sig_role_name");
|
|
|
+ queryWrapper.eq("type", 4);
|
|
|
+ queryWrapper.eq("tab_id", wbsTreePrivate.getPKeyId());
|
|
|
+ final List<TextdictInfo> textDictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (!textDictInfos.isEmpty()) {
|
|
|
+ for (TextdictInfo textdictInfo : textDictInfos) {
|
|
|
+ if (reData.containsKey(textdictInfo.getColKey())) {
|
|
|
+ String keyVal = reData.get(textdictInfo.getColKey()) + "";
|
|
|
+ } else {
|
|
|
+ reData.put(textdictInfo.getColKey() + "", textdictInfo.getSigRoleName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 移除Id 和 p_key_id
|
|
|
+ reData.remove("id");
|
|
|
+ reData.remove("p_key_id");
|
|
|
+ reData.remove("classify");
|
|
|
+ reData.remove("contractId");
|
|
|
+ reData.remove("pkeyId");
|
|
|
+ reData.remove("projectId");
|
|
|
+ list.add(reData);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 试验 获取填报信息 - 施工关联试验数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getBussDataInfoTrialRecordSG(Long groupId, Long pkeyId) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .select(WbsTreePrivate::getInitTableName, WbsTreePrivate::getHtmlUrl, WbsTreePrivate::getPKeyId, WbsTreePrivate::getInitTableId)
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, pkeyId));
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ if (wbsTreePrivate.getHtmlUrl() == null) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //表单是否存储在
|
|
|
+ String tabName = wbsTreePrivate.getInitTableName();
|
|
|
+ String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
+ List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
|
|
|
+ if (tabList.size() <= 0) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //实体数据
|
|
|
+ String querySql = "select * from " + wbsTreePrivate.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + groupId;
|
|
|
+ List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+
|
|
|
+ //对应实体表的对应Key字段的KeyName字段名
|
|
|
+ Map<String, WbsFormElement> elementMap = null;
|
|
|
+ if (StringUtils.isNotEmpty(wbsTreePrivate.getInitTableId())) {
|
|
|
+ String eleSql = "select e_key,e_name from m_wbs_form_element where f_id = " + wbsTreePrivate.getInitTableId();
|
|
|
+ elementMap = jdbcTemplate.query(eleSql, new BeanPropertyRowMapper<>(WbsFormElement.class)).stream().collect(Collectors.toMap(WbsFormElement::getEKey, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 匹配关联
|
|
|
+ try {
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dataIn.size() >= 1) {
|
|
|
+ Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ for (String key : mysqlData.keySet()) {
|
|
|
+ String tabVal = mysqlData.get(key) + "";
|
|
|
+
|
|
|
+ //映射KeyName名称
|
|
|
+ if (elementMap != null && elementMap.size() > 0) {
|
|
|
+ WbsFormElement wbsFormElement = elementMap.get(key);
|
|
|
+ if (wbsFormElement != null) {
|
|
|
+
|
|
|
+ key = wbsFormElement.getEName();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
+
|
|
|
+ //处理相同字段名称问题,同一个KeyName,那么拼接value
|
|
|
+ Object oldValue = reData.get(key);
|
|
|
+ if (oldValue != null) {
|
|
|
+ reData.put(key, oldValue + "、" + tabVal);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间段处理
|
|
|
+ if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+
|
|
|
+ if (reData.containsKey("pickerKey")) {
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," + key;
|
|
|
+ reData.put("pickerKey", pickerKey);
|
|
|
+ } else {
|
|
|
+ reData.put("pickerKey", key);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = tabData[0];
|
|
|
+ sql = sql.replaceAll("\\[", "['");
|
|
|
+ sql = sql.replaceAll("]", "']");
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z',");
|
|
|
+ sql = sql.replaceAll(", 20", ", '20");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ reData.put(key, sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间和字符串合作
|
|
|
+ } else if (tabVal.contains("T") && tabVal.contains(".000Z")) { //时间
|
|
|
+ if (tabVal.contains("☆")) {
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
+ for (String data : mysql) {
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ reData.put(key, tabData[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ reData.put(key, tabData[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (tabVal.contains("☆")) {
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
+ for (String data : mysql) {
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ reData.put(key, tabData[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (tabVal.contains("_^_")) {
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
+ reData.put(key, tabData[0]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reData.put(key, tabVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取默认值
|
|
|
QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.select("col_key", "sig_role_name");
|
|
|
queryWrapper.eq("type", 4);
|
|
|
queryWrapper.eq("tab_id", wbsTreePrivate.getPKeyId());
|
|
|
final List<TextdictInfo> textDictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
@@ -1536,9 +1690,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
reData.remove("pkeyId");
|
|
|
reData.remove("projectId");
|
|
|
list.add(reData);
|
|
|
+
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 试验 单pdf
|
|
|
*/
|
|
@@ -1620,7 +1776,35 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
x1 = 1;
|
|
|
}
|
|
|
String myData = DataInfo.get(val) + "";
|
|
|
- if (myData.contains("T") && myData.contains("-")) {
|
|
|
+
|
|
|
+ if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+ if (myData.contains(",") && myData.contains("]")) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+
|
|
|
+ Date Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
+ Date end_dataStr = sdf.parse(dataVal[1]);
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+
|
|
|
if (myData.contains(",") && myData.contains("]")) {
|
|
|
myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
String[] dataVal = myData.split(",");
|
|
@@ -1628,6 +1812,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1).trim();
|
|
|
|
|
|
String[] end_dataStr = dataVal[1].split("T")[0].split("-");
|
|
|
+
|
|
|
String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1).trim();
|
|
|
if (StartDate.equals(endDate)) {
|
|
|
myData = StartDate;
|
|
@@ -1638,7 +1823,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String[] dataStr = myData.split("T")[0].split("-");
|
|
|
myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
if (myData.contains("https") && myData.contains("aliyuncs")) {
|
|
|
BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
|
|
@@ -1846,22 +2032,23 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
public void saveOrUpdateInfoTrial(List<TableInfo> tableInfoList, Long groupId) {
|
|
|
//试验填报
|
|
|
if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
|
- try {
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
- WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
- .eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
|
|
|
- if (wbsTreePrivate == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
|
|
|
- String tabName = wbsTreePrivate.getInitTableName();
|
|
|
- //判读修改还是添加
|
|
|
- String delSql = "delete from " + tabName + " where p_key_id='" + tableInfo.getPkeyId() + "' and group_id = '" + groupId + "'";
|
|
|
- jdbcTemplate.execute(delSql);
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .select(WbsTreePrivate::getInitTableName)
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
|
|
|
+ if (wbsTreePrivate == null || StringUtils.isEmpty(wbsTreePrivate.getInitTableName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //删除SQL
|
|
|
+ String delSql = "delete from " + wbsTreePrivate.getInitTableName() + " where p_key_id='" + tableInfo.getPkeyId() + "' and group_id = '" + groupId + "'";
|
|
|
|
|
|
+ //新增SQL
|
|
|
String sqlInfo = "";
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- sqlInfo = "INSERT INTO " + tabName + " ( ";
|
|
|
+ sqlInfo = "INSERT INTO " + wbsTreePrivate.getInitTableName() + " ( ";
|
|
|
String keyStr = "id,group_id,";
|
|
|
String valStr = SnowFlakeUtil.getId() + "," + groupId + ",";
|
|
|
for (String keys : dataMap2.keySet()) {
|
|
@@ -1872,10 +2059,23 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
+ try {
|
|
|
+ //删除
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
+ //新增
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
+ //提交事务
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
+ } catch (Exception e) {
|
|
|
+ //回滚
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+
|
|
|
+ throw new ServiceException("字段过长,新增失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|