|
@@ -24,11 +24,14 @@ import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.entity.corporation.po.Corporation;
|
|
|
import com.fjhx.common.entity.currency.po.CurrencyRate;
|
|
|
import com.fjhx.common.entity.documentary.bo.DocumentaryData;
|
|
|
+import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
import com.fjhx.common.service.currency.CurrencyRateService;
|
|
|
import com.fjhx.common.service.documentary.GetDocumentaryBusinessTemplate;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
+import com.fjhx.common.utils.ExchangeRateUtil;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
@@ -169,6 +172,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Autowired
|
|
|
private DictTenantDataService dictTenantDataService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CodingRuleService codingRuleService;
|
|
|
/**
|
|
|
* 分页
|
|
|
*
|
|
@@ -466,6 +471,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 合同明细
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public ContractVo detail(Long id) {
|
|
|
Contract contract = this.getById(id);
|
|
@@ -497,13 +507,80 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 暂存合同
|
|
|
+ * @param contract
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
- public void add(ContractDto contractDto) {
|
|
|
- setAreaId(contractDto);
|
|
|
- this.save(contractDto);
|
|
|
+ public long add(ContractDto contract) {
|
|
|
+ if (StringUtils.isEmpty(contract.getCurrency())) {
|
|
|
+ throw new ServiceException("币种不能为空");
|
|
|
+ }
|
|
|
+ //赋值合同号
|
|
|
+ contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
|
|
|
+ // 保存合同产品
|
|
|
+ List<ContractProduct> contractProductList = contract.getContractProductList();
|
|
|
+ // 赋值待处理数量
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProductList)) {
|
|
|
+ contractProductList.forEach(item -> item.setExpendQuantity(item.getQuantity()));
|
|
|
+ }
|
|
|
+ contract = commStart(contract, 0);
|
|
|
+ return contract.getId();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 开始公共代码抽取
|
|
|
+ *
|
|
|
+ * @param opType 操作类型 0直接发起 1重新发起
|
|
|
+ */
|
|
|
+ public ContractDto commStart(ContractDto contract, Integer opType) {
|
|
|
+ // 赋值城市省份信息
|
|
|
+ CustomizeAreaUtil.setAreaId(contract);
|
|
|
+ contract.setUserName(SecurityUtils.getUsername());
|
|
|
+ contract.setStatus(FlowStatusEnum1.DRAFT.getKey());
|
|
|
+ contract.setBuyCityId(contract.getCityId());
|
|
|
+ contract.setBuyCountryId(contract.getCountryId());
|
|
|
+ contract.setBuyProvinceId(contract.getProvinceId());
|
|
|
+ contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
|
|
|
+ contractService.saveOrUpdate(contract);
|
|
|
+ // 保存合同产品
|
|
|
+ List<ContractProduct> contractProductList = contract.getContractProductList();
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProductList)) {
|
|
|
+ for (ContractProduct c : contractProductList) {
|
|
|
+ c.setContractId(contract.getId());
|
|
|
+ }
|
|
|
+ contractProductService.saveOrUpdateBatch(contractProductList);
|
|
|
+ }
|
|
|
+ // 保存收费项目
|
|
|
+ List<ContractProject> contractProjectList = contract.getContractProjectList();
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProjectList)) {
|
|
|
+ for (ContractProject c : contractProjectList) {
|
|
|
+ c.setContractId(contract.getId());
|
|
|
+ }
|
|
|
+ contractProjectService.saveOrUpdateBatch(contractProjectList);
|
|
|
+ }
|
|
|
+ // 保存自定义出货
|
|
|
+ List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
|
|
|
+ if (CollectionUtils.isNotEmpty(contractShipmentList)) {
|
|
|
+ for (ContractShipment c : contractShipmentList) {
|
|
|
+ c.setContractId(contract.getId());
|
|
|
+ }
|
|
|
+ contractShipmentService.saveOrUpdateBatch(contractShipmentList);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(contract.getId())) {
|
|
|
+ // 交接单附件列表
|
|
|
+ ObsFileUtil.editFile(contract.getFileList(), contract.getId(), 1);
|
|
|
+ // 包装指示附件列表
|
|
|
+ ObsFileUtil.editFile(contract.getPackageFileList(), contract.getId(), 2);
|
|
|
+ } else {
|
|
|
+ // 交接单附件列表
|
|
|
+ ObsFileUtil.saveFile(contract.getFileList(), contract.getId(), 1);
|
|
|
+ // 包装指示附件列表
|
|
|
+ ObsFileUtil.saveFile(contract.getPackageFileList(), contract.getId(), 2);
|
|
|
+ }
|
|
|
+ return contract;
|
|
|
}
|
|
|
-
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void edit(ContractDto contractDto) {
|