From 5506edbe54883b31db3cc8e4a1d9d0795a18a3c9 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 27 十二月 2024 14:37:54 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1 --- server/service/src/main/java/com/doumee/service/business/impl/ContractServiceImpl.java | 520 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 420 insertions(+), 100 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ContractServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ContractServiceImpl.java index 655bfe3..7f7b204 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/ContractServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/ContractServiceImpl.java @@ -1,20 +1,36 @@ package com.doumee.service.business.impl; +import com.doumee.biz.system.SystemDictDataBiz; +import com.doumee.core.constants.ResponseStatus; +import com.doumee.core.exception.BusinessException; +import com.doumee.core.model.LoginUserInfo; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; +import com.doumee.core.utils.Constants; import com.doumee.core.utils.Utils; +import com.doumee.dao.business.CompanyMapper; import com.doumee.dao.business.ContractMapper; -import com.doumee.dao.business.model.Contract; +import com.doumee.dao.business.MultifileMapper; +import com.doumee.dao.business.NoticesMapper; +import com.doumee.dao.business.join.ContractJoinMapper; +import com.doumee.dao.business.model.*; +import com.doumee.dao.system.model.SystemUser; import com.doumee.service.business.ContractService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.doumee.service.business.third.SignService; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.Date; import java.util.List; +import java.util.Objects; /** * 鍚堝悓淇℃伅琛⊿ervice瀹炵幇 @@ -27,15 +43,118 @@ @Autowired private ContractMapper contractMapper; + @Autowired + private ContractJoinMapper contractJoinMapper; + + @Autowired + private MultifileMapper multifileMapper; + + @Autowired + private SystemDictDataBiz systemDictDataBiz; + + @Autowired + private CompanyMapper companyMapper; + + @Autowired + private SignService signService; + + @Autowired + private NoticesMapper noticesMapper; + @Override public Integer create(Contract contract) { + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + initCreateParam(contract); + contract.setIsdeleted(Constants.ZERO); + contract.setCreateDate(new Date()); + contract.setCreator(loginUserInfo.getId()); + contract.setEditor(loginUserInfo.getId()); + contract.setEditDate(new Date()); + contract.setStatus(Constants.ZERO); + contract.setFileUrl(contract.getFileUrl()); + Company company = companyMapper.selectById(contract.getCompanyId()); + if(Constants.equalsInteger(loginUserInfo.getType(),Constants.ZERO)){ + if(Constants.equalsInteger(company.getType(),Constants.ONE)){ + contract.setSignType(Constants.ZERO); + }else{ + contract.setSignType(Constants.ONE); + } + }else if(Constants.equalsInteger(loginUserInfo.getType(),Constants.TWO)){ + contract.setPartyCompanyId(loginUserInfo.getCompanyId()); + contract.setSignType(Constants.TWO); + }else{ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浼佷笟鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�!"); + } contractMapper.insert(contract); + + Multifile file = contract.getMultifile(); + file.setIsdeleted(Constants.ZERO); + file.setCreateDate(contract.getCreateDate()); + file.setCreator(contract.getCreator()); + file.setObjId(contract.getId()); + file.setObjType(Constants.MultiFile.CONTRACT_PDF.getKey()); + file.setType(Constants.formatIntegerNum(file.getType())); + multifileMapper.insert(file); + + + + //瀛樺偍寰呭姙淇℃伅 + Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.CONTRACT; + //骞冲彴寰呭姙 + Notices notices = new Notices(noticeObjectType, + Constants.equalsInteger(contract.getSignType(),Constants.TWO)?Constants.TWO:Constants.ZERO + ,contract.getId(), + this.getNoticeInfo(contract,company), + Constants.equalsInteger(contract.getSignType(),Constants.TWO)? + contract.getPartyCompanyId():null + ,Constants.NoticeType.ZERO); + noticesMapper.insert(notices); + return contract.getId(); } + public String getNoticeInfo(Contract contract,Company company){ + String noticeInfo = contract.getName(); + //鍟嗘埛淇℃伅 + if(Constants.equalsInteger(contract.getSignType(),Constants.TWO)){ + Company shop = companyMapper.selectById(contract.getPartyCompanyId()); + noticeInfo = noticeInfo + "("+shop.getName()+"/"+company.getName()+")"; + }else{ + noticeInfo = noticeInfo + "(骞冲彴/"+company.getName()+")"; + } + return noticeInfo; + } + + + private void initCreateParam(Contract contract) { + if(StringUtils.isBlank(contract.getName()) + || Objects.isNull(contract.getType()) + || Objects.isNull(contract.getCompanyId()) + || Objects.isNull(contract.getStartTime()) + || Objects.isNull(contract.getEndTime()) + || Objects.isNull(contract.getMultifile()) + || Objects.isNull(contract.getMultifile().getFileurl()) + ){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + } + + @Override public void deleteById(Integer id) { - contractMapper.deleteById(id); + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + Contract contract = contractJoinMapper.selectById(id); + if(Objects.isNull(contract)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍚堝悓淇℃伅"); + } + if(!Constants.equalsInteger(contract.getStatus(),Constants.CONTRACT_STATUS.CANCEL.getKey())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝悓淇℃伅淇℃伅宸叉祦杞�"); + } + contract.setStatus(Constants.CONTRACT_STATUS.CLOSE.getKey()); + contract.setIsdeleted(Constants.ONE); + contract.setEditor(loginUserInfo.getId()); + contract.setEditDate(new Date()); + contractMapper.updateById(contract); } @Override @@ -69,7 +188,63 @@ @Override public Contract findById(Integer id) { - return contractMapper.selectById(id); + MPJLambdaWrapper<Contract> queryWrapper = new MPJLambdaWrapper<>(); + queryWrapper.selectAll(Contract.class); + queryWrapper.select(" ifnull(t2.name,'瀹夊窘浜戞槗淇濈鎶�鏈夐檺鍏徃') as partyCompanyName , t3.name as companyName "); + queryWrapper.select(" t4.REALNAME as firstSignUserName , t5.REALNAME as doneSignUserName "); + queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Contract::getCreator); + queryWrapper.leftJoin(" company t2 on t2.id = t.PARTY_COMPANY_ID "); + queryWrapper.leftJoin(" company t3 on t3.id = t.COMPANY_ID "); + queryWrapper.leftJoin(" system_user t4 on t4.id = t.SIGN_USER_ID "); + queryWrapper.leftJoin(" system_user t5 on t5.id = t.COM_SIGN_USER_ID "); + queryWrapper.eq(Contract::getId,id); + queryWrapper.last(" limit 1"); + Contract contract = contractJoinMapper.selectJoinOne(Contract.class,queryWrapper); + + + Multifile multifile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjType,Constants.MultiFile.CONTRACT_PDF.getKey()) + .eq(Multifile::getObjId,contract.getId()) + .last(" limit 1 ") + ); + + if(Objects.nonNull(multifile)&&StringUtils.isNotBlank(multifile.getFileurl())){ + String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ + systemDictDataBiz.queryByCode(Constants.OSS,Constants.CONTRACT).getCode(); + multifile.setFileurlFull(url + multifile.getFileurl()); + contract.setMultifile(multifile); + } + + if(Constants.equalsInteger(contract.getStatus(),Constants.ONE) || Constants.equalsInteger(contract.getStatus(),Constants.THREE) ){ + Multifile multiFirstFile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjType,Constants.MultiFile.CONTRACT_FIRST_PDF.getKey()) + .eq(Multifile::getObjId,contract.getId()) + .last(" limit 1 ") + ); + String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ + systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode(); + + if(Objects.nonNull(multiFirstFile)&&StringUtils.isNotBlank(multiFirstFile.getFileurl())){ + multiFirstFile.setFileurlFull(path + multiFirstFile.getFileurl()); + contract.setMultiFirstFile(multiFirstFile); + } + + if(StringUtils.isNotBlank(contract.getDoneFileUrl())){ + Multifile multiDoneFile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjType,Constants.MultiFile.CONTRACT_DONE_PDF.getKey()) + .eq(Multifile::getObjId,contract.getId()) + .last(" limit 1 ") + ); + + if(Objects.nonNull(multiDoneFile)&&StringUtils.isNotBlank(multiDoneFile.getFileurl())){ + multiDoneFile.setFileurlFull(path + multiDoneFile.getFileurl()); + contract.setMultiDoneFile(multiDoneFile); + } + } + + } + + return contract; } @Override @@ -87,112 +262,257 @@ @Override public PageData<Contract> findPage(PageWrap<Contract> pageWrap) { IPage<Contract> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); - QueryWrapper<Contract> queryWrapper = new QueryWrapper<>(); + MPJLambdaWrapper<Contract> queryWrapper = new MPJLambdaWrapper<>(); Utils.MP.blankToNull(pageWrap.getModel()); - if (pageWrap.getModel().getId() != null) { - queryWrapper.lambda().eq(Contract::getId, pageWrap.getModel().getId()); + queryWrapper.selectAll(Contract.class); + queryWrapper.select(" ifnull(t2.name,'瀹夊窘浜戞槗淇濈鎶�鏈夐檺鍏徃') as partyCompanyName , t3.name as companyName "); + queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Contract::getCreator); + queryWrapper.leftJoin(" company t2 on t2.id = t.PARTY_COMPANY_ID "); + queryWrapper.leftJoin(" company t3 on t3.id = t.COMPANY_ID "); + queryWrapper.eq(Contract::getIsdeleted,Constants.ZERO); + queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getCompanyId()), + Contract::getCompanyId,pageWrap.getModel().getCompanyId()); + + queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()), + Contract::getName,pageWrap.getModel().getName()); + + queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getStatus()), + Contract::getStatus,pageWrap.getModel().getStatus()); + + queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getSignType()), + Contract::getSignType,pageWrap.getModel().getSignType()); + + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + if(Constants.equalsInteger(loginUserInfo.getType(),Constants.ONE)){ + //浼佷笟鍙湅鏁版嵁 + queryWrapper.eq(Contract::getCompanyId,loginUserInfo.getCompanyId()); + }else if(Constants.equalsInteger(loginUserInfo.getType(),Constants.TWO)){ + //鍟嗘埛鍙湅鍒扮殑鏁版嵁 + queryWrapper.and(i->i.eq(Contract::getPartyCompanyId,loginUserInfo.getCompanyId()).or() + .eq(Contract::getCompanyId,loginUserInfo.getCompanyId())); } - if (pageWrap.getModel().getCreator() != null) { - queryWrapper.lambda().eq(Contract::getCreator, pageWrap.getModel().getCreator()); - } - if (pageWrap.getModel().getCreateDate() != null) { - queryWrapper.lambda().ge(Contract::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); - queryWrapper.lambda().le(Contract::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); - } - if (pageWrap.getModel().getEditor() != null) { - queryWrapper.lambda().eq(Contract::getEditor, pageWrap.getModel().getEditor()); - } - if (pageWrap.getModel().getEditDate() != null) { - queryWrapper.lambda().ge(Contract::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); - queryWrapper.lambda().le(Contract::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); - } - if (pageWrap.getModel().getIsdeleted() != null) { - queryWrapper.lambda().eq(Contract::getIsdeleted, pageWrap.getModel().getIsdeleted()); - } - if (pageWrap.getModel().getRemark() != null) { - queryWrapper.lambda().eq(Contract::getRemark, pageWrap.getModel().getRemark()); - } - if (pageWrap.getModel().getName() != null) { - queryWrapper.lambda().eq(Contract::getName, pageWrap.getModel().getName()); - } - if (pageWrap.getModel().getCompanyId() != null) { - queryWrapper.lambda().eq(Contract::getCompanyId, pageWrap.getModel().getCompanyId()); - } - if (pageWrap.getModel().getContent() != null) { - queryWrapper.lambda().eq(Contract::getContent, pageWrap.getModel().getContent()); - } - if (pageWrap.getModel().getStatus() != null) { - queryWrapper.lambda().eq(Contract::getStatus, pageWrap.getModel().getStatus()); - } - if (pageWrap.getModel().getComSignUserId() != null) { - queryWrapper.lambda().eq(Contract::getComSignUserId, pageWrap.getModel().getComSignUserId()); - } - if (pageWrap.getModel().getComSignDate() != null) { - queryWrapper.lambda().ge(Contract::getComSignDate, Utils.Date.getStart(pageWrap.getModel().getComSignDate())); - queryWrapper.lambda().le(Contract::getComSignDate, Utils.Date.getEnd(pageWrap.getModel().getComSignDate())); - } - if (pageWrap.getModel().getComSignInfo() != null) { - queryWrapper.lambda().eq(Contract::getComSignInfo, pageWrap.getModel().getComSignInfo()); - } - if (pageWrap.getModel().getType() != null) { - queryWrapper.lambda().eq(Contract::getType, pageWrap.getModel().getType()); - } - if (pageWrap.getModel().getSignUserId() != null) { - queryWrapper.lambda().eq(Contract::getSignUserId, pageWrap.getModel().getSignUserId()); - } - if (pageWrap.getModel().getSignDate() != null) { - queryWrapper.lambda().ge(Contract::getSignDate, Utils.Date.getStart(pageWrap.getModel().getSignDate())); - queryWrapper.lambda().le(Contract::getSignDate, Utils.Date.getEnd(pageWrap.getModel().getSignDate())); - } - if (pageWrap.getModel().getSignInfo() != null) { - queryWrapper.lambda().eq(Contract::getSignInfo, pageWrap.getModel().getSignInfo()); - } - if (pageWrap.getModel().getFileUrl() != null) { - queryWrapper.lambda().eq(Contract::getFileUrl, pageWrap.getModel().getFileUrl()); - } - if (pageWrap.getModel().getFileSignUrl() != null) { - queryWrapper.lambda().eq(Contract::getFileSignUrl, pageWrap.getModel().getFileSignUrl()); - } - if (pageWrap.getModel().getDoneFileUrl() != null) { - queryWrapper.lambda().eq(Contract::getDoneFileUrl, pageWrap.getModel().getDoneFileUrl()); - } - if (pageWrap.getModel().getAppyno() != null) { - queryWrapper.lambda().eq(Contract::getAppyno, pageWrap.getModel().getAppyno()); - } - if (pageWrap.getModel().getDoneApplyno() != null) { - queryWrapper.lambda().eq(Contract::getDoneApplyno, pageWrap.getModel().getDoneApplyno()); - } - if (pageWrap.getModel().getStartTime() != null) { - queryWrapper.lambda().ge(Contract::getStartTime, Utils.Date.getStart(pageWrap.getModel().getStartTime())); - queryWrapper.lambda().le(Contract::getStartTime, Utils.Date.getEnd(pageWrap.getModel().getStartTime())); - } - if (pageWrap.getModel().getEndTime() != null) { - queryWrapper.lambda().ge(Contract::getEndTime, Utils.Date.getStart(pageWrap.getModel().getEndTime())); - queryWrapper.lambda().le(Contract::getEndTime, Utils.Date.getEnd(pageWrap.getModel().getEndTime())); - } - if (pageWrap.getModel().getCancelDate() != null) { - queryWrapper.lambda().ge(Contract::getCancelDate, Utils.Date.getStart(pageWrap.getModel().getCancelDate())); - queryWrapper.lambda().le(Contract::getCancelDate, Utils.Date.getEnd(pageWrap.getModel().getCancelDate())); - } - if (pageWrap.getModel().getCancelUserId() != null) { - queryWrapper.lambda().eq(Contract::getCancelUserId, pageWrap.getModel().getCancelUserId()); - } - if (pageWrap.getModel().getCancelInfo() != null) { - queryWrapper.lambda().eq(Contract::getCancelInfo, pageWrap.getModel().getCancelInfo()); - } - for(PageWrap.SortData sortData: pageWrap.getSorts()) { - if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { - queryWrapper.orderByDesc(sortData.getProperty()); - } else { - queryWrapper.orderByAsc(sortData.getProperty()); + if(Objects.nonNull(pageWrap.getModel().getQueryStatus())){ + if(Constants.equalsInteger(pageWrap.getModel().getQueryStatus(),Constants.ZERO)){ + queryWrapper.apply(" t.status = 0 and t.sign_type in (0,1) "); + }else if(Constants.equalsInteger(pageWrap.getModel().getQueryStatus(),Constants.ONE)){ + queryWrapper.apply(" ( (t.status = 0 and t.sign_type = 2 ) or ( t.status = 1 and t.sign_type = 0 ) )"); + }else if(Constants.equalsInteger(pageWrap.getModel().getQueryStatus(),Constants.TWO)){ + queryWrapper.apply(" ( (t.status = 1 and t.sign_type = 1 ) or ( t.status = 1 and t.sign_type = 2 ) )"); + }else{ + queryWrapper.eq(Contract::getStatus,pageWrap.getModel().getQueryStatus()); } } - return PageData.from(contractMapper.selectPage(page, queryWrapper)); + queryWrapper.orderByDesc(Contract::getCreateDate); + PageData<Contract> pageData = PageData.from(contractJoinMapper.selectJoinPage(page,Contract.class, queryWrapper)); + for (Contract contract:pageData.getRecords()) { + this.dealQueryStauts(contract); + } + return pageData; } + + public void dealQueryStauts(Contract contract){ + if(Constants.equalsInteger(contract.getSignType(),Constants.ZERO)){ + if(Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + contract.setQueryStatus(Constants.ZERO); + }else if(Constants.equalsInteger(contract.getStatus(),Constants.ONE)){ + contract.setQueryStatus(Constants.ONE); + }else{ + contract.setQueryStatus(contract.getStatus()); + } + }else if(Constants.equalsInteger(contract.getSignType(),Constants.ONE)){ + if(Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + contract.setQueryStatus(Constants.ZERO); + }else if(Constants.equalsInteger(contract.getStatus(),Constants.ONE)){ + contract.setQueryStatus(Constants.TWO); + }else{ + contract.setQueryStatus(contract.getStatus()); + } + }else{ + if(Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + contract.setQueryStatus(Constants.ONE); + }else if(Constants.equalsInteger(contract.getStatus(),Constants.ONE)){ + contract.setQueryStatus(Constants.TWO); + }else{ + contract.setQueryStatus(contract.getStatus()); + } + } + } + + @Override + public void cancel(Integer id) { + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + Contract contract = contractJoinMapper.selectById(id); + if(Objects.isNull(contract)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍚堝悓淇℃伅"); + } + if(!Constants.equalsInteger(contract.getStatus(),Constants.CONTRACT_STATUS.WAIT.getKey())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝悓淇℃伅淇℃伅宸叉祦杞�"); + } + if(StringUtils.isNotBlank(contract.getApplyNo())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝悓绛剧讲涓紝鏃犳硶杩涜鍙栨秷"); + } + + contract.setStatus(Constants.CONTRACT_STATUS.CANCEL.getKey()); + contract.setCancelDate(new Date()); + contract.setCancelUserId(loginUserInfo.getId()); + contract.setEditor(loginUserInfo.getId()); + contract.setEditDate(new Date()); + contractMapper.updateById(contract); + + //鍒犻櫎寰呭姙 + Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.CONTRACT; + noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,contract.getId())); + + } + @Override public long count(Contract contract) { QueryWrapper<Contract> wrapper = new QueryWrapper<>(contract); return contractMapper.selectCount(wrapper); } + + + @Override + public String getContractSignLink(Integer id) { + if(id == null ){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + MPJLambdaWrapper<Contract> queryWrapper = new MPJLambdaWrapper<>(); + queryWrapper.selectAll(Contract.class); + queryWrapper.select(" ifnull(t2.name,'瀹夊窘浜戞槗淇濈鎶�鏈夐檺鍏徃') as partyCompanyName , t3.name as companyName "); + queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Contract::getCreator); + queryWrapper.leftJoin(" company t2 on t2.id = t.PARTY_COMPANY_ID "); + queryWrapper.leftJoin(" company t3 on t3.id = t.COMPANY_ID "); + queryWrapper.eq(Contract::getIsdeleted,Constants.ZERO); + queryWrapper.eq(Contract::getId,id); + queryWrapper.last(" limit 1"); + Contract contract = contractJoinMapper.selectJoinOne(Contract.class,queryWrapper); + if(contract == null ||!Constants.equalsInteger(contract.getIsdeleted(),Constants.ZERO) ){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + Company company = companyMapper.selectById(contract.getCompanyId()); + if(Objects.isNull(company)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌浼佷笟淇℃伅!"); + } + //褰撳墠绛剧讲浜� 0=鎴戞柟锛�2=浼佷笟/鍟嗘埛 + Integer signatory = Constants.ZERO; + //鍒ゆ柇褰撳墠鏄惁鍙互绛剧讲 + if(Constants.equalsInteger(user.getType(),Constants.ZERO)){ + //鍒ゆ柇骞冲彴鏄惁鍙互绛剧讲 + if(!( !Constants.equalsInteger(contract.getSignType(),Constants.TWO) && Constants.equalsInteger(contract.getStatus(),Constants.ZERO))){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠闈炲钩鍙扮敤鎴峰彲绛剧讲娴佺▼"); + } + }else if(Constants.equalsInteger(user.getType(),Constants.TWO)){ + //骞冲彴鍒涘缓鐨� + if(!Constants.equalsInteger(contract.getSignType(),Constants.TWO) ){ + signatory = Constants.ONE; + //鍒ゆ柇鐘舵�佹槸鍚︾瓑浜庡緟鍟嗘埛绛剧讲 绛剧讲浼佷笟鏄惁绛変簬褰撳墠鐧诲綍浜轰紒涓� + if(!(Constants.equalsInteger(contract.getStatus(),Constants.ONE) && Constants.equalsInteger(contract.getCompanyId(),user.getCompanyId()))){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠闈炲晢鎴风敤鎴峰彲绛剧讲娴佺▼"); + } + }else{ + //鍟嗘埛鍒涘缓 + //鍒ゆ柇鐘舵�佹槸鍚︾瓑浜庡緟鍟嗘埛绛剧讲 + if(!Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠闈炲晢鎴风敤鎴峰彲绛剧讲娴佺▼"); + } + } + }else{ + signatory = Constants.ONE; + //浼佷笟鐢ㄦ埛鍒ゆ柇 + if(!(Constants.equalsInteger(contract.getCompanyId(),user.getCompanyId()) && Constants.equalsInteger(contract.getStatus(),Constants.ONE) )){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠闈炰紒涓氱敤鎴峰彲绛剧讲娴佺▼"); + } + } + + Constants.ApplyLogType applyLogType = null; + String info = ""; + + Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjId,contract.getId()) + .eq(Multifile::getObjType,Constants.MultiFile.CONTRACT_PDF.getKey()) + .eq(Multifile::getIsdeleted,Constants.ZERO).last("limit 1")); + if(f == null || StringUtils.isBlank(f.getFileurl())){ + throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇寰呯绔犳枃浠跺け璐ワ紝璇疯仈绯荤‘璁ょ缃叉枃浠舵槸鍚︽纭紒"); + } + String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode(); + if(Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + url = url + systemDictDataBiz.queryByCode(Constants.OSS,Constants.CONTRACT).getCode() + f.getFileurl(); + }else{ + url = url + systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode() + contract.getFileSignUrl(); + } + + String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode(); + + String companyName = ""; + String creditCode = ""; + String email = ""; + //骞冲彴绛剧讲 + if(!Constants.equalsInteger(contract.getSignType(),Constants.TWO) && Constants.equalsInteger(contract.getStatus(),Constants.ZERO)){ + companyName = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLAT_COMPANY_NAME).getCode(); + creditCode = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLAT_CREDIT_CODE).getCode(); + email = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLAT_EMAIL).getCode(); + }else if((Constants.equalsInteger(contract.getSignType(),Constants.ZERO) && Constants.equalsInteger(contract.getStatus(),Constants.ONE))|| + Constants.equalsInteger(contract.getSignType(),Constants.TWO) && Constants.equalsInteger(contract.getStatus(),Constants.ZERO) + ) { + //鍟嗘埛绛剧讲 + Company shop = null; + if(Constants.equalsInteger(contract.getStatus(),Constants.ONE)){ + shop = companyMapper.selectById(contract.getCompanyId()); + }else{ + shop = companyMapper.selectById(contract.getPartyCompanyId()); + } + if(Objects.isNull(shop)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍟嗘埛淇℃伅"); + } + companyName = shop.getName(); + creditCode = shop.getCode(); + email = shop.getEmail(); + } else { + companyName = Constants.equalsInteger(contract.getStatus(),Constants.ZERO)?contract.getPartyCompanyName():contract.getCompanyName(); + creditCode = company.getCode(); + email = company.getEmail(); + } + String applyNo = signService.applySign(contract.getName(),url, + companyName + ,creditCode,email,null,company.getSignId(),notifyUrl); + if(StringUtils.isBlank(applyNo) ){ + throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�"); + } + String link = signService.signLink(applyNo,companyName,creditCode); + if(StringUtils.isBlank(link) ){ + throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�"); + } + Contract update= new Contract(); + update.setId(contract.getId()); + update.setEditor(user.getId()); + update.setEditDate(new Date()); + if(Constants.equalsInteger(signatory,Constants.ZERO)){ + update.setApplyNo(applyNo); + update.setSignUserId(user.getId()); + update.setSignDate(new Date()); + + //瀛樺偍寰呭姙淇℃伅 + Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.CONTRACT; + noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,update.getId())); + Notices notices = new Notices(noticeObjectType, + Constants.equalsInteger(contract.getSignType(),Constants.TWO)?Constants.ONE:Constants.TWO + ,contract.getId(), + this.getNoticeInfo(contract,company), + contract.getCompanyId() + ,Constants.NoticeType.ZERO); + noticesMapper.insert(notices); + + }else{ + update.setDoneApplyNo(applyNo); + update.setComSignUserId(user.getId()); + update.setComSignDate(new Date()); + } + contractMapper.updateById(update); + return link; + } + + } -- Gitblit v1.9.3