1.项目季度查询时增加逻辑删除
2.项目立项/编辑增加校验,修改时修复权限问题
This commit is contained in:
parent
e29ee055aa
commit
2f3fd0d8ad
@ -58,7 +58,7 @@
|
||||
from project_assessment_indicators a
|
||||
right join(SELECT quarter, AVG((ext_ ->> 'sum')::FLOAT), project_id
|
||||
from project_assessment_indicators
|
||||
WHERE project_id = #{map.projectId}
|
||||
WHERE project_id = #{map.projectId} and is_deleted='0'
|
||||
<if test="map.verifyStatus==1">
|
||||
and ext_ ->> 'executor' like CONCAT('%', #{map.userId}, '%')
|
||||
</if>
|
||||
|
@ -113,6 +113,24 @@ public class ProjectInitComtroller implements ProjectInitApi {
|
||||
@Autowired
|
||||
ProjectInfoController projectInfoController;
|
||||
|
||||
private void verification(ProjectInfoReq infoReq) throws XQException {
|
||||
if (StringUtils.isEmpty(infoReq.getProjectName())) {
|
||||
throw new XQException(ErrorCode.PROJECTINFO_PROJECTNAME_EMPTY_ERROR, null);
|
||||
}
|
||||
if (StringUtils.isEmpty(infoReq.getProjectCategory())) {
|
||||
throw new XQException(ErrorCode.PROJECTINFO_PROJECTCATEGORY_EMPTY_ERROR, null);
|
||||
}
|
||||
if (StringUtils.isEmpty(infoReq.getProjectStep())) {
|
||||
throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null);
|
||||
}
|
||||
JSONObject ext = infoReq.getExt();
|
||||
JSONArray jsonArray = ext.getJSONArray("membersList");
|
||||
List<ProjectMembers> membersList = ext.getJSONArray("membersList").toJavaList(ProjectMembers.class);
|
||||
if (membersList == null || membersList.size() <= 0) {
|
||||
throw new XQException(ErrorCode.PROJECTINFO_MEMBERSLIST_EMPTY_ERROR, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目立项
|
||||
*
|
||||
@ -401,7 +419,18 @@ public class ProjectInitComtroller implements ProjectInitApi {
|
||||
public String edit(@RequestHeader("userId") Long userId, @RequestBody ProjectInfoInitDto initDto,
|
||||
@PathVariable("id") Long id) throws XQException {
|
||||
try {
|
||||
ProjectInfoReq infoReq = new ProjectInfoReq();
|
||||
ProjectInfoReq infoReq = initDto.getProjectInfoReq();
|
||||
verification(infoReq);
|
||||
//判断项目名是否重复
|
||||
EntityWrapper<ProjectInfo> wrapper = new EntityWrapper<>();
|
||||
wrapper.eq("project_name", infoReq.getProjectName());
|
||||
wrapper.eq("project_category", "init");
|
||||
wrapper.eq("is_deleted", false);
|
||||
wrapper.ne(ProjectInfo.ID_,id);
|
||||
List<ProjectInfo> infos = projectInfoService.selectList(wrapper);
|
||||
if (!ObjectUtils.isEmpty(infos)) {
|
||||
return ApiResponse.fillFail("项目名称已存在!");
|
||||
}
|
||||
List<ProjectAssessmentIndicators> membersList = new ArrayList<>();
|
||||
if (!ObjectUtils.isEmpty(initDto)) {
|
||||
infoReq = initDto.getProjectInfoReq();
|
||||
@ -410,8 +439,45 @@ public class ProjectInitComtroller implements ProjectInitApi {
|
||||
if (!ObjectUtils.isEmpty(id)) {
|
||||
indicatorsService.updateByProjectId(id);
|
||||
if (!ObjectUtils.isEmpty(membersList)) {
|
||||
membersList.forEach(a -> a.setProjectId(id));
|
||||
indicatorsService.insertBatch(membersList);
|
||||
ProjectInfo info = projectInfoService.selectById(id);
|
||||
JSONObject ext = info.getExt();
|
||||
String projectManagerData = String.valueOf(((JSONArray) ext.get("projectManagerData")).get(1));
|
||||
if (!membersList.isEmpty()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("executor", getSystemUserLogin(projectManagerData).getId());//第一个节点执行人一定是项目负责人
|
||||
jsonObject.put("historyExecutor", jsonObject.get("executor"));
|
||||
jsonObject.put("taskName", "季度审核填报");
|
||||
jsonObject.put("projectManager", jsonObject.get("executor"));
|
||||
membersList.forEach(item -> {
|
||||
item.setProjectId(info.getId());
|
||||
item.setCreatedBy(userId);
|
||||
item.setExt(jsonObject);
|
||||
item.setCreatedAt(new Timestamp(System.currentTimeMillis()));
|
||||
item.setUpdatedBy(null);
|
||||
});
|
||||
Map<String, List<ProjectAssessmentIndicators>> collect = membersList.stream().collect(Collectors.groupingBy(ProjectAssessmentIndicators::getQuarter));
|
||||
List<ProjectAssessmentIndicators> indicatorsList = new ArrayList<>();
|
||||
collect.forEach((a, b) -> {
|
||||
String budgetRate = new String();//预算执行率
|
||||
for (int i = 0; i < b.size(); i++) {
|
||||
ProjectAssessmentIndicators projectAssessmentIndicators = b.get(i);
|
||||
if (!StringUtils.isEmpty(projectAssessmentIndicators.getBudgetRate())) {
|
||||
budgetRate = projectAssessmentIndicators.getBudgetRate();
|
||||
} else {
|
||||
projectAssessmentIndicators.setBudgetRate(budgetRate);
|
||||
}
|
||||
indicatorsList.add(b.get(i));
|
||||
}
|
||||
});
|
||||
indicatorsService.insertBatch(indicatorsList);
|
||||
ProjectInfo projectInfo = infoService.selectById(info.getId());
|
||||
JSONObject ext1 = projectInfo.getExt();
|
||||
ext1.put("membersList", indicatorsList);
|
||||
projectInfo.setExt(ext1);
|
||||
infoService.updateById(projectInfo);
|
||||
}
|
||||
// membersList.forEach(a -> a.setProjectId(id));
|
||||
// indicatorsService.insertBatch(membersList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user