| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657 |
- 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.factory.annotation.Autowired;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.stereotype.Service;
- import org.springframework.web.socket.TextMessage;
- import com.goafanti.admin.bo.AdminListBo;
- import com.goafanti.common.bo.EmailBo;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.enums.NoticeStatus;
- import com.goafanti.common.error.BusinessException;
- import com.goafanti.common.model.Admin;
- import com.goafanti.common.model.Notice;
- import com.goafanti.common.model.OrganizationContactBook;
- import com.goafanti.common.model.PublicRelease;
- import com.goafanti.common.model.PublicReleaseLog;
- import com.goafanti.common.model.User;
- import com.goafanti.common.utils.AsyncUtils;
- import com.goafanti.common.utils.DateUtils;
- import com.goafanti.common.utils.SendEmailUtil;
- import com.goafanti.common.utils.WeChatUtils;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.customer.bo.FollowBusinessBo;
- import com.goafanti.customer.service.CustomerService;
- import com.goafanti.weChat.bo.InputPublicDtails;
- import com.goafanti.weChat.bo.InputPublicRelease;
- import com.goafanti.weChat.bo.InputPublicReleaseList;
- import com.goafanti.weChat.bo.InputPublicStatistics;
- import com.goafanti.weChat.bo.OutPublicDtails;
- import com.goafanti.weChat.bo.OutPublicRelease;
- import com.goafanti.weChat.bo.OutPublicReleaseList;
- import com.goafanti.weChat.bo.OutPublicStatistics;
- import com.goafanti.weChat.bo.outPublicReleaseLog;
- import com.goafanti.weChat.service.PublicReleaseService;
- import com.goafanti.core.websocket.SystemWebSocketHandler;
- import cn.jiguang.common.utils.StringUtils;
- @Service
- public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper> implements PublicReleaseService {
- @Autowired
- private PublicReleaseMapper publicReleaseMapper;
- @Autowired
- private PublicReleaseLogMapper publicReleaseLogMapper;
- @Autowired
- private CustomerService customerService;
- @Autowired
- private OrderService orderService;
- @Autowired
- private WeChatUtils weChatUtils;
- @Autowired
- private AdminMapper adminMapper;
- @Autowired
- private AsyncUtils asyncUtils;
- @Autowired
- private UserMapper userMapper;
- @Autowired
- private OrganizationContactBookMapper organizationContactBookMapper;
- @Autowired
- private SystemWebSocketHandler systemWebSocketHandler;
- @Autowired
- private TOrderNewMapper tOrderNewMapper;
- @Override
- public Map<String, Object> addPublicRelease(InputPublicRelease in) {
- Date date =new Date();
- in.setCreateTime(date);
- in.setStatus(1);
- in.setAid(TokenManager.getAdminId());
- in.setNewUser(0);
- User u=userMapper.selectByPrimaryKey(in.getUid());
- if (u!=null&&u.getShareType()==2){
- in.setNewUser(1);
- }
- if (u.getAid().equals(TokenManager.getAdminId())){
- in.setMainStatus(1);
- }
- AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
- if (in.getAssist()==1){
- in.setAssistAidName(getAssistAidName(in.getAssistAid()));
- in.setMainName(my.getName());
- }
- publicReleaseMapper.insertSelective(in);
- addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
- Map<String, Object> map=addPublicReleaseLog(my, in,u.getNickname(),date);
- return map;
- }
- /**
- *
- * @param my 我的相关人员
- * @param in 公出信息
- * @param nickname 客户名称
- * @param date 时间
- */
- private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date ) {
- Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
- String openid=a.getOpenId();
- 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));
- 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);
- }
- 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) {
- systemWebSocketHandler.sendMessageToUser(id, new TextMessage("unread"));
- Notice n =new Notice();
- n.setId(UUID.randomUUID().toString());
- n.setAid(id);
- n.setNoticeType(type);
- n.setContent(content);
- n.setReaded(0);//未读
- asyncUtils.addNotice(n);
- }
- /**
- *
- * @param my 发送人
- * @param a 接受者
- * @param type 类型
- */
- private void sendEmail(AdminListBo my, Admin a,Integer type) {
- String title="外出申请提醒";
- if (type==0) title="外出申请驳回提醒";
- else if (type==2) title="外出申请同意提醒";
- if (SendEmailUtil.isEmail(a.getEmail())) {
- EmailBo email=new EmailBo(title,a.getEmail() , my.getDepartmentName(), my.getName(),"详情请登录微信打卡小程序查看,谢谢!") ;
- asyncUtils.send(email);
- }
- }
- @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));
- } catch (ParseException e) {
- e.printStackTrace();
- throw new BusinessException("转换异常");
- }
- User u=userMapper.selectByPrimaryKey(in.getUid());
- if (u!=null&&u.getShareType()==2){
- in.setNewUser(1);
- }
- if (u!=null&&u.getAid().equals(TokenManager.getAdminId())){
- 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 {
- log.setStatus(PublicReleaseLog.states.cx.getCode());
- List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId());
- for (PublicRelease out : list) {
- addpublicLog(out.getId(), PublicReleaseLog.states.sc.getCode(), "修改撤销协单");
- }
- }
- return publicReleaseMapper.updateByPrimaryKeySelective(in);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<OutPublicReleaseList> listPublicRelease(InputPublicReleaseList in) {
- Map<String,Object> map =new HashMap<String, Object>();
- map.put("type", in.getType()==null?0:in.getType());
- 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());
- 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
- public int pushExaminePublicRelease(Integer id, Integer status, String remarks) {
- 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(")");
- if (status==0){
- str=str.append("驳回,");
- }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());
- p.setRejectName(ad.getName());
- 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);
- if (my.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);
- if (res!=0) {
- sendEmail( my, a, status);
- }
- return res;
- }
- return 1;
- }
- private void addpublicLog(Integer id, Integer status, String remarks) {
- PublicReleaseLog log = new PublicReleaseLog(id, TokenManager.getAdminId(), status, remarks, new Date());
- publicReleaseLogMapper.insertSelective(log);
- }
- @Override
- public int pushTechReject(Integer id, String remarks) {
- Integer status=0;
- PublicRelease use=publicReleaseMapper.selectByPrimaryKey(id);
- 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("只有技术公出能发起技术驳回");
- }
- str=str.append("拒绝技术协单,").append(remarks);
- PublicRelease newMain=new PublicRelease();
- newMain.setId(mainPublic.getId());
- newMain.setStatus(4);
- newMain.setRejectName(ad.getName());
- newMain.setAuditInfo(str.toString());
- addpublicLog(mainPublic.getId(), status, remarks);
- publicReleaseMapper.updateByPrimaryKeySelective(newMain);
- PublicRelease up=new PublicRelease();
- up.setId(id);
- up.setAuditInfo(str.toString());
- up.setStatus(3);
- addpublicLog(id, status, remarks);
- publicReleaseMapper.updateByPrimaryKeySelective(up);
- return addNoticeAndWeChat(mainPublic.getId(), mainPublic.getAid(), str.toString(), status);
- }
- /**
- * 新增日志、站内信、微信提醒
- * @param id 日志公出编号
- * @param aid 接受者
- * @param remarks 日志内容
- * @param status 0驳回
- * @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) {
- if (remarks.length()>19) {
- remarks=remarks.substring(0, 15)+"...";
- }
- return weChatUtils.addNotice(my.getOpenId(),status,id,new Date(),my.getName(), remarks);
- }else {
- sendEmail( my, a, status);
- 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;
- 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 (!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.ty.getCode(), "同意协单信息", date);
- publicReleaseLogMapper.insertSelective(log);
- }
- }
- }
- }
- @Override
- public List<outPublicReleaseLog> listPublicReleaseLog(Integer id,String ufid) {
- List<outPublicReleaseLog> list=publicReleaseLogMapper.listPublicReleaseLog(id,ufid);
- return list;
- }
- @Override
- public int pushPublicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks ) {
- if(clockIn==null)clockIn=1;
- PublicRelease p=new PublicRelease();
- PublicRelease use=publicReleaseMapper.selectByPrimaryKey(id);
- String aid=TokenManager.getAdminId();
- p.setId(id);
- p.setClockIn(clockIn);
- p.setClockInRemarks(clockInRemarks);
- p.setPhotoUrl(photoUrl);
- p.setClockInTime(new Date());
- String str="";
- if (use.getClockIn()==0) {
- FollowBusinessBo fbb=new FollowBusinessBo();
- fbb.setUid(use.getUid());
- fbb.setContactType("5");
- fbb.setResult(use.getRemarks());
- OrganizationContactBook ub=organizationContactBookMapper.getMajor(use.getUid(),aid);
- if (ub !=null) {
- fbb.setOcbId(ub.getId());
- }
- fbb.setFollowTime(DateUtils.formatDate(p.getClockInTime(), AFTConstants.YYYYMMDDHHMMSS));
- String ufid=UUID.randomUUID().toString();
- p.setUfid(ufid);
- customerService.addFollow(fbb,ufid,use.getMainStatus());
- if (clockIn==1)str="公出人员打卡";
- else if(clockIn==2)str="公出人员异常打卡";
- }else {
- str="刷新打卡";
- }
- PublicReleaseLog log=new PublicReleaseLog(id,aid,PublicReleaseLog.states.dk.getCode(),str,new Date());
- log.setPhotoUrl(photoUrl);
- publicReleaseLogMapper.insertSelective(log);
- publicReleaseMapper.updateByPrimaryKeySelective(p);
- return 1;
- }
- @Override
- public OutPublicRelease dtails(Integer id) {
- //如果不是本人和审核人员则不返回信息
- OutPublicRelease out=publicReleaseMapper.selectDtails(id,null);
- 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())&&
- !TokenManager.hasRole(AFTConstants.TECH_FINANCE_DIRECTOR)){
- flag=true;
- }
- if(flag){
- out=null;
- }else {
- if(TokenManager.getAdminId().equals(out.getAid())) {
- out.setPermission(0);
- }else {
- out.setPermission(1);
- }
- }
- }
- return out;
- }
- @Override
- public OutPublicRelease followDtails(String id) {
- return publicReleaseMapper.selectDtails(null,id);
- }
- @SuppressWarnings("unchecked")
- @Override
- @Cacheable(value = "publicReleaseStatistics#300", key = "'publicReleaseStatistics:" +
- "aid:'+#in.aid+'depId:'+#in.depId+'clockStart:'+#in.clockStart+" +
- "'clockEnd:'+#in.clockEnd+'createStart:'+#in.createStart+'createEnd'+#in.createEnd+" +
- "'pageNo:'+#in.pageNo+'pageSzie:'+#in.pageSize")
- public Object publicReleaseStatistics(InputPublicStatistics in) {
- Map<String,Object> map =new HashMap<String, Object>();
- if(in.getAid()!=null)map.put("aid", in.getAid());
- if(in.getDepId()!=null)map.put("depId", in.getDepId());
- if(in.getClockStart()!=null)map.put("clockStart", in.getClockStart());
- if(in.getClockEnd()!=null)map.put("clockEnd", in.getClockEnd()+" 23:59:59");
- if(in.getCreateStart()!=null)map.put("createStart", in.getCreateStart());
- if(in.getCreateEnd()!=null)map.put("createEnd", in.getCreateEnd()+" 23:59:59");
- return (Pagination<OutPublicStatistics>) findPage("listPublicStatistics", "countPublicStatistics", map, in.getPageNo(), in.getPageSize());
- }
- @SuppressWarnings("unchecked")
- @Override
- public List<OutPublicStatistics> publicReleaseStatisticsList(InputPublicStatistics in) {
- Map<String,Object> map =new HashMap<String, Object>();
- if(in.getAid()!=null)map.put("aid", in.getAid());
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN)|| TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)||
- TokenManager.hasRole(AFTConstants.CED)|| TokenManager.hasRole(AFTConstants.CED_ASSISTANT)){
- if(in.getDepId()!=null)map.put("depId", in.getDepId());
- }else if (TokenManager.hasRole(AFTConstants.COMPANY_MANAGER)||TokenManager.hasRole(AFTConstants.PERSONNEL_AUDITOR)){
- }
- if(in.getClockStart()!=null)map.put("clockStart", in.getClockStart());
- if(in.getClockEnd()!=null)map.put("clockEnd", in.getClockEnd()+" 23:59:59");
- if(in.getCreateStart()!=null)map.put("createStart", in.getCreateStart());
- if(in.getCreateEnd()!=null)map.put("createEnd", in.getCreateEnd()+" 23:59:59");
- return (List<OutPublicStatistics>) findList("listPublicStatistics",map, in.getPageNo(), 99999);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Object publicReleaseListDtails(InputPublicDtails in) {
- Map<String,Object> map =new HashMap<String, Object>();
- addParams(in, map);
- Pagination<OutPublicDtails> page = (Pagination<OutPublicDtails>) findPage("listPublicDtails", "countPublicDtails", map, in.getPageNo(), in.getPageSize());
- return page;
- }
- private void addParams(InputPublicDtails in, Map<String, Object> map) {
- if(in.getAid()!=null) map.put("aid", in.getAid());
- if(in.getSid()!=null) map.put("sid", in.getSid());
- 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)
- ||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{
- in.setType(0);
- if (in.getAid()==null) map.put("aid",TokenManager.getAdminId());
- }
- map.put("type", in.getType());
- }
- @SuppressWarnings("unchecked")
- @Override
- public List<OutPublicDtails> publicReleaseListDtailsList(InputPublicDtails in) {
- Map<String,Object> map =new HashMap<String, Object>();
- addParams(in, map);
- return (List<OutPublicDtails>) findList("listPublicDtails", map, in.getPageNo(), 99999);
- }
- @Override
- public int addSupplement(Integer id, String supplement, String nextPlan) {
- PublicRelease pr=new PublicRelease();
- pr.setId(id);
- pr.setSupplement(supplement);
- pr.setNextPlan(nextPlan);
- return publicReleaseMapper.updateByPrimaryKeySelective(pr);
- }
- @Override
- public boolean checkTime(InputPublicRelease in) {
- try {
- in.setReleaseStart(DateUtils.parseDate(in.getReleaseStarts(), AFTConstants.YYYYMMDDHHMMSS));
- in.setReleaseEnd(DateUtils.parseDate(in.getReleaseEnds(), AFTConstants.YYYYMMDDHHMMSS));
- } catch (ParseException e) {
- e.printStackTrace();
- throw new BusinessException("转换异常");
- }
- List<Integer> is=publicReleaseMapper.checkTime(TokenManager.getAdminId(),in.getReleaseStart(),in.getReleaseEnd());
- if (is.size()>1) {
- return true;
- }else if(is.size()==1){
- if (in.getId()!=null && !in.getId().equals(is.get(0))){
- return true;
- }
- }
- return false;
- }
- @Override
- public List<Map<String, Object>> selectOrderByUid(String uid) {
- return tOrderNewMapper.selectOrderByuid(uid);
- }
- @Override
- public List<OutPublicRelease> publicByOrder(String orderNo) {
- 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;
- }
- }
|