From 99de1af0add8cb4eb0d09add255c2fa0ff518376 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 26 一月 2024 11:25:44 +0800
Subject: [PATCH] 开发业务接口
---
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 228 insertions(+), 6 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 3b4aaf7..d43ad88 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1,6 +1,8 @@
package com.doumee.service.business.impl;
import com.alibaba.fastjson.JSONObject;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -21,6 +23,7 @@
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.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
@@ -51,8 +54,15 @@
private InsuranceApplyMapper insuranceApplyMapper;
@Autowired
+ private CompanySolutionMapper companySolutionMapper;
+
+ @Autowired
private ApplyChangeJoinMapper applyChangeJoinMapper;
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+ @Autowired
+ private SignService signService;
@Autowired
private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper;
@@ -158,9 +168,13 @@
multifileMapper.insert(param.getPidanFile());
update.setApplyId(model.getApplyId());
- long times = param.getApplyStartTime().getTime() - model.getValidTime().getTime();
- //澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
- dealDetailsValidTime(update,times);
+ if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
+ //濡傛灉鏄姞鍑忎繚鐢宠 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
+ dealDetailsValidTime(update);
+ }else{
+ //濡傛灉鏄崲鍘傜敵璇� 澶勭悊鏄庣粏鏁版嵁
+ dealDetailsDUdata(update);
+ }
Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
@@ -234,9 +248,45 @@
/**
* 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
* @param update
- * @param times
*/
- private void dealDetailsValidTime(ApplyChange update,long times) {
+ private void dealDetailsDUdata(ApplyChange update ) {
+ List<ApplyChagneDetail> detailList = applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,
+ new MPJLambdaWrapper<ApplyChagneDetail>()
+ .selectAll(ApplyChagneDetail.class)
+ .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
+ .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
+ .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
+ .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
+ .eq(ApplyChagneDetail::getApplyChangeId,update.getId())
+ .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) );
+ if(detailList ==null || detailList.size()==0){
+ return;
+ }
+ for(ApplyChagneDetail detail : detailList){
+ //鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
+ ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
+ .eq(ApplyDetail::getApplyId, update.getApplyId())
+ .eq(ApplyDetail::getMemberId, detail.getMemberId())
+ .orderByDesc(ApplyDetail::getCreateDate)
+ .last("limit 1"));
+ if(oldModel == null ){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鐢ㄦ埛銆�"+detail.getMemberName()+"銆戝師淇濆崟淇℃伅鏈夎锛屽綋鍓嶇敵璇蜂笉鏀寔鍑忎繚澶勭悊锛�");
+ }
+ applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
+ .set(ApplyDetail::getEditor,update.getEditor())
+ .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
+ .set(ApplyDetail::getDuId,detail.getDuId())
+ .set(ApplyDetail::getEditDate,update.getEditDate())
+ .eq(ApplyDetail::getId,oldModel.getApplyId())
+ );
+
+ }
+ }
+ /**
+ * 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
+ * @param update
+ */
+ private void dealDetailsValidTime(ApplyChange update ) {
List<ApplyChagneDetail> detailList = applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,
new MPJLambdaWrapper<ApplyChagneDetail>()
.selectAll(ApplyChagneDetail.class)
@@ -308,7 +358,7 @@
}
}
if(addList!=null && addList.size()>0){
- applyChagneDetailJoinMapper.insertBatchSomeColumn(addList);
+ applyDetailJoinMapper.insertBatchSomeColumn(addList);
}
if(totalFee.compareTo(new BigDecimal(0)) != 0){
//濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
@@ -413,6 +463,15 @@
if(Objects.isNull(solutions)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
}
+ CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
+ .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(CompanySolution::getSolutionBaseId,solutions.getId())
+ .eq(CompanySolution::getIsdeleted,Constants.ZERO)
+ .last(" limit 1 ")
+ );
+ if(Objects.isNull(companySolution)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌浼佷笟鍒嗛厤淇濋櫓鏂规淇℃伅");
+ }
//鐢宠鏃堕棿蹇呴』澶勪簬淇濆崟鐨勬椂闂磋寖鍥村唴
if (!(DateUtil.compareDate(applyChange.getValidTime(), insuranceApply.getStartTime()) >= Constants.ZERO
&& DateUtil.compareDate(insuranceApply.getEndTime(), applyChange.getValidTime()) >= Constants.ZERO)) {
@@ -445,12 +504,18 @@
//鍔犱繚鏁版嵁
List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
if (CollectionUtils.isNotEmpty(addDetailList)) {
+ if(companySolution.getCanAdd().equals(Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+ }
this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo);
}
//鍑忎繚鏁版嵁
List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
if (CollectionUtils.isNotEmpty(delDetailList)) {
+ if(companySolution.getCanReduce().equals(Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+ }
this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
}
//鎹㈠巶涓氬姟
@@ -870,8 +935,165 @@
ApplyChange applyChange = applyChangeJoinMapper.selectOne(queryWrapper);
return applyChange;
}
+ /**
+ * 瀵煎嚭鎹㈠巶鐢宠琛�
+ * @param param
+ * @return
+ */
+ @Override
+ public ApplyChange exportChangeUnitExcel(ApplyChange param){
+ ApplyChange model = findJoinDetail(param);
+ if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+
+ //鏌ヨ鏄庣粏
+ List<ApplyChagneDetail> detailList =findJoinChangeDetailList(model);
+ model.setChangeDetailList(detailList!=null?detailList:new ArrayList<>());
+ model.setChangeNum(model.getChangeDetailList().size());
+ return model;
+ }
+ /**
+ * 瀵煎嚭鎹㈠巶鐢宠琛�
+ * @param param
+ * @return
+ */
+ @Override
+ public String getSignLinkJiajiabao(ApplyChange param){
+ ApplyChange model = exportJiajianBaoExcel(param);
+ return getOnlineSignLink(model);
+ }
+ /**
+ * 瀵煎嚭鎹㈠巶鐢宠琛�
+ * @param param
+ * @return
+ */
+ @Override
+ public String getSignLinkChangeUnit(ApplyChange param){
+ ApplyChange model = exportChangeUnitExcel(param);
+ return getOnlineSignLink(model);
+ }
+
+ private String getOnlineSignLink(ApplyChange model) {
+ if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(!Constants.equalsInteger(Constants.ZERO,model.getStatus())){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇ョ敵璇风姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔绛剧珷鎿嶄綔锛�");
+ }
+ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ Company company = user.getCompany();
+ if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝浼佷笟灏氭湭鍏峰鍦ㄧ嚎绛剧珷鏉′欢锛岃鑱旂郴骞冲彴绠$悊鍛樼‘璁");
+ }
+
+ String fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"缂撳瓨鐢宠琛�");
+ String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode();
+ notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString());
+ String applyNo = signService.applySignLocalFile(company.getName(),fileUrl,company.getName(),company.getCode(),company.getEmail(),null,company.getSignId(),notifyUrl);
+ if(StringUtils.isBlank(applyNo) ){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+ }
+ String link = signService.signLink(applyNo,company.getEmail(),company.getCode());
+ if(StringUtils.isBlank(link) ){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+ }
+ ApplyChange update= new ApplyChange();
+ update.setId(model.getId());
+ update.setEditor(user.getId());
+ update.setEditDate(new Date());
+ update.setSignApplyNo(applyNo);
+ applyChangeMapper.updateById(update);
+ return link;
+ }
+ /**
+ * 瀵煎嚭鍔犲噺淇濈敵璇疯〃
+ * @param param
+ * @return
+ */
+ @Override
+ public ApplyChange exportJiajianBaoExcel(ApplyChange param){
+
+ ApplyChange model = findJoinDetail(param);
+ if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+
+ //鏌ヨ鏄庣粏
+ List<ApplyChagneDetail> detailList =findJoinDetailList(model);
+ model.setAddDetailList(new ArrayList<>());
+ model.setDelDetailList(new ArrayList<>());
+ if(detailList!=null){
+ for(ApplyChagneDetail ad :detailList){
+ if(Constants.equalsInteger(ad.getType(),Constants.ZERO)){
+ model.getAddDetailList().add(ad);
+ }else{
+ model.getDelDetailList().add(ad);
+ }
+ }
+ }
+ model.setDelNum(model.getDelDetailList().size());
+ model.setAddNum(model.getAddDetailList().size());
+ return model;
+ }
+ private ApplyChange findJoinDetail(ApplyChange param) {
+ MPJLambdaWrapper wrapper= new MPJLambdaWrapper<ApplyChange>()
+ .selectAll(ApplyChange.class)
+ .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
+ .selectAs(Company::getName,ApplyChange::getCompanyName)
+ .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
+ .selectAs(InsuranceApply::getStartTime,ApplyChange::getStartTime)
+ .selectAs(InsuranceApply::getStartTime,ApplyChange::getEndTime)
+ .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
+ .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
+ .leftJoin(Company.class,Company::getId,ApplyChange::getCompanyId)
+ .eq(ApplyChange::getId,param.getId())
+ .last("limit 1");
+
+ ApplyChange model = applyChangeJoinMapper.selectJoinOne(ApplyChange.class,wrapper);
+ return model;
+ }
+ private List<ApplyChagneDetail> findJoinDetailList(ApplyChange model) {
+ MPJLambdaWrapper wrapper1= new MPJLambdaWrapper<ApplyChagneDetail>()
+ .selectAll(ApplyChagneDetail.class)
+ .selectAs(Member::getName,ApplyChagneDetail::getMemberName)
+ .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+ .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+ .selectAs(Worktype::getName,ApplyChagneDetail::getWorkTypeName)
+ .selectAs(DispatchUnit::getName,ApplyChagneDetail::getDuName)
+ .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
+ .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
+ .leftJoin(Member.class,Member::getId,ApplyChagneDetail::getMemberId)
+ .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO)
+ .eq(ApplyChagneDetail::getApplyChangeId,model.getId());
+ //鏌ヨ鏄庣粏
+ List<ApplyChagneDetail> detailList =applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,wrapper1);
+ return detailList;
+ }
+ private List<ApplyChagneDetail> findJoinChangeDetailList(ApplyChange model) {
+ MPJLambdaWrapper wrapper1= new MPJLambdaWrapper<ApplyChagneDetail>()
+ .selectAll(ApplyChagneDetail.class)
+ .selectAs(Member::getName,ApplyChagneDetail::getMemberName)
+ .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+ .select("t1.name as worktypeName")
+ .select("t2.name as duName")
+ .select("t3.name as oldWorktypeName")
+ .select("t4.name as oldDuName")
+ .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+ .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+ .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
+ .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
+ .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getOldWorktypeId)
+ .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getOldDuId)
+ .leftJoin(Member.class,Member::getId,ApplyChagneDetail::getMemberId)
+ .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO)
+ .eq(ApplyChagneDetail::getApplyChangeId,model.getId());
+ //鏌ヨ鏄庣粏
+ List<ApplyChagneDetail> detailList =applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,wrapper1);
+ return detailList;
+ }
}
--
Gitblit v1.9.3