|
|
@@ -108,115 +108,40 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
List<User> users=new ArrayList<>();
|
|
|
StringBuilder str =new StringBuilder();
|
|
|
//判定是单独协单还是一起协单
|
|
|
- if (in.getType()==0&&in.getAssist()==4){
|
|
|
- String[] split = in.getAssistAid().split(",");
|
|
|
- List<sendListBo> aidList = new ArrayList<>();
|
|
|
-
|
|
|
- //每一个协单都是单独的一份
|
|
|
- for (String s : split) {
|
|
|
- Admin publicAdmin = adminMapper.selectByPrimaryKey(s);
|
|
|
- in.setAid(s);
|
|
|
- in.setType(3);
|
|
|
- in.setMainName(my.getName());
|
|
|
- in.setAssistProcess(2);
|
|
|
- publicReleaseMapper.insert(in);
|
|
|
- addPRD(in, users, str, prdList);
|
|
|
- addPublicReleaseDateClock(in);
|
|
|
- String userNames=str.substring(0,str.length()-1);
|
|
|
- in.setUserNames(userNames);
|
|
|
- PublicRelease updateName=new PublicRelease();
|
|
|
- updateName.setId(in.getId());
|
|
|
- updateName.setUserNames(userNames);
|
|
|
- publicReleaseMapper.update(updateName);
|
|
|
- addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起[仅技术协单公出]申请");
|
|
|
- sendNoticeAndSoucket(in.getAid(),1, "["+my.getName()+"]发起["+userNames+"]的发起[仅技术协单公出]邀请。");
|
|
|
- List<AdminPublicReviewerBo> adminPublicReviewerBos = adminPublicReviewerMapper.selectByAid(in.getAid());
|
|
|
- //通知技术协单人
|
|
|
- //处理通知技术协单审核人
|
|
|
- adminPublicReviewerBos=adminPublicReviewerBos.stream().filter(e -> e.getType() == 1).collect(Collectors.toList());
|
|
|
- //如果没有直接改变状态
|
|
|
- if (adminPublicReviewerBos.size()==0){
|
|
|
- addpublicLog(in.getId(), PublicReleaseLog.states.ty.getCode(), "未设置技术协单审核人,跳过审核");
|
|
|
-// sendNoticeAndSoucket(my.getId(), 2, "你发起的["+userNames+"]仅技术协单公出申请,已通过。");
|
|
|
- PublicRelease updateStatus=new PublicRelease();
|
|
|
- updateStatus.setId(in.getId());
|
|
|
- updateStatus.setAssistProcess(4);
|
|
|
- updateStatus.setStatus(2);
|
|
|
- publicReleaseMapper.update(updateStatus);
|
|
|
- }else {
|
|
|
- for (AdminPublicReviewerBo adminPublicReviewerBo : adminPublicReviewerBos) {
|
|
|
- if (aidList.contains(adminPublicReviewerBo.getAid())==false){
|
|
|
- sendListBo bo =new sendListBo(adminPublicReviewerBo.getAid(),
|
|
|
- s,in.getId(),userNames);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- if (!aidList.isEmpty()){
|
|
|
- List<Integer> listMap=new ArrayList<>();
|
|
|
- for (sendListBo e : aidList) {
|
|
|
- Admin a = adminMapper.selectByPrimaryKey(e.getAid());
|
|
|
- sendNoticeAndSoucket(e.getAid(),1, "["+my.getName()+"]发起["+e.getUserNames()+"]仅技术协单公出申请,请及时审核。");
|
|
|
- if (a.getOpenId() !=null) {
|
|
|
- Integer res= weChatUtils.addNotice(a.getOpenId(), in.getStatus(), e.getPrid(), date, my.getName(),"["+ my.getName()+"]发起仅协单申请");
|
|
|
- if (res!=0) {
|
|
|
- sendEmail(my, a,1);
|
|
|
- }
|
|
|
- //返回微信错误码
|
|
|
- listMap.add(res);
|
|
|
- }else {
|
|
|
- //返回没有绑定微信
|
|
|
- sendEmail(my, a,1);
|
|
|
- listMap.add(2);
|
|
|
- }
|
|
|
- }
|
|
|
- map.put("code", listMap);
|
|
|
- }else {
|
|
|
- map.put("code", 0);
|
|
|
- }
|
|
|
- return map;
|
|
|
- }else {
|
|
|
- in.setAid(TokenManager.getAdminId());
|
|
|
- if (in.getAssist()==1){
|
|
|
+ in.setAid(TokenManager.getAdminId());
|
|
|
+ if (in.getAssist()==1){
|
|
|
// in.setAssistAidName(getAssistAidName(in.getAssistAid()));
|
|
|
- in.setMainName(my.getName());
|
|
|
- in.setAssistProcess(1);
|
|
|
- }
|
|
|
- if (in.getType() == 1) {
|
|
|
- //技术公出
|
|
|
- checkOrderNo = checkOrderNoDuration(in,my,1);
|
|
|
- boolean isValid = (boolean) checkOrderNo.get("code");
|
|
|
- if (isValid){
|
|
|
- in.setTechStartProcess(0);
|
|
|
- }else {
|
|
|
- in.setTechStartProcess(1);
|
|
|
- }
|
|
|
- }
|
|
|
- publicReleaseMapper.insertSelective(in);
|
|
|
- if (in.getType()==1&&in.getOrderNo()!=null){
|
|
|
- TOrderNew tOrderNew = tOrderNewMapper.selectByPrimaryKey(in.getOrderNo());
|
|
|
- orderNewService.pushOrderPublicReleaseCount(tOrderNew);
|
|
|
+ in.setMainName(my.getName());
|
|
|
+ in.setAssistProcess(1);
|
|
|
+ }
|
|
|
+ if (in.getType() == 1) {
|
|
|
+ //技术公出
|
|
|
+ checkOrderNo = checkOrderNoDuration(in,my,1);
|
|
|
+ boolean isValid = (boolean) checkOrderNo.get("code");
|
|
|
+ if (isValid){
|
|
|
+ in.setTechStartProcess(0);
|
|
|
+ }else {
|
|
|
+ in.setTechStartProcess(1);
|
|
|
}
|
|
|
- addPRD(in, users, str, prdList);
|
|
|
- addPublicReleaseDateClock(in);
|
|
|
- String userNames=str.substring(0,str.length()-1);
|
|
|
- in.setUserNames(userNames);
|
|
|
- PublicRelease updateName=new PublicRelease();
|
|
|
- updateName.setId(in.getId());
|
|
|
- updateName.setUserNames(userNames);
|
|
|
- publicReleaseMapper.update(updateName);
|
|
|
- addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
|
|
|
- pushPublicCarbonCopy(in, my, userNames);
|
|
|
- return (Map<String, Object>) addPublicReleaseLog(my, in,userNames,date,users,checkOrderNo);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }else if (in.getType() == 2) {
|
|
|
|
|
|
+ }
|
|
|
+ publicReleaseMapper.insertSelective(in);
|
|
|
+ if (in.getType()==1&&in.getOrderNo()!=null){
|
|
|
+ TOrderNew tOrderNew = tOrderNewMapper.selectByPrimaryKey(in.getOrderNo());
|
|
|
+ orderNewService.pushOrderPublicReleaseCount(tOrderNew);
|
|
|
+ }
|
|
|
+ addPRD(in, users, str, prdList);
|
|
|
+ addPublicReleaseDateClock(in);
|
|
|
+ String userNames=str.substring(0,str.length()-1);
|
|
|
+ in.setUserNames(userNames);
|
|
|
+ PublicRelease updateName=new PublicRelease();
|
|
|
+ updateName.setId(in.getId());
|
|
|
+ updateName.setUserNames(userNames);
|
|
|
+ publicReleaseMapper.update(updateName);
|
|
|
+ addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
|
|
|
+ pushPublicCarbonCopy(in, my, userNames);
|
|
|
+ return (Map<String, Object>) addPublicReleaseLog(my, in,userNames,date,users,checkOrderNo);
|
|
|
}
|
|
|
|
|
|
private void addPRD(InputPublicRelease in, List<User> users, StringBuilder str, List<PublicReleaseDetails> prdList) {
|
|
|
@@ -559,6 +484,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
throw new BusinessException("该公出已签到,无法取消");
|
|
|
}
|
|
|
}
|
|
|
+ pushUpdatePublic(in, uses, use, log, userNames, date, checkOrderNo);
|
|
|
}else if (in.getAssist()==0){
|
|
|
publicReleaseMapper.updateAssist(in);
|
|
|
in.setAssistProcess(0);
|
|
|
@@ -568,62 +494,80 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
throw new BusinessException("该协单公出已打卡,无法取消");
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (in.getUids()!=null){
|
|
|
- List<String> split = Arrays.asList(in.getUids().split(","));
|
|
|
- List<OutPublicReleaseDetails> prList = publicReleaseDetailsMapper.selectByPrid(in.getId());
|
|
|
- uses=pushPublicReleaseDetails(split,prList,use,in);
|
|
|
- }
|
|
|
- in.setStatus(1);
|
|
|
- log.setStatus(PublicReleaseLog.states.xg.getCode());
|
|
|
- in.setUpdateStatus(1);
|
|
|
-
|
|
|
- //如果是业务切公出则撤销营销审核与审核人
|
|
|
- pushUpdateType(in,use);
|
|
|
- //如果是业务公出,切审核状态为其他,则重置审核
|
|
|
- if(in.getType()==0&&(use.getPublicType()==2||use.getPublicType()==3)){
|
|
|
- in.setPublicType(1);
|
|
|
- PublicExamine pe=new PublicExamine();
|
|
|
- pe.setPrid(in.getId());
|
|
|
- pe.setStatus(0);
|
|
|
- publicExamineMapper.updateByPridSelective(pe);
|
|
|
- }
|
|
|
- //处理协单,修改,正常不存在协单,反想操作有协单需要单独处理
|
|
|
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
|
|
|
- String[] split = in.getAssistAid().split(",");
|
|
|
- if (split.length==0){
|
|
|
- for (PublicRelease e : list) {
|
|
|
+ pushUpdatePublic(in, uses, use, log, userNames, date, checkOrderNo);
|
|
|
+ }else if (in.getAssist()==4){
|
|
|
+ List<PublicRelease> publicReleases = publicReleaseMapper.selectByMainId(in.getId(), null, null);
|
|
|
+ for (PublicRelease e : publicReleases) {
|
|
|
if (e.getClockIn()==1){
|
|
|
- throw new BusinessException("协单打卡不能删除");
|
|
|
+ throw new BusinessException("该协单公出已打卡,无法取消");
|
|
|
}
|
|
|
}
|
|
|
- for (PublicRelease e : list) {
|
|
|
- publicReleaseMapper.deleteById(e.getId());
|
|
|
+ AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
+ publicReleaseMapper.deleteById(in.getId());
|
|
|
+ publicReleaseMapper.deleteByMainId(in.getId());
|
|
|
+ String[] split = in.getAssistAid().split(",");
|
|
|
+ List<sendListBo> aidList = new ArrayList<>();
|
|
|
+ List<PublicReleaseDetails> prdList=new ArrayList<>();
|
|
|
+ List<User> users=new ArrayList<>();
|
|
|
+ StringBuilder str =new StringBuilder();
|
|
|
+ //每一个协单都是单独的一份
|
|
|
+ for (String s : split) {
|
|
|
+ Admin publicAdmin = adminMapper.selectByPrimaryKey(s);
|
|
|
+ in.setAid(s);
|
|
|
+ in.setType(3);
|
|
|
+ in.setMainName(my.getName());
|
|
|
+ in.setAssistProcess(2);
|
|
|
+ publicReleaseMapper.insert(in);
|
|
|
+ addPRD(in, users, str, prdList);
|
|
|
+ addPublicReleaseDateClock(in);
|
|
|
+ userNames=str.substring(0,str.length()-1);
|
|
|
+ in.setUserNames(userNames);
|
|
|
+ PublicRelease updateName=new PublicRelease();
|
|
|
+ updateName.setId(in.getId());
|
|
|
+ updateName.setUserNames(userNames);
|
|
|
+ publicReleaseMapper.update(updateName);
|
|
|
+ addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起[仅技术协单公出]申请");
|
|
|
+ sendNoticeAndSoucket(in.getAid(),1, "["+my.getName()+"]发起["+userNames+"]的发起[仅技术协单公出]邀请。");
|
|
|
+ List<AdminPublicReviewerBo> adminPublicReviewerBos = adminPublicReviewerMapper.selectByAid(in.getAid());
|
|
|
+ //通知技术协单人
|
|
|
+ //处理通知技术协单审核人
|
|
|
+ adminPublicReviewerBos=adminPublicReviewerBos.stream().filter(e -> e.getType() == 1).collect(Collectors.toList());
|
|
|
+ //如果没有直接改变状态
|
|
|
+ if (adminPublicReviewerBos.size()==0){
|
|
|
+ addpublicLog(in.getId(), PublicReleaseLog.states.ty.getCode(), "未设置技术协单审核人,跳过审核");
|
|
|
+// sendNoticeAndSoucket(my.getId(), 2, "你发起的["+userNames+"]仅技术协单公出申请,已通过。");
|
|
|
+ PublicRelease updateStatus=new PublicRelease();
|
|
|
+ updateStatus.setId(in.getId());
|
|
|
+ updateStatus.setAssistProcess(4);
|
|
|
+ updateStatus.setStatus(2);
|
|
|
+ publicReleaseMapper.update(updateStatus);
|
|
|
+ }else {
|
|
|
+ for (AdminPublicReviewerBo adminPublicReviewerBo : adminPublicReviewerBos) {
|
|
|
+ if (aidList.contains(adminPublicReviewerBo.getAid())==false){
|
|
|
+ sendListBo bo =new sendListBo(adminPublicReviewerBo.getAid(),
|
|
|
+ s,in.getId(),userNames);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!aidList.isEmpty()){
|
|
|
+ for (sendListBo e : aidList) {
|
|
|
+ Admin a = adminMapper.selectByPrimaryKey(e.getAid());
|
|
|
+ sendNoticeAndSoucket(e.getAid(),1, "["+my.getName()+"]发起["+e.getUserNames()+"]仅技术协单公出申请,请及时审核。");
|
|
|
+ if (a.getOpenId() !=null) {
|
|
|
+ Integer res= weChatUtils.addNotice(a.getOpenId(), in.getStatus(), e.getPrid(), date, my.getName(),"["+ my.getName()+"]发起仅协单申请");
|
|
|
+ if (res!=0) {
|
|
|
+ sendEmail(my, a,1);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //返回没有绑定微信
|
|
|
+ sendEmail(my, a,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
-// List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);
|
|
|
|
|
|
-// for (PublicRelease out : list) {
|
|
|
-// addpublicLog(out.getId(), PublicReleaseLog.states.xg.getCode(), "修改公出信息,协单自动更改状态");
|
|
|
-// out.setStatus(1);
|
|
|
-// publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
-// }
|
|
|
-// for (PublicRelease out : list2) {
|
|
|
-// addpublicLog(out.getId(), PublicReleaseLog.states.xg.getCode(), "修改公出信息,协单助手自动更改状态");
|
|
|
-// out.setStatus(1);
|
|
|
-// publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
-// }
|
|
|
- AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
- if (StringUtils.isNotEmpty(my.getPublicCarbonCopy())){
|
|
|
- String str=String.format("营销员%s,%s - %s,将公出%s,请知悉!",my.getName(),
|
|
|
- DateUtils.formatDateYYYYMMddHHmm(in.getReleaseStart()),
|
|
|
- DateUtils.formatDateYYYYMMddHHmm(in.getReleaseEnd()),
|
|
|
- userNames);
|
|
|
- asyncUtils.addNoticAndEmail(NoticeStatus.PUBLIC_CARBON_COPY.getCode(),my.getPublicCarbonCopy()
|
|
|
- ,str);
|
|
|
- }
|
|
|
- //重新发起
|
|
|
- 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);
|
|
|
@@ -650,6 +594,63 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void pushUpdatePublic(InputPublicRelease in, List<User> uses, PublicRelease use, PublicReleaseLog log, String userNames, Date date, Map checkOrderNo) {
|
|
|
+ if (in.getUids()!=null){
|
|
|
+ List<String> split = Arrays.asList(in.getUids().split(","));
|
|
|
+ List<OutPublicReleaseDetails> prList = publicReleaseDetailsMapper.selectByPrid(in.getId());
|
|
|
+ uses =pushPublicReleaseDetails(split,prList, use, in);
|
|
|
+ }
|
|
|
+ in.setStatus(1);
|
|
|
+ log.setStatus(PublicReleaseLog.states.xg.getCode());
|
|
|
+ in.setUpdateStatus(1);
|
|
|
+
|
|
|
+ //如果是业务切公出则撤销营销审核与审核人
|
|
|
+ pushUpdateType(in, use);
|
|
|
+ //如果是业务公出,切审核状态为其他,则重置审核
|
|
|
+ if(in.getType()==0&&(use.getPublicType()==2|| use.getPublicType()==3)){
|
|
|
+ in.setPublicType(1);
|
|
|
+ PublicExamine pe=new PublicExamine();
|
|
|
+ pe.setPrid(in.getId());
|
|
|
+ pe.setStatus(0);
|
|
|
+ publicExamineMapper.updateByPridSelective(pe);
|
|
|
+ }
|
|
|
+ //处理协单,修改,正常不存在协单,反想操作有协单需要单独处理
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
|
|
|
+ String[] split = in.getAssistAid().split(",");
|
|
|
+ if (split.length==0){
|
|
|
+ for (PublicRelease e : list) {
|
|
|
+ if (e.getClockIn()==1){
|
|
|
+ throw new BusinessException("协单打卡不能删除");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (PublicRelease e : list) {
|
|
|
+ publicReleaseMapper.deleteById(e.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+// List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);
|
|
|
+
|
|
|
+// for (PublicRelease out : list) {
|
|
|
+// addpublicLog(out.getId(), PublicReleaseLog.states.xg.getCode(), "修改公出信息,协单自动更改状态");
|
|
|
+// out.setStatus(1);
|
|
|
+// publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
+// }
|
|
|
+// for (PublicRelease out : list2) {
|
|
|
+// addpublicLog(out.getId(), PublicReleaseLog.states.xg.getCode(), "修改公出信息,协单助手自动更改状态");
|
|
|
+// out.setStatus(1);
|
|
|
+// publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
+// }
|
|
|
+ AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
+ if (StringUtils.isNotEmpty(my.getPublicCarbonCopy())){
|
|
|
+ String str=String.format("营销员%s,%s - %s,将公出%s,请知悉!",my.getName(),
|
|
|
+ DateUtils.formatDateYYYYMMddHHmm(in.getReleaseStart()),
|
|
|
+ DateUtils.formatDateYYYYMMddHHmm(in.getReleaseEnd()),
|
|
|
+ userNames);
|
|
|
+ asyncUtils.addNoticAndEmail(NoticeStatus.PUBLIC_CARBON_COPY.getCode(),my.getPublicCarbonCopy()
|
|
|
+ ,str);
|
|
|
+ }
|
|
|
+ //重新发起
|
|
|
+ addPublicReleaseLog(my, in, in.getUserNames(), date, uses, checkOrderNo);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private void pushUpdateType(InputPublicRelease in, PublicRelease use) {
|