|
@@ -1156,11 +1156,7 @@ public List<ElementData> setScale(Integer scale,List<ElementData> data){
|
|
|
|
|
|
private List<KeyMapper> listForContract(List<Long> ids,String projectId,String nodeId){
|
|
private List<KeyMapper> listForContract(List<Long> ids,String projectId,String nodeId){
|
|
String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
- List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation " +
|
|
|
|
- "from m_wbs_tree_contract a " +
|
|
|
|
- "inner join m_table_info b on a.init_table_name=b.tab_en_name " +
|
|
|
|
- "INNER JOIN m_wbs_form_element c on b.id=c.f_id " +
|
|
|
|
- "where a.p_key_id in("+pkIds+") ORDER BY field(a.p_key_id,"+pkIds+")");
|
|
|
|
|
|
+ List<Map<String,Object>> listMap = listMap(ids,ExecuteType.INSPECTION);
|
|
List<Long> nodeIds= this.jdbcTemplate.queryForList("select b.parent_id from m_wbs_tree_contract a join m_wbs_tree_private b on a.is_type_private_pid=b.p_key_id where a.p_key_id in("+pkIds+")",Long.class);
|
|
List<Long> nodeIds= this.jdbcTemplate.queryForList("select b.parent_id from m_wbs_tree_contract a join m_wbs_tree_private b on a.is_type_private_pid=b.p_key_id where a.p_key_id in("+pkIds+")",Long.class);
|
|
if(Func.isNotEmpty(listMap)){
|
|
if(Func.isNotEmpty(listMap)){
|
|
/*当前节点的某个元素存在多种作用域的公式,作用域范围越小优先级越高*/
|
|
/*当前节点的某个元素存在多种作用域的公式,作用域范围越小优先级越高*/
|
|
@@ -1174,73 +1170,95 @@ public List<ElementData> setScale(Integer scale,List<ElementData> data){
|
|
"from m_element_formula_mapping " +
|
|
"from m_element_formula_mapping " +
|
|
"where element_id in(" + list.stream().map(KeyMapper::getFieldId).map(Func::toStr).collect(Collectors.joining(",")) + ") " +
|
|
"where element_id in(" + list.stream().map(KeyMapper::getFieldId).map(Func::toStr).collect(Collectors.joining(",")) + ") " +
|
|
"and is_deleted=0 " + " and ( scope<2 or (scope=2 and node_id in(" + nodeIdStr + ")) or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id in (" + nodeIdStr + ")))");
|
|
"and is_deleted=0 " + " and ( scope<2 or (scope=2 and node_id in(" + nodeIdStr + ")) or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id in (" + nodeIdStr + ")))");
|
|
- if(Func.isNotEmpty(efMap)){
|
|
|
|
- Map<Long,List<Map<String,Object>>> efGroup= efMap.stream().collect(Collectors.groupingBy(e->Func.toLong(e.get("elementId"))));
|
|
|
|
- list.forEach(e->{
|
|
|
|
- List<Map<String,Object>> tmp = efGroup.get(e.getFieldId());
|
|
|
|
- if(Func.isNotEmpty(tmp)){
|
|
|
|
- tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
|
|
|
|
- e.setFormulaId(Func.toLong(d.get("formulaId")));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ setFormula(list,efMap);
|
|
/*节点参数公式*/
|
|
/*节点参数公式*/
|
|
- if(StringUtils.isNotEmpty(nodeId)){
|
|
|
|
- /*存在工序节点id则检查节点参数*/
|
|
|
|
- WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,nodeId));
|
|
|
|
- if(wtc!=null){
|
|
|
|
- List<WbsParam> total = new ArrayList<>();
|
|
|
|
- WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId,wtc.getProjectId()).eq(WbsTreePrivate::getWbsId,wtc.getWbsId()).and(e->e.eq(WbsTreePrivate::getId,wtc.getId()).or().eq(WbsTreePrivate::getId,wtc.getOldId())));
|
|
|
|
- if(wtp!=null){
|
|
|
|
- List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wtp.getPKeyId()));
|
|
|
|
- if(Func.isEmpty(wpsPrivate)){
|
|
|
|
- WbsTree wt = this.wbsTreeService.getOne(Wrappers.<WbsTree>lambdaQuery().and(e->e.eq(WbsTree::getId,wtc.getId()).or().eq(WbsTree::getId,wtc.getOldId())));
|
|
|
|
- if(wt!=null){
|
|
|
|
- List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wt.getId()));
|
|
|
|
- if(Func.isNotEmpty(wpsPublic)){
|
|
|
|
- total.addAll(wpsPublic);
|
|
|
|
- }
|
|
|
|
|
|
+ setParamsFormula( nodeId, list);
|
|
|
|
+ if(list.size()>0){
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setParamsFormula(String nodeId, List<KeyMapper> list){
|
|
|
|
+ if(StringUtils.isNotEmpty(nodeId)){
|
|
|
|
+ /*存在工序节点id则检查节点参数*/
|
|
|
|
+ WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,nodeId));
|
|
|
|
+ if(wtc!=null){
|
|
|
|
+ List<WbsParam> total = new ArrayList<>();
|
|
|
|
+ WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId,wtc.getProjectId()).eq(WbsTreePrivate::getWbsId,wtc.getWbsId()).and(e->e.eq(WbsTreePrivate::getId,wtc.getId()).or().eq(WbsTreePrivate::getId,wtc.getOldId())));
|
|
|
|
+ if(wtp!=null){
|
|
|
|
+ List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wtp.getPKeyId()));
|
|
|
|
+ if(Func.isEmpty(wpsPrivate)){
|
|
|
|
+ WbsTree wt = this.wbsTreeService.getOne(Wrappers.<WbsTree>lambdaQuery().and(e->e.eq(WbsTree::getId,wtc.getId()).or().eq(WbsTree::getId,wtc.getOldId())));
|
|
|
|
+ if(wt!=null){
|
|
|
|
+ List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wt.getId()));
|
|
|
|
+ if(Func.isNotEmpty(wpsPublic)){
|
|
|
|
+ total.addAll(wpsPublic);
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- total.addAll(wpsPrivate);
|
|
|
|
}
|
|
}
|
|
|
|
+ }else{
|
|
|
|
+ total.addAll(wpsPrivate);
|
|
}
|
|
}
|
|
- if(Func.isNotEmpty(total)){
|
|
|
|
- List<ElementFormulaMapping> mappingList = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().in(ElementFormulaMapping::getParamId,total.stream().map(WbsParam::getId).collect(Collectors.toList())));
|
|
|
|
- if(Func.isNotEmpty(mappingList)){
|
|
|
|
- list.forEach(e->{
|
|
|
|
- mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getFieldId())).findAny().ifPresent(d->{
|
|
|
|
- e.setFormulaId(d.getFormulaId());
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ if(Func.isNotEmpty(total)){
|
|
|
|
+ List<ElementFormulaMapping> mappingList = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().in(ElementFormulaMapping::getParamId,total.stream().map(WbsParam::getId).collect(Collectors.toList())));
|
|
|
|
+ if(Func.isNotEmpty(mappingList)){
|
|
|
|
+ list.forEach(e->{
|
|
|
|
+ mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getFieldId())).findAny().ifPresent(d->{
|
|
|
|
+ e.setFormulaId(d.getFormulaId());
|
|
});
|
|
});
|
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
|
|
|
|
+ /**/
|
|
|
|
+ List<Map<String,Object>> listMap = listMap(ids,ExecuteType.TESTING);
|
|
|
|
+ List<KeyMapper> list= listMap.stream().map(m->BeanUtil.toBean(m,KeyMapper.class)).collect(Collectors.toList());
|
|
|
|
+ if(Func.isNotEmpty(listMap)){
|
|
|
|
+ List<Map<String,Object>> efMap= this.jdbcTemplate.queryForList("select element_id elementId,formula_id formulaId,scope " +
|
|
|
|
+ "from m_element_formula_mapping " +
|
|
|
|
+ "where element_id in(" + list.stream().map(KeyMapper::getFieldId).distinct().map(Func::toStr).collect(Collectors.joining(",")) + ") " +
|
|
|
|
+ "and is_deleted=0 " + " and ( scope<2 or (scope =10 and project_id = " + projectId + ") )");
|
|
|
|
+ setFormula(list,efMap);
|
|
if(list.size()>0){
|
|
if(list.size()>0){
|
|
- return list;
|
|
|
|
|
|
+ return list;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
|
|
|
|
- private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
|
|
|
|
- /**/
|
|
|
|
|
|
+
|
|
|
|
+ private List<Map<String,Object>> listMap(List<Long> ids,ExecuteType type){
|
|
String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
- List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation " +
|
|
|
|
- "from m_wbs_tree_private a " +
|
|
|
|
|
|
+ String tableName=ExecuteType.INSPECTION.equals(type)?"m_wbs_tree_contract":"m_wbs_tree_private";
|
|
|
|
+ return this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation " +
|
|
|
|
+ "from "+tableName+" a " +
|
|
"inner join m_table_info b on a.init_table_name=b.tab_en_name " +
|
|
"inner join m_table_info b on a.init_table_name=b.tab_en_name " +
|
|
"INNER JOIN m_wbs_form_element c on b.id=c.f_id " +
|
|
"INNER JOIN m_wbs_form_element c on b.id=c.f_id " +
|
|
"where a.p_key_id in("+pkIds+") ORDER BY field(a.p_key_id,"+pkIds+")");
|
|
"where a.p_key_id in("+pkIds+") ORDER BY field(a.p_key_id,"+pkIds+")");
|
|
- if(Func.isNotEmpty(listMap)){
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void setFormula(List<KeyMapper> list,List<Map<String,Object>> efMap){
|
|
|
|
+ if(Func.isNotEmpty(efMap)){
|
|
|
|
+ Map<Long,List<Map<String,Object>>> efGroup= efMap.stream().collect(Collectors.groupingBy(e->Func.toLong(e.get("elementId"))));
|
|
|
|
+ list.forEach(e->{
|
|
|
|
+ List<Map<String,Object>> tmp = efGroup.get(e.getFieldId());
|
|
|
|
+ if(Func.isNotEmpty(tmp)){
|
|
|
|
+ tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
|
|
|
|
+ e.setFormulaId(Func.toLong(d.get("formulaId")));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- return Collections.emptyList();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
|
|
public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
|
|
if(Func.isNotEmpty(keyMapperList)){
|
|
if(Func.isNotEmpty(keyMapperList)){
|