|
|
|
|
@@ -10,13 +10,20 @@ import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
|
|
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
|
|
|
|
import com.zt.plat.module.bpm.api.task.dto.*;
|
|
|
|
|
import com.zt.plat.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.PurchaseorderReqVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.api.vo.contract.ContractRespVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.DownOrUpOrderReqVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.DownOrUpOrderRespVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.LinkOrderReqVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.PurchaseOrderRespVO;
|
|
|
|
|
import com.zt.plat.module.contractorder.controller.admin.salesorder.vo.*;
|
|
|
|
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.SystemRelativityDO;
|
|
|
|
|
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PurchaseOrderDO;
|
|
|
|
|
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
|
|
|
|
|
import com.zt.plat.module.contractorder.dal.mysql.contract.SystemRelativityMapper;
|
|
|
|
|
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderMapper;
|
|
|
|
|
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
|
|
|
|
import com.zt.plat.module.contractorder.enums.purchaseorder.OrderStatusEnum;
|
|
|
|
|
import com.zt.plat.module.contractorder.service.contract.ContractService;
|
|
|
|
|
import com.zt.plat.module.contractorder.util.constants.ProcessDefinitionKeyConstants;
|
|
|
|
|
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpSalesOrderSaveReqVO;
|
|
|
|
|
import com.zt.plat.module.erp.service.erp.ErpOrderService;
|
|
|
|
|
@@ -40,6 +47,7 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_ORDER_EXISTS;
|
|
|
|
|
import static com.zt.plat.module.contractorder.enums.purchaseorder.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -72,6 +80,13 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpOrderService erpOrderService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SystemRelativityMapper systemRelativityMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ContractService contractService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
@@ -249,7 +264,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
|
|
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(SecurityFrameworkUtils.getLoginUserId()).getData();
|
|
|
|
|
if (ObjectUtils.isEmpty(salesOrderDO.getProcessInstanceId())) {
|
|
|
|
|
BpmProcessInstanceCreateReqDTO pidto = new BpmProcessInstanceCreateReqDTO();
|
|
|
|
|
pidto.setProcessDefinitionKey(ProcessDefinitionKeyConstants.PURCHASE_ORDER_REVIEW_PROCESS);
|
|
|
|
|
pidto.setProcessDefinitionKey(ProcessDefinitionKeyConstants.SALES_ORDER_REVIEW_PROCESS);
|
|
|
|
|
pidto.setBusinessKey(String.valueOf(id));
|
|
|
|
|
String data = bpmProcessInstanceApi.createProcessInstance(adminUserRespDTO.getId(), pidto).getData();
|
|
|
|
|
if (StringUtils.isNotBlank(data)) {
|
|
|
|
|
@@ -277,7 +292,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
|
|
if (BpmProcessInstanceStatusEnum.REJECT.getStatus().equals(approvalDetail.getStatus())) {
|
|
|
|
|
// 如果状态是驳回状态,需要重新创建一个流程实例
|
|
|
|
|
BpmProcessInstanceCreateReqDTO pidtoNew = new BpmProcessInstanceCreateReqDTO();
|
|
|
|
|
pidtoNew.setProcessDefinitionKey(ProcessDefinitionKeyConstants.PURCHASE_ORDER_REVIEW_PROCESS);
|
|
|
|
|
pidtoNew.setProcessDefinitionKey(ProcessDefinitionKeyConstants.SALES_ORDER_REVIEW_PROCESS);
|
|
|
|
|
pidtoNew.setBusinessKey(String.valueOf(id));
|
|
|
|
|
String data = bpmProcessInstanceApi.createProcessInstance(adminUserRespDTO.getId(), pidtoNew).getData();
|
|
|
|
|
if (StringUtils.isNotBlank(data)) {
|
|
|
|
|
@@ -350,5 +365,81 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean linkOrder(LinkOrderReqVO LinkOrderReqVO) {
|
|
|
|
|
|
|
|
|
|
SystemRelativityDO saveDO = new SystemRelativityDO();
|
|
|
|
|
saveDO.setStatus(DictEnum.BSE_SYS_REL_TP_ORDER.getCode());
|
|
|
|
|
saveDO.setUpId(LinkOrderReqVO.getUpOrderId());
|
|
|
|
|
saveDO.setDownId(LinkOrderReqVO.getDownOrderId());
|
|
|
|
|
//判断订单有没有关联过
|
|
|
|
|
if (systemRelativityMapper.selectCount(new LambdaQueryWrapper<SystemRelativityDO>().eq(SystemRelativityDO::getUpId, saveDO.getUpId()).eq(SystemRelativityDO::getDownId, saveDO.getDownId())) > 0) {
|
|
|
|
|
throw exception(CONTRACT_ORDER_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
return systemRelativityMapper.insert(saveDO) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DownOrUpOrderRespVO> getOrderByOrderIdAndType(DownOrUpOrderReqVO reqVO) {
|
|
|
|
|
SalesOrderDO salesOrderDO = salesOrderMapper.selectById(reqVO.getOrderId());
|
|
|
|
|
if (salesOrderDO == null) {
|
|
|
|
|
throw exception(PURCHASE_ORDER_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
String contractNumber = salesOrderDO.getContractNumber();// 合同号
|
|
|
|
|
|
|
|
|
|
ContractRespVO upRelation = null;
|
|
|
|
|
if ("up".equals(reqVO.getOrderType())) {
|
|
|
|
|
log.info("获取上游订单");
|
|
|
|
|
//上游
|
|
|
|
|
upRelation = contractService.getUpRelation(Long.valueOf(contractNumber));
|
|
|
|
|
} else {
|
|
|
|
|
//下游
|
|
|
|
|
log.info("获取下游订单");
|
|
|
|
|
upRelation = contractService.getDownRelation(Long.valueOf(contractNumber));
|
|
|
|
|
}
|
|
|
|
|
List<DownOrUpOrderRespVO> orderList = new ArrayList<>();
|
|
|
|
|
if (upRelation != null) {
|
|
|
|
|
String systemContractNumber = upRelation.getSystemContractNumber();
|
|
|
|
|
|
|
|
|
|
List<SalesOrderDO> salesOrderDOS = salesOrderMapper.selectList(new LambdaQueryWrapper<SalesOrderDO>().eq(SalesOrderDO::getContractNumber, systemContractNumber));
|
|
|
|
|
salesOrderDOS.forEach(p -> {
|
|
|
|
|
DownOrUpOrderRespVO downOrUpOrderRespVO = new DownOrUpOrderRespVO();
|
|
|
|
|
downOrUpOrderRespVO.setOrderId(String.valueOf(p.getId()));
|
|
|
|
|
downOrUpOrderRespVO.setOrderNo(p.getSystemOrderNumber());
|
|
|
|
|
downOrUpOrderRespVO.setOrderType(reqVO.getOrderType());
|
|
|
|
|
downOrUpOrderRespVO.setContractId(String.valueOf(p.getId()));
|
|
|
|
|
downOrUpOrderRespVO.setContractName(p.getContractName());
|
|
|
|
|
downOrUpOrderRespVO.setContractNumber(p.getContractNumber());
|
|
|
|
|
downOrUpOrderRespVO.setOrder(BeanUtils.toBean(p, SalesOrderRespVO.class));
|
|
|
|
|
orderList.add(downOrUpOrderRespVO);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return orderList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PurchaseOrderRespVO> getBindOrderByOrder(DownOrUpOrderReqVO reqVO) {
|
|
|
|
|
List<PurchaseOrderRespVO> orderList = new ArrayList<>();
|
|
|
|
|
if ("up".equals(reqVO.getOrderType())) {
|
|
|
|
|
log.info("获取上游订单");
|
|
|
|
|
//上游
|
|
|
|
|
List<SystemRelativityDO> systemRelativityDOS = systemRelativityMapper.selectList(new LambdaQueryWrapper<SystemRelativityDO>().eq(SystemRelativityDO::getDownId, reqVO.getOrderId()));
|
|
|
|
|
if (!systemRelativityDOS.isEmpty()) {
|
|
|
|
|
List<SalesOrderDO> salesOrderDOS = salesOrderMapper.selectByIds(systemRelativityDOS.stream().map(SystemRelativityDO::getUpId).toList());
|
|
|
|
|
orderList = BeanUtils.toBean(salesOrderDOS, PurchaseOrderRespVO.class);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//下游
|
|
|
|
|
log.info("获取下游订单");
|
|
|
|
|
List<SystemRelativityDO> systemRelativityDOS = systemRelativityMapper.selectList(new LambdaQueryWrapper<SystemRelativityDO>().eq(SystemRelativityDO::getUpId, reqVO.getOrderId()));
|
|
|
|
|
if (!systemRelativityDOS.isEmpty()) {
|
|
|
|
|
List<SalesOrderDO> purchaseOrderDOS = salesOrderMapper.selectByIds(systemRelativityDOS.stream().map(SystemRelativityDO::getDownId).toList());
|
|
|
|
|
orderList = BeanUtils.toBean(purchaseOrderDOS, PurchaseOrderRespVO.class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return orderList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|