订单管理相关

This commit is contained in:
潘荣晟
2025-10-14 17:40:18 +08:00
parent db04862660
commit a1747fba8b
13 changed files with 381 additions and 194 deletions

View File

@@ -1,12 +1,15 @@
package com.zt.plat.module.erp.controller.admin.erp.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* ERP采购订单保存请求VO
@@ -24,7 +27,7 @@ public class ErpOrderUpdateReqVO {
@Schema(description = "删除标识ELOEK", example = " ")
@ExcelProperty("删除标识")
private String deleteInd;
private Integer deleteInd;
@Schema(description = "货币码WAERS", requiredMode = Schema.RequiredMode.REQUIRED, example = "CNY")
@NotEmpty(message = "货币码不能为空")
@@ -54,170 +57,201 @@ public class ErpOrderUpdateReqVO {
private String zlifnr;
// ====================== 3. 行项目字段(列表-item ======================
@Schema(description = "行号EBELP", requiredMode = Schema.RequiredMode.REQUIRED, example = "00010")
@NotEmpty(message = "行号不能为空")
@ExcelProperty("行号")
private String poItem;
private List<item> items;
@Schema(description = "物料号MATNR", example = "M0010001")
@ExcelProperty("物料号")
private String material;
@Schema(description = "工厂WERKS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
@NotEmpty(message = "工厂不能为空")
@ExcelProperty("工厂")
private String plant;
@Schema(description = "库存地点LGORT", example = "0001")
@ExcelProperty("库存地点")
private String stgeLoc;
@Schema(description = "数量MENGE保留3位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.000")
@NotNull(message = "数量不能为空")
@ExcelProperty("数量")
private BigDecimal quantity;
@Schema(description = "计量单位MEINS必须与该物料基本计量单位一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "PC")
@NotEmpty(message = "计量单位不能为空")
@ExcelProperty("计量单位")
private String poUnit;
@Schema(description = "含税单价NETPR保留2位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "199.99")
@NotNull(message = "含税单价不能为空")
@ExcelProperty("含税单价")
private BigDecimal netPrice;
@Schema(description = "价格单位PEINH固定值1", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "价格单位不能为空")
@ExcelProperty("价格单位")
private Integer priceUnit;
@Schema(description = "税码MWSKZ", example = "J1")
@ExcelProperty("税码")
private String taxCode;
@Schema(description = "基于GR的发票校验WEBRE", example = "Y")
@ExcelProperty("基于GR发票校验")
private String grBasediv;
@Schema(description = "允许无限制过量交货UEBTK", example = "N")
@ExcelProperty("允许过量交货")
private String unlimitedDlv;
@Schema(description = "批次CHARG", example = "B202405001")
@ExcelProperty("批次")
private String batch;
@Schema(description = "项目类别PSTYP委托加工订单时填入L", example = "L")
@ExcelProperty("项目类别")
private String itemCat;
@Schema(description = "科目分配类别KNTTP固定资产采购:A服务采购:S-销售服务费/K-成本中心/F-订单", example = "K")
@ExcelProperty("科目分配类别")
private String acctasscat;
@Schema(description = "物料组MATKL服务采购订单必填", example = "01")
@ExcelProperty("物料组")
private String matlGroup;
@Schema(description = "短文本TXZ01服务采购订单必填", example = "设备维修服务")
@ExcelProperty("短文本")
private String shortText;
@Schema(description = "退货项目标识RETPO退货行项目填X", example = "X")
@ExcelProperty("退货标识")
private String retItem;
@Schema(description = "免费项目标识UMSON免费行项目填X", example = "X")
@ExcelProperty("免费标识")
private String freeItem;
@Schema(description = "外部行项目号LICHN绿星链通必填", example = "EXT0010")
@ExcelProperty("外部行号")
private String vendrbatch;
@Schema(description = "备注信息-需求单位TDLINE", example = "生产一部")
@ExcelProperty("需求单位备注")
private String noteXq;
@Schema(description = "备注信息-物料详细TDLINE", example = "304不锈钢厚度2mm")
@ExcelProperty("物料详细备注")
private String noteWl;
@Schema(description = "行项目删除标识ELOEK", example = "N")
@ExcelProperty("行项目删除标识")
private String itemDeleteInd;
// ====================== 4. 行项目扩展字段(列表-itex ======================
@Schema(description = "销售物料号zmatnr科目分配类别为S时必填", example = "S0010001")
@ExcelProperty("销售物料号")
private String zmatnr;
@Schema(description = "统计型内部订单zaufnr", example = "OR0010001")
@ExcelProperty("统计内部订单")
private String zaufnr;
@Schema(description = "采购类别zpurty0-生产性物资类1-项目投资类", example = "0")
@ExcelProperty("采购类别")
private String zpurty;
@Schema(description = "原料湿重zmenge", example = "105.500")
@ExcelProperty("原料湿重")
private BigDecimal zmenge;
private List<itex> itexs;
// ====================== 5. 科目分配字段(列表-acct类别为K或P时使用 ======================
@Schema(description = "科目分配的序号DZEKKN从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "科目分配序号不能为空")
@ExcelProperty("科目分配序号")
private Integer serialNo;
@Schema(description = "总账科目编号SAKNR", example = "1001010000")
@ExcelProperty("总账科目")
private String glAccount;
@Schema(description = "成本中心KOSTL科目分配类别为K或F时必填", example = "C0010001")
@ExcelProperty("成本中心")
private String costcenter;
@Schema(description = "订单号AUFNR科目分配类别为F时必填", example = "OR0010001")
@ExcelProperty("订单号")
private String orderid;
@Schema(description = "主资产号ANLN1科目分配类别为A时必填", example = "AS0010001")
@ExcelProperty("主资产号")
private String assetNo;
@Schema(description = "资产子编号ANLN2科目分配类别为A时必填固定值0", example = "0")
@ExcelProperty("资产子编号")
private String subNumber;
private JSONArray accts;
// ====================== 6. 委托加工物料字段(列表-comp委托加工订单时使用 ======================
@Schema(description = "计划行号ETENR从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "计划行号不能为空")
@ExcelProperty("计划行号")
private Integer schedLine;
private List<comp> comps;
@Schema(description = "项目编号RSPOS从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "项目编号不能为空")
@ExcelProperty("项目编号")
private Integer itemNo;
@Data
@Schema(description = "ERP采购订单item更新请求VO")
public static class item {
@Schema(description = "行号EBELP", requiredMode = Schema.RequiredMode.REQUIRED, example = "00010")
@NotEmpty(message = "行号不能为空")
@ExcelProperty("行号")
private Long po_item;
@Schema(description = "加工前物料号MATNR", requiredMode = Schema.RequiredMode.REQUIRED, example = "M0020001")
@NotEmpty(message = "加工前物料号不能为空")
@ExcelProperty("加工前物料号")
private String compMaterial;
@Schema(description = "物料号MATNR", example = "M0010001")
@ExcelProperty("物料号")
private String material;
@Schema(description = "委托加工发货工厂PLANT", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
@NotEmpty(message = "委托加工发货工厂不能为空")
@ExcelProperty("委托发货工厂")
private String compPlant;
@Schema(description = "工厂WERKS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
@NotEmpty(message = "工厂不能为空")
@ExcelProperty("工厂")
private String plant;
@Schema(description = "委托加工需求数量MENGE保留3位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "95.000")
@NotNull(message = "委托加工需求数量不能为空")
@ExcelProperty("委托需求数量")
private BigDecimal entryQuantity;
@Schema(description = "库存地点LGORT", example = "0001")
@ExcelProperty("库存地点")
private String stge_loc;
@Schema(description = "数量MENGE保留3位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.000")
@NotNull(message = "数量不能为空")
@ExcelProperty("数量")
private String quantity;
@Schema(description = "计量单位MEINS必须与该物料基本计量单位一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "PC")
@NotEmpty(message = "计量单位不能为空")
@ExcelProperty("计量单位")
private BigDecimal po_unit;
@Schema(description = "含税单价NETPR保留2位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "199.99")
@NotNull(message = "含税单价不能为空")
@ExcelProperty("含税单价")
private BigDecimal net_price;
@Schema(description = "价格单位PEINH固定值1", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "价格单位不能为空")
@ExcelProperty("价格单位")
private Integer price_unit;
@Schema(description = "税码MWSKZ", example = "J1")
@ExcelProperty("税码")
private String tax_code;
@Schema(description = "基于GR的发票校验WEBRE", example = "Y")
@ExcelProperty("基于GR发票校验")
private String gr_basediv;
@Schema(description = "允许无限制过量交货UEBTK", example = "N")
@ExcelProperty("允许过量交货")
private String unlimited_dlv;
@Schema(description = "批次CHARG", example = "B202405001")
@ExcelProperty("批次")
private String batch;
@Schema(description = "项目类别PSTYP委托加工订单时填入L", example = "L")
@ExcelProperty("项目类别")
private String item_cat;
@Schema(description = "科目分配类别KNTTP固定资产采购:A服务采购:S-销售服务费/K-成本中心/F-订单", example = "K")
@ExcelProperty("科目分配类别")
private String acctasscat;
@Schema(description = "物料组MATKL服务采购订单必填", example = "01")
@ExcelProperty("物料组")
private String matl_group;
@Schema(description = "短文本TXZ01服务采购订单必填", example = "设备维修服务")
@ExcelProperty("短文本")
private String short_text;
@Schema(description = "退货项目标识RETPO退货行项目填X", example = "X")
@ExcelProperty("退货标识")
private String ret_item;
@Schema(description = "免费项目标识UMSON免费行项目填X", example = "X")
@ExcelProperty("免费标识")
private String free_item;
@Schema(description = "外部行项目号LICHN绿星链通必填", example = "EXT0010")
@ExcelProperty("外部行号")
private String vendrbatch;
@Schema(description = "备注信息-需求单位TDLINE", example = "生产一部")
@ExcelProperty("需求单位备注")
private String note_xq;
@Schema(description = "备注信息-物料详细TDLINE", example = "304不锈钢厚度2mm")
@ExcelProperty("物料详细备注")
private String note_wl;
@Schema(description = "行项目删除标识ELOEK", example = "N")
@ExcelProperty("行项目删除标识")
private Integer delete_ind;
}
@Data
public static class itex {
@Schema(description = "行号EBELP", requiredMode = Schema.RequiredMode.REQUIRED, example = "00010")
@NotEmpty(message = "行号不能为空")
@ExcelProperty("行号")
private Long po_item;
@Schema(description = "销售物料号zmatnr科目分配类别为S时必填", example = "S0010001")
@ExcelProperty("销售物料号")
private BigDecimal zmatnr;
@Schema(description = "统计型内部订单zaufnr", example = "OR0010001")
@ExcelProperty("统计内部订单")
private String zaufnr;
@Schema(description = "采购类别zpurty0-生产性物资类1-项目投资类", example = "0")
@ExcelProperty("采购类别")
private String zpurty;
@Schema(description = "原料湿重zmenge", example = "105.500")
@ExcelProperty("原料湿重")
private BigDecimal zmenge;
}
//
// @Data
// public static class acct {
// @Schema(description = "行号EBELP", requiredMode = Schema.RequiredMode.REQUIRED, example = "00010")
// @NotEmpty(message = "行号不能为空")
// @ExcelProperty("行号")
// private String poItem;
// @Schema(description = "科目分配的序号DZEKKN从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
// @NotNull(message = "科目分配序号不能为空")
// @ExcelProperty("科目分配序号")
// private Integer serialNo;
//
// @Schema(description = "总账科目编号SAKNR", example = "1001010000")
// @ExcelProperty("总账科目")
// private String glAccount;
//
// @Schema(description = "成本中心KOSTL科目分配类别为K或F时必填", example = "C0010001")
// @ExcelProperty("成本中心")
// private String costcenter;
//
// @Schema(description = "订单号AUFNR科目分配类别为F时必填", example = "OR0010001")
// @ExcelProperty("订单号")
// private String orderid;
//
// @Schema(description = "主资产号ANLN1科目分配类别为A时必填", example = "AS0010001")
// @ExcelProperty("主资产号")
// private String assetNo;
//
// @Schema(description = "资产子编号ANLN2科目分配类别为A时必填固定值0", example = "0")
// @ExcelProperty("资产子编号")
// private String subNumber;
// }
@Data
public static class comp {
@Schema(description = "计划行号ETENR从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "计划行号不能为空")
@ExcelProperty("计划行号")
private Integer sched_line;
@Schema(description = "项目编号RSPOS从1开始编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "项目编号不能为空")
@ExcelProperty("项目编号")
private Integer item_no;
@Schema(description = "加工前物料号MATNR", requiredMode = Schema.RequiredMode.REQUIRED, example = "M0020001")
@NotEmpty(message = "加工前物料号不能为空")
@ExcelProperty("加工前物料号")
private String comp_material;
@Schema(description = "委托加工发货工厂PLANT", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
@NotEmpty(message = "委托加工发货工厂不能为空")
@ExcelProperty("委托发货工厂")
private String comp_plant;
@Schema(description = "委托加工需求数量MENGE保留3位小数", requiredMode = Schema.RequiredMode.REQUIRED, example = "95.000")
@NotNull(message = "委托加工需求数量不能为空")
@ExcelProperty("委托需求数量")
private BigDecimal entry_quantity;
@Schema(description = "组件计量单位MEINS为空使用基本计量单位", example = "PC")
@ExcelProperty("组件计量单位")
private String entry_uom;
}
@Schema(description = "组件计量单位MEINS为空使用基本计量单位", example = "PC")
@ExcelProperty("组件计量单位")
private String entryUom;
}

View File

@@ -2,8 +2,11 @@ package com.zt.plat.module.erp.service.erp;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpOrderSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpOrderUpdateReqVO;
public interface ErpOrderService {
String submitOrderToErp(ErpOrderSaveReqVO createVo);
String submitOrderToErp061(ErpOrderSaveReqVO createVo);
String submitOrderToErp062(ErpOrderUpdateReqVO createVo);
}

View File

@@ -6,6 +6,7 @@ import com.zt.plat.module.erp.api.ErpExternalApi;
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpOrderSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpOrderUpdateReqVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -13,12 +14,14 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ErpOrderServiceImpl implements ErpOrderService {
@Resource
public ErpExternalApi erpExternalApi;
@Override
public String submitOrderToErp(ErpOrderSaveReqVO createVo) {
public String submitOrderToErp061(ErpOrderSaveReqVO createVo) {
ErpSubmitReqDTO reqDTO = buildBaseReqDTO(createVo, "061");
@@ -61,6 +64,7 @@ public class ErpOrderServiceImpl implements ErpOrderService {
HashMap<String, String> response = erpExternalApi.submitDataToErp(reqDTO);
return response.get("resStr");
}
private void getMaps(ErpOrderSaveReqVO vo, Map<String, Object> req) {
List<Map<String, Object>> items = new ArrayList<>();
Map<String, Object> item = new HashMap<>();
@@ -87,9 +91,44 @@ public class ErpOrderServiceImpl implements ErpOrderService {
item.put("note_wl", vo.getNoteWl());
item.put("vend_mat", vo.getVendMat());
items.add(item);
if ("K".equals(vo.getAcctassCat())||"P".equals(vo.getAcctassCat())){
if ("K".equals(vo.getAcctassCat()) || "P".equals(vo.getAcctassCat())) {
req.put("acct", vo.getActsCtgrDtl());
}
req.put("item", items);
}
@Override
public String submitOrderToErp062(ErpOrderUpdateReqVO updateVo) {
ErpSubmitReqDTO reqDTO = buildBaseReqDTO062(updateVo, "062");
Map<String, Object> req = new HashMap<>();
Map<String, Object> head = new HashMap<>();
Map<String, Object> exte= new HashMap<>();
head.put("po_number", updateVo.getPoNumber());
head.put("delete_ind", updateVo.getDeleteInd());
head.put("currency", updateVo.getCurrency());
head.put("exch_rate", updateVo.getExchRate());
req.put("head", head);
exte.put("zzhth", updateVo.getZzhth());
exte.put("zzxyh", updateVo.getZzhth());
exte.put("zznote", updateVo.getZnote());
exte.put("zzlifnr", updateVo.getZlifnr());
req.put("exte", exte);
req.put("itex", updateVo.getItexs());
req.put("item", updateVo.getItems());
req.put("acct", updateVo.getAccts());
req.put("comp", updateVo.getComps());
reqDTO.setReq(req);
return submitToErp(reqDTO);
}
private ErpSubmitReqDTO buildBaseReqDTO062(ErpOrderUpdateReqVO vo, String funcnr) {
ErpSubmitReqDTO reqDTO = new ErpSubmitReqDTO();
reqDTO.setFuncnr(funcnr);
reqDTO.setBskey(vo.getPoNumber());
reqDTO.setUsrid(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
reqDTO.setUsrnm((SecurityFrameworkUtils.getLoginUserNickname()));
return reqDTO;
}
}