Browse Source

新增技术公出判定接口

anderx 1 year ago
parent
commit
8a60335d25

+ 1 - 0
src/main/java/com/goafanti/common/dao/PublicReleaseMapper.java

@@ -11,6 +11,7 @@ import java.util.Date;
 import java.util.List;
 
 public interface PublicReleaseMapper {
+
     int deleteByPrimaryKey(Integer id);
 
     int insert(PublicRelease record);

File diff suppressed because it is too large
+ 750 - 870
src/main/java/com/goafanti/common/mapper/PublicReleaseMapper.xml


+ 252 - 2
src/main/java/com/goafanti/common/model/PublicRelease.java

@@ -4,10 +4,13 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * public_release
- * @author 
+ * 公出表
+ * @TableName public_release
  */
 public class PublicRelease implements Serializable {
+    /**
+     * 
+     */
     private Integer id;
 
     /**
@@ -195,309 +198,556 @@ public class PublicRelease implements Serializable {
      */
     private Integer clockIn;
 
+    /**
+     * 0无需审核 1需要审核 2营销审核通过 3营销审核驳回
+     */
+    private Integer techStartProcess;
+
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 
+     */
     public Integer getId() {
         return id;
     }
 
+    /**
+     * 
+     */
     public void setId(Integer id) {
         this.id = id;
     }
 
+    /**
+     * 公出人
+     */
     public String getAid() {
         return aid;
     }
 
+    /**
+     * 公出人
+     */
     public void setAid(String aid) {
         this.aid = aid;
     }
 
+    /**
+     * 公出开始时间
+     */
     public Date getReleaseStart() {
         return releaseStart;
     }
 
+    /**
+     * 公出开始时间
+     */
     public void setReleaseStart(Date releaseStart) {
         this.releaseStart = releaseStart;
     }
 
+    /**
+     * 公出结束时间
+     */
     public Date getReleaseEnd() {
         return releaseEnd;
     }
 
+    /**
+     * 公出结束时间
+     */
     public void setReleaseEnd(Date releaseEnd) {
         this.releaseEnd = releaseEnd;
     }
 
+    /**
+     * 公出目标
+     */
     public String getRemarks() {
         return remarks;
     }
 
+    /**
+     * 公出目标
+     */
     public void setRemarks(String remarks) {
         this.remarks = remarks;
     }
 
+    /**
+     * 附件
+     */
     public String getAnnexUrl() {
         return annexUrl;
     }
 
+    /**
+     * 附件
+     */
     public void setAnnexUrl(String annexUrl) {
         this.annexUrl = annexUrl;
     }
 
+    /**
+     * 状态 0驳回 1发起 2同意 3 撤销 4技术驳回
+     */
     public Integer getStatus() {
         return status;
     }
 
+    /**
+     * 状态 0驳回 1发起 2同意 3 撤销 4技术驳回
+     */
     public void setStatus(Integer status) {
         this.status = status;
     }
 
+    /**
+     * 发起时间
+     */
     public Date getCreateTime() {
         return createTime;
     }
 
+    /**
+     * 发起时间
+     */
     public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
 
+    /**
+     * 项目编号
+     */
     public String getPid() {
         return pid;
     }
 
+    /**
+     * 项目编号
+     */
     public void setPid(String pid) {
         this.pid = pid;
     }
 
+    /**
+     * 项目名称
+     */
     public String getPname() {
         return pname;
     }
 
+    /**
+     * 项目名称
+     */
     public void setPname(String pname) {
         this.pname = pname;
     }
 
+    /**
+     * 时长
+     */
     public Double getDuration() {
         return duration;
     }
 
+    /**
+     * 时长
+     */
     public void setDuration(Double duration) {
         this.duration = duration;
     }
 
+    /**
+     * 有效日期
+     */
     public String getValidDate() {
         return validDate;
     }
 
+    /**
+     * 有效日期
+     */
     public void setValidDate(String validDate) {
         this.validDate = validDate;
     }
 
+    /**
+     * 本次总结
+     */
     public String getSupplement() {
         return supplement;
     }
 
+    /**
+     * 本次总结
+     */
     public void setSupplement(String supplement) {
         this.supplement = supplement;
     }
 
+    /**
+     * 审核信息
+     */
     public String getAuditInfo() {
         return auditInfo;
     }
 
+    /**
+     * 审核信息
+     */
     public void setAuditInfo(String auditInfo) {
         this.auditInfo = auditInfo;
     }
 
+    /**
+     * 公出计划
+     */
     public String getPlan() {
         return plan;
     }
 
+    /**
+     * 公出计划
+     */
     public void setPlan(String plan) {
         this.plan = plan;
     }
 
+    /**
+     * 预计效果
+     */
     public String getExpectedEffect() {
         return expectedEffect;
     }
 
+    /**
+     * 预计效果
+     */
     public void setExpectedEffect(String expectedEffect) {
         this.expectedEffect = expectedEffect;
     }
 
+    /**
+     * 下次计划
+     */
     public String getNextPlan() {
         return nextPlan;
     }
 
+    /**
+     * 下次计划
+     */
     public void setNextPlan(String nextPlan) {
         this.nextPlan = nextPlan;
     }
 
+    /**
+     * 分类 0业务 1技术 2行政 3 技术协单 4 技术助手
+     */
     public Integer getType() {
         return type;
     }
 
+    /**
+     * 分类 0业务 1技术 2行政 3 技术协单 4 技术助手
+     */
     public void setType(Integer type) {
         this.type = type;
     }
 
+    /**
+     * 订单编号
+     */
     public String getOrderNo() {
         return orderNo;
     }
 
+    /**
+     * 订单编号
+     */
     public void setOrderNo(String orderNo) {
         this.orderNo = orderNo;
     }
 
+    /**
+     * 修改时间
+     */
     public Date getUpdateTime() {
         return updateTime;
     }
 
+    /**
+     * 修改时间
+     */
     public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
 
+    /**
+     * 修改状态 0=否 1=是
+     */
     public Integer getUpdateStatus() {
         return updateStatus;
     }
 
+    /**
+     * 修改状态 0=否 1=是
+     */
     public void setUpdateStatus(Integer updateStatus) {
         this.updateStatus = updateStatus;
     }
 
+    /**
+     * 0否 1主公出 2协助公出
+     */
     public Integer getAssist() {
         return assist;
     }
 
+    /**
+     * 0否 1主公出 2协助公出
+     */
     public void setAssist(Integer assist) {
         this.assist = assist;
     }
 
+    /**
+     * 协单人员
+     */
     public String getAssistAid() {
         return assistAid;
     }
 
+    /**
+     * 协单人员
+     */
     public void setAssistAid(String assistAid) {
         this.assistAid = assistAid;
     }
 
+    /**
+     * 协单人员
+     */
     public String getAssistAidName() {
         return assistAidName;
     }
 
+    /**
+     * 协单人员
+     */
     public void setAssistAidName(String assistAidName) {
         this.assistAidName = assistAidName;
     }
 
+    /**
+     * 主要公出编号
+     */
     public Integer getMainId() {
         return mainId;
     }
 
+    /**
+     * 主要公出编号
+     */
     public void setMainId(Integer mainId) {
         this.mainId = mainId;
     }
 
+    /**
+     * 主要公出发起人
+     */
     public String getMainName() {
         return mainName;
     }
 
+    /**
+     * 主要公出发起人
+     */
     public void setMainName(String mainName) {
         this.mainName = mainName;
     }
 
+    /**
+     * 驳回人员
+     */
     public String getRejectName() {
         return rejectName;
     }
 
+    /**
+     * 驳回人员
+     */
     public void setRejectName(String rejectName) {
         this.rejectName = rejectName;
     }
 
+    /**
+     * 协单助手
+     */
     public String getAssistantAid() {
         return assistantAid;
     }
 
+    /**
+     * 协单助手
+     */
     public void setAssistantAid(String assistantAid) {
         this.assistantAid = assistantAid;
     }
 
+    /**
+     * 协单助手名称
+     */
     public String getAssistantName() {
         return assistantName;
     }
 
+    /**
+     * 协单助手名称
+     */
     public void setAssistantName(String assistantName) {
         this.assistantName = assistantName;
     }
 
+    /**
+     * 再次公出
+     */
     public Integer getPublicAgain() {
         return publicAgain;
     }
 
+    /**
+     * 再次公出
+     */
     public void setPublicAgain(Integer publicAgain) {
         this.publicAgain = publicAgain;
     }
 
+    /**
+     * 审核时间
+     */
     public Date getAuditTime() {
         return auditTime;
     }
 
+    /**
+     * 审核时间
+     */
     public void setAuditTime(Date auditTime) {
         this.auditTime = auditTime;
     }
 
+    /**
+     * 客户类型 0新客户 1老客户
+     */
     public String getNewUser() {
         return newUser;
     }
 
+    /**
+     * 客户类型 0新客户 1老客户
+     */
     public void setNewUser(String newUser) {
         this.newUser = newUser;
     }
 
+    /**
+     * 签单数
+     */
     public String getSignSum() {
         return signSum;
     }
 
+    /**
+     * 签单数
+     */
     public void setSignSum(String signSum) {
         this.signSum = signSum;
     }
 
+    /**
+     * 公司名称
+     */
     public String getUserNames() {
         return userNames;
     }
 
+    /**
+     * 公司名称
+     */
     public void setUserNames(String userNames) {
         this.userNames = userNames;
     }
 
+    /**
+     * 公出对象 0企业 1园区
+     */
     public Integer getObjectType() {
         return objectType;
     }
 
+    /**
+     * 公出对象 0企业 1园区
+     */
     public void setObjectType(Integer objectType) {
         this.objectType = objectType;
     }
 
+    /**
+     * 公出分类 0不含他人客户 1待审核 2已审核
+     */
     public Integer getPublicType() {
         return publicType;
     }
 
+    /**
+     * 公出分类 0不含他人客户 1待审核 2已审核
+     */
     public void setPublicType(Integer publicType) {
         this.publicType = publicType;
     }
 
+    /**
+     * 公出企业地址
+     */
     public String getDistrictName() {
         return districtName;
     }
 
+    /**
+     * 公出企业地址
+     */
     public void setDistrictName(String districtName) {
         this.districtName = districtName;
     }
 
+    /**
+     * 打卡状态 0未打卡 1已打卡 2异常打卡(冗余)
+     */
     public Integer getClockIn() {
         return clockIn;
     }
 
+    /**
+     * 打卡状态 0未打卡 1已打卡 2异常打卡(冗余)
+     */
     public void setClockIn(Integer clockIn) {
         this.clockIn = clockIn;
     }
+
+    /**
+     * 0无需审核 1需要审核 2营销审核通过 3营销审核驳回
+     */
+    public Integer getTechStartProcess() {
+        return techStartProcess;
+    }
+
+    /**
+     * 0无需审核 1需要审核 2营销审核通过 3营销审核驳回
+     */
+    public void setTechStartProcess(Integer techStartProcess) {
+        this.techStartProcess = techStartProcess;
+    }
 }

+ 88 - 46
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -78,17 +78,24 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 //			in.setAssistAidName(getAssistAidName(in.getAssistAid()));
 			in.setMainName(my.getName());
 		}
+		Map checkOrderNo = checkOrderNoDuration(in);
+		boolean isValid = (boolean) checkOrderNo.get("code");
+		if (isValid){
+			in.setTechStartProcess(0);
+		}else {
+			in.setTechStartProcess(1);
+		}
 		publicReleaseMapper.insertSelective(in);
 		List<PublicReleaseDetails> prdList=new ArrayList<>();
 		List<User> users=new ArrayList<>();
-		StringBuffer str =new StringBuffer();
+		StringBuilder str =new StringBuilder();
 		if (in.getUids()!=null){
 			List<String> split = Arrays.asList(in.getUids().split(","));
 			int userCount=split.size();
 			Double duration = in.getDuration();
 			//计算平均
 			double d = durationSum(duration, userCount);
-			Integer index=1;
+			int index=1;
 			//获取非已企业公出需要的审核人员
 			for (String s : split) {
 				PublicReleaseDetails prd=new PublicReleaseDetails();
@@ -130,8 +137,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		String userNames=str.substring(0,str.length()-1);
 		in.setUserNames(userNames);
 		addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
-		Map<String, Object> map=addPublicReleaseLog(my, in,userNames,date,users);
-		return map;
+        return (Map<String, Object>) addPublicReleaseLog(my, in,userNames,date,users,checkOrderNo);
 	}
 
 	private void addPublicExamine(Integer id, String aid) {
@@ -175,53 +181,78 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	 * @param nickname	客户名称
 	 * @param date	时间
 	 */
-	private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date,List<User> users) {
-		//获取公出审核人
-		Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
-		String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
-		//默认上级审核
-		AtomicReference<Integer> status= new AtomicReference<>(1);
-		String formatDate = DateUtils.formatDate(in.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
-		Map<String, Object>map=new HashMap<String, Object>();
-		//不是业务员
-		if (in.getType()==0){
-			if (my.getPublicPurview()==0){
-				users.forEach(u->{
-					if (!u.getAid().equals(my.getId())){
-						StringBuffer str2=new StringBuffer();
-						str2=str2.append(my.getName()).append("(需审核),准备公出您的企业");
-						str2=str2.append("[").append(u.getNickname()).append("]!!!。");
-						sendEmailAndNoticeAndSoucket(u.getAid(),3,str2.toString());
-						Admin admin = adminMapper.selectByPrimaryKey(u.getAid());
-						if (in.getType()==0){
-							//不是自己的企业则需要审核并设置非自己客户待审核
-							addPublicExamine(in.getId(), admin);
-							if(in.getPublicType()==null|| in.getPublicType()==0)in.setPublicType(1);
+	private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date,List<User> users,
+													Map<String,Object>  checkOrderNo) {
+			Map<String, Object>map=new HashMap<String, Object>();
+			//无需订单负责人审核
+		if (in.getTechStartProcess()==0){
+			//获取公出审核人
+			Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
+			String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
+			//默认上级审核
+			AtomicReference<Integer> status= new AtomicReference<>(1);
+			String formatDate = DateUtils.formatDate(in.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+			//不是业务员
+			if (in.getType()==0){
+				if (my.getPublicPurview()==0){
+					users.forEach(u->{
+						if (!u.getAid().equals(my.getId())){
+							StringBuffer str2=new StringBuffer();
+							str2=str2.append(my.getName()).append("(需审核),准备公出您的企业");
+							str2=str2.append("[").append(u.getNickname()).append("]!!!。");
+							sendEmailAndNoticeAndSoucket(u.getAid(),3,str2.toString());
+							Admin admin = adminMapper.selectByPrimaryKey(u.getAid());
+							if (in.getType()==0){
+								//不是自己的企业则需要审核并设置非自己客户待审核
+								addPublicExamine(in.getId(), admin);
+								if(in.getPublicType()==null|| in.getPublicType()==0)in.setPublicType(1);
+							}
+							pushNoticeAndSoucketAndEmail(my, in, date, admin, str, map);
+							status.set(0);
 						}
-						pushNoticeAndSoucketAndEmail(my, in, date, admin, str, map);
-						status.set(0);
-					}
-				});
-			}else {
-				users.forEach(u->{
-					if (!u.getAid().equals(my.getId())){
-						StringBuffer str2=new StringBuffer();
-						str2=str2.append(my.getName()).append("计划公出您的企业").append(u.getNickname())
-								.append(",").append(formatDate).append("【小程序端广播提示】");
-						sendNoticeAndSoucket(u.getAid(),3,str2.toString());
-					}
-				});
+					});
+				}else {
+					users.forEach(u->{
+						if (!u.getAid().equals(my.getId())){
+							StringBuffer str2=new StringBuffer();
+							str2=str2.append(my.getName()).append("计划公出您的企业").append(u.getNickname())
+									.append(",").append(formatDate).append("【小程序端广播提示】");
+							sendNoticeAndSoucket(u.getAid(),3,str2.toString());
+						}
+					});
 
+				}
+			}
+			if (status.get()==1){
+				pushNoticeAndSoucketAndEmail(my, in, date, a, str, map);
 			}
-		}
-		if (status.get()==1){
-			pushNoticeAndSoucketAndEmail(my, in, date, a, str, map);
-		}
 			publicReleaseMapper.updateByPrimaryKeySelective(in);
-			map.put("data", publicReleaseMapper.selectDtails(in.getId()));
+		}else {
+			TOrderNew tOrderNew = tOrderNewMapper.selectByPrimaryKey(in.getOrderNo());
+			String salesmanId = tOrderNew.getSalesmanId();
+			Admin a = adminMapper.selectByPrimaryKey(salesmanId);
+			CheckOrderNoOut data = (CheckOrderNoOut) checkOrderNo.get("data");
+			String format = getString(my, data);
+			pushNoticeAndSoucketAndEmail(my, in, date, a, format, map);
+		}
+		map.put("data", publicReleaseMapper.selectDtails(in.getId()));
 		return map;
 	}
 
+	private String getString(AdminListBo my, CheckOrderNoOut data) {
+		String amountName="";
+		if (data.getAmountType()==0)amountName="低于1万";
+		if (data.getAmountType()==1)amountName="在1~3万";
+		if (data.getAmountType()==2)amountName="在3~5万";
+		if (data.getAmountType()==3)amountName="在5~10万";
+		String format = String.format("%s准备公出%s(%s)," +
+						"总计公出:%s人,%s次,%s时。本合同%s,本次公出申请,已超出%s小时。超出公出时长,将计入您的第三方成本," +
+						"从奖金计算基数中扣除!请确认是否同意本次公出?", my.getName(), data.getUserName(), data.getContractNo(),
+				data.getPeopleCount(), data.getTimesCount(), data.getDurationCount().stripTrailingZeros(), amountName,
+				data.getDurationMax());
+		return format;
+	}
+
 	/**
 	 *
 	 * @param my 发送人信息
@@ -346,9 +377,20 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 				publicExamineMapper.updateByPridSelective(pe);
 			}
 			AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
-
+			Map checkOrderNo=new HashMap();
+			if (in.getType()==1){
+				checkOrderNo = checkOrderNoDuration(in);
+				boolean isValid = (boolean) checkOrderNo.get("code");
+				if (isValid){
+					in.setTechStartProcess(0);
+				}else {
+					in.setTechStartProcess(1);
+				}
+			}else {
+				in.setTechStartProcess(0);
+			}
 			//重新发起
-			addPublicReleaseLog(my,in,in.getUserNames(),date,uses);
+			addPublicReleaseLog(my,in,in.getUserNames(),date,uses,checkOrderNo);
 		}else {
 			List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
 			List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);