From c9325ac054b20c1e5ec06bfa8e69707585f000da Mon Sep 17 00:00:00 2001 From: MrZhai Date: Fri, 18 Mar 2022 15:55:42 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=8F=8A=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E6=9F=A5=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=202.=E5=A2=9E=E5=8A=A0=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=95=B0=E6=8D=AE=E7=BB=91=E5=AE=9A=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E4=BB=93=E5=B1=80=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=203.=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E7=B3=BB=E7=BB=9F=E4=B8=8E=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E4=BB=93=E5=BA=93=E6=95=B0=E6=8D=AE=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inventory/InvWarehouseController.java | 61 ++++++++++ .../thrsys/ThrInvWarehouseController.java | 115 ++++++++++++++++++ .../admin/dao/inventory/InvWarehouseDao.java | 9 ++ .../admin/dao/thrsys/ThrInvWarehouseDao.java | 30 +++++ .../entity/inventory/InvWarehouseEntity.java | 9 ++ .../entity/thrsys/ThrInvWarehouseEntity.java | 32 +++++ .../thrsys/FilterThrInvWarehouseRequest.java | 19 +++ .../InvWarehouseThirdSysResponse.java | 18 +++ .../res/thrsys/ThrInvWarehouseResponse.java | 24 ++++ .../inventory/InvWarehouseService.java | 27 ++++ .../impl/InvWarehouseServiceImpl.java | 99 +++++++++++++++ .../thrsys/ThrInvWarehouseService.java | 28 +++++ .../impl/ThrInvWarehouseServiceImpl.java | 86 +++++++++++++ .../mapper/inventory/InvWarehouseDao.xml | 31 +++-- .../mapper/thrsys/ThrInvWarehouseDao.xml | 103 ++++++++++++++++ 15 files changed, 682 insertions(+), 9 deletions(-) create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/thrsys/ThrInvWarehouseEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvWarehouseThirdSysResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/thrsys/ThrInvWarehouseResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java create mode 100644 api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java index c794656..05618c0 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java @@ -1,13 +1,18 @@ package com.glxp.sale.admin.controller.inventory; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageInfo; import com.glxp.sale.admin.annotation.AuthRuleAnnotation; import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity; +import com.glxp.sale.admin.req.basic.FilterBasicThirdSysRequest; import com.glxp.sale.admin.req.info.DeleteRequest; import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest; +import com.glxp.sale.admin.res.PageSimpleResponse; import com.glxp.sale.admin.res.inventory.InvWarehouseExportResponse; import com.glxp.sale.admin.res.inventory.InvWarehouseResponse; +import com.glxp.sale.admin.res.inventory.InvWarehouseThirdSysResponse; import com.glxp.sale.admin.service.auth.CustomerService; import com.glxp.sale.admin.service.inventory.InvWarehouseService; import com.glxp.sale.admin.util.DateUtil; @@ -207,5 +212,61 @@ public class InvWarehouseController { return ResultVOUtils.success("后台正在导入仓库信息,请稍后查看!"); } + /** + * 绑定第三方仓库ID + * + * @param id + * @param thridWarehouseId + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/spms/inv/warehouse/bindThrWarehouse") + public BaseResponse bindThrWarehouse(Integer id, Integer thridWarehouseId, String sysId) { + if (null == id || null == thridWarehouseId || StrUtil.isBlank(sysId)) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + invWarehouseService.bindThrWarehouse(id, thridWarehouseId, sysId); + return ResultVOUtils.success(); + } + + /** + * 解绑第三方仓库ID + * + * @param id + * @param thridWarehouseId + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/spms/inv/warehouse/unbindThrWarehouse") + public BaseResponse unbindThrWarehouse(Integer id, String sysId) { + if (null == id || StrUtil.isBlank(sysId)) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + invWarehouseService.unbindThrWarehouse(id, sysId); + return ResultVOUtils.success(); + } + + /** + * 查询第三方系统和仓库数据关联信息 + * + * @return + */ + @AuthRuleAnnotation("") + @GetMapping("/spms/inv/warehouse/thridSys/detail") + public BaseResponse getThirdSysDetail(FilterInvWarehouseRequest request) { + if (null == request || null == request.getId()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + FilterBasicThirdSysRequest sysRequest = new FilterBasicThirdSysRequest(); + sysRequest.setEnabled(true); + List list = invWarehouseService.getThirdSysDetail(sysRequest, request.getId()); + PageInfo pageInfo; + pageInfo = new PageInfo<>(list); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(list); + return ResultVOUtils.success(pageSimpleResponse); + } + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java new file mode 100644 index 0000000..d2b6ca7 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java @@ -0,0 +1,115 @@ +package com.glxp.sale.admin.controller.thrsys; + +import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.sale.admin.req.inout.DeleteRequest; +import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest; +import com.glxp.sale.admin.res.thrsys.ThrInvWarehouseResponse; +import com.glxp.sale.admin.service.thrsys.ThrInvWarehouseService; +import com.glxp.sale.common.enums.ResultEnum; +import com.glxp.sale.common.res.BaseResponse; +import com.glxp.sale.common.util.ResultVOUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 第三方仓库信息接口 + */ +@Slf4j +@RestController +public class ThrInvWarehouseController { + + @Resource + ThrInvWarehouseService thrInvWarehouseService; + + @GetMapping("spms/thrsys/warehouse/filter") + public BaseResponse filterInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { + List thrInvWarehouseEntities = thrInvWarehouseService.filterThrInvWarehouse(filterThrInvWarehouseRequest); + List merge = merge(thrInvWarehouseEntities, 0); + + Map restMap = new HashMap<>(); + restMap.put("list", merge); + return ResultVOUtils.success(restMap); + } + + public List merge(List thrInvWarehouseEntities, Integer pid) { + List thrInvWarehouseResponses = new ArrayList<>(); + for (ThrInvWarehouseEntity thrInvWarehouseEntity : thrInvWarehouseEntities) { + ThrInvWarehouseResponse thrInvWarehouseResponse = new ThrInvWarehouseResponse(); + BeanUtils.copyProperties(thrInvWarehouseEntity, thrInvWarehouseResponse); + if (pid.equals(thrInvWarehouseEntity.getPid())) { + thrInvWarehouseResponse.setChildren(merge(thrInvWarehouseEntities, thrInvWarehouseEntity.getId())); + thrInvWarehouseResponses.add(thrInvWarehouseResponse); + } + } + return thrInvWarehouseResponses; + } + + @GetMapping("spms/thrsys/warehouse/filterAll") + public BaseResponse filterAllInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { + filterThrInvWarehouseRequest.setPid(0); + List thrInvWarehouseEntities = thrInvWarehouseService.filterThrInvWarehouse(filterThrInvWarehouseRequest); + return ResultVOUtils.success(thrInvWarehouseEntities); + } + + @PostMapping("/spms/thrsys/warehouse/save") + public BaseResponse save(@RequestBody @Valid ThrInvWarehouseEntity thrInvWarehouseEntity, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + + if (thrInvWarehouseEntity.getPid() == null) { + thrInvWarehouseEntity.setPid(0); // 默认设置 + } + boolean b = thrInvWarehouseService.insertInvWarehouse(thrInvWarehouseEntity); + if (!b) { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + return ResultVOUtils.success("添加成功!"); + } + + @PostMapping("/spms/thrsys/warehouse/edit") + public BaseResponse edit(@RequestBody @Valid ThrInvWarehouseEntity thrInvWarehouseEntity, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + if (thrInvWarehouseEntity.getId() == null) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + thrInvWarehouseEntity.setPid(null); // 不能修改父级 pid + boolean b = thrInvWarehouseService.updateInvWarehouse(thrInvWarehouseEntity); + if (!b) { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + return ResultVOUtils.success(); + } + + @PostMapping("/spms/thrsys/warehouse/delete") + public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) { + + if (deleteRequest.getId() == null) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + boolean b = thrInvWarehouseService.deleteById(deleteRequest.getId()); + if (!b) { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + return ResultVOUtils.success(); + } + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java index fdee334..a06b0cf 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java @@ -33,4 +33,13 @@ public interface InvWarehouseDao { */ void importInvWarehouse(@Param("invWarehouseEntities") List invWarehouseEntities); + /** + * 更新第三方仓库ID + * + * @param id + * @param thridWarehouseId + * @param sysId + * @return + */ + boolean updateThridId(@Param("id") Integer id, @Param("thridWarehouseId") Integer thridWarehouseId, @Param("sysId") String sysId); } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java new file mode 100644 index 0000000..5124861 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java @@ -0,0 +1,30 @@ +package com.glxp.sale.admin.dao.thrsys; + +import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ThrInvWarehouseDao { + + List filterThrInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); + + List filterThrGroupInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); + + boolean insertThrInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); + + boolean updateThrInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); + + ThrInvWarehouseEntity selectById(@Param("id") String id); + + boolean deleteById(@Param("id") String id); + + /** + * 根据code查询第三方仓库数据 + * + * @param code + * @return + */ + ThrInvWarehouseEntity selectByCode(@Param("code") String code); +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvWarehouseEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvWarehouseEntity.java index a955d6d..9eee9ce 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvWarehouseEntity.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvWarehouseEntity.java @@ -20,4 +20,13 @@ public class InvWarehouseEntity { private Integer level; private String pcode; + /** + * 第三方仓库ID + */ + private String thirdId; + private String thirdId1; + private String thirdId2; + private String thirdId3; + private String thirdId4; + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/thrsys/ThrInvWarehouseEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/thrsys/ThrInvWarehouseEntity.java new file mode 100644 index 0000000..87e134f --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/thrsys/ThrInvWarehouseEntity.java @@ -0,0 +1,32 @@ +package com.glxp.sale.admin.entity.thrsys; + +import lombok.Data; + +import java.util.Date; + +/** + * 第三方仓库信息 + */ +@Data +public class ThrInvWarehouseEntity { + + private Integer id; + private Integer pid; + private String code; + private String name; + private Boolean advanceType; + private Boolean isDefault; + private Integer status; + private Date updateTime; + private String remark; + + /** + * 仓库等级 + */ + private Integer level; + + /** + * 父级仓库编码 + */ + private String pcode; +} \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java new file mode 100644 index 0000000..8833fc1 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java @@ -0,0 +1,19 @@ +package com.glxp.sale.admin.req.thrsys; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +import java.util.Date; + +@Data +public class FilterThrInvWarehouseRequest extends ListPageRequest { + + private Integer id; + private Integer pid; + private String code; + private String name; + private Boolean advanceType; + private Boolean isDefault; + private Date updateTime; + private String key; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvWarehouseThirdSysResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvWarehouseThirdSysResponse.java new file mode 100644 index 0000000..8504c1c --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvWarehouseThirdSysResponse.java @@ -0,0 +1,18 @@ +package com.glxp.sale.admin.res.inventory; + +import lombok.Data; + +@Data +public class InvWarehouseThirdSysResponse { + private String sysId; + private String sysName; + private String thirdName; + private String thirdId; + + //仓位码 + private String code; + + //仓位名称 + private String name; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/thrsys/ThrInvWarehouseResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/thrsys/ThrInvWarehouseResponse.java new file mode 100644 index 0000000..175ede7 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/thrsys/ThrInvWarehouseResponse.java @@ -0,0 +1,24 @@ +package com.glxp.sale.admin.res.thrsys; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class ThrInvWarehouseResponse { + + + private Integer id; + private Integer pid; + private String code; + private String name; + private Boolean advanceType; + private Boolean isDefault; + private Integer status; + private Date updateTime; + private String remark; + + private List children; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java index 0a2011b..023f4ee 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java @@ -1,7 +1,9 @@ package com.glxp.sale.admin.service.inventory; import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity; +import com.glxp.sale.admin.req.basic.FilterBasicThirdSysRequest; import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest; +import com.glxp.sale.admin.res.inventory.InvWarehouseThirdSysResponse; import java.util.List; @@ -35,4 +37,29 @@ public interface InvWarehouseService { */ void importInvWarehouse(List invWarehouseEntities); + /** + * 绑定第三方仓库 + * + * @param id + * @param thridWarehouseId + */ + boolean bindThrWarehouse(Integer id, Integer thridWarehouseId, String sysId); + + /** + * 解绑第三方仓库 + * + * @param id + * @param thridWarehouseId + */ + boolean unbindThrWarehouse(Integer id, String sysId); + + /** + * 查询第三方系统和仓库信息关联数据 + * + * @param request + * @param id + * @return + */ + List getThirdSysDetail(FilterBasicThirdSysRequest request, Integer id); + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java index 00de528..f743bfc 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java @@ -1,14 +1,22 @@ package com.glxp.sale.admin.service.inventory.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ReflectUtil; import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.basic.BasicThirdSysDao; import com.glxp.sale.admin.dao.inventory.InvWarehouseDao; +import com.glxp.sale.admin.dao.thrsys.ThrInvWarehouseDao; +import com.glxp.sale.admin.entity.basic.BasicThirdSysEntity; import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity; +import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.sale.admin.req.basic.FilterBasicThirdSysRequest; import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest; +import com.glxp.sale.admin.res.inventory.InvWarehouseThirdSysResponse; import com.glxp.sale.admin.service.inventory.InvWarehouseService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -18,6 +26,10 @@ public class InvWarehouseServiceImpl implements InvWarehouseService { @Resource InvWarehouseDao invWarehouseDao; + @Resource + private ThrInvWarehouseDao thrInvWarehouseDao; + @Resource + private BasicThirdSysDao basicThirdSysDao; @Override public InvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault) { @@ -111,4 +123,91 @@ public class InvWarehouseServiceImpl implements InvWarehouseService { invWarehouseDao.importInvWarehouse(invWarehouseEntities); } } + + @Override + public boolean bindThrWarehouse(Integer id, Integer thridWarehouseId, String sysId) { + return invWarehouseDao.updateThridId(id, thridWarehouseId, sysId); + } + + @Override + public boolean unbindThrWarehouse(Integer id,String sysId) { + return invWarehouseDao.updateThridId(id, null, sysId); + } + + @Override + public List getThirdSysDetail(FilterBasicThirdSysRequest request, Integer id) { + //查询第三方系统数据 + if (request == null) { + return Collections.emptyList(); + } + if (request.getPage() != null) { + int offset = (request.getPage() - 1) * request.getLimit(); + PageHelper.offsetPage(offset, request.getLimit()); + } + List data = basicThirdSysDao.filterBasicThiSys(request); + if (CollUtil.isEmpty(data)) { + return Collections.emptyList(); + } + List result = new ArrayList<>(data.size()); + InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectById(String.valueOf(id)); + for (BasicThirdSysEntity sys : data) { + if (sys.getThirdId().equals("thirdId")) { + InvWarehouseThirdSysResponse response = new InvWarehouseThirdSysResponse(); + response.setSysId(sys.getThirdId()); + response.setSysName(sys.getThirdName()); + Object thirdId = ReflectUtil.getFieldValue(invWarehouseEntity, sys.getThirdId()); + if (null != thirdId) { + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(String.valueOf(thirdId)); + response.setThirdId(thrInvWarehouseEntity.getCode()); + response.setThirdName(thrInvWarehouseEntity.getName()); + } + result.add(response); + } else if (sys.getThirdId().equals("thirdId1")) { + InvWarehouseThirdSysResponse response = new InvWarehouseThirdSysResponse(); + response.setSysId(sys.getThirdId()); + response.setSysName(sys.getThirdName()); + Object thirdId = ReflectUtil.getFieldValue(invWarehouseEntity, sys.getThirdId()); + if (null != thirdId) { + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(String.valueOf(thirdId)); + response.setThirdId(thrInvWarehouseEntity.getCode()); + response.setThirdName(thrInvWarehouseEntity.getName()); + } + result.add(response); + }else if (sys.getThirdId().equals("thirdId2")) { + InvWarehouseThirdSysResponse response = new InvWarehouseThirdSysResponse(); + response.setSysId(sys.getThirdId()); + response.setSysName(sys.getThirdName()); + Object thirdId = ReflectUtil.getFieldValue(invWarehouseEntity, sys.getThirdId()); + if (null != thirdId) { + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(String.valueOf(thirdId)); + response.setThirdId(thrInvWarehouseEntity.getCode()); + response.setThirdName(thrInvWarehouseEntity.getName()); + } + result.add(response); + }else if (sys.getThirdId().equals("thirdId3")) { + InvWarehouseThirdSysResponse response = new InvWarehouseThirdSysResponse(); + response.setSysId(sys.getThirdId()); + response.setSysName(sys.getThirdName()); + Object thirdId = ReflectUtil.getFieldValue(invWarehouseEntity, sys.getThirdId()); + if (null != thirdId) { + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(String.valueOf(thirdId)); + response.setThirdId(thrInvWarehouseEntity.getCode()); + response.setThirdName(thrInvWarehouseEntity.getName()); + } + result.add(response); + }else if (sys.getThirdId().equals("thirdId4")) { + InvWarehouseThirdSysResponse response = new InvWarehouseThirdSysResponse(); + response.setSysId(sys.getThirdId()); + response.setSysName(sys.getThirdName()); + Object thirdId = ReflectUtil.getFieldValue(invWarehouseEntity, sys.getThirdId()); + if (null != thirdId) { + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectByCode(String.valueOf(thirdId)); + response.setThirdId(thrInvWarehouseEntity.getCode()); + response.setThirdName(thrInvWarehouseEntity.getName()); + } + result.add(response); + } + } + return result; + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java new file mode 100644 index 0000000..5b905f9 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java @@ -0,0 +1,28 @@ +package com.glxp.sale.admin.service.thrsys; + + +import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest; + +import java.util.List; + +public interface ThrInvWarehouseService { + + + ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault); + + List filterThrInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); + + List filterGroupInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); + + boolean insertInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); + + boolean updateInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); + + ThrInvWarehouseEntity selectById(String id); + + ThrInvWarehouseEntity selectByCode(String code); + + boolean deleteById(String id); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java new file mode 100644 index 0000000..a85eae1 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java @@ -0,0 +1,86 @@ +package com.glxp.sale.admin.service.thrsys.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.thrsys.ThrInvWarehouseDao; +import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest; +import com.glxp.sale.admin.service.thrsys.ThrInvWarehouseService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService { + + + @Resource + ThrInvWarehouseDao thrInvWarehouseDao; + + @Override + public ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault) { + + FilterThrInvWarehouseRequest filterThrInvWarehouseRequest = new FilterThrInvWarehouseRequest(); + filterThrInvWarehouseRequest.setIsDefault(isDefault); + filterThrInvWarehouseRequest.setAdvanceType(advaceType); + List thrInvWarehouseEntities = thrInvWarehouseDao.filterThrInvWarehouse(filterThrInvWarehouseRequest); + if (thrInvWarehouseEntities != null && thrInvWarehouseEntities.size() > 0) + return thrInvWarehouseEntities.get(0); + return null; + } + + @Override + public List filterThrInvWarehouse(FilterThrInvWarehouseRequest FilterThrInvWarehouseRequest) { + if (FilterThrInvWarehouseRequest == null) { + return Collections.emptyList(); + } + if (FilterThrInvWarehouseRequest.getPage() != null) { + int offset = (FilterThrInvWarehouseRequest.getPage() - 1) * FilterThrInvWarehouseRequest.getLimit(); + PageHelper.offsetPage(offset, FilterThrInvWarehouseRequest.getLimit()); + } + return thrInvWarehouseDao.filterThrInvWarehouse(FilterThrInvWarehouseRequest); + } + + @Override + public List filterGroupInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { + if (filterThrInvWarehouseRequest == null) { + return Collections.emptyList(); + } + if (filterThrInvWarehouseRequest.getPage() != null) { + int offset = (filterThrInvWarehouseRequest.getPage() - 1) * filterThrInvWarehouseRequest.getLimit(); + PageHelper.offsetPage(offset, filterThrInvWarehouseRequest.getLimit()); + } + return thrInvWarehouseDao.filterThrGroupInvWarehouse(filterThrInvWarehouseRequest); + } + + @Override + public boolean insertInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity) { + return thrInvWarehouseDao.insertThrInvWarehouse(thrInvWarehouseEntity); + } + + @Override + public boolean updateInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity) { + return thrInvWarehouseDao.updateThrInvWarehouse(thrInvWarehouseEntity); + } + + @Override + public ThrInvWarehouseEntity selectById(String id) { + return thrInvWarehouseDao.selectById(id); + } + + @Override + public ThrInvWarehouseEntity selectByCode(String code) { + FilterThrInvWarehouseRequest thrInvWarehouseRequest = new FilterThrInvWarehouseRequest(); + thrInvWarehouseRequest.setCode(code); + List invWarehouseEntities = thrInvWarehouseDao.filterThrInvWarehouse(thrInvWarehouseRequest); + if (invWarehouseEntities != null && invWarehouseEntities.size() > 0) + return invWarehouseEntities.get(0); + return null; + } + + @Override + public boolean deleteById(String id) { + return thrInvWarehouseDao.deleteById(id); + } +} diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml index d730730..5ef71a6 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml @@ -184,23 +184,36 @@ remark=#{remark}, level=#{level}, pcode=#{pcode}, + remark=#{thirdId}, + remark=#{thirdId1}, + remark=#{thirdId2}, + remark=#{thirdId3}, + remark=#{thirdId4}, WHERE id = #{id} replace into inv_warehouse (id, pId, code, name, advanceType, isDefault, status, - updateTime, remark,level,pcode) values + updateTime, remark, level, pcode, thirdId, thirdId1, thirdId2, thirdId3, + thirdId4) values (#{item.id}, - #{item.pid}, - #{item.code}, - #{item.name}, - #{item.advanceType}, - #{item.isDefault}, - #{item.status}, - #{item.updateTime}, - #{item.remark}, #{item.level}, #{item.pcode}) + #{item.pid}, + #{item.code}, + #{item.name}, + #{item.advanceType}, + #{item.isDefault}, + #{item.status}, + #{item.updateTime}, + #{item.remark}, #{item.level}, + #{item.pcode}, #{thirdId}, + #{thirdId1}, #{thirdId2}, + #{thirdId3}, #{thirdId4}) + + + update inv_warehouse set ${sysId} = ${thridWarehouseId} where id = ${id} + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml new file mode 100644 index 0000000..e269047 --- /dev/null +++ b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + insert INTO thr_inv_warehouse + (pid, code, name, advanceType, isDefault, + status, updateTime, remark) + values (#{pid}, #{code}, + #{name}, #{advanceType}, #{isDefault}, + #{status}, #{updateTime}, + #{remark}) + + + + + DELETE + FROM thr_inv_warehouse + WHERE id = #{id} + + + + UPDATE thr_inv_warehouse + + pid=#{pid}, + name=#{name}, + code=#{code}, + advanceType=#{advanceType}, + isDefault=#{isDefault}, + status=#{status}, + updateTime=#{updateTime}, + remark=#{remark}, + + WHERE id = #{id} + + + + \ No newline at end of file