|
|
@@ -2,6 +2,7 @@ package com.goafanti.weChat.service.impl;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import com.goafanti.admin.service.DepartmentService;
|
|
|
import com.goafanti.common.dao.*;
|
|
|
@@ -10,6 +11,7 @@ import com.goafanti.weChat.bo.*;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.socket.TextMessage;
|
|
|
|
|
|
import com.goafanti.admin.bo.AdminListBo;
|
|
|
@@ -57,12 +59,16 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
private TOrderNewMapper tOrderNewMapper;
|
|
|
@Autowired
|
|
|
private DepartmentService departmentService;
|
|
|
+ @Autowired
|
|
|
+ private PublicExamineMapper publicExamineMapper;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Map<String, Object> addPublicRelease(InputPublicRelease in) {
|
|
|
Date date =new Date();
|
|
|
if (in.getPublicAgain()==null)in.setPublicAgain(0);
|
|
|
in.setCreateTime(date);
|
|
|
+ in.setPublicType(0);
|
|
|
in.setStatus(1);
|
|
|
in.setAid(TokenManager.getAdminId());
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
@@ -72,6 +78,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
publicReleaseMapper.insertSelective(in);
|
|
|
List<PublicReleaseDetails> prdList=new ArrayList<>();
|
|
|
+ List<User> users=new ArrayList<>();
|
|
|
StringBuffer str =new StringBuffer();
|
|
|
if (in.getUids()!=null){
|
|
|
List<String> split = Arrays.asList(in.getUids().split(","));
|
|
|
@@ -80,9 +87,11 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
//计算平均
|
|
|
double d = durationSum(duration, userCount);
|
|
|
Integer index=1;
|
|
|
+ //获取非已企业公出需要的审核人员
|
|
|
for (String s : split) {
|
|
|
PublicReleaseDetails prd=new PublicReleaseDetails();
|
|
|
User u=userMapper.selectByPrimaryKey(s);
|
|
|
+ users.add(u);
|
|
|
str.append(u.getNickname()).append(",");
|
|
|
if (u!=null&&u.getShareType()==2){
|
|
|
prd.setNewUser(1);
|
|
|
@@ -93,6 +102,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
prd.setMainStatus(1);
|
|
|
}else {
|
|
|
prd.setMainStatus(0);
|
|
|
+ if(in.getPublicType()==null||in.getPublicType()==0)in.setPublicType(1);
|
|
|
}
|
|
|
prd.setPrid(in.getId());
|
|
|
prd.setUid(s);
|
|
|
@@ -120,12 +130,37 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
PublicRelease upName=new PublicRelease();
|
|
|
upName.setId(in.getId());
|
|
|
upName.setUserNames(userNames);
|
|
|
- publicReleaseMapper.updateByPrimaryKeySelective(upName);
|
|
|
+ if (in.getPublicType()==1){
|
|
|
+ upName.setPublicType(1);
|
|
|
+ }
|
|
|
addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
|
|
|
- Map<String, Object> map=addPublicReleaseLog(my, in,userNames,date);
|
|
|
+ Map<String, Object> map=addPublicReleaseLog(my, in,userNames,date,users);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(upName);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ private void addPublicExamine(Integer id, String aid) {
|
|
|
+ Admin admin = adminMapper.selectByPrimaryKey(aid);
|
|
|
+ addPublicExamine(id,admin);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPublicExamine(Integer id, Admin a) {
|
|
|
+ List<PublicExamine> publicExamines = publicExamineMapper.selectByPrid(id);
|
|
|
+ boolean flag=false;
|
|
|
+ for (PublicExamine pe : publicExamines) {
|
|
|
+ if (pe.getAid().equals(a.getId())){
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag){
|
|
|
+ PublicExamine pe=new PublicExamine();
|
|
|
+ pe.setPrid(id);
|
|
|
+ pe.setAid(a.getId());
|
|
|
+ pe.setAname(a.getName());
|
|
|
+ pe.setStatus(0);
|
|
|
+ publicExamineMapper.insertSelective(pe);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private double durationSum(Double duration, Integer sum) {
|
|
|
@@ -145,26 +180,67 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @param nickname 客户名称
|
|
|
* @param date 时间
|
|
|
*/
|
|
|
- private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date ) {
|
|
|
+ private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date,List<User> users) {
|
|
|
+ //获取公出审核人
|
|
|
Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
|
|
|
- String openid=a.getOpenId();
|
|
|
String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
|
|
|
- sendNoticeAndSoucket(a.getId(),1,str);
|
|
|
+ //默认上级审核
|
|
|
+ AtomicReference<Integer> status= new AtomicReference<>(1);
|
|
|
Map<String, Object>map=new HashMap<String, Object>();
|
|
|
- map.put("data", publicReleaseMapper.selectDtails(in.getId()));
|
|
|
- if (openid!=null) {
|
|
|
- Integer res= weChatUtils.addNotice(openid, in.getStatus(),in.getId(),date,my.getName(),"["+my.getName()+"]发起外出申请");
|
|
|
+ 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());
|
|
|
+ //不是自己的企业则需要审核并设置非自己客户待审核
|
|
|
+ addPublicExamine(in.getId(), admin);
|
|
|
+ if(in.getPublicType()==null|| in.getPublicType()==0) in.setPublicType(1);
|
|
|
+ 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("业务员").append(my.getName()).append("(无需审核),准备公出您的企业");
|
|
|
+ str2=str2.append("[").append(u.getNickname()).append("]!!!");
|
|
|
+ sendNoticeAndSoucket(u.getAid(),3,str2.toString());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ if (status.get()==1){
|
|
|
+ pushNoticeAndSoucketAndEmail(my, in, date, a, str, map);
|
|
|
+ }
|
|
|
+ map.put("data", publicReleaseMapper.selectDtails(in.getId()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param my 发送人信息
|
|
|
+ * @param in 公出信息
|
|
|
+ * @param date 时间
|
|
|
+ * @param a 接受者信息
|
|
|
+ * @param str 站内信内容
|
|
|
+ * @param map 返回实体
|
|
|
+ */
|
|
|
+ private void pushNoticeAndSoucketAndEmail(AdminListBo my, PublicRelease in, Date date, Admin a, String str, Map<String, Object> map) {
|
|
|
+ sendNoticeAndSoucket(a.getId(),1, str);
|
|
|
+ if (a.getOpenId() !=null) {
|
|
|
+ Integer res= weChatUtils.addNotice(a.getOpenId(), in.getStatus(), in.getId(), date, my.getName(),"["+ my.getName()+"]发起外出申请");
|
|
|
if (res!=0) {
|
|
|
sendEmail(my, a,1);
|
|
|
}
|
|
|
map.put("code", res);
|
|
|
-
|
|
|
-
|
|
|
}else {
|
|
|
sendEmail(my, a,1);
|
|
|
map.put("code", 2);
|
|
|
}
|
|
|
- return map;
|
|
|
}
|
|
|
|
|
|
private String getAssistAidName(String assistAid) {
|
|
|
@@ -178,11 +254,28 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return sb.deleteCharAt(sb.length() - 1).toString();
|
|
|
}
|
|
|
|
|
|
+ private void sendEmailAndNoticeAndSoucket(String id,Integer type,String content){
|
|
|
+ sendNoticeAndSoucket(id,type,content);
|
|
|
+ Admin admin = adminMapper.selectByPrimaryKey(id);
|
|
|
+ String title="暂无标题";
|
|
|
+ if (type==3)title=NoticeStatus.PUBLIC_OTHERS_USER.getDesc();
|
|
|
+ EmailBo emailBo=new EmailBo(title,admin.getEmail(),content);
|
|
|
+ asyncUtils.send(emailBo);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param id 接受者编号
|
|
|
+ * @param type 状态 0驳回 1发起 2同意 3 公出他人企业
|
|
|
+ * @param content 内容
|
|
|
+ */
|
|
|
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();
|
|
|
+ else if (type==3)noticeType=NoticeStatus.PUBLIC_OTHERS_USER.getCode();
|
|
|
+ //触发通知有未读消息
|
|
|
systemWebSocketHandler.sendMessageToUser(id, new TextMessage("unread"));
|
|
|
Notice n =new Notice();
|
|
|
n.setId(UUID.randomUUID().toString());
|
|
|
@@ -210,6 +303,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public int updatePublicRelease(InputPublicRelease in) {
|
|
|
Date date = new Date();
|
|
|
@@ -220,13 +315,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
e.printStackTrace();
|
|
|
throw new BusinessException("转换异常");
|
|
|
}
|
|
|
+ List<User> uses=null;
|
|
|
PublicRelease use = publicReleaseMapper.selectByPrimaryKey(in.getId());
|
|
|
if (in.getUids()!=null){
|
|
|
List<String> split = Arrays.asList(in.getUids().split(","));
|
|
|
List<OutPublicReleaseDetails> prList = publicReleaseDetailsMapper.selectByPCid(in.getId());
|
|
|
- pushPublicReleaseDetails(split,prList,use,in);
|
|
|
+ uses=pushPublicReleaseDetails(split,prList,use,in);
|
|
|
}
|
|
|
-
|
|
|
String userNames=publicReleaseDetailsMapper.getNamesByPrid(in.getId());
|
|
|
PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),null,in.getReason(),date);
|
|
|
in.setUserNames(userNames);
|
|
|
@@ -234,10 +329,17 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
in.setStatus(1);
|
|
|
log.setStatus(PublicReleaseLog.states.xg.getCode());
|
|
|
in.setUpdateStatus(1);
|
|
|
+ if(use.getPublicType()==2||use.getPublicType()==3){
|
|
|
+ in.setPublicType(1);
|
|
|
+ PublicExamine pe=new PublicExamine();
|
|
|
+ pe.setPrid(in.getId());
|
|
|
+ pe.setStatus(0);
|
|
|
+ publicExamineMapper.updatePrid(pe);
|
|
|
+ }
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
//新增修改日志
|
|
|
//重新发起
|
|
|
- addPublicReleaseLog(my,in,in.getUserNames(),date);
|
|
|
+ addPublicReleaseLog(my,in,in.getUserNames(),date,uses);
|
|
|
}else {
|
|
|
List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
|
|
|
List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);
|
|
|
@@ -256,16 +358,22 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(in);
|
|
|
+
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- private void pushPublicReleaseDetails(List<String> split, List<OutPublicReleaseDetails> prList, PublicRelease use, InputPublicRelease in) {
|
|
|
+ private List<User> pushPublicReleaseDetails(List<String> split, List<OutPublicReleaseDetails> prList, PublicRelease use, InputPublicRelease in) {
|
|
|
//先删除,再修改个,再新增,有利于减少计算
|
|
|
deletePRD(split,prList);
|
|
|
publicReleaseDetailsMapper.updateDistrictByPrid(in);
|
|
|
- addPRD(split,prList,use);
|
|
|
+ List<User> users = addPRD(split, prList, use);
|
|
|
+
|
|
|
+
|
|
|
+ return users;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private void deletePRD(List<String> split, List<OutPublicReleaseDetails> prdList) {
|
|
|
for (OutPublicReleaseDetails prd : prdList) {
|
|
|
boolean flag=true;
|
|
|
@@ -285,9 +393,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @param prdList 修改前客户集
|
|
|
* @param use 原订单信息
|
|
|
*/
|
|
|
- private void addPRD(List<String> split, List<OutPublicReleaseDetails> prdList, PublicRelease use) {
|
|
|
+ private List<User> addPRD(List<String> split, List<OutPublicReleaseDetails> prdList, PublicRelease use) {
|
|
|
List<PublicReleaseDetails> addPrdList=new ArrayList<>();
|
|
|
+ List<User> users=new ArrayList<>();
|
|
|
+ Integer publicType = use.getPublicType();
|
|
|
for (String s : split) {
|
|
|
+ User u=userMapper.selectByPrimaryKey(s);
|
|
|
+ users.add(u);
|
|
|
boolean flag=true;
|
|
|
Integer id=null;
|
|
|
String districtName=null,latitude=null,longitude=null;
|
|
|
@@ -302,7 +414,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
if (flag){
|
|
|
PublicReleaseDetails prd=new PublicReleaseDetails();
|
|
|
- User u=userMapper.selectByPrimaryKey(s);
|
|
|
if (u!=null&&u.getShareType()==2){
|
|
|
prd.setNewUser(1);
|
|
|
}else {
|
|
|
@@ -321,9 +432,25 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
prd.setLongitude(longitude);
|
|
|
prd.setClockIn(0);
|
|
|
addPrdList.add(prd);
|
|
|
+ if (!use.getAid().equals(u.getAid())){
|
|
|
+ addPublicExamine(use.getId(), u.getAid());
|
|
|
+ if (publicType==1)publicType=1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
+ for (User u : users) {
|
|
|
+ str=str.append(use.getUserNames()).append(",");
|
|
|
+ }
|
|
|
+ if (publicType!=use.getPublicType()){
|
|
|
+ PublicRelease newP=new PublicRelease();
|
|
|
+ newP.setId(use.getId());
|
|
|
+ if (str.length()>1)newP.setUserNames(str.substring(0,str.length()-1));
|
|
|
+ newP.setPublicType(publicType);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(newP);
|
|
|
+ }
|
|
|
if (!addPrdList.isEmpty())publicReleaseDetailsMapper.insertBatch(addPrdList);
|
|
|
+ return users;
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@@ -345,63 +472,152 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
if(in.getClockIn()!=null) map.put("clockIn", in.getClockIn());
|
|
|
map.put("assist",in.getAssist()==null?0:in.getAssist());
|
|
|
Pagination<OutPublicReleaseList> p=(Pagination<OutPublicReleaseList>) findPage("listPublicRelease", "countPublicRelease", map, in.getPageNo(), in.getPageSize());
|
|
|
+ if(in.getType()==0||in.getType()==4){
|
|
|
+ pushExamines(p);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
return p;
|
|
|
}
|
|
|
|
|
|
+ private void pushExamines(Pagination<OutPublicReleaseList> p) {
|
|
|
+ List<OutPublicReleaseList> list = (List<OutPublicReleaseList>) p.getList();
|
|
|
+ if (!list.isEmpty()){
|
|
|
+ List<Integer> ids=new ArrayList<>();
|
|
|
+ list.forEach(e ->{ ids.add(e.getId()); });
|
|
|
+ List<PublicExamine> publicExamines = publicExamineMapper.selectByIds(ids);
|
|
|
+ for (OutPublicReleaseList e : list) {
|
|
|
+ if (!publicExamines.isEmpty()){
|
|
|
+ StringBuffer str =new StringBuffer();
|
|
|
+ for (PublicExamine pe : publicExamines) {
|
|
|
+ if (e.getId().equals(pe.getPrid())){
|
|
|
+ str=str.append(pe.getAname());
|
|
|
+ if (pe.getStatus()==0)str=str.append(" 未审核,");
|
|
|
+ if (pe.getStatus()==1)str=str.append(" 已审核,");
|
|
|
+ }
|
|
|
+ if (str.length()>1) e.setAdminExamine(str.substring(0,str.length()-1));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public int pushExaminePublicRelease(Integer id, Integer status, String remarks) {
|
|
|
+ @Transactional
|
|
|
+ public int pushExaminePublicRelease(Integer id, Integer status, String remarks,Integer examineType) {
|
|
|
PublicRelease p=new PublicRelease();
|
|
|
Date date =new Date();
|
|
|
+ boolean flag=false;
|
|
|
String aid=TokenManager.getAdminId();
|
|
|
p.setId(id);
|
|
|
- p.setStatus(status);
|
|
|
PublicRelease use=publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
if (use.getStatus()!=1) {
|
|
|
throw new BusinessException("只能修改发起的状态公出");
|
|
|
}
|
|
|
- StringBuffer str=new StringBuffer();
|
|
|
+ //当前审核人员
|
|
|
Admin ad=adminMapper.selectByPrimaryKey(aid);
|
|
|
+ //公出负责人
|
|
|
+ Admin a;
|
|
|
+ Admin publicAdmin =adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
+ a=publicAdmin;
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
str=str.append("(").append(ad.getName()).append(")");
|
|
|
- Integer type=0;
|
|
|
- String content="";
|
|
|
- Admin a=adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
- if (status==0){
|
|
|
- str=str.append("驳回,");
|
|
|
- if (use.getAssist()==2){
|
|
|
- content="["+use.getUserNames()+"]公司的外出申请,技术协单被["+ad.getName()+"]拒绝!";
|
|
|
- }else {
|
|
|
- content="["+use.getUserNames()+"]公司的外出申请,未通过公出审核!";
|
|
|
+ StringBuffer content=new StringBuffer().append("[").append(use.getUserNames()).append("]公司的外出申请,");
|
|
|
+ //上级审核
|
|
|
+ if(examineType==0){
|
|
|
+ p.setStatus(status);
|
|
|
+ if (status==0){
|
|
|
+ str=str.append("驳回,");
|
|
|
+ if (use.getAssist()==2){
|
|
|
+ content=content.append("技术协单被[").append(ad.getName()).append("]拒绝!");
|
|
|
+ }else {
|
|
|
+ content=content.append("未通过公出审核!");
|
|
|
+ }
|
|
|
+ if(use.getPublicType()>1){
|
|
|
+ p.setPublicType(1);
|
|
|
+ PublicExamine inpe=new PublicExamine();
|
|
|
+ inpe.setStatus(0);
|
|
|
+ inpe.setPrid(use.getId());
|
|
|
+ publicExamineMapper.updatePrid(inpe);
|
|
|
+ }
|
|
|
+ }else if(status==2){
|
|
|
+ str=str.append("同意,");
|
|
|
+ //如果是协单公出主公出,在审核通过
|
|
|
+ if (use.getAssist()==1){
|
|
|
+ pushPublicReleaseAssist(use,status,date,a);
|
|
|
+ }else if (use.getAssist()==0){
|
|
|
+ publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
|
|
|
+ }
|
|
|
+ content=content.append("已通过审核!");
|
|
|
}
|
|
|
- }else if(status==2){
|
|
|
- str=str.append("同意,");
|
|
|
- //如果是协单公出主公出,在审核通过
|
|
|
- if (use.getAssist()==1){
|
|
|
- pushPublicReleaseAssist(use,status,date,a);
|
|
|
- }else if (use.getAssist()==0){
|
|
|
- publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
|
|
|
+ str=str.append(remarks);
|
|
|
+ p.setAuditInfo(str.toString());
|
|
|
+ p.setAuditTime(date);
|
|
|
+ p.setRejectName(ad.getName());
|
|
|
+ addpublicLog(id, status, remarks);
|
|
|
+ flag=true;
|
|
|
+ //营销员审核
|
|
|
+ }else if (examineType==1){
|
|
|
+ //通知公出人切换成公出人审核人
|
|
|
+ a=adminMapper.selectByPrimaryKey(a.getReviewer());
|
|
|
+ if (status==2){//审核通过
|
|
|
+ str=str.append("同意公出我的企业,").append(remarks);
|
|
|
+ content=content.append("已通过审核,请尽快审核。");
|
|
|
+ List<PublicExamine> publicExamines = publicExamineMapper.selectByPrid(use.getId());
|
|
|
+ int x=0;
|
|
|
+ for (PublicExamine pe : publicExamines) {
|
|
|
+ if (pe.getAid().equals(aid)){
|
|
|
+ pe.setStatus(1);
|
|
|
+ PublicExamine newp=new PublicExamine();
|
|
|
+ newp.setId(pe.getId());
|
|
|
+ newp.setStatus(1);
|
|
|
+ publicExamineMapper.updateByPrimaryKeySelective(newp);
|
|
|
+ x++;
|
|
|
+ }else {
|
|
|
+ if (pe.getStatus()==1){
|
|
|
+ x++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (x==publicExamines.size()){
|
|
|
+ p.setPublicType(2);
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ addpublicLog(id, status, str.toString());
|
|
|
+
|
|
|
+ }else if (status==0){//审核驳回
|
|
|
+ //切换通知人公出负责人
|
|
|
+ a=publicAdmin;
|
|
|
+ str=str.append("不同意公出我的企业,").append(remarks);;
|
|
|
+ content=content.append("未通过审核,请修改后重新发起。");
|
|
|
+ p.setPublicType(3);
|
|
|
+ p.setStatus(0);
|
|
|
+ p.setAuditInfo(str.toString());
|
|
|
+ p.setRejectName(ad.getName());
|
|
|
+ addpublicLog(id, 0, str.toString());
|
|
|
}
|
|
|
-
|
|
|
- content="["+use.getUserNames()+"]公司的外出申请,已通过审核!";
|
|
|
}
|
|
|
- str=str.append(remarks);
|
|
|
- p.setAuditInfo(str.toString());
|
|
|
- p.setAuditTime(date);
|
|
|
- p.setRejectName(ad.getName());
|
|
|
- publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
- addpublicLog(id, status, remarks);
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
-
|
|
|
- sendNoticeAndSoucket(a.getId(),status,content);
|
|
|
- if (my.getOpenId()!=null) {
|
|
|
+ if (flag){
|
|
|
+ sendNoticeAndSoucket(a.getId(),status,content.toString());
|
|
|
+ }
|
|
|
+ if (p.getStatus()!=null||p.getPublicType()!=null){
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
+ }
|
|
|
+ if (a.getOpenId()!=null) {
|
|
|
if (remarks.length()>19) {
|
|
|
remarks=remarks.substring(0, 15)+"...";
|
|
|
}
|
|
|
- Integer res=weChatUtils.addNotice(a.getOpenId(),p.getStatus(),p.getId(),date,my.getName(),remarks);
|
|
|
+ Integer res=weChatUtils.addNotice(a.getOpenId(),status,p.getId(),date,my.getName(),remarks);
|
|
|
if (res!=0) {
|
|
|
sendEmail( my, a, status);
|
|
|
|
|
|
}
|
|
|
return res;
|
|
|
+ }else {
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -605,7 +821,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
* @param use
|
|
|
*/
|
|
|
private void updatepushAssistant(PublicRelease use,Admin a) {
|
|
|
- List<String> list=new ArrayList();
|
|
|
List<PublicRelease> uselist = publicReleaseMapper.selectByMainId(use.getId(),4,null);
|
|
|
for (PublicRelease p : uselist) {
|
|
|
if(!use.getReleaseStart().equals(p.getReleaseStart()))p.setReleaseStart(use.getReleaseStart());
|
|
|
@@ -619,7 +834,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
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);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -634,9 +848,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
public int pushPublicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks ,String uid) {
|
|
|
if (clockIn == null) clockIn = 1;
|
|
|
PublicRelease use = publicReleaseMapper.selectByPrimaryKey(id);
|
|
|
+ if (use.getPublicType()==1||use.getPublicType()==3){
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
List<OutPublicReleaseDetails> prdList = publicReleaseDetailsMapper.selectByPCid(id);
|
|
|
String str = "";
|
|
|
boolean flag=false;
|
|
|
+ Integer clockCount=0;
|
|
|
for (OutPublicReleaseDetails prd : prdList) {
|
|
|
if (prd.getUid().equals(uid)){
|
|
|
String aid = TokenManager.getAdminId();
|
|
|
@@ -669,8 +887,17 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
publicReleaseDetailsMapper.updateByPrimaryKeySelective(prd);
|
|
|
flag=true;
|
|
|
+ clockCount++;
|
|
|
+ }else if (prd.getClockIn()==1){
|
|
|
+ clockCount++;
|
|
|
}
|
|
|
}
|
|
|
+ if (prdList.size()==clockCount){
|
|
|
+ PublicRelease newp=new PublicRelease();
|
|
|
+ newp.setId(id);
|
|
|
+ newp.setClockIn(1);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(newp);
|
|
|
+ }
|
|
|
if (!flag){
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -679,25 +906,48 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
|
|
|
@Override
|
|
|
public OutPublicRelease dtails(Integer id) {
|
|
|
+ String aid=TokenManager.getAdminId();
|
|
|
//如果不是本人和审核人员则不返回信息
|
|
|
OutPublicRelease out=publicReleaseMapper.selectDtails(id);
|
|
|
+ List<PublicExamine> ps = publicExamineMapper.selectByPrid(out.getId());
|
|
|
+ out.setPeList(ps);
|
|
|
if(out!=null){
|
|
|
boolean flag=false;
|
|
|
//自己、审核人员与部门负责人可以查看
|
|
|
AdminListBo ab=adminMapper.getDeptNameByAid(out.getAid());
|
|
|
- if (!TokenManager.getAdminId().equals( out.getAid())&&
|
|
|
- !TokenManager.getAdminId().equals(out.getReviewer())&&
|
|
|
- !TokenManager.getAdminId().equals(ab.getDepManager())&&
|
|
|
+ if (!aid.equals( out.getAid())&&
|
|
|
+ !aid.equals(out.getReviewer())&&
|
|
|
+ !aid.equals(ab.getDepManager())&&
|
|
|
!TokenManager.hasRole(AFTConstants.TECH_FINANCE_DIRECTOR)){
|
|
|
flag=true;
|
|
|
}
|
|
|
+ //是否可以查看
|
|
|
+ if (!ps.isEmpty()){
|
|
|
+ for (PublicExamine p : ps) {
|
|
|
+ if (p.getAid().equals(aid)){
|
|
|
+ if (p.getStatus()==1)out.setMyExamine(1);
|
|
|
+ else out.setMyExamine(0);
|
|
|
+ flag=false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(flag){
|
|
|
out=null;
|
|
|
+ return out;
|
|
|
}else {
|
|
|
- if(TokenManager.getAdminId().equals(out.getAid())) {
|
|
|
- out.setPermission(0);
|
|
|
+ if (out.getPublicType()==1){
|
|
|
+ if (aid.equals(out.getAid())){
|
|
|
+ out.setPermission(0);
|
|
|
+ }else {
|
|
|
+ out.setPermission(1);
|
|
|
+ }
|
|
|
}else {
|
|
|
- out.setPermission(1);
|
|
|
+ if(aid.equals(out.getAid())) {
|
|
|
+ out.setPermission(0);
|
|
|
+ }else {
|
|
|
+ out.setPermission(1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|