From 3651b54080a0e32d77968b81331b4c2b2666a82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Sat, 25 Mar 2023 15:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=BA=A7=E4=BA=A7=E5=93=81=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/inout/ioCodeRelController.java | 106 ++++++++++++++++++ .../api/entity/inout/IoCodeRelEntity.java | 2 +- .../glxp/api/req/inout/IoOrderRelRequest.java | 2 + .../api/service/inout/IoCodeRelService.java | 8 ++ .../inout/impl/IoCodeRelServiceImpl.java | 49 ++++++++ .../mybatis/mapper/inout/IoCodeRelMapper.xml | 3 + 6 files changed, 169 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java b/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java index 282dd5194..f04728c84 100644 --- a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java +++ b/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java @@ -1,21 +1,28 @@ package com.glxp.api.controller.inout; +import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageInfo; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.entity.basic.UdiEntity; +import com.glxp.api.entity.basic.UdiProductEntity; +import com.glxp.api.entity.inout.IoCodeRelEntity; import com.glxp.api.req.inout.IoOrderRelRequest; import com.glxp.api.req.purchase.PurApplyRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.inout.IoCodeLostResponse; import com.glxp.api.res.inout.IoCodeRelResponse; import com.glxp.api.res.purchase.PurApplyResponse; +import com.glxp.api.service.basic.UdiProductService; import com.glxp.api.service.inout.IoCodeRelService; +import com.glxp.api.util.udi.FilterUdiUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.Date; import java.util.List; @RestController @@ -23,6 +30,8 @@ public class ioCodeRelController { @Resource IoCodeRelService ioCodeRelServicec; + @Resource + UdiProductService udiProductService; @GetMapping("/udi/ioCode/Rel/list") @@ -35,6 +44,103 @@ public class ioCodeRelController { pageSimpleResponse.setTotal(pageInfo.getTotal()); pageSimpleResponse.setList(list); return ResultVOUtils.success(pageSimpleResponse); + } + + @GetMapping("/udi/ioCode/Rel/checkUpProduct") + public BaseResponse checkUpProduct(String code) { + + + //判断码有没有重复 + List list=ioCodeRelServicec.selectIoCodeRelByCode("",code); + if(list.size()>0){ + return ResultVOUtils.error(999,"此码已做关联!"); + } + + if(StrUtil.isNotEmpty(code)){ + UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(code); + UdiProductEntity udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); + if(udiProductEntity.getPackLevel()!=null){ + if(Integer.valueOf(udiProductEntity.getPackLevel())>1){ + return ResultVOUtils.success(udiProductEntity.getBhxjcpbm()); + } + } + } + return ResultVOUtils.error(999,"扫码错误!"); + } + + @GetMapping("/udi/ioCode/Rel/checkLowProduct") + public BaseResponse checkLowProduct(String upCode,String lowCode) { + + UdiProductEntity udiProductEntity=new UdiProductEntity(); + //查询上级产品信息 + if(StrUtil.isNotEmpty(upCode)){ + UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(upCode); + udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); + } + + //判断码有没有重复 + List list=ioCodeRelServicec.selectIoCodeRelByCode(lowCode,upCode); + if(list.size()>0){ + return ResultVOUtils.error(999,"此码已做关联!"); + } + + //判断条数是否超出 + Long count=ioCodeRelServicec.selectIoCodeRelCount(upCode); + if(count>=udiProductEntity.getBhxjsl()){ + return ResultVOUtils.error(999,"数量超出!"); + } + + //查询下级产品信息 + if(StrUtil.isNotEmpty(lowCode)){ + UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(lowCode); + UdiProductEntity udiProductEntity1=udiProductService.findByNameCode(udiEntity.getUdi()); + if(udiProductEntity!=null){ + if(udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())){ + IoCodeRelEntity ioCodeRelEntity=new IoCodeRelEntity(); + ioCodeRelEntity.setCode(lowCode); + ioCodeRelEntity.setParentCode(upCode); + ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode()); + ioCodeRelEntity.setDiType(udiProductEntity1.getDiType()); + ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel()); + ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate()); + ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate()); + ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo()); + ioCodeRelEntity.setCreateTime(new Date()); + ioCodeRelEntity.setUpdateTime(new Date()); + ioCodeRelServicec.insert(ioCodeRelEntity); + return ResultVOUtils.success(); + }else{ + return ResultVOUtils.error(999,"该条码不属于下级产品!"); + } + } + } + return ResultVOUtils.error(999,""); + } + + @GetMapping("/udi/ioCode/Rel/delectList") + public BaseResponse delectList(IoOrderRelRequest ioOrderRelRequest) { + + List list = ioCodeRelServicec.selectIoCodeRelList(ioOrderRelRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(list); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(list); + return ResultVOUtils.success(pageSimpleResponse); + } + + + @GetMapping("/udi/ioCode/Rel/del") + public BaseResponse del(String code,String parentCode) { + + int count=ioCodeRelServicec.delIoCodeRel(code,parentCode); + if(count>0){ + return ResultVOUtils.success("删除成功"); + }else{ + return ResultVOUtils.error(999,"删除失败"); + } } + + } diff --git a/src/main/java/com/glxp/api/entity/inout/IoCodeRelEntity.java b/src/main/java/com/glxp/api/entity/inout/IoCodeRelEntity.java index c28402c87..b1b031695 100644 --- a/src/main/java/com/glxp/api/entity/inout/IoCodeRelEntity.java +++ b/src/main/java/com/glxp/api/entity/inout/IoCodeRelEntity.java @@ -38,7 +38,7 @@ public class IoCodeRelEntity { * DI类型 */ @TableField(value = "diType") - private Byte diType; + private Integer diType; /** * 主产品DI标识 diff --git a/src/main/java/com/glxp/api/req/inout/IoOrderRelRequest.java b/src/main/java/com/glxp/api/req/inout/IoOrderRelRequest.java index fd22afb75..a4792a492 100644 --- a/src/main/java/com/glxp/api/req/inout/IoOrderRelRequest.java +++ b/src/main/java/com/glxp/api/req/inout/IoOrderRelRequest.java @@ -16,4 +16,6 @@ public class IoOrderRelRequest extends ListPageRequest { private String serialNo; private String startTime; private String endTime; + private String upCode; + private String parentCode; } diff --git a/src/main/java/com/glxp/api/service/inout/IoCodeRelService.java b/src/main/java/com/glxp/api/service/inout/IoCodeRelService.java index 8cbd17dc1..a61ecbff2 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCodeRelService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCodeRelService.java @@ -11,5 +11,13 @@ public interface IoCodeRelService { List selectIoCodeRelList(IoOrderRelRequest ioOrderRelRequest); + int insert(IoCodeRelEntity ioCodeRelEntity); + + List selectIoCodeRelByCode(String code,String parentCode); + + Long selectIoCodeRelCount(String parentCode); + + int delIoCodeRel(String code,String parentCode); + } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoCodeRelServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoCodeRelServiceImpl.java index 6b0ccdb39..51401ac1f 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoCodeRelServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoCodeRelServiceImpl.java @@ -1,7 +1,10 @@ package com.glxp.api.service.inout.impl; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.glxp.api.dao.inout.IoCodeRelMapper; +import com.glxp.api.entity.inout.IoCodeRelEntity; import com.glxp.api.req.inout.IoOrderRelRequest; import com.glxp.api.res.inout.IoCodeRelResponse; import com.glxp.api.service.inout.IoCodeRelService; @@ -28,4 +31,50 @@ public class IoCodeRelServiceImpl implements IoCodeRelService { } return ioCodeRelMapper.selectIoCodeRelList(ioOrderRelRequest); } + + @Override + public int insert(IoCodeRelEntity ioCodeRelEntity) { + return ioCodeRelMapper.insert(ioCodeRelEntity); + } + + @Override + public List selectIoCodeRelByCode(String code, String parentCode) { + + QueryWrapper ew=new QueryWrapper<>(); + if(StrUtil.isNotEmpty(code)){ + ew.eq("code",code); + } + if(StrUtil.isNotEmpty(parentCode)){ + ew.eq("parentCode",parentCode); + } + List list=ioCodeRelMapper.selectList(ew); + return list; + } + + @Override + public Long selectIoCodeRelCount(String parentCode) { + + QueryWrapper ew=new QueryWrapper<>(); + if(StrUtil.isNotEmpty(parentCode)){ + ew.eq("parentCode",parentCode); + } + Long count=ioCodeRelMapper.selectCount(ew); + return count; + } + + @Override + public int delIoCodeRel(String code, String parentCode) { + + QueryWrapper ew=new QueryWrapper<>(); + if(StrUtil.isNotEmpty(code)){ + ew.eq("code",code); + } + if(StrUtil.isNotEmpty(parentCode)){ + ew.eq("parentCode",parentCode); + } + int count=ioCodeRelMapper.delete(ew); + return count; + } + + } diff --git a/src/main/resources/mybatis/mapper/inout/IoCodeRelMapper.xml b/src/main/resources/mybatis/mapper/inout/IoCodeRelMapper.xml index 807c58992..82c3881dd 100644 --- a/src/main/resources/mybatis/mapper/inout/IoCodeRelMapper.xml +++ b/src/main/resources/mybatis/mapper/inout/IoCodeRelMapper.xml @@ -11,6 +11,9 @@ and io_code_rel.code like concat('%', #{code}, '%') + + and io_code_rel.parentCode =#{parentCode} + and io_code_rel.nameCode=#{nameCode}