|
|
@@ -1,11 +1,7 @@
|
|
|
package com.goafanti.weChat.service.impl;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
import com.goafanti.common.dao.*;
|
|
|
@@ -79,7 +75,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
Date date =new Date();
|
|
|
in.setCreateTime(date);
|
|
|
in.setStatus(1);
|
|
|
-
|
|
|
in.setAid(TokenManager.getAdminId());
|
|
|
in.setNewUser(0);
|
|
|
User u=userMapper.selectByPrimaryKey(in.getUid());
|
|
|
@@ -89,13 +84,30 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
if (u.getAid().equals(TokenManager.getAdminId())){
|
|
|
in.setMainStatus(1);
|
|
|
}
|
|
|
- publicReleaseMapper.insertSelective(in);
|
|
|
AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
+ if (in.getAssist()==1){
|
|
|
+ in.setAssistAidName(getAssistAidName(in.getAssistAid()));
|
|
|
+ in.setMainName(my.getName());
|
|
|
+ }
|
|
|
+ publicReleaseMapper.insertSelective(in);
|
|
|
+ Map<String, Object> map=addPublicReleaseLog(my, in,PublicReleaseLog.states.fq.getCode(),u.getNickname(),date);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param my 我的相关人员
|
|
|
+ * @param in 公出信息
|
|
|
+ * @param logStatus 公出状态
|
|
|
+ * @param nickname 客户名称
|
|
|
+ * @param date 时间
|
|
|
+ */
|
|
|
+ private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,Integer logStatus,String nickname,Date date ) {
|
|
|
Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
|
|
|
- PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),1,"发起外出申请",new Date());
|
|
|
+ PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),logStatus,"发起外出申请",new Date());
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
String openid=a.getOpenId();
|
|
|
- String str="["+my.getName()+"]发起["+u.getNickname()+"]的外出申请,请及时审核。";
|
|
|
+ String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
|
|
|
sendNoticeAndSoucket(a.getId(),NoticeStatus.PUBLIC_RELEASE_START.getCode(),str);
|
|
|
Map<String, Object>map=new HashMap<String, Object>();
|
|
|
map.put("data", publicReleaseMapper.selectDtails(in.getId(),null));
|
|
|
@@ -114,11 +126,16 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ private String getAssistAidName(String assistAid) {
|
|
|
+ String [] ss=assistAid.split(",");
|
|
|
+ StringBuffer sb=new StringBuffer();
|
|
|
+ for (String s : ss) {
|
|
|
+ Admin a=adminMapper.selectByPrimaryKey(s);
|
|
|
+ if (a!=null&&a.getName()!=null)sb=sb.append(a.getName()).append(",");
|
|
|
+ }
|
|
|
+ if (sb.length()<1)return "";
|
|
|
+ return sb.deleteCharAt(sb.length() - 1).toString();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private void sendNoticeAndSoucket(String id,Integer type,String content) {
|
|
|
@@ -144,6 +161,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
|
|
|
@Override
|
|
|
public int updatePublicRelease(InputPublicRelease in) {
|
|
|
+ Date date = new Date();
|
|
|
try {
|
|
|
if(in.getReleaseStarts()!=null)in.setReleaseStart(DateUtils.parseDate(in.getReleaseStarts(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
if(in.getReleaseEnds()!=null)in.setReleaseEnd(DateUtils.parseDate(in.getReleaseEnds(), AFTConstants.YYYYMMDDHHMMSS));
|
|
|
@@ -159,14 +177,31 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
if (u!=null&&u.getAid().equals(TokenManager.getAdminId())){
|
|
|
in.setMainStatus(1);
|
|
|
}
|
|
|
- PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),null,in.getReason(),new Date());
|
|
|
+ PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),null,in.getReason(),date);
|
|
|
if(in.getStatus()==null||in.getStatus()!=3) {
|
|
|
in.setStatus(1);
|
|
|
- log.setStatus(5);
|
|
|
+ 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());
|
|
|
+ addPublicReleaseLog(my,in,PublicReleaseLog.states.xg.getCode(),u.getNickname(),date);
|
|
|
+
|
|
|
}else {
|
|
|
- log.setStatus(4);
|
|
|
+ log.setStatus(PublicReleaseLog.states.cx.getCode());
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId());
|
|
|
+ for (PublicRelease out : list) {
|
|
|
+ PublicReleaseLog log2 = new PublicReleaseLog(out.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.sc.getCode(), "修改撤销协单", new Date());
|
|
|
+ publicReleaseLogMapper.insertSelective(log2);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+ publicReleaseMapper.updateStatusByMainId(in.getStatus(),in.getId());
|
|
|
+
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
return publicReleaseMapper.updateByPrimaryKeySelective(in);
|
|
|
}
|
|
|
@@ -176,14 +211,21 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
public Pagination<OutPublicReleaseList> listPublicRelease(InputPublicReleaseList in) {
|
|
|
Map<String,Object> map =new HashMap<String, Object>();
|
|
|
map.put("type", in.getType()==null?0:in.getType());
|
|
|
- map.put("aid", TokenManager.getAdminId());
|
|
|
+ if (in.getType()==3) {
|
|
|
+ in.setAssist(2);
|
|
|
+ if (!TokenManager.hasRole(AFTConstants.TECH_FINANCE_DIRECTOR))map.put("aid",TokenManager.getAdminId());
|
|
|
+ }else{
|
|
|
+ map.put("aid",TokenManager.getAdminId());
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(in.getClockTime())) map.put("clockTime", in.getClockTime());
|
|
|
if(StringUtils.isNotEmpty(in.getReleaseStarts())) map.put("releaseStarts", in.getReleaseStarts());
|
|
|
if(StringUtils.isNotEmpty(in.getReleaseEnds())) map.put("publicEnd", in.getReleaseEnds()+" 23:59:59");
|
|
|
if(StringUtils.isNotEmpty(in.getUserName())) map.put("userName", in.getUserName());
|
|
|
if(in.getStatus()!=null) map.put("status", in.getStatus());
|
|
|
if(in.getClockIn()!=null) map.put("clockIn", in.getClockIn());
|
|
|
- return (Pagination<OutPublicReleaseList>) findPage("listPublicRelease", "countPublicRelease", map, in.getPageNo(), in.getPageSize());
|
|
|
+ map.put("assist",in.getAssist()==null?0:in.getAssist());
|
|
|
+ Pagination<OutPublicReleaseList> p=(Pagination<OutPublicReleaseList>) findPage("listPublicRelease", "countPublicRelease", map, in.getPageNo(), in.getPageSize());
|
|
|
+ return p;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -200,8 +242,18 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
StringBuffer str=new StringBuffer();
|
|
|
Admin ad=adminMapper.selectByPrimaryKey(aid);
|
|
|
str=str.append("(").append(ad.getName()).append(")");
|
|
|
- if (status==0){str=str.append("驳回,");}
|
|
|
- else if(status==2){str=str.append("同意,");}
|
|
|
+ if (status==0){
|
|
|
+ str=str.append("驳回,");
|
|
|
+ publicReleaseMapper.updateStatusByMainId(status,use.getId());
|
|
|
+ }else if(status==2){
|
|
|
+ str=str.append("同意,");
|
|
|
+ //如果是协单公出主公出,在审核通过
|
|
|
+ if (use.getAssist()==1){
|
|
|
+ pushPublicReleaseAssist(use,status,date);
|
|
|
+ }else if (use.getAssist()==0){
|
|
|
+ publicReleaseMapper.updateStatusByMainId(3,use.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
str=str.append(remarks);
|
|
|
p.setAuditInfo(str.toString());
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
@@ -234,6 +286,62 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void pushPublicReleaseAssist(PublicRelease use,Integer status,Date date) {
|
|
|
+ Integer useId=use.getId();
|
|
|
+ if (use.getAssistAid()!=null){
|
|
|
+ List<PublicRelease> list = publicReleaseMapper.selectByMainId(use.getId());
|
|
|
+ String []ss=use.getAssistAid().split(",");
|
|
|
+ //数据库与传入比对,如果不存在就标记撤销 ,如果存在就修改成
|
|
|
+ for (PublicRelease out : list) {
|
|
|
+ boolean flag=false;
|
|
|
+ for (String s : ss) {
|
|
|
+ if (out.getAid().equals(s)){
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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.sc.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.xg.getCode(), "修改协单信息", date);
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String s : ss) {
|
|
|
+ boolean flag2 = false;
|
|
|
+ for (PublicRelease o : list) {
|
|
|
+ if (s.equals(o.getAid())) {
|
|
|
+ flag2 = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag2) {
|
|
|
+ use.setAssist(2);
|
|
|
+ use.setAid(s);
|
|
|
+ use.setStatus(2);
|
|
|
+ use.setType(3);
|
|
|
+ use.setMainId(useId);
|
|
|
+ use.setId(null);
|
|
|
+ publicReleaseMapper.insert(use);
|
|
|
+ PublicReleaseLog log = new PublicReleaseLog(use.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.xg.getCode(), "修改协单信息", date);
|
|
|
+ publicReleaseLogMapper.insertSelective(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<outPublicReleaseLog> listPublicReleaseLog(Integer id,String ufid) {
|
|
|
List<outPublicReleaseLog> list=publicReleaseLogMapper.listPublicReleaseLog(id,ufid);
|
|
|
@@ -268,7 +376,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
}else {
|
|
|
str="刷新打卡";
|
|
|
}
|
|
|
- PublicReleaseLog log=new PublicReleaseLog(id,aid,3,str,new Date());
|
|
|
+ PublicReleaseLog log=new PublicReleaseLog(id,aid,PublicReleaseLog.states.dk.getCode(),str,new Date());
|
|
|
log.setPhotoUrl(photoUrl);
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
@@ -285,7 +393,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
AdminListBo ab=adminMapper.getDeptNameByAid(out.getAid());
|
|
|
if (!TokenManager.getAdminId().equals( out.getAid())&&
|
|
|
!TokenManager.getAdminId().equals(out.getReviewer())&&
|
|
|
- !TokenManager.getAdminId().equals(ab.getDepManager())){
|
|
|
+ !TokenManager.getAdminId().equals(ab.getDepManager())&&
|
|
|
+ !TokenManager.hasRole(AFTConstants.TECH_FINANCE_DIRECTOR)){
|
|
|
flag=true;
|
|
|
}
|
|
|
if(flag){
|
|
|
@@ -301,6 +410,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public OutPublicRelease followDtails(String id) {
|
|
|
return publicReleaseMapper.selectDtails(null,id);
|
|
|
@@ -354,7 +465,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
public Object publicReleaseListDtails(InputPublicDtails in) {
|
|
|
Map<String,Object> map =new HashMap<String, Object>();
|
|
|
addParams(in, map);
|
|
|
- Date date = new Date();
|
|
|
Pagination<OutPublicDtails> page = (Pagination<OutPublicDtails>) findPage("listPublicDtails", "countPublicDtails", map, in.getPageNo(), in.getPageSize());
|
|
|
return page;
|
|
|
}
|
|
|
@@ -365,18 +475,23 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
if(in.getDepId()!=null) map.put("depId", in.getDepId());
|
|
|
if(in.getReleaseStart()!=null) map.put("releaseStart", in.getReleaseStart());
|
|
|
if(in.getReleaseEnd()!=null) map.put("releaseEnd", in.getReleaseEnd()+" 23:59:59");
|
|
|
+ if(in.getCreateStart()!=null) map.put("createStart", in.getCreateStart());
|
|
|
+ if(in.getCreateEnd()!=null) map.put("createEnd", in.getCreateEnd()+" 23:59:59");
|
|
|
if(in.getUid()!=null) map.put("uid", in.getUid());
|
|
|
if(in.getStatus()!=null) map.put("status", in.getStatus());
|
|
|
if(in.getClockIn()!=null) map.put("clockIn", in.getClockIn());
|
|
|
if(in.getPublicType()!=null)map.put("publicType",in.getPublicType());
|
|
|
//type 0私有 1管理权限 2所有权限
|
|
|
if(TokenManager.hasRole(AFTConstants.SUPERADMIN)||TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)
|
|
|
- ||TokenManager.hasRole(AFTConstants.CED_ASSISTANT )||TokenManager.hasRole(AFTConstants.PERSONNEL_AUDITOR)){
|
|
|
- in.setType(2);}
|
|
|
- else if(TokenManager.hasRole(AFTConstants.COMPANY_MANAGER)||TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
|
|
|
+ ||TokenManager.hasRole(AFTConstants.CED_ASSISTANT )||TokenManager.hasRole(AFTConstants.PERSONNEL_AUDITOR)
|
|
|
+ ||TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)
|
|
|
+ ||TokenManager.hasRole(AFTConstants.FINANCE)||TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)){
|
|
|
+ //添加财务和财务经理。查看客户所有公出
|
|
|
+ in.setType(2);
|
|
|
+ }else if(TokenManager.hasRole(AFTConstants.COMPANY_MANAGER)||TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
|
|
|
in.setType(1);
|
|
|
map.put("deps", orderService.selectMyDeps());
|
|
|
- } else{
|
|
|
+ }else{
|
|
|
in.setType(0);
|
|
|
if (in.getAid()==null) map.put("aid",TokenManager.getAdminId());
|
|
|
}
|
|
|
@@ -413,9 +528,12 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
throw new BusinessException("转换异常");
|
|
|
}
|
|
|
List<Integer> is=publicReleaseMapper.checkTime(TokenManager.getAdminId(),in.getReleaseStart(),in.getReleaseEnd());
|
|
|
+ is.forEach(System.out::println);
|
|
|
+ System.out.println(in.getId());
|
|
|
if (is.size()>1) {
|
|
|
return true;
|
|
|
}else if(is.size()==1){
|
|
|
+ System.out.println(is.get(0));
|
|
|
if (in.getId()!=null && !in.getId().equals(is.get(0))){
|
|
|
return true;
|
|
|
}
|
|
|
@@ -434,5 +552,40 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
return publicReleaseMapper.publicByOrder(orderNo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Object getMyNewPublic() {
|
|
|
+ List<OutPublicReleaseList> myPublic = getMyPublic(0,1);
|
|
|
+ if (myPublic.isEmpty()){
|
|
|
+ List<OutPublicReleaseList> myPublic2 = getMyPublic(0,0);
|
|
|
+ if (!myPublic2.isEmpty()){
|
|
|
+ return myPublic2.get(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return myPublic.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param type 查看类型 0我的公出 1公出审核 2管理员 3协单(技术财税总监看全部)
|
|
|
+ * @param dateType 是否含打卡时间 0否 1是
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<OutPublicReleaseList>getMyPublic(Integer type ,Integer dateType){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (type==null)type=0;
|
|
|
+ map.put("type",type);
|
|
|
+ if (dateType==1){
|
|
|
+ Date date = new Date();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
}
|