From 902ec017c2c6b01bacc67a0a65fbb5a53a951c1e Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期二, 19 八月 2025 10:56:16 +0800 Subject: [PATCH] 企业信息同步 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Companys.java | 2 rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/CompaniesParam.java | 53 +++++++++++++++++ rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/BaseInfoController.java | 41 +++++++++++-- rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java | 8 ++ rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java | 34 +++++++++++ rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java | 9 ++ rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/CompanysType.java | 15 +++++ rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/SyncOrderController.java | 2 8 files changed, 155 insertions(+), 9 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/BaseInfoController.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/BaseInfoController.java index 87a657c..41392fb 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/BaseInfoController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/BaseInfoController.java @@ -18,7 +18,7 @@ @RestController @RequestMapping("/base") -@Api(tags = "鍩虹淇℃伅鍚屾") +@Api(tags = "鍩虹淇℃伅") public class BaseInfoController { @Autowired @@ -30,7 +30,7 @@ * @description: 鐗╂枡淇℃伅鍚屾 * @version 1.0 */ - @ApiOperation(value = "鍩虹鐗╂枡淇℃伅鍚屾", tags = "鍩虹淇℃伅鍚屾") + @ApiOperation(value = "鍩虹鐗╂枡淇℃伅鍚屾") @PostMapping("/sync/base/matnrs") public R syncMatnrs(@RequestBody List<BaseMatParms> matnrs) { if (Objects.isNull(matnrs)) { @@ -47,7 +47,7 @@ * @version 1.0 */ @PostMapping("/sync/locs") - @ApiOperation(value = "搴撲綅淇℃伅鍚屾", tags = "鍩虹淇℃伅鍚屾") + @ApiOperation(value = "搴撲綅淇℃伅鍚屾") public R syncLocs(@RequestBody List<SyncLocsParams> locs) { if (locs.isEmpty()) { throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); @@ -62,7 +62,7 @@ * @version 1.0 */ @PostMapping("/sync/matGroups") - @ApiOperation(value = "鐗╂枡鍒嗙粍淇℃伅鍚屾", tags = "鍩虹淇℃伅鍚屾") + @ApiOperation(value = "鐗╂枡鍒嗙粍淇℃伅鍚屾") public R syncMatGroup(@RequestBody List<SyncMatGroupsParams> matGroupsParams) { if (matGroupsParams.isEmpty()) { throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); @@ -70,7 +70,13 @@ return receiveMsgService.syncMatGroups(matGroupsParams); } - @ApiOperation(value = "搴撳尯鏁版嵁鍚屾", tags = "鍩虹淇℃伅鍚屾") + /** + * @author Ryan + * @date 2025/8/19 + * @description: 搴撳尯鏁版嵁鍚屾 + * @version 1.0 + */ + @ApiOperation(value = "搴撳尯鏁版嵁鍚屾") @PostMapping("/sync/warehouse/areas") public R syncLocAreas(@RequestBody List<LocAreasParams> areasParams) { if (areasParams.isEmpty()) { @@ -80,7 +86,13 @@ } - @ApiOperation(value = "搴撳尯鏁版嵁鍚屾", tags = "鍩虹淇℃伅鍚屾") + /** + * @author Ryan + * @date 2025/8/19 + * @description: 浠撳簱淇℃伅鍚屾 + * @version 1.0 + */ + @ApiOperation(value = "浠撳簱鏁版嵁鍚屾") @PostMapping("/sync/warehouse") public R syncWarehouse(@RequestBody List<WarehouseParams> warehouseParams) { if (warehouseParams.isEmpty()) { @@ -88,4 +100,21 @@ } return receiveMsgService.syncWarehouse(warehouseParams); } + + /** + * @author Ryan + * @date 2025/8/19 + * @description: 浠撳簱淇℃伅鍚屾 + * @version 1.0 + */ + @ApiOperation(value = "浼佷笟淇℃伅鍚屾") + @PostMapping("/sync/companies") + public R syncCompanys(@RequestBody List<CompaniesParam> companyParams) { + if (companyParams.isEmpty()) { + throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); + } + return receiveMsgService.syncCompanies(companyParams); + } + + } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java index a8b019f..2823aca 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java @@ -32,7 +32,7 @@ */ @RestController @RequestMapping("/erp") -@Api(tags = "鏌ヨ") +@Api(tags = "缁煎悎鏌ヨ") public class ReceiveMsgController extends BaseController { @Autowired @@ -40,7 +40,12 @@ @Autowired private MatnrGroupService matnrGroupService; - + /** + * @author Ryan + * @date 2025/8/19 + * @description: 鐗╂枡鍒嗙被鍒楄〃鏌ヨ + * @version 1.0 + */ @ApiOperation(value = "鏌ヨ鍒嗙被淇℃伅") @PostMapping("/query/matnr/group") public R syncMatGroup() { diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/SyncOrderController.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/SyncOrderController.java index 2644760..b4321e1 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/SyncOrderController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/SyncOrderController.java @@ -20,7 +20,7 @@ @RestController @RequestMapping("/order") -@Api(tags = "鍗曟嵁鍚屾") +@Api(tags = "鍗曟嵁") public class SyncOrderController { @Autowired diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/CompaniesParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/CompaniesParam.java new file mode 100644 index 0000000..60a154c --- /dev/null +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/CompaniesParam.java @@ -0,0 +1,53 @@ +package com.vincent.rsf.server.api.controller.erp.params; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@Accessors(chain = true) +@ApiModel(value = "CompaniesParam", description = "鍚屾浼佷笟淇℃伅鍙傛暟") +public class CompaniesParam implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("浼佷笟鍚嶇О") + private String name; + + @ApiModelProperty("浼佷笟鍚嶇О锛堣嫳鏂囧悕锛�") + private String nameEn; + + @ApiModelProperty("浼佷笟鍔╄鐮�") + private String breifCode; + + @ApiModelProperty("浼佷笟绫诲瀷") + private String type; + + @ApiModelProperty("鑱旂郴浜�") + private String contact; + + @ApiModelProperty("鑱旂郴鐢佃瘽") + private String tel; + + @ApiModelProperty("閭") + private String email; + + @ApiModelProperty("閭紪") + private String pcode; + + @ApiModelProperty("鍩庡競") + private String city; + + @ApiModelProperty("鐪佷唤") + private String province; + + @ApiModelProperty("鍦板潃") + private String address; + + @ApiModelProperty("浼佷笟缂栫爜") + private String code; + +} diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java index 4b05789..c3bf1ad 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java @@ -81,4 +81,12 @@ * @version 1.0 */ R syncWarehouse(List<WarehouseParams> warehouses); + + /** + * @author Ryan + * @date 2025/8/19 + * @description: 鍚屾浼佷笟淇℃伅 + * @version 1.0 + */ + R syncCompanies(List<CompaniesParam> companyParams); } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java index f8c7c5d..97b8ffd 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java @@ -12,6 +12,7 @@ import com.vincent.rsf.server.common.domain.PageParam; import com.vincent.rsf.server.manager.controller.dto.LocStockDto; import com.vincent.rsf.server.manager.entity.*; +import com.vincent.rsf.server.manager.enums.CompanysType; import com.vincent.rsf.server.manager.enums.OrderType; import com.vincent.rsf.server.manager.service.*; import com.vincent.rsf.server.manager.service.impl.LocAreaServiceImpl; @@ -69,6 +70,8 @@ private WarehouseAreasService warehouseAreasService; @Autowired private WarehouseService warehouseService; + @Autowired + private CompanysService companysService; /** * @author Ryan @@ -320,4 +323,35 @@ return R.ok(); } + /** + * @author Ryan + * @date 2025/8/19 + * @description: 鍚屾浼佷笟淇℃伅 + * @version 1.0 + */ + @Override + @Transactional(timeout = 60, rollbackFor = Exception.class) + public R syncCompanies(List<CompaniesParam> companyParams) { + companyParams.forEach(param -> { + Companys companys = new Companys(); + BeanUtils.copyProperties(param, companys); + if (Objects.isNull(companys.getCode())) { + throw new CoolException("浼佷笟缂栫爜涓嶈兘涓虹┖锛侊紒"); + } + Companys one = companysService.getOne(new LambdaQueryWrapper<Companys>().eq(Companys::getName, param.getName())); + if (Objects.isNull(one)) { + String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_COMPANYS_CODE, null); + companys.setCode(ruleCode); + } else { + throw new CoolException(one.getName() + "锛屼紒涓氬悕閲嶅锛侊紒"); + } + companys.setType(CompanysType.getCustomVal(param.getType())) + .setId(null); + if (!companysService.save(companys)) { + throw new CoolException("浼佷笟淇濆瓨澶辫触锛侊紒"); + } + }); + return R.ok(); + } + } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Companys.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Companys.java index c8804ed..b5ab94c 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Companys.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Companys.java @@ -9,6 +9,7 @@ import com.vincent.rsf.server.system.constant.DictTypeCode; import com.vincent.rsf.server.system.entity.DictData; import com.vincent.rsf.server.system.service.DictDataService; +import lombok.experimental.Accessors; import org.springframework.format.annotation.DateTimeFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -28,6 +29,7 @@ import java.util.Date; @Data +@Accessors(chain = true) @TableName("man_companys") public class Companys implements Serializable { diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/CompanysType.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/CompanysType.java index e84eafa..2ecb66f 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/CompanysType.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/CompanysType.java @@ -22,4 +22,19 @@ public String val; public String desc; + + + public static String getCustomVal(String desc) { + if (desc.equals(CompanysType.COMPANYS_TYPE_SHIPPER.desc)) { + return CompanysType.COMPANYS_TYPE_SHIPPER.val; + } else if (desc.equals(CompanysType.COMPANYS_TYPE_CUSTOMER.desc)) { + return CompanysType.COMPANYS_TYPE_CUSTOMER.val; + } else if (desc.equals(CompanysType.COMPANYS_TYPE_SUPPLIER.desc)) { + return CompanysType.COMPANYS_TYPE_SUPPLIER.val; + } + return null; + } + + + } -- Gitblit v1.9.1