|
|
@@ -2,10 +2,12 @@ package com.goafanti.weChat.service.impl;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
import com.goafanti.common.dao.*;
|
|
|
import com.goafanti.order.service.OrderService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -154,8 +156,9 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @param type 类型
|
|
|
*/
|
|
|
private void sendEmail(AdminListBo my, Admin a,Integer type) {
|
|
|
- String title="外出申请提醒";
|
|
|
+ String title="";
|
|
|
if (type==0) title="外出申请驳回提醒";
|
|
|
+ else if (type==1) title="外出申请提醒";
|
|
|
else if (type==2) title="外出申请同意提醒";
|
|
|
if (SendEmailUtil.isEmail(a.getEmail())) {
|
|
|
EmailBo email=new EmailBo(title,a.getEmail() , my.getDepartmentName(), my.getName(),"详情请登录微信打卡小程序查看,谢谢!") ;
|
|
|
@@ -200,7 +203,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
|
|
|
}else {
|
|
|
log.setStatus(PublicReleaseLog.states.cx.getCode());
|
|
|
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId());
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
|
|
|
for (PublicRelease out : list) {
|
|
|
addpublicLog(out.getId(), PublicReleaseLog.states.sc.getCode(), "修改撤销协单");
|
|
|
}
|
|
|
@@ -253,7 +256,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
if (use.getAssist()==1){
|
|
|
pushPublicReleaseAssist(use,status,date);
|
|
|
}else if (use.getAssist()==0){
|
|
|
- publicReleaseMapper.updateStatusByMainId(3,use.getId());
|
|
|
+ publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
|
|
|
}
|
|
|
}
|
|
|
str=str.append(remarks);
|
|
|
@@ -354,7 +357,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
private void pushPublicReleaseAssist(PublicRelease use,Integer status,Date date) {
|
|
|
Integer useId=use.getId();
|
|
|
if (use.getAssistAid()!=null){
|
|
|
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(use.getId());
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(use.getId(),3,null);
|
|
|
String []ss=use.getAssistAid().split(",");
|
|
|
//数据库与传入比对,如果不存在就标记撤销 ,如果存在就修改成
|
|
|
for (PublicRelease out : list) {
|
|
|
@@ -653,4 +656,126 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int addAssistant(Integer id,String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ if (p.getAssistantAid()!=null){
|
|
|
+ list =Arrays.asList(p.getAssistantAid().split(","));
|
|
|
+ if (list.contains(aid)){
|
|
|
+ throw new BusinessException("人员已经存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String sname = pushAssistant(aid, list,0);
|
|
|
+ String said =String.join(",",list);
|
|
|
+ addAssistantPublicRelease(p,aid);
|
|
|
+ return updateAssistant(p, said, sname);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addAssistantPublicRelease(PublicRelease p, String aid) {
|
|
|
+ PublicRelease newP= new PublicRelease();
|
|
|
+ BeanUtils.copyProperties(p,newP);
|
|
|
+ newP.setId(null);
|
|
|
+ newP.setAid(aid);
|
|
|
+ newP.setType(4);
|
|
|
+ publicReleaseMapper.insertSelective(newP);
|
|
|
+ addpublicLog(newP.getId(),PublicReleaseLog.states.fq.getCode(),"发起技术协助。");
|
|
|
+ addWeChatNotice( aid,1,"发起技术协助。",newP.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param aid 接受者
|
|
|
+ * @param type 状态 0驳回 1发起 2同意 3撤销
|
|
|
+ * @param str 备注
|
|
|
+ * @param prid 公出编号
|
|
|
+ */
|
|
|
+ private void addWeChatNotice(String aid,Integer type,String str,Integer prid){
|
|
|
+ Admin recipient = adminMapper.selectByPrimaryKey(aid);
|
|
|
+ addWeChatNotice( recipient, type, str, prid);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param recipient 接受者
|
|
|
+ * @param type 状态 0驳回 1发起 2同意
|
|
|
+ * @param str
|
|
|
+ */
|
|
|
+ private Integer addWeChatNotice(Admin recipient,Integer type,String str,Integer prid){
|
|
|
+ AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
+ String openid=recipient.getOpenId();
|
|
|
+ str=new StringBuffer("[").append(my.getName()).append("]").append(str).toString();
|
|
|
+ sendNoticeAndSoucket(recipient.getId(),NoticeStatus.PUBLIC_RELEASE_START.getCode(),str);
|
|
|
+ if (type==0||type==2){
|
|
|
+ if (openid!=null) {
|
|
|
+ Integer res= weChatUtils.addNotice(openid, type,prid,new Date(),my.getName(),str);
|
|
|
+ return res;
|
|
|
+ }else {
|
|
|
+ sendEmail(my, recipient,type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int updateAssistant(PublicRelease p, String said, String sname) {
|
|
|
+ PublicRelease newPr=new PublicRelease();
|
|
|
+ newPr.setId(p.getId());
|
|
|
+ newPr.setAssistantAid(said);
|
|
|
+ newPr.setAssistantName(sname);
|
|
|
+ if (p.getMainId()!=null){
|
|
|
+ PublicRelease mianPr=new PublicRelease();
|
|
|
+ mianPr.setId(p.getMainId());
|
|
|
+ mianPr.setAssistantAid(said);
|
|
|
+ mianPr.setAssistantName(sname);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(mianPr);
|
|
|
+ }
|
|
|
+ return publicReleaseMapper.updateByPrimaryKeySelective(newPr);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param aid 元素
|
|
|
+ * @param list 集合
|
|
|
+ * @param type 0新增 1删除
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String pushAssistant(String aid, List<String> list,Integer type) {
|
|
|
+ StringBuffer sb=new StringBuffer();
|
|
|
+ if(type==0){
|
|
|
+ list.add(aid);
|
|
|
+ }else if (type==1){
|
|
|
+ list=list.stream().filter(s -> !s.equals(aid)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ for (String s : list) {
|
|
|
+ sb.append(adminMapper.selectByPrimaryKey(s).getName());
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int deleteAssistant(Integer id, String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ List<String> list=Arrays.asList(p.getAssistantAid().split(","));
|
|
|
+ if (!list.contains(aid)){
|
|
|
+ throw new BusinessException("人员不存在");
|
|
|
+ }
|
|
|
+ String sname = pushAssistant(aid, list,1);
|
|
|
+ String said =String.join(",",list);
|
|
|
+ deleteAssistantPulicRelease(p,aid);
|
|
|
+ return updateAssistant(p, said, sname);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteAssistantPulicRelease(PublicRelease p, String aid) {
|
|
|
+ publicReleaseMapper.updateStatusByMainId(3,4,p.getMainId(),aid);
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(p.getMainId(), 4, aid);
|
|
|
+ for (PublicRelease pr : list) {
|
|
|
+ addpublicLog(pr.getId(),PublicReleaseLog.states.cx.getCode(),"撤销技术协助。");
|
|
|
+ }
|
|
|
+ addWeChatNotice( aid,3,"撤销技术协助。",p.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|