委托加工更新提交erp优化

This commit is contained in:
潘荣晟
2026-02-26 16:40:42 +08:00
parent 403c385eae
commit 924896b435
9 changed files with 51 additions and 28 deletions

View File

@@ -6,7 +6,10 @@ import cn.hutool.json.JSONObject;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.datapermission.core.annotation.CompanyDataPermissionIgnore;
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.tenant.core.aop.TenantIgnore;
import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
import com.zt.plat.module.contractorder.api.dto.order.PrchOrdDtlDTO;
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
@@ -514,6 +517,9 @@ public class ContractApiImpl implements ContractApi {
}
@Override
@CompanyDataPermissionIgnore
@DeptDataPermissionIgnore
@TenantIgnore
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> ids) {
if (ids == null || ids.isEmpty()) {
throw new RuntimeException("订单id为空");

View File

@@ -5,7 +5,10 @@ import com.zt.plat.framework.common.exception.ErrorCode;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.datapermission.core.annotation.CompanyDataPermissionIgnore;
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.tenant.core.aop.TenantIgnore;
import com.zt.plat.module.contractorder.api.dto.order.*;
import com.zt.plat.module.contractorder.dal.dataobject.entrustorder.EntrustOrderDetailDO;
import com.zt.plat.module.contractorder.dal.dataobject.originalmaterialprocessing.OriginalMaterialProcessingDetailDO;
@@ -43,6 +46,9 @@ public class OrderApiImpl implements OrderApi {
private PurchaseOrderService purchaseOrderService;
@Override
@CompanyDataPermissionIgnore
@DeptDataPermissionIgnore
@TenantIgnore
public CommonResult<List<OrderDTO>> getOrderByOrderIds(List<Long> ids) {
if (ids == null || ids.isEmpty()) {
throw new RuntimeException("订单id为空");
@@ -94,6 +100,9 @@ public class OrderApiImpl implements OrderApi {
}
@Override
@CompanyDataPermissionIgnore
@DeptDataPermissionIgnore
@TenantIgnore
public CommonResult<List<OrderDTO>> getOrderByOrderNos(List<String> orderNoS) {
List<PurchaseOrderDO> orderByNos = purchaseOrderService.getOrderByNos(orderNoS);
if (orderByNos.isEmpty()) {

View File

@@ -163,7 +163,7 @@ public class OriginalMaterialProcessingController {
return success(true);
}
//来料采购提交erp
@PostMapping("/submit-to-erp")
@PostMapping(value = {"/submit-to-erp","/submit-erp061","/submit-erp091"})
@Operation(summary = "来料采购提交erp")
@PreAuthorize("@ss.hasAnyPermissions('base:original-material-processing-order:update','entedOrder:edit')")
public CommonResult<Boolean> submitToErp(@RequestParam("id") Long id) {

View File

@@ -1098,9 +1098,10 @@ public class ContractServiceImpl implements ContractService {
// 更新合同动态字段
if (reqVO.getDynamicsFields() != null && !reqVO.getDynamicsFields().isEmpty()) {
reqVO.getDynamicsFields().forEach(field -> {
tmplInscDatBsnService.updateTmplInscDatBsn(field);
});
tmplInscDatBsnService.updateTmplInscDatBsnList(reqVO.getDynamicsFields());
// reqVO.getDynamicsFields().forEach(field -> {
// tmplInscDatBsnService.updateTmplInscDatBsn(field);
// });
}
// 更新合同动态表单
if (reqVO.getDynamicsItems() != null && !reqVO.getDynamicsItems().isEmpty()) {

View File

@@ -483,7 +483,7 @@ public class OriginalMaterialProcessingServiceImplImpl implements OriginalMateri
throw exception(ORIGINAL_MATERIAL_PROCESSING_DO_NOT_EXISTS);
}
if (!originalMaterialProcessingDO.getOrderSAPNumber().isEmpty()) {
if (originalMaterialProcessingDO.getOrderSAPNumber()!=null) {
throw exception(ORDER_ALREADY_SUBMIT);
}

View File

@@ -247,7 +247,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
if (ObjectUtils.isEmpty(purchaseOrderDO)) {
throw exception(ORDER_ID_NOT_EXISTS);
}
if (purchaseOrderDO.getOrderSAPNumber() != null){
if (purchaseOrderDO.getOrderSAPNumber() != null) {
throw exception(ORDER_ALREADY_SUBMIT);
}
if (purchaseOrderDO.getIsPush() == 0) {
@@ -309,12 +309,16 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void submitErp061(List<Long> ids) {
// 通过订单号查询订单
List<PurchaseOrderWithDetailsVO> purchaseOrderWithDetailsVOS = purchaseOrderMapper.selectOrderByIds(ids);
if (!purchaseOrderWithDetailsVOS.isEmpty()) {
purchaseOrderWithDetailsVOS.forEach(purchaseOrderWithDetailsVO -> {
PurchaseOrderDO purchaseOrderDO = purchaseOrderMapper.selectById(purchaseOrderWithDetailsVO.getPurchaseOrder().getId());
if (purchaseOrderDO.getOrderSAPNumber() != null && !purchaseOrderDO.getOrderSAPNumber().isEmpty()) {
throw exception(ORDER_ALREADY_SUBMIT);
}
ErpOrderSaveReqVO erpOrderSaveReqVO = new ErpOrderSaveReqVO();
PurchaseOrderDO order = purchaseOrderWithDetailsVO.getPurchaseOrder();
erpOrderSaveReqVO.setOrderNo(order.getSystemOrderNumber());
@@ -347,7 +351,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
if (details != null && !details.isEmpty()) {
List<ErpOrderSaveReqVO.Item> items = new ArrayList<>();
List<ErpOrderSaveReqVO.Itex> itexes = new ArrayList<>();
List<JSONObject> jsonObjects=new ArrayList<>();
List<JSONObject> jsonObjects = new ArrayList<>();
for (PrchOrdDtlDO detail : details) {
ErpOrderSaveReqVO.Item item = new ErpOrderSaveReqVO.Item();
@@ -370,7 +374,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
// WarehouseFactoryRespVO factoryAndWarehouse = getBoundFactoryAndWarehouse(detail.getRcvFactNum(), detail.getRcvWrhNum());
// 3.1 行项目基本信息
item.setPo_item(detail.getLineNum() != null ? detail.getLineNum().intValue() : null); // 行项目 -> 行号
item.setMaterial(!mtrlZhongtongCode.isEmpty()?mtrlZhongtongCode:null); // 物料编码 -> 物料号
item.setMaterial(!mtrlZhongtongCode.isEmpty() ? mtrlZhongtongCode : null); // 物料编码 -> 物料号
item.setPlant(detail.getRcvFactNum()); // 收货工厂编码 -> 工厂
item.setStge_loc(detail.getRcvWrhNum()); // 收货库位编码 -> 库存地点
item.setQuantity(detail.getQty()); // 暂估数量 -> 数量
@@ -407,7 +411,8 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
itex.setZaufnr(detail.getInOrd()); // 统计型内部订单 -> 统计型内部订单
itex.setZpurty(detail.getPrchCtgr()); // 采购类别 -> 采购类别
itex.setZmenge(detail.getOrigWet()); // 原料湿重 -> 原料湿重
itexes.add(itex); JSONArray objects = JSONArray.parseArray(detail.getActsCtgrDtl());
itexes.add(itex);
JSONArray objects = JSONArray.parseArray(detail.getActsCtgrDtl());
for (Object object : objects) {
if (object instanceof JSONObject jsonObj) {
jsonObj.remove("costcenter_name");
@@ -455,7 +460,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
upVo.setCause(result);
log.warn("订单推送ERP失败本地订单ID【{}】,失败原因【{}】", localOrderId, result);
purchaseOrderMapper.updateById(upVo);
throw exception(ERP_ERO,result);
throw exception(ERP_ERO, result);
}
} catch (Exception e) {
upVo.setOrderSAPNumber(null);
@@ -464,7 +469,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
// 异常时仍需更新数据库,保证订单状态一致性
purchaseOrderMapper.updateById(upVo);
log.error("订单推送ERP发生异常本地订单ID【{}】,异常信息如下", localOrderId, e);
throw exception(ERP_ERO,e);
throw exception(ERP_ERO, e);
}
});
}
@@ -1073,10 +1078,13 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
}
@Override
@CompanyDataPermissionIgnore
@DeptDataPermissionIgnore
@TenantIgnore
public OrderRespVO getOrder(Long id) {
PurchaseOrderDO purchaseOrderDO = purchaseOrderMapper.selectById(id);
OrderRespVO bean = BeanUtils.toBean(purchaseOrderDO, OrderRespVO.class);
if (purchaseOrderDO == null){
if (purchaseOrderDO == null) {
throw exception(PURCHASE_ORDER_NOT_EXISTS);
}
if (OrderTypeEnum.SALE.getCode().equals(bean.getSplyBsnTp())) {