Browse Source

发起最大公出修改接口修改

anderx 1 year ago
parent
commit
bc33f43538

+ 1 - 1
src/main/java/com/goafanti/common/enums/NoticeStatus.java

@@ -91,7 +91,7 @@ public enum NoticeStatus {
 	PUBLIC_CARBON_COPY(81,"公出抄送"),
 	PUBLIC_MAX_DURATION(82,"公出时长审核发起"),
 	PUBLIC_MAX_DURATION_YES(83,"公出时长审核通过"),
-	PUBLIC_MAX_DURATION_REJECT(84,"公出时长审核驳回"),
+	PUBLIC_MAX_DURATION_NO(84,"公出时长审核驳回"),
 	OTHER(0, "其他");
 
 	private NoticeStatus(Integer code, String desc) {

+ 13 - 0
src/main/java/com/goafanti/weChat/controller/AdminReleaseApiController.java

@@ -7,6 +7,7 @@ import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.OrderPublicReleaseLog;
+import com.goafanti.common.model.PublicConfig;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.common.utils.excel.NewExcelUtil;
 import com.goafanti.weChat.bo.*;
@@ -586,4 +587,16 @@ public class AdminReleaseApiController extends CertifyApiController{
 		}
 		return res.data(publicReleaseService.maxDurationLog(orderNo));
 	}
+
+
+
+	/**
+	 * 修改最大公出审核配置
+	 */
+	@RequestMapping(value = "/updatePublicConfig",method = RequestMethod.POST)
+	public Result updatePublicConfig (PublicConfig in){
+		Result res =new Result();
+
+		return res.data(publicReleaseService.updatePublicConfig(in));
+	}
 }

+ 3 - 0
src/main/java/com/goafanti/weChat/service/PublicReleaseService.java

@@ -1,5 +1,6 @@
 package com.goafanti.weChat.service;
 
+import com.goafanti.common.model.PublicConfig;
 import com.goafanti.weChat.bo.*;
 
 import java.util.List;
@@ -92,4 +93,6 @@ public interface PublicReleaseService {
 	Object pushExamineMaxDuration(String orderNo,Integer status, String remarks);
 
 	Object maxDurationLog(String orderNo);
+
+	Object updatePublicConfig(PublicConfig in);
 }

+ 75 - 47
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -1235,66 +1235,93 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		TOrderPublicReleaseCount in =new TOrderPublicReleaseCount();
 		TOrderPublicReleaseCount use = tOrderPublicReleaseCountMapper.selectByOrderNo(orderNo);
 		in.setOrderNo(orderNo);
-		Integer examine =null;
-		int process =0;
-		if (TokenManager.hasRole(AFTConstants.TECH_ADMIN)&&TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
-			process=4;
-			examine=0;
-		}else if (TokenManager.hasRole(AFTConstants.TECH_ADMIN)){
-			if (use.getMaxProcess()!=1){
-				throw new BusinessException("审核人错误,必须是技术管理员才能审核。");
-			}
-			examine=1;
-			process=2;
-		}else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
-			if (use.getMaxProcess()!=2){
-				throw new BusinessException("审核人错误,必须是财务管理员才能审核。");
-			}
-			examine=2;
-			process=4;
-		}else {
-			throw new BusinessException("审核人错误,必须是技术/财务管理员才能审核。");
-		}
+		PublicConfig publicConfig = publicConfigMapper.queryById(1);
 		TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(orderNo);
-		StringBuilder str=new StringBuilder();
-		str.append("合同编号[").append(order.getContractNo()).append("]最大公出限制审核");
-		if(status==1){
-			in.setMaxProcess(process);
-			if (examine==0){
-				addOrderPublicReleaseLog(orderNo,status,1,remarks);
-				addOrderPublicReleaseLog(orderNo,status,2,"相同审核人自动跳过。");
-				pushCompleteMaxDuration(orderNo);
-				str.append("已通过。");
-				addNoticeAndEmail(order.getSalesmanId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
-			}else if (examine==1){
-				addOrderPublicReleaseLog(orderNo,status,1,remarks);
-				if (examine==1){
-					List<Admin> admins = adminMapper.selectAdminByRoleType(AFTConstants.FINANCE_ADMIN);
-					str.append("需要审核,请尽快审核。");
-					admins.forEach(e->{
-						addNoticeAndEmail(e.getId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
-					});
-					pushCompleteMaxDuration(orderNo);
+		in.setMaxProcess(use.getMaxProcess());
+		String aid=TokenManager.getAdminId();
+		 if (use.getMaxProcess()==1){
+				if (publicConfig.getTechAuditorStauts()==1&&TokenManager.getAdminId().equals(publicConfig.getTechAuditor())) {
+					addOrderPublicReleaseLog(orderNo,status,1,remarks);
+				}else {
+				throw new BusinessException("审核人错误,必须是设置的审核人员才能审核。");
 				}
-			}else if (examine==2){
+		}else if (use.getMaxProcess()==2){
+			if (publicConfig.getFinanceAuditorStauts()==1&&TokenManager.getAdminId().equals(publicConfig.getFinanceAuditor())) {
 				addOrderPublicReleaseLog(orderNo,status,2,remarks);
-				pushCompleteMaxDuration(orderNo);
-				str.append("已通过。");
-				addNoticeAndEmail(order.getSalesmanId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
+			}else {
+				throw new BusinessException("审核人错误,必须是设置的审核人员才能审核。");
 			}
-		}else if(status==2){
-			in.setMaxProcess(3);
-			str.append("已驳回。");
-			addNoticeAndEmail(order.getSalesmanId(),NoticeStatus.PUBLIC_MAX_DURATION_REJECT.getCode(), str.toString());
+		}else if (use.getMaxProcess()==3){
+			 if (publicConfig.getOtherAuditorStauts()==1&&TokenManager.getAdminId().equals(publicConfig.getOtherAuditor())) {
+				 addOrderPublicReleaseLog(orderNo,status,3,remarks);
+
+			 }else {
+				 throw new BusinessException("审核人错误,必须是设置的审核人员才能审核。");
+			 }
 		}
+		pushPublicConfigSendNoticeAndEmail(publicConfig, in, aid, order, status);
 		return tOrderPublicReleaseCountMapper.updateByOrderNo(in);
 	}
 
+	private void pushPublicConfigSendNoticeAndEmail(PublicConfig publicConfig, TOrderPublicReleaseCount in, String aid, TOrderNewBo order,Integer status) {
+		StringBuilder str=new StringBuilder();
+		str.append("合同编号[").append(order.getContractNo()).append("]最大公出限制审核");
+		int noticeStatus=0;
+		if (status==1){
+			noticeStatus=NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode();
+		}else if (status==2){
+			noticeStatus=NoticeStatus.PUBLIC_MAX_DURATION_NO.getCode();
+		}
+		//处理当前审核状态确定发送人
+		pushPublicConfig(publicConfig, in);
+		String str1="需要审核,请尽快审核。";
+		if (in.getMaxProcess()==2){
+			aid = publicConfig.getFinanceAuditor();
+		} else if (in.getMaxProcess()==3){
+			aid = publicConfig.getOtherAuditor();
+		}
+		else if (in.getMaxProcess()==5){
+			str1="审核通过。";
+			aid = order.getSalesmanId();
+		}
+		str.append(str1);
+		addNoticeAndEmail(aid, noticeStatus, str.toString());
+		if (in.getMaxProcess()==5){
+			pushCompleteMaxDuration( in.getOrderNo());
+		}
+	}
+
+	private void pushPublicConfig(PublicConfig config, TOrderPublicReleaseCount in) {
+		if (in.getMaxProcess()==1){
+			if (config.getFinanceAuditorStauts()==0){
+				if (config.getOtherAuditorStauts()==0){
+					in.setMaxProcess(5);
+				}else {
+					in.setMaxProcess(3);
+				}
+			}else {
+				in.setMaxProcess(2);
+			}
+		}else if (in.getMaxProcess()==2){
+			if (config.getOtherAuditorStauts()==0){
+				in.setMaxProcess(5);
+			}else {
+				in.setMaxProcess(3);
+			}
+		}
+	}
+
 	@Override
 	public Object maxDurationLog(String orderNo) {
 		return orderPublicReleaseLogMapper.queryByOrderNo(orderNo);
 	}
 
+	@Override
+	public Object updatePublicConfig(PublicConfig in) {
+		in.setId(1);
+		return publicConfigMapper.update(in);
+	}
+
 	private void pushCompleteMaxDuration(String orderNo) {
 		List<OrderPublicReleaseLog> orderPublicReleaseLogs = orderPublicReleaseLogMapper.queryByOrderNo(orderNo);
 		List<PublicRelease> publicReleases = publicReleaseMapper.selectByOrderNo(orderNo);
@@ -1318,6 +1345,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 					newP.setId(e.getId());
 					newP.setStatus(2);
 					addpublicLog(e.getId(),2,"公出审核人已经审核最大公出小时,跳过审核");
+					addNoticeAndEmail(e.getAid(), NoticeStatus.PUBLIC_RELEASE_YES.getCode(), "公出审核人已经审核最大公出小时,跳过审核");
 					publicReleaseMapper.update(e);
 				}
 			}