|
@@ -1990,6 +1990,20 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Boolean isWorkNode(Long pKeyId){
|
|
|
|
+ String sql="SELECT * from m_wbs_tree_contract WHERE id=(SELECT parent_id from m_wbs_tree_contract WHERE is_deleted=0 and p_key_id="+pKeyId+")";
|
|
|
|
+ WbsTreeContract wbsTreeContract= jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeType())){
|
|
|
|
+ if (wbsTreeContract.getNodeType().equals(6)) {
|
|
|
|
+ if(ObjectUtil.isNotEmpty(wbsTreeContract.getMajorDataType())){
|
|
|
|
+ if(wbsTreeContract.getMajorDataType().equals(4)){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -2005,7 +2019,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
if(list.size()>0){
|
|
if(list.size()>0){
|
|
for (WbsTreeContract wbsTreeContract1 : list) {
|
|
for (WbsTreeContract wbsTreeContract1 : list) {
|
|
if(wbsTreeContract1.getNodeName().indexOf("JS107")>=0){
|
|
if(wbsTreeContract1.getNodeName().indexOf("JS107")>=0){
|
|
- target.add(wbsTreeContract1);
|
|
|
|
|
|
+ target.add(wbsTreeContract1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2020,19 +2034,22 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
for (WbsTreeContract treeContract : list2) {
|
|
for (WbsTreeContract treeContract : list2) {
|
|
if(treeContract.getNodeName().indexOf("JS107")>=0){
|
|
if(treeContract.getNodeName().indexOf("JS107")>=0){
|
|
if(!Objects.equals(treeContract.getParentId(), wbsTreeContract2.getId())){
|
|
if(!Objects.equals(treeContract.getParentId(), wbsTreeContract2.getId())){
|
|
|
|
+ if(isWorkNode(treeContract.getPKeyId())){
|
|
source.add(treeContract);
|
|
source.add(treeContract);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<WbsTreeContract>updateList=new ArrayList<>();
|
|
List<WbsTreeContract>updateList=new ArrayList<>();
|
|
-
|
|
|
|
for (WbsTreeContract wbsTreeContract : source) {
|
|
for (WbsTreeContract wbsTreeContract : source) {
|
|
Map<String,Object>maps=new HashMap<>();
|
|
Map<String,Object>maps=new HashMap<>();
|
|
for (WbsTreeContract treeContract : target) {
|
|
for (WbsTreeContract treeContract : target) {
|
|
//名称相同就复制
|
|
//名称相同就复制
|
|
if(wbsTreeContract.getNodeName().equals(treeContract.getNodeName())){
|
|
if(wbsTreeContract.getNodeName().equals(treeContract.getNodeName())){
|
|
|
|
+ //查出元素
|
|
List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
|
|
List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
|
|
|
|
+ //不为空的元素
|
|
if(mapsList.size()>0){
|
|
if(mapsList.size()>0){
|
|
for (Map<String, Object> stringObjectMap : mapsList) {
|
|
for (Map<String, Object> stringObjectMap : mapsList) {
|
|
for (String s : stringObjectMap.keySet()) {
|
|
for (String s : stringObjectMap.keySet()) {
|
|
@@ -2041,12 +2058,54 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ try{
|
|
|
|
+ //没保存的新增,保存了就更新
|
|
|
|
+ String sql1= "SELECT id FROM `" + treeContract.getInitTableName() + "` WHERE p_key_id = "+treeContract.getPKeyId();
|
|
|
|
+ Long id= jdbcTemplate.queryForObject(sql1,Long.class);
|
|
|
|
+ //更新
|
|
|
|
+ updateRecord(id,maps,treeContract.getInitTableName());
|
|
|
|
+ }catch (EmptyResultDataAccessException e){
|
|
|
|
+ //新增
|
|
|
|
+ String tabName = wbsTreeContract.getInitTableName();
|
|
|
|
+ // 字段查询 并去掉公式字段
|
|
|
|
+ String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='" + tabName + "' and COLUMN_NAME not in('id','p_key_id')";
|
|
|
|
+ Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
|
|
|
|
+ colkeys = stringObjectMap.get("colkeys") + "";
|
|
|
|
+ String querySql = "insert into " + tabName + " (id,p_key_id," + colkeys + ") select '" + treeContract.getPKeyId() + "','" + treeContract.getPKeyId() + "'," + colkeys + " from " + tabName + " where p_key_id=" + wbsTreeContract.getPKeyId();
|
|
|
|
+ jdbcTemplate.execute(querySql);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ updateList.add(wbsTreeContract);
|
|
|
|
+ b=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ source.removeAll(updateList);
|
|
|
|
+ for (WbsTreeContract wbsTreeContract : source) {
|
|
|
|
+ //新增
|
|
|
|
+ long tabGroupId = SnowFlakeUtil.getId();
|
|
|
|
+ long newPkId = SnowFlakeUtil.getId();
|
|
|
|
+ WbsTreeContract wbsTreeContract1 = new WbsTreeContract();
|
|
|
|
+ BeanUtil.copy(wbsTreeContract, wbsTreeContract1);
|
|
|
|
+ wbsTreeContract1.setParentId(wbsTreeContract2.getId());
|
|
|
|
+ wbsTreeContract1.setPKeyId(newPkId);
|
|
|
|
+ wbsTreeContract1.setTabGroupId(tabGroupId);
|
|
|
|
+ wbsTreeContract1.setIsCopeTab(2);
|
|
|
|
+ wbsTreeContract1.setIsTabPdf(1); // pdf 不能预览
|
|
|
|
+ wbsTreeContract1.setIsBussShow(1); // 是否隐藏表
|
|
|
|
+ wbsTreeContract1.setTabFileType(1);//没有上传附件
|
|
|
|
+ wbsTreeContract1.setPdfUrl("");
|
|
|
|
+ String tabName = wbsTreeContract1.getInitTableName();
|
|
|
|
+ // 字段查询 并去掉公式字段
|
|
|
|
+ String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='" + tabName + "' and COLUMN_NAME not in('id','p_key_id')";
|
|
|
|
+ Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
|
|
|
|
+ colkeys = stringObjectMap.get("colkeys") + "";
|
|
|
|
+ // 复制表数据
|
|
|
|
+ String querySql = "insert into " + tabName + " (id,p_key_id," + colkeys + ") select '" + newPkId + "','" + newPkId + "'," + colkeys + " from " + tabName + " where p_key_id=" + wbsTreeContract.getPKeyId();
|
|
|
|
+ jdbcTemplate.execute(querySql);
|
|
|
|
+ wbsTreeContractService.save(wbsTreeContract1);
|
|
|
|
+ b=true;
|
|
|
|
+ }
|
|
if(!b){
|
|
if(!b){
|
|
return R.data("请检查工序节点中是否包含JS107表");
|
|
return R.data("请检查工序节点中是否包含JS107表");
|
|
}else {
|
|
}else {
|
|
@@ -2054,6 +2113,28 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void updateRecord(Long id, Map<String, Object> fieldValues,String tableName) {
|
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder("UPDATE "+tableName+" SET ");
|
|
|
|
+ StringBuilder paramsBuilder = new StringBuilder();
|
|
|
|
+ Object[] params = new Object[fieldValues.size() + 1];
|
|
|
|
+ int paramIndex = 0;
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, Object> entry : fieldValues.entrySet()) {
|
|
|
|
+ if (paramIndex > 0) {
|
|
|
|
+ paramsBuilder.append(", ");
|
|
|
|
+ }
|
|
|
|
+ paramsBuilder.append(entry.getKey()).append(" = ?");
|
|
|
|
+ params[paramIndex++] = entry.getValue();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sqlBuilder.append(paramsBuilder.toString());
|
|
|
|
+ sqlBuilder.append(" WHERE id = ?");
|
|
|
|
+ params[paramIndex] = id;
|
|
|
|
+
|
|
|
|
+ String sql = sqlBuilder.toString();
|
|
|
|
+ jdbcTemplate.update(sql, params);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void formulaInto(List<FormData> curFormDatas, String projectId, String nodeId, ExecuteType executeType) {
|
|
public void formulaInto(List<FormData> curFormDatas, String projectId, String nodeId, ExecuteType executeType) {
|
|
if(executeType.equals(ExecuteType.INSPECTION)){
|
|
if(executeType.equals(ExecuteType.INSPECTION)){
|