新增发货单ERP接口
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.zt.plat.module.erp.api;
|
||||
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.erp.api.dto.ErpBillMainSaveReqDTO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpBillMainService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
public class ErpBillMainApiImpl implements ErpBillMainApi{
|
||||
|
||||
@Resource
|
||||
private ErpBillMainService erpBillMainService;
|
||||
|
||||
@Override
|
||||
public String submitBillMainToErp(ErpBillMainSaveReqDTO reqDTO) {
|
||||
ErpBillMainSaveReqVO erpBillMainSaveReqDTO = BeanUtils.toBean(reqDTO,ErpBillMainSaveReqVO.class);
|
||||
return erpBillMainService.submitBillMainToErp(erpBillMainSaveReqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String submitBillMainReverseToErp(ErpBillMainSaveReqDTO reqDTO) {
|
||||
ErpBillMainSaveReqVO erpBillMainSaveReqDTO = BeanUtils.toBean(reqDTO,ErpBillMainSaveReqVO.class);
|
||||
return erpBillMainService.submitBillMainReverseToErp(erpBillMainSaveReqDTO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.zt.plat.module.erp.controller.admin.erp;
|
||||
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpBillMainService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "管理后台 - ERP收货订单")
|
||||
@RestController
|
||||
@RequestMapping("/base/bill-main")
|
||||
@Validated
|
||||
public class ErpBillMainController {
|
||||
|
||||
@Resource
|
||||
private ErpBillMainService erpBillMainService;
|
||||
|
||||
@PostMapping("/submitBillMainToErp")
|
||||
@Operation(summary = "ERP收货订单推送")
|
||||
@PreAuthorize("@ss.hasPermission('sply:erp-bom:create')")
|
||||
public String submitBillMainToErp(ErpBillMainSaveReqVO createVo) {
|
||||
return erpBillMainService.submitBillMainToErp(createVo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 收发货单新增/修改 Request VO")
|
||||
@Data
|
||||
public class ErpBillMainSaveReqVO {
|
||||
|
||||
@Schema(description = "收货单号;自动生成")
|
||||
private String billNumber;
|
||||
|
||||
@Schema(description = "过账日期")
|
||||
private LocalDateTime postingDate;
|
||||
|
||||
@Schema(description = "实物物料编码")
|
||||
private String materialCoding;
|
||||
|
||||
@Schema(description = "工厂编码")
|
||||
private String factoryNumber;
|
||||
|
||||
@Schema(description = "库位编码")
|
||||
private String warehouseNumber;
|
||||
|
||||
@Schema(description = "实物收发货数量")
|
||||
private BigDecimal materialQuantity;
|
||||
|
||||
@Schema(description = "实物计量单位")
|
||||
private String materialUom;
|
||||
|
||||
@Schema(description = "批次")
|
||||
private String batch;
|
||||
|
||||
@Schema(description = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
@Schema(description = "采购订单行号")
|
||||
private String poItem;
|
||||
|
||||
@Schema(description = "客商编号")
|
||||
private String customerNumber;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private String creatorId;
|
||||
|
||||
@Schema(description = "用户名称")
|
||||
private String creatorName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
|
||||
|
||||
public interface ErpBillMainService {
|
||||
String submitBillMainToErp(ErpBillMainSaveReqVO createVo);
|
||||
String submitBillMainReverseToErp(ErpBillMainSaveReqVO createVo);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
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 jakarta.annotation.Resource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@Service
|
||||
public class ErpBillMainServiceImpl implements ErpBillMainService {
|
||||
|
||||
@Resource
|
||||
public ErpExternalApi erpExternalApi;
|
||||
|
||||
@Override
|
||||
public String submitBillMainToErp(ErpBillMainSaveReqVO createVo) {
|
||||
ErpSubmitReqDTO reqDTO = buildBaseReqDTO(createVo, "071");
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
Map<String, Object> head = new HashMap<>();
|
||||
head.put("pstng_date", createVo.getPostingDate());
|
||||
head.put("doc_date", createVo.getPostingDate());
|
||||
head.put("header_txt", createVo.getRemark());
|
||||
head.put("bill_of_lading", "");
|
||||
req.put("head", head);
|
||||
|
||||
List<Map<String, Object>> items = getMaps(createVo);
|
||||
req.put("item", items);
|
||||
reqDTO.setReq(req);
|
||||
|
||||
return submitToErp(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String submitBillMainReverseToErp(ErpBillMainSaveReqVO createVo) {
|
||||
ErpSubmitReqDTO reqDTO = buildBaseReqDTO(createVo, "079");
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
Map<String, Object> head = new HashMap<>();
|
||||
head.put("pstng_date", createVo.getPostingDate());
|
||||
head.put("mat_doc", createVo.getMaterialCoding());
|
||||
head.put("doc_year", "");
|
||||
head.put("header_txt", "");
|
||||
req.put("head", head);
|
||||
|
||||
List<Map<String, Object>> items = new ArrayList<>();
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("matdoc_item", createVo.getPoItem());
|
||||
item.put("line_id", "");
|
||||
items.add(item);
|
||||
req.put("item", items);
|
||||
reqDTO.setReq(req);
|
||||
|
||||
return submitToErp(reqDTO);
|
||||
}
|
||||
|
||||
// 抽取重复代码:构建基础 ErpSubmitReqDTO
|
||||
private ErpSubmitReqDTO buildBaseReqDTO(ErpBillMainSaveReqVO vo, String funcnr) {
|
||||
ErpSubmitReqDTO reqDTO = new ErpSubmitReqDTO();
|
||||
reqDTO.setFuncnr(funcnr);
|
||||
reqDTO.setBskey(vo.getBillNumber());
|
||||
reqDTO.setUsrid(vo.getCreatorId());
|
||||
reqDTO.setUsrnm(vo.getCreatorName());
|
||||
return reqDTO;
|
||||
}
|
||||
|
||||
// 抽取重复代码:提交 ERP 并记录日志
|
||||
private String submitToErp(ErpSubmitReqDTO reqDTO) {
|
||||
ResponseEntity<String> response = erpExternalApi.submitDataToErp(reqDTO);
|
||||
if (response.getStatusCode() == HttpStatus.OK) {
|
||||
log.info("ERP数据提交成功");
|
||||
}
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Map<String, Object>> getMaps(ErpBillMainSaveReqVO createVo) {
|
||||
List<Map<String, Object>> items = new ArrayList<>();
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("material", createVo.getMaterialCoding());
|
||||
item.put("plant", createVo.getFactoryNumber());
|
||||
item.put("stge_loc", createVo.getWarehouseNumber());
|
||||
item.put("batch", createVo.getBatch());
|
||||
item.put("entry_qnt", createVo.getMaterialQuantity());
|
||||
item.put("entry_uom", createVo.getMaterialUom());
|
||||
item.put("po_number", createVo.getOrderNo());
|
||||
item.put("po_item", createVo.getPoItem());
|
||||
item.put("customer", createVo.getCustomerNumber());
|
||||
item.put("sales_ord", "");
|
||||
item.put("s_ord_item", "");
|
||||
item.put("consume_ant", "");
|
||||
item.put("item_text", createVo.getRemark());
|
||||
item.put("ref_doc_yr", "");
|
||||
item.put("ref_doc", "");
|
||||
item.put("ref_doc_it", "");
|
||||
item.put("unload_pt", "");
|
||||
items.add(item);
|
||||
return items;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user