diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java index 3056b24..3766c0c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java @@ -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(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspRequestParam.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspRequestParam.java new file mode 100644 index 0000000..d5c4e73 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspRequestParam.java @@ -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 datas; + + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class DataInfo{ + private String id; + + private Object val; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspResponse.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspResponse.java new file mode 100644 index 0000000..5e71e4e --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/AspResponse.java @@ -0,0 +1,8 @@ +package com.ruoyi.api.domain.erp; + +import lombok.Data; + +@Data +public class AspResponse { + private Body body; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Body.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Body.java new file mode 100644 index 0000000..fad0dd6 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Body.java @@ -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; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Col.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Col.java new file mode 100644 index 0000000..9709452 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Col.java @@ -0,0 +1,9 @@ +package com.ruoyi.api.domain.erp; + +import lombok.Data; + +@Data +public class Col { + private String id; + private String dbtype; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Field.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Field.java new file mode 100644 index 0000000..c28b048 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Field.java @@ -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; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Layout.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Layout.java new file mode 100644 index 0000000..ed37f10 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Layout.java @@ -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 fields; + private List buttons; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Page.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Page.java new file mode 100644 index 0000000..ac9b68f --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Page.java @@ -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; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Source.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Source.java new file mode 100644 index 0000000..f4249f5 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Source.java @@ -0,0 +1,9 @@ +package com.ruoyi.api.domain.erp; + +import lombok.Data; + +@Data +public class Source { + private String type; + private Table table; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Table.java b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Table.java new file mode 100644 index 0000000..8e88979 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/domain/erp/Table.java @@ -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 cols; + private List> rows; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToErpService.java b/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToErpService.java index 9af94ed..5b7564e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToErpService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/service/IToErpService.java @@ -17,9 +17,9 @@ public interface IToErpService { Map billCompletedCallBack(); - AjaxResult receiveMaterial(BasProduct basProduct); + AjaxResult receiveProduct(); - AjaxResult receiveCustomer(BasCustomer basProduct); + AjaxResult receiveCustomer(); AjaxResult receiveSupplier(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToErpServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToErpServiceImpl.java index d78445b..ed63cfd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToErpServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/service/impl/ToErpServiceImpl.java @@ -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 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 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 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 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 row : responseBean.getRows()) { BasSupplier supplier = new BasSupplier(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/bas/BasProduct/service/impl/BasProductServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/bas/BasProduct/service/impl/BasProductServiceImpl.java index f7a50d2..1f80bd2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/bas/BasProduct/service/impl/BasProductServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/bas/BasProduct/service/impl/BasProductServiceImpl.java @@ -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 结果 */ diff --git a/ruoyi-ui/src/views/bas/basCustomer/index.vue b/ruoyi-ui/src/views/bas/basCustomer/index.vue index 8dc5c5b..7a6f7fb 100644 --- a/ruoyi-ui/src/views/bas/basCustomer/index.vue +++ b/ruoyi-ui/src/views/bas/basCustomer/index.vue @@ -7,19 +7,19 @@ - - - - - - - - + 搜索 @@ -44,37 +44,20 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + +