@@ -23,5 +23,6 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CONTRACT_STATUS_NOT_APPROVAL = new ErrorCode(1_027_000_008, "{}状态合同不允许审核");
|
||||
ErrorCode CONTRACT_ERP_COMPANY_PLEASE_BIND = new ErrorCode(1_027_000_009, "请先绑定{}ERP公司信息");
|
||||
ErrorCode CONTRACT_STATUS_NOT_DELETE = new ErrorCode(1_027_000_010, "{}状态合同不允许删除");
|
||||
ErrorCode CONTRACT_ERP_RCV_DLVY_NOT_EXISTS = new ErrorCode(1_027_000_010, "不存在的收支类型或收支类型为空");
|
||||
ErrorCode CONTRACT_ERP_RCV_DLVY_NOT_EXISTS = new ErrorCode(1_027_000_011, "不存在的收支类型或收支类型为空");
|
||||
ErrorCode CONTRACT_STATUS_NOT_ARCHIVE = new ErrorCode(1_027_000_012, "{}状态合同不允许归档");
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -101,35 +103,35 @@ public class ContractController implements BusinessControllerMarker {
|
||||
@PostMapping("/download")
|
||||
@Operation(summary = "下载文件")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:download')")
|
||||
public void download(@RequestBody List<Long> ids) {
|
||||
contractService.download(ids);
|
||||
public ResponseEntity<ByteArrayResource> download(@RequestBody List<Long> ids) {
|
||||
return contractService.download(ids);
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/preview")
|
||||
@Operation(summary = "预览文件 TODO")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:preview')")
|
||||
public void preview() {
|
||||
@PostMapping("/cancel")
|
||||
@Operation(summary = "作废")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:cancel')")
|
||||
public CommonResult<Boolean> cancel(@RequestBody List<Long> ids) {
|
||||
return success(contractService.cancel(ids));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/complete")
|
||||
@Operation(summary = "完结 TODO")
|
||||
@Operation(summary = "完结")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:complete')")
|
||||
public void complete() {
|
||||
public CommonResult<Boolean> complete(@RequestBody List<Long> ids) {
|
||||
return success(contractService.complete(ids));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/archive")
|
||||
@Operation(summary = "归档 TODO")
|
||||
@Operation(summary = "归档")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:archive')")
|
||||
public void archive() {
|
||||
public CommonResult<Boolean> archive(@RequestBody List<Long> ids) {
|
||||
return success(contractService.archive(ids));
|
||||
}
|
||||
|
||||
@GetMapping("/submit/approval")
|
||||
@Operation(summary = "合同提交审批")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:approval')")
|
||||
public CommonResult<String> submitApproval(@RequestParam("id") Long id) {
|
||||
public CommonResult<Boolean> submitApproval(@RequestParam("id") Long id) {
|
||||
return success(contractService.submitApproval(id));
|
||||
}
|
||||
|
||||
@@ -141,13 +143,6 @@ public class ContractController implements BusinessControllerMarker {
|
||||
return success(contractService.approval(reqVO));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/view/approval")
|
||||
@Operation(summary = "查看审批 TODO")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:approval')")
|
||||
public void viewApproval() {
|
||||
}
|
||||
|
||||
@PostMapping("/submit/erp")
|
||||
@Operation(summary = "提交ERP")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
||||
|
||||
@@ -162,9 +162,6 @@ public class ContractSaveReqVO {
|
||||
@Schema(description = "备注;与ERP(BZXX)对应", example = "备注")
|
||||
private String remark;
|
||||
|
||||
// 物料信息
|
||||
private List<DetailSaveReqVO> detail;
|
||||
|
||||
// 扩展信息
|
||||
@Schema(description = "原币金额-变更后;与ERP(BGHHTYBZJE)对应,拓展信息")
|
||||
private BigDecimal changeCooAmount;
|
||||
@@ -216,6 +213,9 @@ public class ContractSaveReqVO {
|
||||
@Schema(description = "模板实例主键", example = "10196")
|
||||
private Long instanceId;
|
||||
|
||||
// 物料信息
|
||||
private List<DetailSaveReqVO> detail;
|
||||
|
||||
// 合同动态表单
|
||||
private List<TemplateInstanceDataSaveReqVO> dynamicsFields;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
@@ -45,7 +46,7 @@ public class FormulaSaveReqVO {
|
||||
private String elementName;
|
||||
|
||||
@Schema(description = "结算类型,多条使用逗号分隔(字典:PRCH_STLM_TP)", example = "1")
|
||||
private String settlementType;
|
||||
private JSONArray settlementType;
|
||||
|
||||
// 基础系数配置
|
||||
private List<CoefficientSaveReqVO> coefficients;
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
|
||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -54,7 +56,7 @@ public interface ContractService {
|
||||
* @param id 合同ID
|
||||
* @return 提交审批结果
|
||||
*/
|
||||
String submitApproval(Long id);
|
||||
Boolean submitApproval(Long id);
|
||||
|
||||
/**
|
||||
* 合同审批
|
||||
@@ -164,6 +166,31 @@ public interface ContractService {
|
||||
* 下载文件
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 压缩文件流
|
||||
*/
|
||||
void download(List<Long> ids);
|
||||
ResponseEntity<ByteArrayResource> download(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 归档
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 归档结果
|
||||
*/
|
||||
Boolean archive(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 作废
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 作废结果
|
||||
*/
|
||||
Boolean cancel(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 完结
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 完结结果
|
||||
*/
|
||||
Boolean complete(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ import com.zt.plat.module.base.controller.admin.templtp.vo.TemplateInstanceDataR
|
||||
import com.zt.plat.module.base.controller.admin.templtp.vo.TemplateInstanceItemRespVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.tmpltp.TemplateInstanceDataDO;
|
||||
import com.zt.plat.module.base.dal.dataobject.tmpltp.TemplateInstanceItemDO;
|
||||
import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscBsnRelDO;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TemplateInstanceDataMapper;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TemplateInstanceItemMapper;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TmplInscBsnRelMapper;
|
||||
import com.zt.plat.module.base.service.tmpltp.TemplateInstanceDataService;
|
||||
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
||||
@@ -28,6 +30,7 @@ import com.zt.plat.module.contractorder.enums.*;
|
||||
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpCompanyDO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpCompanyService;
|
||||
import com.zt.plat.module.erp.service.erp.ErpContractService;
|
||||
@@ -40,15 +43,23 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.*;
|
||||
@@ -102,6 +113,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
private SystemRelativityMapper systemRelativityMapper;
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
@Resource
|
||||
private TmplInscBsnRelMapper tmplInscBsnRelMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<ContractMainDO> getContractPage(ContractPageReqVO pageReqVO) {
|
||||
@@ -128,23 +141,33 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
}
|
||||
|
||||
// 合同主信息
|
||||
ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
|
||||
|
||||
// 校验ERP的公司
|
||||
if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber())
|
||||
|| StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) {
|
||||
if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber())) {
|
||||
if (erpCompanyService.getErpCompanyByNumber(reqVO.getPurchaseCompanyNumber()) == null) {
|
||||
ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getPurchaseCompanyNumber());
|
||||
if (erpCompany == null) {
|
||||
throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.PURCHASE);
|
||||
} else {
|
||||
contractMainDO.setErpPurchaseCompanyNumber(erpCompany.getNumber());
|
||||
contractMainDO.setErpPurchaseCompanyName(erpCompany.getName());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) {
|
||||
if (erpCompanyService.getErpCompanyByNumber(reqVO.getSalesCompanyNumber()) == null) {
|
||||
ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getSalesCompanyNumber());
|
||||
if (erpCompany == null) {
|
||||
throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.SALES);
|
||||
} else {
|
||||
contractMainDO.setErpSalesCompanyNumber(erpCompany.getNumber());
|
||||
contractMainDO.setErpSalesCompanyName(erpCompany.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 合同主信息
|
||||
ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
|
||||
|
||||
// 合同状态保存为草稿
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DRAFT.getCode());
|
||||
// 生成系统合同编号
|
||||
@@ -675,6 +698,17 @@ public class ContractServiceImpl implements ContractService {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!(DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus()))) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_UPDATE,
|
||||
DictEnum.getByCode(oldContractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 校验合同名称是否重复
|
||||
ContractMainDO contract = contractMainMapper.selectOne(new QueryWrapper<ContractMainDO>()
|
||||
.eq(TableFieldConstants.BSE_CTRT_MAIN_CTRT_NAME, reqVO.getContractName())
|
||||
@@ -693,17 +727,6 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(oldContractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_UPDATE,
|
||||
DictEnum.getByCode(oldContractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 请求更新的合同信息
|
||||
ContractMainDO newContractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
|
||||
|
||||
@@ -759,6 +782,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractDetailDO detailDO = BeanUtils.toBean(detail, ContractDetailDO.class);
|
||||
// 设置合同主信息ID
|
||||
detailDO.setContractMainId(id);
|
||||
// 主键
|
||||
detailDO.setId(null);
|
||||
// 保存合同明细
|
||||
contractDetailMapper.insert(detailDO);
|
||||
|
||||
@@ -771,6 +796,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractPlanDO planDO = BeanUtils.toBean(plan, ContractPlanDO.class);
|
||||
// 合同明细主键
|
||||
planDO.setContractDetailId(detailDOId);
|
||||
// 主键
|
||||
planDO.setId(null);
|
||||
// 保存交货计划
|
||||
contractPlanMapper.insert(planDO);
|
||||
});
|
||||
@@ -785,6 +812,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractFormulaDO formulaDO = BeanUtils.toBean(formula, ContractFormulaDO.class);
|
||||
// 合同主键
|
||||
formulaDO.setContractId(id);
|
||||
// 主键
|
||||
formulaDO.setId(null);
|
||||
// 保存价款结算条款
|
||||
contractFormulaMapper.insert(formulaDO);
|
||||
|
||||
@@ -797,6 +826,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractCoefficientDO coefficientDO = BeanUtils.toBean(coefficient, ContractCoefficientDO.class);
|
||||
// 条款主键
|
||||
coefficientDO.setFormulaId(formulaDOId);
|
||||
// 主键
|
||||
coefficientDO.setId(null);
|
||||
// 保存基础系数配置
|
||||
contractCoefficientMapper.insert(coefficientDO);
|
||||
});
|
||||
@@ -808,6 +839,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractGradeDO gradeDO = BeanUtils.toBean(grade, ContractGradeDO.class);
|
||||
// 条款主键
|
||||
gradeDO.setFormulaId(formulaDOId);
|
||||
// 主键
|
||||
gradeDO.setId(null);
|
||||
// 保存品位等级价配置
|
||||
contractGradeMapper.insert(gradeDO);
|
||||
});
|
||||
@@ -819,6 +852,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractDeductDO deductDO = BeanUtils.toBean(deduct, ContractDeductDO.class);
|
||||
// 条款主键
|
||||
deductDO.setFormulaId(formulaDOId);
|
||||
// 主键
|
||||
deductDO.setId(null);
|
||||
// 保存品位等级价配置
|
||||
contractDeductMapper.insert(deductDO);
|
||||
});
|
||||
@@ -830,6 +865,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractPriceDO priceDO = BeanUtils.toBean(price, ContractPriceDO.class);
|
||||
// 条款主键
|
||||
priceDO.setFormulaId(formulaDOId);
|
||||
// 主键
|
||||
priceDO.setId(null);
|
||||
// 保存市场价配置
|
||||
contractPriceMapper.insert(priceDO);
|
||||
});
|
||||
@@ -844,6 +881,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractDemoteDO demoteDO = BeanUtils.toBean(demote, ContractDemoteDO.class);
|
||||
// 设置合同主键
|
||||
demoteDO.setContractId(id);
|
||||
// 主键
|
||||
demoteDO.setId(null);
|
||||
// 保存参数降级规则
|
||||
contractDemoteMapper.insert(demoteDO);
|
||||
});
|
||||
@@ -856,6 +895,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
ContractNotDO notDO = BeanUtils.toBean(not, ContractNotDO.class);
|
||||
// 条款主键
|
||||
notDO.setContractId(id);
|
||||
// 主键
|
||||
notDO.setId(null);
|
||||
// 保存品位不计价规则
|
||||
contractNotMapper.insert(notDO);
|
||||
});
|
||||
@@ -876,13 +917,19 @@ public class ContractServiceImpl implements ContractService {
|
||||
templateInstanceDataService.setTemplateInstanceData(templateInstanceDataDOS);
|
||||
}
|
||||
|
||||
// 合同状态更新
|
||||
if (DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode().equals(oldContractMainDO.getStatus())) {
|
||||
// “推送失败”的状态编辑后状态变为“待推送”
|
||||
newContractMainDO.setStatus(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode());
|
||||
} else if (DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(oldContractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus())) {
|
||||
newContractMainDO.setStatus(DictEnum.BSE_CTRT_STS_WAIT_AUDIT.getCode());
|
||||
}
|
||||
|
||||
// 更新合同主信息
|
||||
int updateNum = contractMainMapper.updateById(newContractMainDO);
|
||||
if (updateNum > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return updateNum > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -963,7 +1010,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String submitApproval(Long id) {
|
||||
public Boolean submitApproval(Long id) {
|
||||
|
||||
// 判断主键
|
||||
if (ObjectUtils.isEmpty(id)) {
|
||||
@@ -977,11 +1024,8 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
|
||||
if (!(DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_WAIT_AUDIT.getCode().equals(contractMainDO.getStatus()))) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
@@ -996,7 +1040,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
if (StringUtils.isNotBlank(contractMainDO.getProcessInstanceId())) {
|
||||
|
||||
// TODO:驳回状态重新提交审批处理
|
||||
// TODO:待审核状态重新提交审批处理
|
||||
// 进入审批流程的合同,查询当前审批的任务节点
|
||||
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(contractMainDO.getProcessInstanceId()).getData();
|
||||
} else {
|
||||
@@ -1017,11 +1061,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode());
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
return "提交审批成功";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return "提交审批失败";
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1359,23 +1403,169 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<Long> ids) {
|
||||
public ResponseEntity<ByteArrayResource> download(List<Long> ids) {
|
||||
try {
|
||||
|
||||
// 返回的压缩包
|
||||
ByteArrayOutputStream zipsByte = new ByteArrayOutputStream();
|
||||
ZipOutputStream zips = new ZipOutputStream(zipsByte);
|
||||
|
||||
// 遍历合同ID集合
|
||||
ids.forEach(id -> {
|
||||
try {
|
||||
// 查询合同信息
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
|
||||
// 查询合同信息
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
JSONArray fileObjectOther = new JSONArray(contractMainDO.getFileObjectOther());
|
||||
System.out.println(fileObjectOther);
|
||||
CommonResult<FileRespDTO> fileRespDTOResult = fileApi
|
||||
.getFile(fileObjectOther.getJSONObject(0).getLong("id"));
|
||||
// 单个合同文件压缩
|
||||
ByteArrayOutputStream zipByte = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(zipByte);
|
||||
|
||||
// 关联的模版附件查询
|
||||
TmplInscBsnRelDO tmplInscBsnRelDO = tmplInscBsnRelMapper.selectOne("BSN_ID", id);
|
||||
if (tmplInscBsnRelDO != null) {
|
||||
if (StringUtils.isNotEmpty(tmplInscBsnRelDO.getCntt())) {
|
||||
JSONObject cntt = new JSONObject(tmplInscBsnRelDO.getCntt());
|
||||
CommonResult<FileRespDTO> fileRespResult = fileApi
|
||||
.getFile(cntt.getLong("id"));
|
||||
|
||||
zip.putNextEntry(new ZipEntry(System.currentTimeMillis() + fileRespResult.getData().getName()));
|
||||
zip.write(fileRespResult.getData().getContent());
|
||||
zip.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
// 上传模板附件
|
||||
if(StringUtils.isNotBlank(contractMainDO.getFileObject())){
|
||||
JSONArray fileObjects = new JSONArray(contractMainDO.getFileObject());
|
||||
for (int i = 0; i < fileObjects.size(); i++) {
|
||||
JSONObject file = fileObjects.getJSONObject(i);
|
||||
CommonResult<FileRespDTO> fileRespResult = fileApi
|
||||
.getFile(file.getLong("id"));
|
||||
|
||||
zip.putNextEntry(new ZipEntry(System.currentTimeMillis() + fileRespResult.getData().getName()));
|
||||
zip.write(fileRespResult.getData().getContent());
|
||||
zip.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
// 合同其它附件
|
||||
if(StringUtils.isNotBlank(contractMainDO.getFileObjectOther())){
|
||||
JSONArray fileObjectOthers = new JSONArray(contractMainDO.getFileObjectOther());
|
||||
for (int i = 0; i < fileObjectOthers.size(); i++) {
|
||||
JSONObject file = fileObjectOthers.getJSONObject(i);
|
||||
CommonResult<FileRespDTO> fileRespResult = fileApi
|
||||
.getFile(file.getLong("id"));
|
||||
|
||||
zip.putNextEntry(new ZipEntry(System.currentTimeMillis() + fileRespResult.getData().getName()));
|
||||
zip.write(fileRespResult.getData().getContent());
|
||||
zip.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
zip.finish();
|
||||
String zipName = String.format("%s(%s)相关文件.zip", contractMainDO.getContractName(), contractMainDO.getSystemContractNumber());
|
||||
zips.putNextEntry(new ZipEntry(zipName));
|
||||
zips.write(zipByte.toByteArray());
|
||||
zips.closeEntry();
|
||||
} catch (Exception e) {
|
||||
log.info("添加压缩包异常:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
zips.finish();
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=contract-file-"+ System.currentTimeMillis()+".zip")
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(new ByteArrayResource(zipsByte.toByteArray()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean archive(List<Long> ids) {
|
||||
|
||||
// 遍历合同ID
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())) {
|
||||
throw exception(CONTRACT_STATUS_NOT_ARCHIVE,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 设置归档状态
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_ARCHIVED.getCode());
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean cancel(List<Long> ids) {
|
||||
|
||||
// 遍历合同ID
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) {
|
||||
throw exception(CONTRACT_STATUS_NOT_ARCHIVE,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 设置作废状态
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_VOID.getCode());
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean complete(List<Long> ids) {
|
||||
|
||||
// 遍历合同ID
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) {
|
||||
throw exception(CONTRACT_STATUS_NOT_ARCHIVE,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 设置完结状态
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_TERMINATED.getCode());
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验合同内容
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user