|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.zjugis.business.bean.entity.Project;
|
|
|
import com.zjugis.business.converter.commoncost.CommonCostConvert;
|
|
|
import com.zjugis.business.flow.commoncost.entity.CommonCostDO;
|
|
|
+import com.zjugis.business.flow.commoncost.entity.CommonCostDetailDO;
|
|
|
import com.zjugis.business.flow.commoncost.service.CommonCostDetailService;
|
|
|
import com.zjugis.business.flow.commoncost.service.CommonCostService;
|
|
|
import com.zjugis.business.service.ProjectService;
|
|
@@ -19,7 +20,6 @@ import com.zjugis.module.system.api.dept.PostApi;
|
|
|
import com.zjugis.module.system.api.dept.dto.DeptLeaderRespDTO;
|
|
|
import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
import com.zjugis.module.system.api.dept.dto.PostRespDTO;
|
|
|
-import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -31,6 +31,7 @@ import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
import static com.zjugis.business.constants.FlowStatusConstants.*;
|
|
|
import static com.zjugis.framework.common.util.collection.CollectionUtils.convertSet;
|
|
@@ -76,9 +77,15 @@ public class CommonCostEvent extends BaseController {
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
entity.setFlowStatus(FLOW_PROCESS);
|
|
|
commonCostService.updateCommonCost(CommonCostConvert.INSTANCE.convert(entity));
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ StringBuilder projectName = new StringBuilder();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ projectName.append(project.getXmmc());
|
|
|
+ projectName.append(";");
|
|
|
+ });
|
|
|
String applyTime = LocalDateTimeUtils.format(entity.getApplyTime(), null);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
- String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, "¥"+entity.getTotalAmount(), project.getXmmc()), "/");
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, "¥"+entity.getTotalAmount(), projectName), "/");
|
|
|
flowDesc = flowDesc.length() > 1 ? flowDesc.substring(1) : flowDesc;
|
|
|
workflowClient.saveFlowDescribe(flowInstanceId, flowDesc);
|
|
|
return ok("true");
|
|
@@ -328,12 +335,16 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
- String xmjlId = project.getXmjlId();
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> xmjlList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ xmjlList.add(project.getXmjlId());
|
|
|
+ });
|
|
|
String userId = entity.getUserId();
|
|
|
List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
- if (entity != null && CollectionUtil.contains(postCodes, "ceo") && userId.equals(xmjlId)) {
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "ceo") && xmjlList.contains(userId)) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
@@ -347,15 +358,26 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
- String xmjlId = project.getXmjlId();
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> zrbmIdList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ zrbmIdList.add(project.getZrbmId());
|
|
|
+ });
|
|
|
String userId = entity.getUserId();
|
|
|
List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
|
|
|
Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
|
|
|
depts.add(entity.getDeptId());
|
|
|
- if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
|
|
|
+ AtomicBoolean deptFlag = new AtomicBoolean(true);
|
|
|
+ zrbmIdList.forEach(x->{
|
|
|
+ if(!CollectionUtil.contains(depts, zrbmIdList)){
|
|
|
+ deptFlag.set(false);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && deptFlag.get()) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
@@ -369,15 +391,26 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
- String xmjlId = project.getXmjlId();
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> zrbmIdList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ zrbmIdList.add(project.getZrbmId());
|
|
|
+ });
|
|
|
String userId = entity.getUserId();
|
|
|
List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
|
|
|
Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
|
|
|
depts.add(entity.getDeptId());
|
|
|
- if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && !CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
|
|
|
+ AtomicBoolean deptFlag = new AtomicBoolean(true);
|
|
|
+ zrbmIdList.forEach(x->{
|
|
|
+ if(!CollectionUtil.contains(depts, zrbmIdList)){
|
|
|
+ deptFlag.set(false);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && !deptFlag.get()) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
@@ -405,15 +438,18 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> zrbmIdList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ zrbmIdList.add(project.getZrbmId());
|
|
|
+ });
|
|
|
List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
- if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
- DeptRespDTO deptRespDTO = deptApi.getDept(project.getZrbmId()).getCheckedData();
|
|
|
- if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
|
|
|
- HashMap<String,String> map = new HashMap<>();
|
|
|
- map.put("id",deptRespDTO.getLeaderUserId());
|
|
|
- userMaps.add(map);
|
|
|
- }
|
|
|
+ List<DeptRespDTO> deptList = deptApi.getDeptList(zrbmIdList).getCheckedData();
|
|
|
+ for (DeptRespDTO deptRespDTO : deptList) {
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("id",deptRespDTO.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
}
|
|
|
return ok(userMaps);
|
|
|
} else {
|
|
@@ -430,10 +466,15 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> zrbmIdList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ zrbmIdList.add(project.getZrbmId());
|
|
|
+ });
|
|
|
List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
- if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
- DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(project.getZrbmId()).getCheckedData();
|
|
|
+ for (String zrbmId : zrbmIdList){
|
|
|
+ DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(zrbmId).getCheckedData();
|
|
|
if(deptLeaderRespDTO != null && StringUtils.isNotBlank(deptLeaderRespDTO.getUserId())){
|
|
|
HashMap<String,String> map = new HashMap<>();
|
|
|
map.put("id",deptLeaderRespDTO.getUserId());
|
|
@@ -455,10 +496,15 @@ public class CommonCostEvent extends BaseController {
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
|
|
|
+ Set<String> zrbmIdList = new HashSet<>();
|
|
|
+ detailList.forEach(x->{
|
|
|
+ Project project = projectService.selectById(x.getProjectId());
|
|
|
+ zrbmIdList.add(project.getZrbmId());
|
|
|
+ });
|
|
|
List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
- if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
- DeptRespDTO deptRespDTO = deptApi.getSecondDeptByDeptId(project.getZrbmId()).getCheckedData();
|
|
|
+ for (String zrbmId : zrbmIdList){
|
|
|
+ DeptRespDTO deptRespDTO = deptApi.getSecondDeptByDeptId(zrbmId).getCheckedData();
|
|
|
if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
|
|
|
HashMap<String,String> map = new HashMap<>();
|
|
|
map.put("id",deptRespDTO.getLeaderUserId());
|