项目库-法规清单-发起清单确认/认证、法规工程师提交任务接口

This commit is contained in:
wangzhijiang
2022-04-15 18:31:21 +08:00
parent 8555e25354
commit 954b04cb68
3 changed files with 118 additions and 3 deletions
@@ -2,6 +2,7 @@ package com.jero.modules.project.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result;
@@ -167,4 +168,16 @@ public class ProjectLawsInventoryEOController extends JeroController<ProjectLaws
return super.importExcel(request, response, ProjectLawsInventoryEO.class);
}
/**
* 批量更新法规清单状态
* @param params
* @return
*/
@AutoLog(value = "项目库-法规清单表-批量更新状态")
@ApiOperation(value="项目库-法规清单表-批量更新状态", notes="项目库-法规清单表-批量更新状态")
@GetMapping(value = "/updateStatusBatch")
public Result<?> updateStatusBatch(@RequestParam Map<String,Object> params) {
return this.projectLawsInventoryEOService.updateStatusBatch(params);
}
}
@@ -1,8 +1,10 @@
package com.jero.modules.project.service;
import com.jero.common.api.vo.Result;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* @Description: 项目库-法规清单表
@@ -58,4 +60,11 @@ public interface IProjectLawsInventoryEOService extends IService<ProjectLawsInve
* @return
*/
List<ProjectLawsInventoryEO> queryList(ProjectLawsInventoryEO projectLawsInventoryEO);
/**
* 批量更新状态
* @param params
* @return
*/
Result<?> updateStatusBatch(Map<String, Object> params);
}
@@ -1,6 +1,7 @@
package com.jero.modules.project.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
@@ -19,9 +20,7 @@ import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -298,4 +297,98 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
}
return result;
}
/**
* 批量更新状态
* @param params
* @return
*/
@Override
public Result<?> updateStatusBatch(Map<String, Object> params) {
String result = "";
//operatorType: 0studio工程师发起清单确认 1:法规工程师/认证工程师 (提交或拒绝)
String operatorType = (String) params.get("operatorType");
String projectLibraryId = (String) params.get("projectLibraryId");//项目id
String ids = (String) params.get("ids");
if(StringUtils.isEmpty(operatorType)){
throw new JeroBootException("操作类型不能为空!");
}
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
try {
if(StringUtils.equals(operatorType,"0")){
QueryWrapper<ProjectLawsInventoryEO> queryWrapper = new QueryWrapper<>();
if(StringUtils.isNotEmpty(ids)){
queryWrapper.lambda().in(ProjectLawsInventoryEO::getId, Arrays.asList(ids.split(",")));
}
queryWrapper.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId);
List<ProjectLawsInventoryEO> projectLawsInventoryEOS = this.baseMapper.selectList(queryWrapper);
for (ProjectLawsInventoryEO projectLawsInventoryEO : projectLawsInventoryEOS) {
//如果该数据的状态为 未发起或拒绝 可以发起清单确认
boolean checkStatus = (StringUtils.equals(projectLawsInventoryEO.getInventoryAffirmStatus(),InventoryAffirmStatusEnum.NOT_STARTED.getValue())
||StringUtils.equals(projectLawsInventoryEO.getInventoryAffirmStatus(),InventoryAffirmStatusEnum.REJECTED.getValue()));
//如果该数据的法规工程师、认证工程师都不为空
boolean checkUser = (StringUtils.isNotEmpty(projectLawsInventoryEO.getRegulationOwnerId())
&& StringUtils.isNotEmpty(projectLawsInventoryEO.getHomologationEngineerId()));
if(checkStatus && checkUser){
projectLawsInventoryEO.setInventoryAffirmStatus(InventoryAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
projectLawsInventoryEO.setRegulationOwnerSubmitStatus(null);
projectLawsInventoryEO.setHomologationEngineerSubmitStatus(null);
super.updateById(projectLawsInventoryEO);
}
}
result = "发起清单确认";
}else if(StringUtils.equals(operatorType,"1")){
//提交结果 0通过 1拒绝
String operatorResult = (String) params.get("operatorResult");
if(StringUtils.equals(operatorResult,"0")){
result = "提交";
}else if(StringUtils.equals(operatorResult,"1")){
result = "拒绝";
}
List<String> idList = Arrays.asList(ids.split(","));
for (String id : idList) {
int isProjectRole = checkUserRole(projectLibraryId, currentUser.getId(), id);
ProjectLawsInventoryEO projectLawsInventoryEO = getById(id);
if(isProjectRole == Integer.parseInt(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue())){
projectLawsInventoryEO.setRegulationOwnerSubmitStatus(operatorResult);
projectLawsInventoryEO.setHomologationEngineerSubmitStatus(operatorResult);
}else if(isProjectRole == Integer.parseInt(ProjectRoleEnum.REGULATI_ENGINEER.getValue())){
projectLawsInventoryEO.setRegulationOwnerSubmitStatus(operatorResult);
}else if(isProjectRole == Integer.parseInt(ProjectRoleEnum.HOMOLOGATION_ENGINEER.getValue())){
projectLawsInventoryEO.setHomologationEngineerSubmitStatus(operatorResult);
}
//如果不是studio
if(isProjectRole != -1 && isProjectRole != Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue())){
String inventoryAffirmStatus = "";
//如果法规工程师与认证工程师都是提交通过 把清单确认状态设置为 接受
if(projectLawsInventoryEO.getRegulationOwnerSubmitStatus().equals("0") && projectLawsInventoryEO.getHomologationEngineerSubmitStatus().equals("0")){
inventoryAffirmStatus = InventoryAffirmStatusEnum.ACCEPTED.getValue();
}
//如果法规工程师与认证工程师 其中一个人是拒绝 把清单确认状态设置为 拒绝
if(projectLawsInventoryEO.getRegulationOwnerSubmitStatus().equals("1") || projectLawsInventoryEO.getHomologationEngineerSubmitStatus().equals("1")){
inventoryAffirmStatus = InventoryAffirmStatusEnum.REJECTED.getValue();
}
if(StringUtils.isNotEmpty(inventoryAffirmStatus)){
projectLawsInventoryEO.setInventoryAffirmStatus(inventoryAffirmStatus);
super.baseMapper.updateById(projectLawsInventoryEO);
}
}
}
}
}catch (Exception ex){
log.error("批量"+result+" 更新状态失败:" + ex.getMessage());
throw new JeroBootException("批量" +result+ "失败!");
}
return new Result<>().success(result + "成功!");
}
}