|
|
@@ -3,9 +3,9 @@ package com.goafanti.weChat.service.impl;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
|
|
|
-
|
|
|
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;
|
|
|
@@ -106,7 +106,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
|
|
|
String openid=a.getOpenId();
|
|
|
String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
|
|
|
- sendNoticeAndSoucket(a.getId(),NoticeStatus.PUBLIC_RELEASE_START.getCode(),str);
|
|
|
+ sendNoticeAndSoucket(a.getId(),1,str);
|
|
|
Map<String, Object>map=new HashMap<String, Object>();
|
|
|
map.put("data", publicReleaseMapper.selectDtails(in.getId(),null));
|
|
|
if (openid!=null) {
|
|
|
@@ -137,11 +137,14 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
|
|
|
|
|
|
private void sendNoticeAndSoucket(String id,Integer type,String content) {
|
|
|
+ Integer noticeType=NoticeStatus.PUBLIC_RELEASE_START.getCode();
|
|
|
+ if(type==0)noticeType=NoticeStatus.PUBLIC_RELEASE_NO.getCode();
|
|
|
+ else if (type==2)noticeType=NoticeStatus.PUBLIC_RELEASE_YES.getCode();
|
|
|
systemWebSocketHandler.sendMessageToUser(id, new TextMessage("unread"));
|
|
|
Notice n =new Notice();
|
|
|
n.setId(UUID.randomUUID().toString());
|
|
|
n.setAid(id);
|
|
|
- n.setNoticeType(type);
|
|
|
+ n.setNoticeType(noticeType);
|
|
|
n.setContent(content);
|
|
|
n.setReaded(0);//未读
|
|
|
asyncUtils.addNotice(n);
|
|
|
@@ -154,11 +157,12 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @param type 类型
|
|
|
*/
|
|
|
private void sendEmail(AdminListBo my, Admin a,Integer type) {
|
|
|
- String title="外出申请提醒";
|
|
|
- if (type==0) title="外出申请驳回提醒";
|
|
|
- else if (type==2) title="外出申请同意提醒";
|
|
|
+ StringBuffer title=new StringBuffer();
|
|
|
+ if (type==0) title=title.append("外出申请驳回提醒");
|
|
|
+ else if (type==1) title=title.append("外出申请提醒");
|
|
|
+ else if (type==2) title=title.append("外出申请同意提醒");
|
|
|
if (SendEmailUtil.isEmail(a.getEmail())) {
|
|
|
- EmailBo email=new EmailBo(title,a.getEmail() , my.getDepartmentName(), my.getName(),"详情请登录微信打卡小程序查看,谢谢!") ;
|
|
|
+ EmailBo email=new EmailBo(title.toString(),a.getEmail() , my.getDepartmentName(), my.getName(),"详情请登录微信打卡小程序查看,谢谢!") ;
|
|
|
asyncUtils.send(email);
|
|
|
}
|
|
|
}
|
|
|
@@ -182,30 +186,33 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
in.setMainStatus(1);
|
|
|
}
|
|
|
PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),null,in.getReason(),date);
|
|
|
+
|
|
|
if(in.getStatus()==null||in.getStatus()!=3) {
|
|
|
in.setStatus(1);
|
|
|
log.setStatus(PublicReleaseLog.states.xg.getCode());
|
|
|
in.setUpdateStatus(1);
|
|
|
- if(in.getAssist()==1){
|
|
|
- in.setAssistAidName(getAssistAidName(in.getAssistAid()));
|
|
|
- }else{
|
|
|
- in.setAssistAidName("");
|
|
|
-
|
|
|
- }
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
//新增修改日志
|
|
|
- publicReleaseLogMapper.insertSelective(log);
|
|
|
//重新发起
|
|
|
addPublicReleaseLog(my,in,u.getNickname(),date);
|
|
|
-
|
|
|
}else {
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
|
|
|
+ List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);
|
|
|
log.setStatus(PublicReleaseLog.states.cx.getCode());
|
|
|
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId());
|
|
|
for (PublicRelease out : list) {
|
|
|
addpublicLog(out.getId(), PublicReleaseLog.states.sc.getCode(), "修改撤销协单");
|
|
|
+ out.setStatus(3);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (PublicRelease out : list2) {
|
|
|
+ addpublicLog(out.getId(), PublicReleaseLog.states.sc.getCode(), "修改撤销协单助手");
|
|
|
+ out.setStatus(3);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(out);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
return publicReleaseMapper.updateByPrimaryKeySelective(in);
|
|
|
}
|
|
|
|
|
|
@@ -245,16 +252,27 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
StringBuffer str=new StringBuffer();
|
|
|
Admin ad=adminMapper.selectByPrimaryKey(aid);
|
|
|
str=str.append("(").append(ad.getName()).append(")");
|
|
|
+ Integer type=0;
|
|
|
+ String content="";
|
|
|
+ User u=userMapper.selectByPrimaryKey(use.getUid());
|
|
|
+ Admin a=adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
if (status==0){
|
|
|
str=str.append("驳回,");
|
|
|
+ if (use.getAssist()==2){
|
|
|
+ content="["+u.getNickname()+"]公司的外出申请,技术协单被["+ad.getName()+"]拒绝!";
|
|
|
+ }else {
|
|
|
+ content="["+u.getNickname()+"]公司的外出申请,未通过公出审核!";
|
|
|
+ }
|
|
|
}else if(status==2){
|
|
|
str=str.append("同意,");
|
|
|
//如果是协单公出主公出,在审核通过
|
|
|
if (use.getAssist()==1){
|
|
|
- pushPublicReleaseAssist(use,status,date);
|
|
|
+ pushPublicReleaseAssist(use,status,date,u,a);
|
|
|
}else if (use.getAssist()==0){
|
|
|
- publicReleaseMapper.updateStatusByMainId(3,use.getId());
|
|
|
+ publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
|
|
|
}
|
|
|
+
|
|
|
+ content="["+u.getNickname()+"]公司的外出申请,已通过审核!";
|
|
|
}
|
|
|
str=str.append(remarks);
|
|
|
p.setAuditInfo(str.toString());
|
|
|
@@ -262,23 +280,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
addpublicLog(id, status, remarks);
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
- Admin a=adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
- Integer type=0;
|
|
|
- String content="";
|
|
|
- User u=userMapper.selectByPrimaryKey(use.getUid());
|
|
|
- if (status==0) {
|
|
|
- type=NoticeStatus.PUBLIC_RELEASE_NO.getCode();
|
|
|
|
|
|
- if (use.getAssist()==2){
|
|
|
- content="["+u.getNickname()+"]公司的外出申请,技术协单被["+ad.getName()+"]拒绝!";
|
|
|
- }else {
|
|
|
- content="["+u.getNickname()+"]公司的外出申请,未通过公出审核!";
|
|
|
- }
|
|
|
- }else if(status==2) {
|
|
|
- type=NoticeStatus.PUBLIC_RELEASE_YES.getCode();
|
|
|
- content="["+u.getNickname()+"]公司的外出申请,已通过审核!";
|
|
|
- }
|
|
|
- sendNoticeAndSoucket(a.getId(),type,content);
|
|
|
+ sendNoticeAndSoucket(a.getId(),status,content);
|
|
|
if (my.getOpenId()!=null) {
|
|
|
if (remarks.length()>19) {
|
|
|
remarks=remarks.substring(0, 15)+"...";
|
|
|
@@ -305,7 +308,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
PublicRelease mainPublic= publicReleaseMapper.selectByPrimaryKey(use.getMainId());
|
|
|
Admin ad=adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
|
|
|
StringBuffer str=new StringBuffer();
|
|
|
- str=str.append("(").append(ad.getName()).append(")");
|
|
|
if (use.getAssist()!=2){
|
|
|
throw new BusinessException("只有技术公出能发起技术驳回");
|
|
|
}
|
|
|
@@ -315,7 +317,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
newMain.setStatus(4);
|
|
|
newMain.setRejectName(ad.getName());
|
|
|
newMain.setAuditInfo(str.toString());
|
|
|
- addpublicLog(mainPublic.getId(), status, remarks);
|
|
|
+ addWeChatNotice(mainPublic.getAid(),0,str.toString(),mainPublic.getId());
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(newMain);
|
|
|
PublicRelease up=new PublicRelease();
|
|
|
up.setId(id);
|
|
|
@@ -323,6 +325,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
up.setStatus(3);
|
|
|
addpublicLog(id, status, remarks);
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(up);
|
|
|
+ deleteAssistantPulicRelease(use,null);
|
|
|
return addNoticeAndWeChat(mainPublic.getId(), mainPublic.getAid(), str.toString(), status);
|
|
|
}
|
|
|
|
|
|
@@ -335,9 +338,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @return
|
|
|
*/
|
|
|
private Integer addNoticeAndWeChat(Integer id,String aid, String remarks, Integer status) {
|
|
|
- Integer noticeType=0;
|
|
|
- if (status ==0)noticeType=NoticeStatus.PUBLIC_RELEASE_NO.getCode();
|
|
|
- sendNoticeAndSoucket(aid,noticeType, remarks);
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(aid);
|
|
|
Admin a = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
|
|
|
if (my.getOpenId()!=null) {
|
|
|
@@ -351,60 +351,128 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void pushPublicReleaseAssist(PublicRelease use,Integer status,Date date) {
|
|
|
- Integer useId=use.getId();
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param use 原始公出信息
|
|
|
+ * @param status 状态
|
|
|
+ * @param date 时间
|
|
|
+ * @param u 客户
|
|
|
+ * @param a
|
|
|
+ */
|
|
|
+ private void pushPublicReleaseAssist(PublicRelease use,Integer status,Date date,User u,Admin a) {
|
|
|
if (use.getAssistAid()!=null){
|
|
|
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(use.getId());
|
|
|
- String []ss=use.getAssistAid().split(",");
|
|
|
- //数据库与传入比对,如果不存在就标记撤销 ,如果存在就修改成
|
|
|
- for (PublicRelease out : list) {
|
|
|
+ updatePushassist(use, status, date,u,a);
|
|
|
+ if(use.getAssistantAid()!=null){
|
|
|
+ updatepushAssistant(use,u,a);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理技术协单
|
|
|
+ * @param use
|
|
|
+ * @param status
|
|
|
+ * @param date
|
|
|
+ */
|
|
|
+ private void updatePushassist(PublicRelease use, Integer status, Date date, User u,Admin a) {
|
|
|
+ //协单
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(use.getId(),3,null);
|
|
|
+ String []ss= use.getAssistAid().split(",");
|
|
|
+ //数据库与传入比对,如果不存在就标记撤销 ,如果存在就修改成
|
|
|
+ for (PublicRelease out : list) {
|
|
|
+ boolean flag=false;
|
|
|
+ for (String s : ss) {
|
|
|
+ if (out.getAid().equals(s)){
|
|
|
+ flag=true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag){
|
|
|
+ PublicRelease in = new PublicRelease();
|
|
|
+ in.setId(out.getId());
|
|
|
+ in.setStatus(3);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(in);
|
|
|
+ StringBuffer str = new StringBuffer("[").append(a.getName()).append("]取消公出").append("[").append(u.getUsername()).append("]。");
|
|
|
+ PublicReleaseLog log = new PublicReleaseLog(in.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.cx.getCode(), str.toString(), date);
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
+ sendNoticeAndSoucket(out.getAid(),in.getStatus(),str.toString());
|
|
|
+ }else {
|
|
|
+ PublicRelease np = new PublicRelease();
|
|
|
+ BeanUtils.copyProperties(use,np);
|
|
|
+ np.setId(out.getId());
|
|
|
+ np.setMainId(null);
|
|
|
+ np.setClockIn(null);
|
|
|
+ np.setClockInTime(null);
|
|
|
+ np.setType(null);
|
|
|
+ np.setAssist(2);
|
|
|
+ np.setStatus(status);
|
|
|
+ np.setAid(null);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(np);
|
|
|
+ StringBuffer str = new StringBuffer("[").append(a.getName()).append("]修改了公出").append("[").append(u.getUsername()).append("]。");
|
|
|
+ PublicReleaseLog log = new PublicReleaseLog(np.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.xg.getCode(),str.toString(), date);
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
+ sendNoticeAndSoucket(out.getAid(),np.getStatus(),str.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String s : ss) {
|
|
|
+ boolean flag2 = false;
|
|
|
+ for (PublicRelease o : list) {
|
|
|
+ if (s.equals(o.getAid())) {
|
|
|
+ flag2 = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag2) {
|
|
|
+ PublicRelease np = new PublicRelease();
|
|
|
+ BeanUtils.copyProperties(use,np);
|
|
|
+ np.setAssist(2);
|
|
|
+ np.setAid(s);
|
|
|
+ np.setStatus(2);
|
|
|
+ np.setType(3);
|
|
|
+ np.setMainId(use.getMainId());
|
|
|
+ np.setId(null);
|
|
|
+ publicReleaseMapper.insertSelective(np);
|
|
|
+ StringBuffer str = new StringBuffer("[").append(a.getName()).append("]邀请你技术协单").append("[").append(u.getUsername()).append("]。");
|
|
|
+ PublicReleaseLog log = new PublicReleaseLog(np.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.fq.getCode(), str.toString(), date);
|
|
|
+ sendNoticeAndSoucket(np.getAid(),np.getStatus(),str.toString());
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理技术助手
|
|
|
+ * @param use
|
|
|
+ */
|
|
|
+ private void updatepushAssistant(PublicRelease use,User u,Admin a) {
|
|
|
+ List<String> list=new ArrayList();
|
|
|
+ list =new ArrayList<>(Arrays.asList(use.getAssistantAid().split(",")));
|
|
|
+ List<PublicRelease> deletelist = publicReleaseMapper.selectByMainId(use.getId(),4,null);
|
|
|
+ for (PublicRelease p : deletelist) {
|
|
|
boolean flag=false;
|
|
|
- for (String s : ss) {
|
|
|
- if (out.getAid().equals(s)){
|
|
|
+ for (String s : list) {
|
|
|
+ if (p.getAid().equals(s)){
|
|
|
flag=true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (!flag){
|
|
|
- PublicRelease in = new PublicRelease();
|
|
|
- in.setId(out.getId());
|
|
|
- in.setStatus(3);
|
|
|
- publicReleaseMapper.updateByPrimaryKeySelective(in);
|
|
|
- PublicReleaseLog log = new PublicReleaseLog(in.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.ty.getCode(), "同意修改,撤销此协单", date);
|
|
|
- publicReleaseLogMapper.insertSelective(log);
|
|
|
- }else {
|
|
|
- use.setId(out.getId());
|
|
|
- use.setAid(out.getAid());
|
|
|
- use.setMainId(null);
|
|
|
- use.setClockIn(null);
|
|
|
- use.setClockInTime(null);
|
|
|
- use.setType(null);
|
|
|
- use.setAssist(2);
|
|
|
- use.setStatus(status);
|
|
|
- publicReleaseMapper.updateByPrimaryKeySelective(use);
|
|
|
- PublicReleaseLog log = new PublicReleaseLog(out.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.ty.getCode(), "同意协单信息", date);
|
|
|
- publicReleaseLogMapper.insertSelective(log);
|
|
|
- }
|
|
|
- }
|
|
|
- for (String s : ss) {
|
|
|
- boolean flag2 = false;
|
|
|
- for (PublicRelease o : list) {
|
|
|
- if (s.equals(o.getAid())) {
|
|
|
- flag2 = true;
|
|
|
+ if (flag){
|
|
|
+ if (!use.getUid().equals(p.getUid()))p.setUid(use.getUid());
|
|
|
+ if (!use.getUserName().equals(p.getUserName())){
|
|
|
+ p.setUserName(use.getUserName());
|
|
|
+ p.setLatitude(use.getLatitude());
|
|
|
+ p.setLongitude(use.getLongitude());
|
|
|
}
|
|
|
- }
|
|
|
- if (!flag2) {
|
|
|
- use.setAssist(2);
|
|
|
- use.setAid(s);
|
|
|
- use.setStatus(2);
|
|
|
- use.setType(3);
|
|
|
- use.setMainId(useId);
|
|
|
- use.setId(null);
|
|
|
- publicReleaseMapper.insertSelective(use);
|
|
|
- PublicReleaseLog log = new PublicReleaseLog(use.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.ty.getCode(), "同意协单信息", date);
|
|
|
+ if(!use.getReleaseStart().equals(p.getReleaseStart()))p.setReleaseStart(use.getReleaseStart());
|
|
|
+ if (!use.getReleaseEnd().equals(p.getReleaseEnd()))p.setReleaseEnd(use.getReleaseEnd());
|
|
|
+ p.setStatus(2);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
+ StringBuffer str = new StringBuffer("[").append(a.getName()).append("]修改了").append("[").append(u.getUsername()).append("]。");
|
|
|
+ PublicReleaseLog log = new PublicReleaseLog(p.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.ty.getCode(), str.toString(), new Date());
|
|
|
+ sendNoticeAndSoucket(p.getAid(),p.getStatus(),str.toString());
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -657,10 +725,188 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
String clockTime=DateUtils.formatDate(date,AFTConstants.YYYYMMDDHHMMSS);
|
|
|
map.put("clockTime",clockTime);
|
|
|
}
|
|
|
- map.put("assistType",1);
|
|
|
map.put("aid",TokenManager.getAdminId());
|
|
|
List<OutPublicReleaseList> list = (List<OutPublicReleaseList>) findList("listPublicRelease",map,1,1);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int addAssistant(Integer id,String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(p.getAssistantAid())){
|
|
|
+ list =new ArrayList<>(Arrays.asList(p.getAssistantAid().split(",")));
|
|
|
+ }
|
|
|
+ String sname = pushAssistant(aid, list,0);
|
|
|
+ String said =String.join(",",list);
|
|
|
+ p.setAssistantAid(said);
|
|
|
+ p.setAssistantName(sname);
|
|
|
+ addAssistantPublicRelease(p,aid);
|
|
|
+ return updateAssistant(p, said, sname);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addAssistantPublicRelease(PublicRelease p, String aid) {
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(p.getMainId(), 4, aid);
|
|
|
+ PublicRelease newP= new PublicRelease();
|
|
|
+ if(list.isEmpty()){
|
|
|
+ BeanUtils.copyProperties(p,newP);
|
|
|
+ newP.setId(null);
|
|
|
+ newP.setAid(aid);
|
|
|
+ newP.setAssist(3);
|
|
|
+ newP.setType(4);
|
|
|
+ publicReleaseMapper.insertSelective(newP);
|
|
|
+ }else {
|
|
|
+ for (PublicRelease pr : list) {
|
|
|
+ if (pr.getAid().equals(aid)){
|
|
|
+ newP.setId(pr.getId());
|
|
|
+ newP.setStatus(2);
|
|
|
+ newP.setAssistantAid(pr.getAssistantAid());
|
|
|
+ newP.setAssistantName(pr.getAssistantName());
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(newP);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ User u=userMapper.selectByPrimaryKey(p.getUid());
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
+ str=str.append("公出").append("[").append(u.getUsername()).append("]").append("邀请你协助!");
|
|
|
+ addWeChatNotice( aid,1,str.toString(),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同意 3撤销
|
|
|
+ * @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();
|
|
|
+ if(type==3){
|
|
|
+ addpublicLog(prid,4,str);
|
|
|
+ }else {
|
|
|
+ addpublicLog(prid,type,str);
|
|
|
+ }
|
|
|
+ sendNoticeAndSoucket(recipient.getId(),type,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){
|
|
|
+ Iterator<String > it =list.iterator();
|
|
|
+ while (it.hasNext()){
|
|
|
+ if (it.next().equals(aid))
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String s : list) {
|
|
|
+ sb.append(adminMapper.selectByPrimaryKey(s).getName()).append(",");
|
|
|
+ }
|
|
|
+ return sb.length()>0?sb.substring(0,sb.length()-1):sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int deleteAssistant(Integer id, String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ if (p.getAssistantAid()==null){
|
|
|
+ throw new BusinessException("人员不存在");
|
|
|
+ }
|
|
|
+ List<String> list=new ArrayList<>(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);
|
|
|
+ User u=userMapper.selectByPrimaryKey(p.getUid());
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
+ str=str.append("公出").append("[").append(u.getUsername()).append("]").append("撤销了你的协助!");
|
|
|
+ for (PublicRelease pr : list) {
|
|
|
+ addWeChatNotice( pr.getAid(),3,str.toString(),pr.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean checkdeleteAssistant(Integer id, String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(p.getMainId(), 4, aid);
|
|
|
+ for (PublicRelease use : list) {
|
|
|
+ if (use.getClockIn()==1){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean checkaddAssistant(Integer id, String aid) {
|
|
|
+ PublicRelease p = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(p.getMainId(), 4, aid);
|
|
|
+ for (PublicRelease use : list) {
|
|
|
+ if (use.getAid().equals(aid)&&use.getStatus()!=3){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|