Commit 83f5653150af012c9c902ff5d90e3b573da7b56d
1 parent
802cf135
1. 增加ERP对接接口
Showing
13 changed files
with
313 additions
and
6 deletions
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/controller/ErpController.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.erp.controller; | |
2 | + | |
3 | + | |
4 | +import com.google.gson.Gson; | |
5 | +import io.swagger.annotations.ApiOperation; | |
6 | +import net.sf.json.JSON; | |
7 | +import org.jeecg.common.api.vo.Result; | |
8 | +import org.jeecg.common.aspect.annotation.AutoLog; | |
9 | +import org.jeecg.common.system.base.controller.JeecgController; | |
10 | +import org.jeecg.common.system.util.JwtUtil; | |
11 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceipt; | |
12 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceiptDetail; | |
13 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceiptHeader; | |
14 | +import org.jeecg.modules.wms.api.erp.service.IErpService; | |
15 | +import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; | |
16 | +import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; | |
17 | +import org.jeecg.modules.wms.framework.controller.BaseController; | |
18 | +import org.jeecg.utils.StringUtils; | |
19 | +import org.springframework.web.bind.annotation.*; | |
20 | + | |
21 | +import javax.annotation.Resource; | |
22 | +import javax.servlet.http.HttpServletRequest; | |
23 | +import java.util.ArrayList; | |
24 | +import java.util.List; | |
25 | + | |
26 | +/** | |
27 | + * @author 游杰 | |
28 | + */ | |
29 | +@RestController | |
30 | +@RequestMapping("/API/WMS/erp") | |
31 | +public class ErpController extends BaseController { | |
32 | + | |
33 | + @Resource | |
34 | + private IErpService erpService; | |
35 | + | |
36 | + @PostMapping("/receipt") | |
37 | + @ResponseBody | |
38 | + @ApiLogger(apiName = "入库单下发", from="WCS") | |
39 | + public Result receipt(@RequestBody ErpReceipt erpReceipt, HttpServletRequest req) { | |
40 | + String warehouseCode = JwtUtil.getWarehouseCodeByToken(req); | |
41 | + Result result = handleMultiProcess("receipt", new JeecgController.MultiProcessListener() { | |
42 | + @Override | |
43 | + public Result doProcess() { | |
44 | + return erpService.receipt(erpReceipt, warehouseCode); | |
45 | + } | |
46 | + }); | |
47 | + return result; | |
48 | + } | |
49 | +} | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/entity/ErpReceipt.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.erp.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author 游杰 | |
10 | + */ | |
11 | +@Data | |
12 | +public class ErpReceipt { | |
13 | + | |
14 | + private ErpReceiptHeader receiptHeader; | |
15 | + private List<ErpReceiptDetail> receiptDetailList; | |
16 | +} | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/entity/ErpReceiptDetail.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.erp.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.math.BigDecimal; | |
6 | + | |
7 | +/** | |
8 | + * @author 游杰 | |
9 | + */ | |
10 | +@Data | |
11 | +public class ErpReceiptDetail { | |
12 | + | |
13 | + /** | |
14 | + * 物料编码 | |
15 | + */ | |
16 | + private String materialCode; | |
17 | + | |
18 | + /** | |
19 | + * 单据数量 | |
20 | + */ | |
21 | + private BigDecimal qty; | |
22 | + | |
23 | + /** | |
24 | + * 库存状况 | |
25 | + */ | |
26 | + private String inventoryStatus; | |
27 | + | |
28 | + /** | |
29 | + * 批次 | |
30 | + */ | |
31 | + private String batch; | |
32 | + | |
33 | + /** | |
34 | + * 批号 | |
35 | + */ | |
36 | + private String lot; | |
37 | + | |
38 | + /** | |
39 | + * 项目号 | |
40 | + */ | |
41 | + private String project; | |
42 | +} | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/entity/ErpReceiptHeader.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.erp.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author 游杰 | |
7 | + */ | |
8 | +@Data | |
9 | +public class ErpReceiptHeader { | |
10 | + | |
11 | + /** | |
12 | + * 货主 | |
13 | + */ | |
14 | + private String companyCode; | |
15 | + /** | |
16 | + * 入库单类型 | |
17 | + */ | |
18 | + private String receiptType; | |
19 | + /** | |
20 | + * 上游单号 | |
21 | + */ | |
22 | + private String referCode; | |
23 | + /** | |
24 | + * 供应商编码 | |
25 | + */ | |
26 | + private String supplierCode; | |
27 | + /** | |
28 | + * 备注 | |
29 | + */ | |
30 | + private String remark; | |
31 | + | |
32 | +} | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/service/IErpService.java
0 → 100644
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.erp.service.impl; | |
2 | + | |
3 | +import com.aliyun.oss.ServiceException; | |
4 | +import org.jeecg.common.api.vo.Result; | |
5 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceipt; | |
6 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceiptDetail; | |
7 | +import org.jeecg.modules.wms.api.erp.entity.ErpReceiptHeader; | |
8 | +import org.jeecg.modules.wms.api.erp.service.IErpService; | |
9 | +import org.jeecg.modules.wms.config.company.entity.Company; | |
10 | +import org.jeecg.modules.wms.config.company.service.ICompanyService; | |
11 | +import org.jeecg.modules.wms.config.material.entity.Material; | |
12 | +import org.jeecg.modules.wms.config.material.service.IMaterialService; | |
13 | +import org.jeecg.modules.wms.config.warehouse.entity.Warehouse; | |
14 | +import org.jeecg.modules.wms.config.warehouse.service.IWarehouseService; | |
15 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; | |
16 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; | |
17 | +import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptDetailService; | |
18 | +import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptHeaderService; | |
19 | +import org.jeecg.utils.StringUtils; | |
20 | +import org.jeecg.utils.constant.QuantityConstant; | |
21 | +import org.springframework.stereotype.Service; | |
22 | +import org.springframework.transaction.annotation.Transactional; | |
23 | + | |
24 | +import javax.annotation.Resource; | |
25 | +import java.math.BigDecimal; | |
26 | +import java.util.List; | |
27 | + | |
28 | +/** | |
29 | + * @author 游杰 | |
30 | + */ | |
31 | +@Service | |
32 | +public class ErpServiceImpl implements IErpService { | |
33 | + | |
34 | + @Resource | |
35 | + private IWarehouseService warehouseService; | |
36 | + @Resource | |
37 | + private ICompanyService companyService; | |
38 | + @Resource | |
39 | + private IReceiptHeaderService receiptHeaderService; | |
40 | + @Resource | |
41 | + private IMaterialService materialService; | |
42 | + @Resource | |
43 | + private IReceiptDetailService receiptDetailService; | |
44 | + | |
45 | + @Override | |
46 | + @Transactional(rollbackFor = Exception.class) | |
47 | + public Result receipt(ErpReceipt erpReceipt, String warehouseCode) { | |
48 | + if(StringUtils.isEmpty(warehouseCode)) { | |
49 | + return Result.error("入库单下发,仓库编码为空"); | |
50 | + } | |
51 | + Warehouse warehouse = warehouseService.getWarehouseByCode(warehouseCode); | |
52 | + if(warehouse == null) { | |
53 | + return Result.error("入库单下发, 没有找到仓库"); | |
54 | + } | |
55 | + if(erpReceipt == null) { | |
56 | + return Result.error("入库单下发,没有传receipt"); | |
57 | + } | |
58 | + ErpReceiptHeader erpReceiptHeader = erpReceipt.getReceiptHeader(); | |
59 | + List<ErpReceiptDetail> erpReceiptDetailList = erpReceipt.getReceiptDetailList(); | |
60 | + if(erpReceiptHeader == null) { | |
61 | + return Result.error("入库单下发,没有传receiptHeader"); | |
62 | + } | |
63 | + if(erpReceiptDetailList == null) { | |
64 | + return Result.error("入库单下发,没有传receiptDetailList"); | |
65 | + } | |
66 | + String receiptType = erpReceiptHeader.getReceiptType(); | |
67 | + String referCode = erpReceiptHeader.getReferCode(); | |
68 | + String companyCode = erpReceiptHeader.getCompanyCode(); | |
69 | + String remark = erpReceiptHeader.getRemark(); | |
70 | + String supplierCode = erpReceiptHeader.getSupplierCode(); | |
71 | + if(StringUtils.isEmpty(receiptType)) { | |
72 | + return Result.error("入库单下发, receiptType为空"); | |
73 | + } | |
74 | + if(StringUtils.isEmpty(referCode)) { | |
75 | + return Result.error("入库单下发, referCode为空"); | |
76 | + } | |
77 | + if(StringUtils.isEmpty(companyCode)) { | |
78 | + Company company = companyService.getDefaultCompany(); | |
79 | + if(company == null) { | |
80 | + return Result.error("入库单下发, company为空"); | |
81 | + } | |
82 | + companyCode = company.getCode(); | |
83 | + } | |
84 | + ReceiptHeader receiptHeader = new ReceiptHeader(); | |
85 | + receiptHeader.setCompanyCode(companyCode); | |
86 | + receiptHeader.setType(receiptType); | |
87 | + receiptHeader.setReferCode(referCode); | |
88 | + receiptHeader.setSupplierCode(supplierCode); | |
89 | + receiptHeader.setRemark(remark); | |
90 | + Result result = receiptHeaderService.saveReceiptHeader(receiptHeader); | |
91 | + if(!result.isSuccess()) { | |
92 | + throw new ServiceException("创建入库单头失败"); | |
93 | + } | |
94 | + for(ErpReceiptDetail erpReceiptDetail : erpReceiptDetailList) { | |
95 | + BigDecimal qty = erpReceiptDetail.getQty(); | |
96 | + String materialCode = erpReceiptDetail.getMaterialCode(); | |
97 | + String inventoryStatus = erpReceiptDetail.getInventoryStatus(); | |
98 | + String batch = erpReceiptDetail.getBatch(); | |
99 | + String lot = erpReceiptDetail.getLot(); | |
100 | + String project = erpReceiptDetail.getProject(); | |
101 | + if(StringUtils.isEmpty(materialCode)) { | |
102 | + throw new ServiceException("入库单下发, 物料编码为空"); | |
103 | + } | |
104 | + if(StringUtils.isEmpty(inventoryStatus)) { | |
105 | + inventoryStatus = QuantityConstant.QUALITY_GOOD; | |
106 | + } | |
107 | + if(qty.compareTo(BigDecimal.ZERO) > 0) { | |
108 | + throw new ServiceException("入库单下发, 单据数量大于0"); | |
109 | + } | |
110 | + ReceiptDetail receiptDetail = new ReceiptDetail(); | |
111 | + receiptDetail.setCompanyCode(companyCode); | |
112 | + receiptDetail.setReceiptCode(receiptHeader.getCode()); | |
113 | + receiptDetail.setReceiptId(receiptHeader.getId()); | |
114 | + receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_BUILD); | |
115 | + receiptDetail.setQty(qty); | |
116 | + Material material = materialService.getMaterialByCode(materialCode); | |
117 | + if(material == null) { | |
118 | + throw new ServiceException("入库单下发, 没有找到物料信息" + materialCode); | |
119 | + } | |
120 | + receiptDetail.setInventoryStatus(inventoryStatus); | |
121 | + receiptDetail.setMaterialCode(materialCode); | |
122 | + receiptDetail.setMaterialName(material.getName()); | |
123 | + receiptDetail.setMaterialSpec(material.getSpec()); | |
124 | + receiptDetail.setMaterialUnit(material.getUnit()); | |
125 | + receiptDetail.setBatch(batch); | |
126 | + receiptDetail.setLot(lot); | |
127 | + receiptDetail.setProject(project); | |
128 | + boolean success = receiptDetailService.save(receiptDetail); | |
129 | + if(!success) { | |
130 | + throw new ServiceException("入库单下发, 保存入库单详情失败"); | |
131 | + } | |
132 | + } | |
133 | + return Result.OK("入库单下发成功"); | |
134 | + } | |
135 | + | |
136 | + | |
137 | +} | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... | ... | @@ -28,8 +28,8 @@ public class WcsController extends BaseController { |
28 | 28 | @Resource |
29 | 29 | private ITaskHeaderService taskHeaderService; |
30 | 30 | |
31 | - /* | |
32 | - WCS给的长,宽,高,重在有不同规格库位才有用,destination是区域, locationType库位类型 | |
31 | + /** | |
32 | + ** WCS给的长,宽,高,重在有不同规格库位才有用,destination是区域, locationType库位类型 | |
33 | 33 | */ |
34 | 34 | @AutoLog(value = "WCS仓位分配") |
35 | 35 | @PostMapping("/warecellAllocation") |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/config/company/service/ICompanyService.java
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/config/company/service/impl/CompanyServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.config.company.service.impl; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | 5 | import org.jeecg.modules.wms.config.company.entity.Company; |
4 | 6 | import org.jeecg.modules.wms.config.company.mapper.CompanyMapper; |
5 | 7 | import org.jeecg.modules.wms.config.company.service.ICompanyService; |
... | ... | @@ -16,4 +18,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
16 | 18 | @Service |
17 | 19 | public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements ICompanyService { |
18 | 20 | |
21 | + @Override | |
22 | + public Company getDefaultCompany() { | |
23 | + LambdaQueryWrapper<Company> companyLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
24 | + companyLambdaQueryWrapper.last(" limit 1"); | |
25 | + Company company = getOne(companyLambdaQueryWrapper); | |
26 | + return company; | |
27 | + } | |
19 | 28 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/config/warehouse/service/IWarehouseService.java
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/config/warehouse/service/impl/WarehouseServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.config.warehouse.service.impl; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | 5 | import org.jeecg.modules.wms.config.warehouse.entity.Warehouse; |
4 | 6 | import org.jeecg.modules.wms.config.warehouse.mapper.WarehouseMapper; |
5 | 7 | import org.jeecg.modules.wms.config.warehouse.service.IWarehouseService; |
... | ... | @@ -22,4 +24,12 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse |
22 | 24 | public List<Warehouse> getAllWarehouseList() { |
23 | 25 | return list(); |
24 | 26 | } |
27 | + | |
28 | + @Override | |
29 | + public Warehouse getWarehouseByCode(String code) { | |
30 | + LambdaQueryWrapper<Warehouse> warehouseLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
31 | + warehouseLambdaQueryWrapper.eq(Warehouse::getCode, code); | |
32 | + Warehouse warehouse = getOne(warehouseLambdaQueryWrapper); | |
33 | + return warehouse; | |
34 | + } | |
25 | 35 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptHeaderServiceImpl.java
... | ... | @@ -94,8 +94,8 @@ public class ReceiptHeaderServiceImpl extends ServiceImpl<ReceiptHeaderMapper, R |
94 | 94 | receiptHeader.setCode(code); |
95 | 95 | receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_BUILD); |
96 | 96 | receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_BUILD); |
97 | - boolean result = save(receiptHeader); | |
98 | - if(!result) { | |
97 | + boolean success = save(receiptHeader); | |
98 | + if(!success) { | |
99 | 99 | return Result.OK("添加失败!"); |
100 | 100 | } |
101 | 101 | return Result.OK("添加成功!"); |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml
... | ... | @@ -131,9 +131,9 @@ spring: |
131 | 131 | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 |
132 | 132 | datasource: |
133 | 133 | master: |
134 | - url: jdbc:mysql://localhost:3306/wms4?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true | |
134 | + url: jdbc:mysql://172.16.29.45:3306/wms4?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true | |
135 | 135 | username: root |
136 | - password: HHsoft123. | |
136 | + password: hhsoftware | |
137 | 137 | driver-class-name: com.mysql.cj.jdbc.Driver |
138 | 138 | # 多数据源配置 |
139 | 139 | #multi-datasource1: |
... | ... |