feat(erp): 新增ERP接口对接功能并优化物料管理服务
- 新增多个ERP接口对接相关的请求和响应实体类 - 移除物料管理服务中冗余的字段设置逻辑 - 优化接收物料、客户和供应商信息的方法实现 - 调整前端页面布局及字段显示以适配新数据结构 - 更新API控制器以支持新的ERP数据同步方式
This commit is contained in:
@@ -21,23 +21,23 @@ public class ToErpApiController {
|
||||
/**
|
||||
* 接收物料信息
|
||||
*/
|
||||
@GetMapping("/receiveMaterial")
|
||||
public AjaxResult receiveMaterial(@RequestBody BasProduct basProduct) {
|
||||
return toErpService.receiveMaterial(basProduct);
|
||||
@GetMapping("/receiveProduct")
|
||||
public AjaxResult receiveProduct() {
|
||||
return toErpService.receiveProduct();
|
||||
}
|
||||
/**
|
||||
* 接收客户信息
|
||||
*/
|
||||
@GetMapping("/receiveCustomer")
|
||||
public AjaxResult receiveCustomer(@RequestBody BasCustomer basProduct) {
|
||||
return toErpService.receiveCustomer(basProduct);
|
||||
public AjaxResult receiveCustomer() {
|
||||
return toErpService.receiveCustomer();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收供应商信息
|
||||
*/
|
||||
@GetMapping("/receiveSupplier")
|
||||
public AjaxResult receiveSupplier(/*@RequestBody BasSupplier basSupplier*/) {
|
||||
public AjaxResult receiveSupplier() {
|
||||
return toErpService.receiveSupplier();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AspRequestParam {
|
||||
private String session;
|
||||
|
||||
private String cmdkey;
|
||||
|
||||
private List<DataInfo> datas;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class DataInfo{
|
||||
private String id;
|
||||
|
||||
private Object val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AspResponse {
|
||||
private Body body;
|
||||
}
|
||||
10
ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Body.java
Normal file
10
ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Body.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Body {
|
||||
private String action;
|
||||
private String model;
|
||||
private Source source;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Col {
|
||||
private String id;
|
||||
private String dbtype;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Field {
|
||||
private String type;
|
||||
private Object source;
|
||||
private String text;
|
||||
private String post;
|
||||
private boolean notnull;
|
||||
private boolean onlyread;
|
||||
private int minl;
|
||||
private int maxl;
|
||||
private boolean edit;
|
||||
private boolean visible;
|
||||
private boolean canset;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Layout {
|
||||
private String uitype;
|
||||
private String action;
|
||||
private String url;
|
||||
private List<Field> fields;
|
||||
private List<Object> buttons;
|
||||
}
|
||||
11
ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Page.java
Normal file
11
ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Page.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Page {
|
||||
private int recordcount;
|
||||
private int pagesize;
|
||||
private int pagecount;
|
||||
private int pageindex;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Source {
|
||||
private String type;
|
||||
private Table table;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.api.domain.erp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Table {
|
||||
private Layout layout;
|
||||
private Page page;
|
||||
private List<Col> cols;
|
||||
private List<List<String>> rows;
|
||||
}
|
||||
@@ -17,9 +17,9 @@ public interface IToErpService {
|
||||
|
||||
Map<String,String> billCompletedCallBack();
|
||||
|
||||
AjaxResult receiveMaterial(BasProduct basProduct);
|
||||
AjaxResult receiveProduct();
|
||||
|
||||
AjaxResult receiveCustomer(BasCustomer basProduct);
|
||||
AjaxResult receiveCustomer();
|
||||
|
||||
AjaxResult receiveSupplier();
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@ import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.api.domain.erp.ErpSupplierParam;
|
||||
import com.ruoyi.api.domain.erp.ErpSupplierResponse;
|
||||
import com.ruoyi.api.domain.erp.LoginParam;
|
||||
import com.ruoyi.api.domain.erp.LoginResponse;
|
||||
import com.ruoyi.api.domain.erp.*;
|
||||
import com.ruoyi.api.service.IToErpService;
|
||||
import com.ruoyi.bas.BasCustomer.domain.BasCustomer;
|
||||
import com.ruoyi.bas.BasCustomer.service.IBasCustomerService;
|
||||
@@ -51,6 +48,10 @@ public class ToErpServiceImpl implements IToErpService {
|
||||
|
||||
private static final String loginUrl = erpUrl+"/webapi/v3/ov1/login";
|
||||
private static final String supplierListUrl = erpUrl+"/webapi/v3/store/supplierList";
|
||||
private static final String customerListUrl = erpUrl+"/sysa/mobilephone/salesmanage/custom/list.asp";
|
||||
private static final String productListUrl = erpUrl+"/sysa/mobilephone/salesmanage/product/billlist.asp";
|
||||
|
||||
private static final String TOKEN_KEY = "ZBAPI-Token";
|
||||
|
||||
|
||||
@Override
|
||||
@@ -68,26 +69,80 @@ public class ToErpServiceImpl implements IToErpService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult receiveMaterial(BasProduct basProduct) {
|
||||
String productId = basProduct.getProductId();
|
||||
BasProduct oldProduct = basProductService.selectBasProductByProductId(productId);
|
||||
if (ObjUtil.isNotNull(oldProduct)){
|
||||
basProductService.updateBasProduct(basProduct);
|
||||
}else {
|
||||
basProductService.insertBasProduct(basProduct);
|
||||
public AjaxResult receiveProduct() {
|
||||
AspRequestParam erpCustomerParam = new AspRequestParam();
|
||||
erpCustomerParam.setSession(login());
|
||||
erpCustomerParam.setCmdkey("refresh");
|
||||
List<AspRequestParam.DataInfo> dataInfoList = new ArrayList<>();
|
||||
dataInfoList.add(new AspRequestParam.DataInfo("pagesize", 100000));
|
||||
dataInfoList.add(new AspRequestParam.DataInfo("pageindex", 1));
|
||||
dataInfoList.add(new AspRequestParam.DataInfo("idProductClass", "532"));
|
||||
erpCustomerParam.setDatas(dataInfoList);
|
||||
String body = HttpRequest.post(productListUrl).header(TOKEN_KEY, login()).body(JSONUtil.toJsonStr(erpCustomerParam)).execute().body();
|
||||
AspResponse responseBean = JSONUtil.toBean(body, AspResponse.class);
|
||||
for (List<String> row : responseBean.getBody().getSource().getTable().getRows()) {
|
||||
BasProduct product = new BasProduct();
|
||||
product.setProductGuid(row.get(0));
|
||||
product.setProductId(row.get(0));
|
||||
product.setProductName(row.get(1));
|
||||
product.setCargoNo(row.get(2));
|
||||
product.setSpec(row.get(3));
|
||||
product.setUnit(row.get(4));
|
||||
product.setSpare1(row.get(5));
|
||||
product.setPrice(row.get(6));
|
||||
product.setParentId(row.get(7));
|
||||
product.setSpare3(row.get(8));
|
||||
product.setSpare4(row.get(9));
|
||||
product.setSpare5(row.get(10));
|
||||
product.setSpare6(row.get(11));
|
||||
product.setSpare7(row.get(12));
|
||||
BasProduct basProduct = basProductService.selectBasProductByProductId(product.getProductId());
|
||||
if (ObjUtil.isNotNull(basProduct)){
|
||||
BeanUtil.copyProperties(product,basProduct);
|
||||
basProductService.updateBasProduct(basProduct);
|
||||
}else {
|
||||
basProductService.insertBasProduct(product);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult receiveCustomer(BasCustomer basCustomer) {
|
||||
String customerNo = basCustomer.getId();
|
||||
BasCustomer oldCustomer = basCustomerService.selectBasCustomerById(customerNo);
|
||||
if (ObjUtil.isNotNull(oldCustomer)){
|
||||
basCustomerService.updateBasCustomer(basCustomer);
|
||||
}else {
|
||||
basCustomerService.insertBasCustomer(basCustomer);
|
||||
public AjaxResult receiveCustomer() {
|
||||
AspRequestParam erpCustomerParam = new AspRequestParam();
|
||||
erpCustomerParam.setSession(login());
|
||||
erpCustomerParam.setCmdkey("refresh");
|
||||
List<AspRequestParam.DataInfo> dataInfoList = new ArrayList<>();
|
||||
dataInfoList.add(new AspRequestParam.DataInfo("pagesize", 100000));
|
||||
dataInfoList.add(new AspRequestParam.DataInfo("pageindex", 1));
|
||||
erpCustomerParam.setDatas(dataInfoList);
|
||||
|
||||
String body = HttpRequest.post(customerListUrl).header(TOKEN_KEY, login()).body(JSONUtil.toJsonStr(erpCustomerParam)).execute().body();
|
||||
AspResponse responseBean = JSONUtil.toBean(body, AspResponse.class);
|
||||
for (List<String> row : responseBean.getBody().getSource().getTable().getRows()) {
|
||||
BasCustomer customer = new BasCustomer();
|
||||
customer.setCustomerName(Convert.toStr(row.get(0)));
|
||||
customer.setSalesman(Convert.toStr(row.get(1)));
|
||||
customer.setBusinessDepartment(Convert.toStr(row.get(2)));
|
||||
customer.setSupCustomer(Convert.toStr(row.get(3)));
|
||||
customer.setContactName(Convert.toStr(row.get(4)));
|
||||
customer.setMnemonicCode(Convert.toStr(row.get(5)));
|
||||
customer.setType(Convert.toStr(row.get(6)));
|
||||
customer.setTaxpayerRegistrationNumber(Convert.toStr(row.get(7)));
|
||||
customer.setOrganization(Convert.toStr(row.get(8)));
|
||||
customer.setRetailInvestor(Convert.toStr(row.get(9)));
|
||||
customer.setId(Convert.toStr(row.get(10)));
|
||||
customer.setCustomerNo(Convert.toStr(row.get(10)));
|
||||
customer.setShipment(Convert.toStr(row.get(11)));
|
||||
customer.setTaxCategory(Convert.toStr(row.get(12)));
|
||||
BasCustomer basCustomer = basCustomerService.selectBasCustomerById(customer.getId());
|
||||
if (ObjUtil.isNotNull(basCustomer)){
|
||||
basCustomerService.updateBasCustomer(customer);
|
||||
}else {
|
||||
basCustomerService.insertBasCustomer(customer);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -96,7 +151,7 @@ public class ToErpServiceImpl implements IToErpService {
|
||||
ErpSupplierParam erpSupplierParam = new ErpSupplierParam();
|
||||
erpSupplierParam.setPage_index(1);
|
||||
erpSupplierParam.setPage_size(100000);
|
||||
String body = HttpRequest.post(supplierListUrl).header("ZBAPI-Token", login()).body(JSONUtil.toJsonStr(erpSupplierParam)).execute().body();
|
||||
String body = HttpRequest.post(supplierListUrl).header(TOKEN_KEY, login()).body(JSONUtil.toJsonStr(erpSupplierParam)).execute().body();
|
||||
ErpSupplierResponse responseBean = JSONUtil.toBean(body, ErpSupplierResponse.class);
|
||||
for (List<Object> row : responseBean.getRows()) {
|
||||
BasSupplier supplier = new BasSupplier();
|
||||
|
||||
@@ -15,19 +15,19 @@ import com.ruoyi.bas.BasProduct.service.IBasProductService;
|
||||
|
||||
/**
|
||||
* 物料管理Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author gw
|
||||
* @date 2025-09-17
|
||||
*/
|
||||
@Service
|
||||
public class BasProductServiceImpl implements IBasProductService
|
||||
public class BasProductServiceImpl implements IBasProductService
|
||||
{
|
||||
@Autowired
|
||||
private BasProductMapper basProductMapper;
|
||||
|
||||
/**
|
||||
* 查询物料管理
|
||||
*
|
||||
*
|
||||
* @param productGuid 物料管理主键
|
||||
* @return 物料管理
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ public class BasProductServiceImpl implements IBasProductService
|
||||
|
||||
/**
|
||||
* 查询物料管理列表
|
||||
*
|
||||
*
|
||||
* @param basProduct 物料管理
|
||||
* @return 物料管理
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public class BasProductServiceImpl implements IBasProductService
|
||||
|
||||
/**
|
||||
* 新增物料管理
|
||||
*
|
||||
*
|
||||
* @param basProduct 物料管理
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -77,16 +77,12 @@ public class BasProductServiceImpl implements IBasProductService
|
||||
throw new RuntimeException("物料编号已存在");
|
||||
}
|
||||
basProduct.setProductGuid(basProduct.getProductId());
|
||||
basProduct.setSpare3(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
//获取当前系统登录用户名
|
||||
String username = SecurityUtils.getUsername();
|
||||
basProduct.setSpare4(username);
|
||||
return basProductMapper.insertBasProduct(basProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料管理
|
||||
*
|
||||
*
|
||||
* @param basProduct 物料管理
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -105,7 +101,7 @@ public class BasProductServiceImpl implements IBasProductService
|
||||
|
||||
/**
|
||||
* 批量删除物料管理
|
||||
*
|
||||
*
|
||||
* @param productGuids 需要删除的物料管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -117,7 +113,7 @@ public class BasProductServiceImpl implements IBasProductService
|
||||
|
||||
/**
|
||||
* 删除物料管理信息
|
||||
*
|
||||
*
|
||||
* @param productGuid 物料管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user