|
@@ -9,6 +9,7 @@ import com.mixsmart.utils.StringUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
@@ -70,96 +71,97 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean copyBussTab(Long pKeyId, Long id) {
|
|
|
- WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getPKeyId, pKeyId));
|
|
|
- List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getId, wbsTreePrivate.getId()).eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId()).eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType()).eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreePrivate::getParentId, wbsTreePrivate.getParentId()));
|
|
|
- List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateList.stream().sorted(Comparator.comparing(WbsTreePrivate::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
- long newPkId = SnowFlakeUtil.getId();
|
|
|
- wbsTreePrivate.setPKeyId(newPkId);
|
|
|
- wbsTreePrivate.setCreateTime(new Date());
|
|
|
- String nodeName = wbsTreePrivates.get(0).getNodeName();
|
|
|
- if (nodeName.contains("__")) {
|
|
|
- String[] oldName = nodeName.split("__");
|
|
|
- nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
|
|
|
- } else {
|
|
|
- nodeName = nodeName + "__" + 1;
|
|
|
- }
|
|
|
- wbsTreePrivate.setNodeName(nodeName);
|
|
|
- String tabName = wbsTreePrivate.getInitTableName();
|
|
|
-
|
|
|
- //字段查询 并去掉公式字段
|
|
|
- /*String colkeys = "SELECT GROUP_CONCAT(e_key) as colkeys from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '" + tabName + "' and a.id=b.f_id and b.id not in(SELECT element_id from m_formula c where c.is_deleted=0) ";
|
|
|
- Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
|
|
|
- colkeys = stringObjectMap.get("colkeys") + "";*/
|
|
|
-
|
|
|
- //查询字段
|
|
|
- String sql = "select COLUMN_NAME from information_schema.`COLUMNS` WHERE table_name = '" + tabName + "'";
|
|
|
- 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);
|
|
|
+ public boolean copyBussTab(Long pKeyId, Long id, Long contractId) {
|
|
|
+ if (ObjectUtils.isNotEmpty(id)) {
|
|
|
+ //编辑复制 复制数据 附件文件
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getPKeyId, pKeyId));
|
|
|
+ List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getId, wbsTreePrivate.getId()).eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId()).eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType()).eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreePrivate::getParentId, wbsTreePrivate.getParentId()));
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateList.stream().sorted(Comparator.comparing(WbsTreePrivate::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
+ long newPkId = SnowFlakeUtil.getId();
|
|
|
+ wbsTreePrivate.setPKeyId(newPkId);
|
|
|
+ wbsTreePrivate.setCreateTime(new Date());
|
|
|
+ String nodeName = wbsTreePrivates.get(0).getNodeName();
|
|
|
+ if (nodeName.contains("__")) {
|
|
|
+ String[] oldName = nodeName.split("__");
|
|
|
+ nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
|
|
|
+ } else {
|
|
|
+ nodeName = nodeName + "__" + 1;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //复制表数据
|
|
|
- String querySql = "select " + org.apache.commons.lang3.StringUtils.join(filed, ",") + " from " + tabName + " where p_key_id=" + pKeyId + " and group_id = " + id;
|
|
|
- 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 " + tabName + " ( ";
|
|
|
-
|
|
|
- StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
|
|
|
- StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + wbsTreePrivate.getPKeyId() + "," + id + ",");
|
|
|
-
|
|
|
- for (String keys : dataMap2.keySet()) {
|
|
|
- if (!(dataMap2.get(keys) + "").equals("null")) {
|
|
|
- keyStr.append(keys).append(",");
|
|
|
- valStr.append("'").append(dataMap2.get(keys)).append("',");
|
|
|
+ wbsTreePrivate.setNodeName(nodeName);
|
|
|
+ wbsTreePrivate.setTrialTabContractId(contractId); //试验表绑定当前合同段
|
|
|
+
|
|
|
+ String tabName = wbsTreePrivate.getInitTableName();
|
|
|
+
|
|
|
+ //查询字段
|
|
|
+ String sql = "select COLUMN_NAME from information_schema.`COLUMNS` WHERE table_name = '" + tabName + "'";
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
- keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
|
|
|
- valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
|
|
|
|
|
|
- sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
+ //复制表数据
|
|
|
+ String querySql = "select " + org.apache.commons.lang3.StringUtils.join(filed, ",") + " from " + tabName + " where p_key_id=" + pKeyId + " and group_id = " + id;
|
|
|
+ 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 " + tabName + " ( ";
|
|
|
+ StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
|
|
|
+ StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + wbsTreePrivate.getPKeyId() + "," + id + ",");
|
|
|
+ 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);
|
|
|
- }
|
|
|
+ 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 = " + id, 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(newPkId + ""); //新表pKeyId
|
|
|
- obj.setTrialRecordId(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 = " + id, 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(newPkId + ""); //新表pKeyId
|
|
|
+ obj.setTrialRecordId(id);
|
|
|
+ newFiles.add(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean result = tableFileClient.saveBatch(newFiles);
|
|
|
+ if (result) {
|
|
|
+ wbsTreePrivateService.save(wbsTreePrivate);
|
|
|
+ return true;
|
|
|
}
|
|
|
- }
|
|
|
- boolean result = tableFileClient.saveBatch(newFiles);
|
|
|
- if (result) {
|
|
|
- wbsTreePrivateService.save(wbsTreePrivate);
|
|
|
- return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean removeBussTabInfoById(Long pKeyId) {
|
|
|
- String sql = "delete from m_wbs_tree_private where p_key_id = '" + pKeyId + "'";
|
|
|
- jdbcTemplate.execute(sql);
|
|
|
- return true;
|
|
|
+ //查询当前表是否已经填报
|
|
|
+ List<TrialSelfDataRecord> query = jdbcTemplate.query("select id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
|
|
|
+ if (query.size() > 0) {
|
|
|
+ throw new ServiceException("当前表在试验记录中有填报数据,删除失败");
|
|
|
+ } else {
|
|
|
+ jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -211,7 +213,12 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getTrialDataInfo(String pKeyId, Long id) {
|
|
|
- return excelTabServiceImpl.getBussDataInfoTrial(id, Long.parseLong(pKeyId));
|
|
|
+ return excelTabServiceImpl.getBussDataInfoTrial(id, Long.parseLong(pKeyId), null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveObj(WbsTreePrivate wbsTreePrivate) {
|
|
|
+ wbsTreePrivateService.save(wbsTreePrivate);
|
|
|
}
|
|
|
|
|
|
private void foreachSetChildList(List<WbsTreeContractTreeVOS> vosResult, List<WbsTreePrivateVO> voList) {
|