|
@@ -894,26 +894,26 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
@Override
|
|
|
public R<String> syncPrivateProjectFormula(Long projectId, Long pKeyId) {
|
|
|
- if(projectId!=null&&pKeyId!=null){
|
|
|
+ if (projectId != null && pKeyId != null) {
|
|
|
ProjectInfo projectInfo = projectInfoMapper.selectById(projectId);
|
|
|
- ProjectInfo sourceProject=jdbcTemplate.queryForObject("select a.* from m_project_info a join m_wbs_tree_private b on a.id=b.project_id where b.p_key_id="+projectInfo.getReferenceWbsTemplateId()+" limit 1",new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
+ ProjectInfo sourceProject = jdbcTemplate.queryForObject("select a.* from m_project_info a join m_wbs_tree_private b on a.id=b.project_id where b.p_key_id=" + projectInfo.getReferenceWbsTemplateId() + " limit 1", new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
/*只需要同步私有引用就可以了*/
|
|
|
- if("private".equals(projectInfo.getReferenceWbsTemplateType())&&sourceProject!=null){
|
|
|
+ if ("private".equals(projectInfo.getReferenceWbsTemplateType()) && sourceProject != null) {
|
|
|
WbsTreePrivate selectNodeNow = baseMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId).eq(WbsTreePrivate::getStatus, 1));
|
|
|
if (selectNodeNow == null) {
|
|
|
throw new ServiceException("未获取到当前选择同步的节点信息,请联系管理员");
|
|
|
}
|
|
|
- List<ElementFormulaMapping> insertList=new ArrayList<>();
|
|
|
- List<Formula> insertFormulaList=new ArrayList<>();
|
|
|
- List<Formula> updateFormulaList=new ArrayList<>();
|
|
|
+ List<ElementFormulaMapping> insertList = new ArrayList<>();
|
|
|
+ List<Formula> insertFormulaList = new ArrayList<>();
|
|
|
+ List<Formula> updateFormulaList = new ArrayList<>();
|
|
|
/*同步公共部分*/
|
|
|
- global(sourceProject.getId(),projectInfo,insertList,insertFormulaList,updateFormulaList);
|
|
|
+ global(sourceProject.getId(), projectInfo, insertList, insertFormulaList, updateFormulaList);
|
|
|
/*同步节点部分,查找模版的叶子节点,查找目标叶子节点,id一样的是关联数据 */
|
|
|
- part(sourceProject.getId(),projectInfo,insertList,insertFormulaList,updateFormulaList);
|
|
|
+ part(sourceProject.getId(), projectInfo, insertList, insertFormulaList, updateFormulaList);
|
|
|
/*保存记录*/
|
|
|
- int n=saveAll(insertList,insertFormulaList,updateFormulaList);
|
|
|
- if(n>0){
|
|
|
- R.success("成功同步"+n+"条公式");
|
|
|
+ int n = saveAll(insertList, insertFormulaList, updateFormulaList);
|
|
|
+ if (n > 0) {
|
|
|
+ R.success("成功同步" + n + "条公式");
|
|
|
}
|
|
|
}
|
|
|
return R.success("引用公有模版无需同步");
|
|
@@ -921,73 +921,75 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
return R.fail("同步异常,请联系管理员");
|
|
|
}
|
|
|
|
|
|
- private int saveAll(List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
|
|
|
- int n=0;
|
|
|
- if(!insertList.isEmpty()) {
|
|
|
- this.elementFormulaMappingService.saveBatch(insertList,1000);
|
|
|
+ private int saveAll(List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
|
|
|
+ int n = 0;
|
|
|
+ if (!insertList.isEmpty()) {
|
|
|
+ this.elementFormulaMappingService.saveBatch(insertList, 1000);
|
|
|
}
|
|
|
- if(!insertFormulaList.isEmpty()) {
|
|
|
- this.formulaService.saveBatch(insertFormulaList,1000);
|
|
|
- n+=insertList.size();
|
|
|
+ if (!insertFormulaList.isEmpty()) {
|
|
|
+ this.formulaService.saveBatch(insertFormulaList, 1000);
|
|
|
+ n += insertList.size();
|
|
|
}
|
|
|
- if(!updateFormulaList.isEmpty()) {
|
|
|
- this.formulaService.updateBatchById(updateFormulaList,1000);
|
|
|
- n+=updateFormulaList.size();
|
|
|
+ if (!updateFormulaList.isEmpty()) {
|
|
|
+ this.formulaService.updateBatchById(updateFormulaList, 1000);
|
|
|
+ n += updateFormulaList.size();
|
|
|
}
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
- private void global(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
|
|
|
- this.check( srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList,FormulaBean.PRO_GLOBAL);
|
|
|
+ private void global(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
|
|
|
+ this.check(srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList, FormulaBean.PRO_GLOBAL);
|
|
|
}
|
|
|
- private void part(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
|
|
|
- this.check( srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList,FormulaBean.PRO_PART);
|
|
|
+
|
|
|
+ private void part(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
|
|
|
+ this.check(srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList, FormulaBean.PRO_PART);
|
|
|
}
|
|
|
- private void check(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList,int model){
|
|
|
- Map<String,ElementFormulaMapping> efmListScopeMap=new HashMap<>();
|
|
|
- Map<String,ElementFormulaMapping> sourceEfmListScopeMap=new HashMap<>();
|
|
|
- Map<Long,Formula> formulaScopeMap = new HashMap<>();
|
|
|
- Map<Long,Formula> sourceFormulaScopeMap = new HashMap<>();
|
|
|
- List<ElementFormulaMapping> efmListScope=this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId,distProject.getId()).eq(ElementFormulaMapping::getScope, model));
|
|
|
- if(!efmListScope.isEmpty()){
|
|
|
+
|
|
|
+ private void check(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList, int model) {
|
|
|
+ Map<String, ElementFormulaMapping> efmListScopeMap = new HashMap<>();
|
|
|
+ Map<String, ElementFormulaMapping> sourceEfmListScopeMap = new HashMap<>();
|
|
|
+ Map<Long, Formula> formulaScopeMap = new HashMap<>();
|
|
|
+ Map<Long, Formula> sourceFormulaScopeMap = new HashMap<>();
|
|
|
+ List<ElementFormulaMapping> efmListScope = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId, distProject.getId()).eq(ElementFormulaMapping::getScope, model));
|
|
|
+ if (!efmListScope.isEmpty()) {
|
|
|
formulaScopeMap = this.formulaService.listByIds(efmListScope.stream().map(ElementFormulaMapping::getFormulaId).collect(Collectors.toList())).stream().collect(Collectors.toMap(Formula::getId, f -> f));
|
|
|
}
|
|
|
- List<ElementFormulaMapping>sourceEfmListScope=this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId,srcProjectId).eq(ElementFormulaMapping::getScope, model));
|
|
|
- if(!sourceEfmListScope.isEmpty()){
|
|
|
+ List<ElementFormulaMapping> sourceEfmListScope = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId, srcProjectId).eq(ElementFormulaMapping::getScope, model));
|
|
|
+ if (!sourceEfmListScope.isEmpty()) {
|
|
|
sourceFormulaScopeMap = this.formulaService.listByIds(sourceEfmListScope.stream().map(ElementFormulaMapping::getFormulaId).collect(Collectors.toList())).stream().collect(Collectors.toMap(Formula::getId, f -> f));
|
|
|
}
|
|
|
- if(FormulaBean.PRO_PART.equals(model)) {
|
|
|
+ if (FormulaBean.PRO_PART.equals(model)) {
|
|
|
efmListScopeMap = efmListScope.stream().collect(Collectors.toMap(e -> e.getElementId() + "" + e.getNodeId(), t -> t));
|
|
|
sourceEfmListScopeMap = sourceEfmListScope.stream().collect(Collectors.toMap(e -> e.getElementId() + "" + e.getNodeId(), t -> t));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
efmListScopeMap = efmListScope.stream().collect(Collectors.toMap(e -> e.getElementId().toString(), t -> t));
|
|
|
sourceEfmListScopeMap = sourceEfmListScope.stream().collect(Collectors.toMap(e -> e.getElementId().toString(), t -> t));
|
|
|
}
|
|
|
- String[] exclude= new String[]{"id"};
|
|
|
+ String[] exclude = new String[]{"id"};
|
|
|
Map<String, ElementFormulaMapping> finalEfmListScopeMap = efmListScopeMap;
|
|
|
Map<Long, Formula> finalSourceFormulaScopeMap = sourceFormulaScopeMap;
|
|
|
Map<Long, Formula> finalFormulaScopeMap = formulaScopeMap;
|
|
|
- sourceEfmListScopeMap.forEach((k, v)->{
|
|
|
- if(!finalEfmListScopeMap.containsKey(k)){
|
|
|
+ sourceEfmListScopeMap.forEach((k, v) -> {
|
|
|
+ if (!finalEfmListScopeMap.containsKey(k)) {
|
|
|
/*不存在*/
|
|
|
ElementFormulaMapping target = new ElementFormulaMapping();
|
|
|
- BeanUtils.copyProperties(v,target,exclude);
|
|
|
+ BeanUtils.copyProperties(v, target, exclude);
|
|
|
target.setWbsId(distProject.getReferenceWbsTemplateId());
|
|
|
target.setProjectId(distProject.getId());
|
|
|
insertList.add(target);
|
|
|
- Formula sf= finalSourceFormulaScopeMap.get(v.getFormulaId());
|
|
|
- Formula target2= new Formula();
|
|
|
- BeanUtils.copyProperties(sf,target2);
|
|
|
- Long id=SnowFlakeUtil.getId();
|
|
|
+ Formula sf = finalSourceFormulaScopeMap.get(v.getFormulaId());
|
|
|
+ Formula target2 = new Formula();
|
|
|
+ BeanUtils.copyProperties(sf, target2);
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
target.setFormulaId(id);
|
|
|
target2.setId(id);
|
|
|
insertFormulaList.add(target2);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
/*存在则比较,有差异则覆盖*/
|
|
|
- Formula sf= finalSourceFormulaScopeMap.get(v.getFormulaId());
|
|
|
- Formula tf= finalFormulaScopeMap.get(finalEfmListScopeMap.get(k).getFormulaId());
|
|
|
- if(!tf.getFormula().equals(sf.getFormula())){
|
|
|
- BeanUtils.copyProperties(sf,tf,exclude);
|
|
|
+ Formula sf = finalSourceFormulaScopeMap.get(v.getFormulaId());
|
|
|
+ Formula tf = finalFormulaScopeMap.get(finalEfmListScopeMap.get(k).getFormulaId());
|
|
|
+ if (!tf.getFormula().equals(sf.getFormula())) {
|
|
|
+ BeanUtils.copyProperties(sf, tf, exclude);
|
|
|
updateFormulaList.add(tf);
|
|
|
}
|
|
|
|
|
@@ -1964,23 +1966,23 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
//获取公式颜色
|
|
|
String tabName = wbsTreePrivate.getInitTableName();
|
|
|
- //字段查询 获取公式字段
|
|
|
- String colKeys = "SELECT e_key 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 in(SELECT element_id from m_formula c where c.is_deleted=0) ";
|
|
|
+ //字段查询、获取公式字段
|
|
|
+ String colKeys = "SELECT e_key from m_table_info a ,m_wbs_form_element b WHERE a.tab_en_name = '" + tabName + "' and a.id=b.f_id and b.id in(SELECT element_id from m_element_formula_mapping c where c.is_deleted=0) ";
|
|
|
List<Map<String, Object>> maps = jdbcTemplate.queryForList(colKeys);
|
|
|
- for (Map<String, Object> keys : maps) {
|
|
|
- String key = keys.get("e_key") + "__";
|
|
|
- Elements gsColor = doc.select("el-input[keyname~=^" + key + "]");
|
|
|
- for (Element element : gsColor) {
|
|
|
- //System.out.println(element.parent());
|
|
|
- element.parent().attr("gscolor", "11");
|
|
|
- }
|
|
|
- Elements dateColor = doc.select("el-date-picker[keyname~=^" + key + "]");
|
|
|
- for (Element element : dateColor) {
|
|
|
- //System.out.println(element.parent());
|
|
|
- element.parent().attr("gscolor", "11");
|
|
|
+ if (maps.size() > 0) {
|
|
|
+ for (Map<String, Object> keys : maps) {
|
|
|
+ String key = keys.get("e_key") + "__";
|
|
|
+ Elements gsColor = doc.select("el-input[keyname~=^" + key + "]");
|
|
|
+ for (Element element : gsColor) {
|
|
|
+ element.parent().attr("gscolor", "11");
|
|
|
+ }
|
|
|
+
|
|
|
+ Elements dateColor = doc.select("el-date-picker[keyname~=^" + key + "]");
|
|
|
+ for (Element element : dateColor) {
|
|
|
+ element.parent().attr("gscolor", "11");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
doc.select("Col").remove();
|
|
|
fileInputStream.close();
|
|
|
return R.data(table + "");
|