|
|
@@ -2,6 +2,8 @@ package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -13,14 +15,15 @@ import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.core.base.StateResult;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
import com.jzg.commons.entity.dto.*;
|
|
|
-import com.jzg.commons.entity.po.PtlAgreementCostExternal;
|
|
|
-import com.jzg.commons.entity.po.PtlAgreementCostExternalType;
|
|
|
+import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.vo.CostExternalListVo;
|
|
|
import com.jzg.commons.entity.vo.CostExternalVo;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.commons.util.DateTimeUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
+import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
import com.jzg.organization.mapper.PtlAgreementCostExternalMapper;
|
|
|
+import com.jzg.organization.mapper.PtlAgreementCostExternalTypeMapper;
|
|
|
import com.jzg.organization.service.PtlAgreementCostExternalService;
|
|
|
import com.jzg.organization.service.PtlAgreementCostExternalTypeService;
|
|
|
import com.jzg.organization.state.listener.CostStateListener;
|
|
|
@@ -39,6 +42,8 @@ public class PtlAgreementCostExternalServiceImpl extends ServiceImpl<PtlAgreemen
|
|
|
|
|
|
@Resource
|
|
|
private PtlAgreementCostExternalTypeService ptlAgreementCostExternalTypeService;
|
|
|
+ @Resource
|
|
|
+ private PtlAgreementCostExternalTypeMapper ptlAgreementCostExternalTypeMapper;
|
|
|
|
|
|
@Resource
|
|
|
private CostStateListener costStateListener;
|
|
|
@@ -260,6 +265,57 @@ public class PtlAgreementCostExternalServiceImpl extends ServiceImpl<PtlAgreemen
|
|
|
return audit(costReviewParam, false);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public HttpResult copyCostExternal(PtlAgreementCostCopyExternalParam costCopyParam) {
|
|
|
+ // 参数校验:所有参数都不能为空
|
|
|
+ if (costCopyParam == null) {
|
|
|
+ return HttpResult.error("复制参数不能为空");
|
|
|
+ }
|
|
|
+ if (CollUtil.isEmpty(costCopyParam.getCostIds())) {
|
|
|
+ return HttpResult.error("费用ID列表不能为空");
|
|
|
+ }
|
|
|
+ if (StrUtil.isBlank(costCopyParam.getAgreementId())) {
|
|
|
+ return HttpResult.error("协议ID不能为空");
|
|
|
+ }
|
|
|
+ if (StrUtil.isBlank(costCopyParam.getContactPerson())) {
|
|
|
+ return HttpResult.error("对接人姓名不能为空");
|
|
|
+ }
|
|
|
+ if (StrUtil.isBlank(costCopyParam.getContactMobile())) {
|
|
|
+ return HttpResult.error("对接人手机号不能为空");
|
|
|
+ }
|
|
|
+ List<String> costIds = costCopyParam.getCostIds();
|
|
|
+ StringBuilder errMsg = new StringBuilder();
|
|
|
+ costIds.forEach(oldCostId-> {
|
|
|
+ PtlAgreementCostExternal oldCostExternal = baseMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<PtlAgreementCostExternal>()
|
|
|
+ .eq(PtlAgreementCostExternal::getId, oldCostId));
|
|
|
+ if(oldCostExternal != null){
|
|
|
+ List<PtlAgreementCostExternalType> ptlAgreementCostTypes = ptlAgreementCostExternalTypeMapper.selectList(new LambdaQueryWrapper<PtlAgreementCostExternalType>()
|
|
|
+ .eq(PtlAgreementCostExternalType::getPtlAgreementCostExternalId, oldCostExternal.getId()));
|
|
|
+ // 调整数据 进行copy
|
|
|
+ oldCostExternal.setId(null);
|
|
|
+ oldCostExternal.setPtlAgreementId(Long.valueOf(costCopyParam.getAgreementId()));
|
|
|
+ oldCostExternal.setCostDescribe("复制的费用:" + oldCostExternal.getCostDescribe());
|
|
|
+ oldCostExternal.setCreateTime(LocalDateTime.now());
|
|
|
+ oldCostExternal.setUpdateTime(LocalDateTime.now());
|
|
|
+ oldCostExternal.setContactPerson(costCopyParam.getContactPerson());
|
|
|
+ oldCostExternal.setContactMobile(costCopyParam.getContactMobile());
|
|
|
+ // 复制的费用为待审核
|
|
|
+ oldCostExternal.setAuditStatus(0);
|
|
|
+ baseMapper.insert(oldCostExternal);
|
|
|
+ ptlAgreementCostTypes.forEach(item ->{
|
|
|
+ item.setId(null);
|
|
|
+ });
|
|
|
+ saveOrUpdate(ptlAgreementCostTypes,oldCostExternal.getId());
|
|
|
+
|
|
|
+ }else{
|
|
|
+ errMsg.append("costId为"+oldCostId+"的费用信息已被删除;");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return HttpResult.ok(errMsg.toString());
|
|
|
+ }
|
|
|
+
|
|
|
private HttpResult audit(CostReviewParam costReviewParam, boolean isSuccess) {
|
|
|
// 批量查询所有记录
|
|
|
List<PtlAgreementCostExternal> records = baseMapper.selectBatchIds(costReviewParam.getIds());
|