|
@@ -10,6 +10,7 @@ import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
@@ -18,13 +19,17 @@ import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
import com.fjhx.purchase.entity.subscribe.enums.SubscribeDetailStatusEnum;
|
|
|
import com.fjhx.purchase.entity.subscribe.po.SubscribeDetail;
|
|
|
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
+import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
|
|
|
import com.fjhx.sale.entity.purchase.po.*;
|
|
|
+import com.fjhx.sale.entity.sample.po.Sample;
|
|
|
import com.fjhx.sale.entity.sample.po.SampleProduct;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
+import com.fjhx.sale.service.contract.ContractService;
|
|
|
import com.fjhx.sale.service.purchase.*;
|
|
|
import com.fjhx.sale.service.sample.SampleProductService;
|
|
|
+import com.fjhx.sale.service.sample.SampleService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -71,6 +76,10 @@ public class EhsdPurchaseFlow extends FlowDelegate {
|
|
|
private CodingRuleService codingRuleService;
|
|
|
@Autowired
|
|
|
private SubscribeDetailService subscribeDetailService;
|
|
|
+ @Autowired
|
|
|
+ private ContractService contractService;
|
|
|
+ @Autowired
|
|
|
+ private SampleService sampleService;
|
|
|
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
@@ -92,7 +101,25 @@ public class EhsdPurchaseFlow extends FlowDelegate {
|
|
|
purchase.setSellCityId(purchase.getCityId());
|
|
|
purchase.setSellCountryId(purchase.getCountryId());
|
|
|
purchase.setSellProvinceId(purchase.getProvinceId());
|
|
|
- purchase.setCode(codingRuleService.createCode(CodingRuleEnum.EHSD_PURCHASE.getKey(), null));
|
|
|
+
|
|
|
+ //手动创建
|
|
|
+ if (0 == purchase.getDataResource()) {
|
|
|
+ purchase.setCode(codingRuleService.createCode(CodingRuleEnum.EHSD_PURCHASE.getKey(), null));
|
|
|
+ }
|
|
|
+ //合同
|
|
|
+ if (1 == purchase.getDataResource()) {
|
|
|
+ Contract contract = contractService.getById(purchase.getDataResourceId());
|
|
|
+ Assert.notEmpty(contract, "查询不到合同信息,无法生成编号");
|
|
|
+ long count = purchaseService.count(q -> q.eq(EhsdPurchase::getDataResourceId, contract.getId()));
|
|
|
+ purchase.setCode(contract.getCode() + "-" + count);
|
|
|
+ }
|
|
|
+ //样品单
|
|
|
+ if (2 == purchase.getDataResource()) {
|
|
|
+ Sample sample = sampleService.getById(purchase.getDataResourceId());
|
|
|
+ Assert.notEmpty(sample, "查询不到样品单信息,无法生成编号");
|
|
|
+ long count = purchaseService.count(q -> q.eq(EhsdPurchase::getDataResourceId, sample.getId()));
|
|
|
+ purchase.setCode(sample.getCode() + "-" + count);
|
|
|
+ }
|
|
|
// purchase.setCode(CodeEnum.PURCHASE.getCode());
|
|
|
purchase.setStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
|
purchase.setUserName(SecurityUtils.getUsername());
|