|
|
@@ -68,10 +68,10 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
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());
|
|
|
-
|
|
|
if (in.getAssist()==1){
|
|
|
// in.setAssistAidName(getAssistAidName(in.getAssistAid()));
|
|
|
in.setMainName(my.getName());
|
|
|
@@ -102,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);
|
|
|
@@ -169,10 +170,10 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
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+"]的外出申请,请及时审核。";
|
|
|
//默认上级审核
|
|
|
AtomicReference<Integer> status= new AtomicReference<>(1);
|
|
|
+ Map<String, Object>map=new HashMap<String, Object>();
|
|
|
if (my.getPublicPurview()==0){
|
|
|
users.forEach(u->{
|
|
|
if (!u.getAid().equals(my.getId())){
|
|
|
@@ -183,6 +184,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
//不是自己的企业则需要审核并设置非自己客户待审核
|
|
|
addPublicExamine(in.getId(), u.getAid());
|
|
|
if(in.getPublicType()==null|| in.getPublicType()==0) in.setPublicType(1);
|
|
|
+ Admin admin = adminMapper.selectByPrimaryKey(u.getAid());
|
|
|
+ pushNoticeAndSoucketAndEmail(my, in, date, admin, str, map);
|
|
|
status.set(0);
|
|
|
}
|
|
|
});
|
|
|
@@ -197,24 +200,36 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
});
|
|
|
|
|
|
}
|
|
|
- Map<String, Object>map=new HashMap<String, Object>();
|
|
|
if (status.get()==1){
|
|
|
- sendNoticeAndSoucket(a.getId(),1,str);
|
|
|
- if (openid!=null) {
|
|
|
- Integer res= weChatUtils.addNotice(openid, 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);
|
|
|
- }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String getAssistAidName(String assistAid) {
|
|
|
String [] ss=assistAid.split(",");
|
|
|
StringBuffer sb=new StringBuffer();
|
|
|
@@ -287,11 +302,12 @@ 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());
|
|
|
@@ -304,7 +320,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
//新增修改日志
|
|
|
//重新发起
|
|
|
- addPublicReleaseLog(my,in,in.getUserNames(),date,null);
|
|
|
+ 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);
|
|
|
@@ -326,11 +342,11 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
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);
|
|
|
+ return addPRD(split,prList,use);
|
|
|
}
|
|
|
|
|
|
private void deletePRD(List<String> split, List<OutPublicReleaseDetails> prdList) {
|
|
|
@@ -352,9 +368,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;
|
|
|
@@ -369,7 +389,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 {
|
|
|
@@ -388,9 +407,20 @@ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (publicType!=use.getPublicType()){
|
|
|
+ PublicRelease newP=new PublicRelease();
|
|
|
+ newP.setId(use.getId());
|
|
|
+ newP.setPublicType(publicType);
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(newP);
|
|
|
+ }
|
|
|
if (!addPrdList.isEmpty())publicReleaseDetailsMapper.insertBatch(addPrdList);
|
|
|
+ return users;
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@@ -416,49 +446,64 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
|
|
|
@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();
|
|
|
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);
|
|
|
- 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 str=new StringBuffer();
|
|
|
+ str=str.append("(").append(ad.getName()).append(")");
|
|
|
+ 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("[").append(use.getUserNames()).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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ //营销员审核
|
|
|
+ }else if (examineType==1){
|
|
|
+ //通知公出人切换成公出人审核人
|
|
|
+ a=adminMapper.selectByPrimaryKey(a.getReviewer());
|
|
|
+ if (status==2){//审核通过
|
|
|
+ str=str.append("同意,");
|
|
|
+
|
|
|
+ addpublicLog(id, status, remarks);
|
|
|
+ }else if (status==0){//审核驳回
|
|
|
+ str=str.append("驳回,");
|
|
|
+ p.setPublicType(3);
|
|
|
+ addpublicLog(id, 0, remarks);
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
+ sendNoticeAndSoucket(a.getId(),status,content.toString());
|
|
|
if (my.getOpenId()!=null) {
|
|
|
if (remarks.length()>19) {
|
|
|
remarks=remarks.substring(0, 15)+"...";
|
|
|
@@ -470,6 +515,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
return 1;
|
|
|
}
|
|
|
|