|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.jfireel.expression.Expression;
|
|
|
import com.mixsmart.utils.*;
|
|
|
+import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.jsoup.Jsoup;
|
|
@@ -1994,55 +1995,58 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R<Object> syncWorkDate(Long nodeId) {
|
|
|
Boolean b=false;
|
|
|
- //先查找当前节点的表格,有JS107就删除
|
|
|
+ //先查找当前节点的表格,有JS107筛选出所有JS107的表
|
|
|
String nodeSql="SELECT * from m_wbs_tree_contract WHERE is_deleted=0 and p_key_id="+nodeId;
|
|
|
WbsTreeContract wbsTreeContract2 = jdbcTemplate.queryForObject(nodeSql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
String sql="SELECT * from m_wbs_tree_contract WHERE is_deleted=0 and parent_id="+wbsTreeContract2.getId()+" AND contract_id="+wbsTreeContract2.getContractId()+" AND project_id="+wbsTreeContract2.getProjectId();
|
|
|
List<WbsTreeContract> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ //所有需要同步的JS107表
|
|
|
+ List<WbsTreeContract>target=new ArrayList<>();
|
|
|
if(list.size()>0){
|
|
|
for (WbsTreeContract wbsTreeContract1 : list) {
|
|
|
if(wbsTreeContract1.getNodeName().indexOf("JS107")>=0){
|
|
|
- //逻辑删除
|
|
|
- String delete="Update m_wbs_tree_contract SET is_deleted=1 where p_key_id="+wbsTreeContract1.getPKeyId();
|
|
|
- jdbcTemplate.update(delete);
|
|
|
+ target.add(wbsTreeContract1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //所有被需要同步的JS107
|
|
|
+ List<WbsTreeContract>source=new ArrayList<>();
|
|
|
//查找父节点下所有的表单,如果有JS107及复制表,就复制到当前节点下
|
|
|
String fatherNodeSql="SELECT * FROM m_wbs_tree_contract WHERE id="+wbsTreeContract2.getParentId()+" AND is_deleted=0"+" AND contract_id="+wbsTreeContract2.getContractId()+" AND project_id="+wbsTreeContract2.getProjectId();
|
|
|
WbsTreeContract fatherNode = jdbcTemplate.queryForObject(fatherNodeSql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- List <WbsTreeContract>list1=new ArrayList<>();
|
|
|
- getAllChildNodes(fatherNode, list1);
|
|
|
- if(list1.size()>0){
|
|
|
- for (WbsTreeContract treeContract : list1) {
|
|
|
+ List <WbsTreeContract>list2=new ArrayList<>();
|
|
|
+ getAllChildNodes(fatherNode, list2);
|
|
|
+ if(list2.size()>0){
|
|
|
+ for (WbsTreeContract treeContract : list2) {
|
|
|
if(treeContract.getNodeName().indexOf("JS107")>=0){
|
|
|
- long tabGroupId = SnowFlakeUtil.getId();
|
|
|
- long newPkId = SnowFlakeUtil.getId();
|
|
|
- WbsTreeContract wbsTreeContract = new WbsTreeContract();
|
|
|
- BeanUtil.copy(treeContract, wbsTreeContract);
|
|
|
- wbsTreeContract.setNodeName(treeContract.getNodeName());
|
|
|
- wbsTreeContract.setPKeyId(newPkId);
|
|
|
- wbsTreeContract.setCreateTime(new Date());
|
|
|
- wbsTreeContract.setTabGroupId(tabGroupId);
|
|
|
- wbsTreeContract.setParentId(wbsTreeContract2.getId());
|
|
|
- wbsTreeContract.setIsCopeTab(2);
|
|
|
- wbsTreeContract.setIsTabPdf(1); // pdf 不能预览
|
|
|
- wbsTreeContract.setIsBussShow(1); // 是否隐藏表
|
|
|
- wbsTreeContract.setTabFileType(1);//没有上传附件
|
|
|
- wbsTreeContract.setPdfUrl("");
|
|
|
- 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 '" + newPkId + "','" + newPkId + "'," + colkeys + " from " + tabName + " where p_key_id=" + treeContract.getPKeyId();
|
|
|
- jdbcTemplate.execute(querySql);
|
|
|
- wbsTreeContractService.save(wbsTreeContract);
|
|
|
- b=true;
|
|
|
+ if(!Objects.equals(treeContract.getParentId(), wbsTreeContract2.getId())){
|
|
|
+ source.add(treeContract);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ List<WbsTreeContract>updateList=new ArrayList<>();
|
|
|
+
|
|
|
+ for (WbsTreeContract wbsTreeContract : source) {
|
|
|
+ Map<String,Object>maps=new HashMap<>();
|
|
|
+ for (WbsTreeContract treeContract : target) {
|
|
|
+ //名称相同就复制
|
|
|
+ if(wbsTreeContract.getNodeName().equals(treeContract.getNodeName())){
|
|
|
+ List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
|
|
|
+ if(mapsList.size()>0){
|
|
|
+ for (Map<String, Object> stringObjectMap : mapsList) {
|
|
|
+ for (String s : stringObjectMap.keySet()) {
|
|
|
+ if(ObjectUtil.isNotEmpty(stringObjectMap.get(s))&&!s.equals("id")&&!s.equals("p_key_id")){
|
|
|
+ maps.put(s,stringObjectMap.get(s));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(!b){
|
|
|
return R.data("请检查工序节点中是否包含JS107表");
|
|
|
}else {
|