diff --git a/src/main/java/com/glxp/api/controller/basic/UdiRelevanceController.java b/src/main/java/com/glxp/api/controller/basic/UdiRelevanceController.java index a257594c..4e227480 100644 --- a/src/main/java/com/glxp/api/controller/basic/UdiRelevanceController.java +++ b/src/main/java/com/glxp/api/controller/basic/UdiRelevanceController.java @@ -12,6 +12,7 @@ import com.glxp.api.constant.BusinessType; import com.glxp.api.constant.ConstantStatus; import com.glxp.api.controller.BaseController; import com.glxp.api.entity.basic.*; +import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.system.SystemParamConfigEntity; import com.glxp.api.entity.thrsys.ThrProductsEntity; import com.glxp.api.entity.thrsys.ThrSystemEntity; @@ -26,6 +27,9 @@ import com.glxp.api.res.basic.BasicProductThirdSysResponse; import com.glxp.api.res.basic.UdiRelevanceResponse; import com.glxp.api.service.auth.CustomerService; import com.glxp.api.service.basic.*; +import com.glxp.api.service.inout.IoCodeService; +import com.glxp.api.service.inv.InvPreProductService; +import com.glxp.api.service.inv.InvProductService; import com.glxp.api.service.system.SystemParamConfigService; import com.glxp.api.service.thrsys.ThrDataService; import com.glxp.api.service.thrsys.ThrSystemService; @@ -246,6 +250,11 @@ public class UdiRelevanceController extends BaseController { return ResultVOUtils.success("删除成功"); } + @Resource + IoCodeService codeService; + @Resource + CompanyProductRelevanceService companyProductRelevanceService; + @AuthRuleAnnotation("") @PostMapping("/udi/udirel/deleteById") @Log(title = "单据管理", businessType = BusinessType.DELETE) @@ -256,37 +265,15 @@ public class UdiRelevanceController extends BaseController { } String ids = deleteRequest.getId(); UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(Long.parseLong(ids)); - //todo 单据未完成 -// if (udiRelevanceEntity != null && udiRelevanceEntity.getUuid() != null) { -// List udiRelevanceEntities = udiRelevanceService.selectByUuid(udiRelevanceEntity.getUuid()); -// if (udiRelevanceEntities != null && !udiRelevanceEntities.isEmpty()) { -// for (UdiRelevanceEntity udiRelevanceEntity1 : udiRelevanceEntities) { -// List udiInfoEntities = udiInfoService.findByUuids(udiRelevanceEntity1.getUuid()); -// if (udiInfoEntities != null && udiInfoEntities.size() > 0) { -// for (int i = 0; i < udiInfoEntities.size(); i++) { -// List warehouseEntityList = warehouseService.searchCode(udiInfoEntities.get(i).getNameCode()); -// if (warehouseEntityList != null && warehouseEntityList.size() > 0) { -// return ResultVOUtils.error(500, "该产品已被" + warehouseEntityList.get(0).getOrderId() + "订单关联不能删除"); -// } -// } -// } -// } -// WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); -// warehouseQueryRequest.setRelId(ids); -// if (StrUtil.isNotEmpty(ids)) { -// List warehouseEntityList = warehouseService.findByOrderId(warehouseQueryRequest); -// if (CollUtil.isNotEmpty(warehouseEntityList)) { -// return ResultVOUtils.error(500, "该产品已被" + warehouseEntityList.get(0).getOrderId() + "订单关联不能删除"); -// } -// } -// } -// } -// -// CompanyProductRelevanceEntity companyProductRelevanceEntity = companyProductRelevanceService.findByUdiRlIdUnitFk(ids, null); -// if (companyProductRelevanceEntity != null) { -// return ResultVOUtils.error(500, "该产品已被已被供应商选入" + "不能删除!"); -// } -// + if (udiRelevanceEntity != null && udiRelevanceEntity.getUuid() != null) { + if (codeService.isExitByRelId(udiRelevanceEntity.getId() + "")) { + return ResultVOUtils.error(500, "该产品已关联单据,无法删除!"); + } + if (companyProductRelevanceService.isExitByRelId(udiRelevanceEntity.getId() + "")) { + return ResultVOUtils.error(500, "该产品已被已被供应商选入,无法删除!"); + } + } + udiRelevanceService.deleteById(ids); List udiRelevanceEntities = udiRelevanceService.selectByUuid(udiRelevanceEntity.getUuid()); @@ -294,9 +281,6 @@ public class UdiRelevanceController extends BaseController { udiProductService.deleteByUuid(udiRelevanceEntity.getUuid()); } - //todo -// companyProductRelevanceService.deleteByRlId(ids);//删除供应商关联表产品信息 - return ResultVOUtils.success("删除成功"); } @@ -421,20 +405,24 @@ public class UdiRelevanceController extends BaseController { } + @Resource + InvProductService invProductService; + @Resource + InvPreProductService invPreProductService; + //查询产品是否可以被禁用 todo 库存还未完成 @AuthRuleAnnotation("") @PostMapping("/udi/udirel/disable") public BaseResponse disable(@RequestBody UdiCombineRequest udiCombineRequest) { -// InvProductEntity invProductEntity = invProductService.selectExit(combineRequest.getRelId()); -// if (invProductEntity != null) { -// return ResultVOUtils.error(500, "库存已存在,无法禁用"); -// } -// -// InvProductEntity invPreProductEntity = invPreProductService.selectExit(combineRequest.getRelId()); -// if (invPreProductEntity != null) { -// return ResultVOUtils.error(500, "库存已存在,无法禁用"); -// } + + if (invProductService.isExitByRelId(udiCombineRequest.getRelId() + "")) { + return ResultVOUtils.error(500, "库存已存在,无法禁用"); + } + + if (invPreProductService.isExitByRelId(udiCombineRequest.getRelId() + "")) { + return ResultVOUtils.error(500, "寄售库存已存在,无法禁用"); + } return ResultVOUtils.success("更新成功"); } diff --git a/src/main/java/com/glxp/api/dao/basic/CompanyProductRelevanceDao.java b/src/main/java/com/glxp/api/dao/basic/CompanyProductRelevanceDao.java index 8437ee33..3e0f627b 100644 --- a/src/main/java/com/glxp/api/dao/basic/CompanyProductRelevanceDao.java +++ b/src/main/java/com/glxp/api/dao/basic/CompanyProductRelevanceDao.java @@ -1,7 +1,9 @@ package com.glxp.api.dao.basic; +import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.basic.CompanyProductRelevanceEntity; +import com.glxp.api.entity.basic.UdiRelevanceEntity; import com.glxp.api.req.basic.CompanyProductRelevanceRequest; import com.glxp.api.res.basic.CompanyProductRelevanceResponse; import org.apache.ibatis.annotations.Mapper; @@ -9,7 +11,7 @@ import org.apache.ibatis.annotations.Mapper; import java.util.List; @Mapper -public interface CompanyProductRelevanceDao { +public interface CompanyProductRelevanceDao extends BaseMapperPlus { List filterUdiGp(CompanyProductRelevanceRequest basicInstrumentMaintainRequest); diff --git a/src/main/java/com/glxp/api/entity/basic/CompanyProductRelevanceEntity.java b/src/main/java/com/glxp/api/entity/basic/CompanyProductRelevanceEntity.java index 9f8e773f..90125645 100644 --- a/src/main/java/com/glxp/api/entity/basic/CompanyProductRelevanceEntity.java +++ b/src/main/java/com/glxp/api/entity/basic/CompanyProductRelevanceEntity.java @@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; + import java.math.BigDecimal; import java.util.Date; + import lombok.Data; @Data @@ -110,4 +112,4 @@ public class CompanyProductRelevanceEntity { public static final String COL_UPDATEUSER = "updateUser"; public static final String COL_UPDATETIME = "updateTime"; -} \ No newline at end of file +} diff --git a/src/main/java/com/glxp/api/service/basic/CompanyProductRelevanceService.java b/src/main/java/com/glxp/api/service/basic/CompanyProductRelevanceService.java index 1f3234ca..0e31f305 100644 --- a/src/main/java/com/glxp/api/service/basic/CompanyProductRelevanceService.java +++ b/src/main/java/com/glxp/api/service/basic/CompanyProductRelevanceService.java @@ -1,8 +1,6 @@ package com.glxp.api.service.basic; - - import com.glxp.api.entity.basic.CompanyProductRelevanceEntity; import com.glxp.api.req.basic.CompanyProductRelevanceRequest; import com.glxp.api.res.basic.CompanyProductRelevanceResponse; @@ -18,4 +16,6 @@ public interface CompanyProductRelevanceService { boolean deleteById(String id); boolean deleteByRlId(String id); + + boolean isExitByRelId(String relId); } diff --git a/src/main/java/com/glxp/api/service/basic/impl/CompanyProductRelevanceServiceImpl.java b/src/main/java/com/glxp/api/service/basic/impl/CompanyProductRelevanceServiceImpl.java index 2f42c49f..7528ab4e 100644 --- a/src/main/java/com/glxp/api/service/basic/impl/CompanyProductRelevanceServiceImpl.java +++ b/src/main/java/com/glxp/api/service/basic/impl/CompanyProductRelevanceServiceImpl.java @@ -1,6 +1,7 @@ package com.glxp.api.service.basic.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.glxp.api.dao.basic.CompanyProductRelevanceDao; import com.glxp.api.entity.basic.CompanyProductRelevanceEntity; @@ -48,4 +49,9 @@ public class CompanyProductRelevanceServiceImpl implements CompanyProductRelevan public boolean deleteByRlId(String id) { return companyProductRelevanceDao.deleteByRlId(id); } + + @Override + public boolean isExitByRelId(String relId) { + return companyProductRelevanceDao.exists(new QueryWrapper().eq("udiRlIdFk", relId)); + } } diff --git a/src/main/java/com/glxp/api/service/inout/IoCodeService.java b/src/main/java/com/glxp/api/service/inout/IoCodeService.java index 326b2dfd..0f0bb567 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCodeService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCodeService.java @@ -21,6 +21,9 @@ public interface IoCodeService { public IoCodeEntity findByUnique(String orderId, String code); + + boolean isExitByRelId(String relId); + /** * 查询正式码表实体数据 * diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoCodeServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoCodeServiceImpl.java index 36afabc7..2f22809f 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoCodeServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoCodeServiceImpl.java @@ -66,6 +66,12 @@ public class IoCodeServiceImpl implements IoCodeService { return ioCodeDao.selectOne(new QueryWrapper().eq("orderId", orderId).eq("code", code)); } + @Override + public boolean isExitByRelId(String relId) { +// return ioCodeDao.selectList(new QueryWrapper().eq("relId", relId).last("limit 1")); + return ioCodeDao.exists(new QueryWrapper().eq("relId", relId)); + } + @Override public List filterCodeList(FilterCodeRequest filterCodeRequest) { if (null == filterCodeRequest) { diff --git a/src/main/java/com/glxp/api/service/inv/InvPreProductService.java b/src/main/java/com/glxp/api/service/inv/InvPreProductService.java index b933fbe7..8db3bcdc 100644 --- a/src/main/java/com/glxp/api/service/inv/InvPreProductService.java +++ b/src/main/java/com/glxp/api/service/inv/InvPreProductService.java @@ -45,4 +45,6 @@ public interface InvPreProductService { * @return */ InvPreProductEntity findById(String id); + + boolean isExitByRelId(String relId); } diff --git a/src/main/java/com/glxp/api/service/inv/InvProductService.java b/src/main/java/com/glxp/api/service/inv/InvProductService.java index 809bd528..7c137d80 100644 --- a/src/main/java/com/glxp/api/service/inv/InvProductService.java +++ b/src/main/java/com/glxp/api/service/inv/InvProductService.java @@ -81,4 +81,6 @@ public interface InvProductService { */ List filterProductNames(FilterInvProductRequest filterInvProductRequest); + boolean isExitByRelId(String relId); + } diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvPreProductServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/InvPreProductServiceImpl.java index 51be15a3..b4f6a5d9 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvPreProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvPreProductServiceImpl.java @@ -74,4 +74,11 @@ public class InvPreProductServiceImpl implements InvPreProductService { return invPreProductDao.selectById(id); } + + @Override + public boolean isExitByRelId(String relId) { + return invPreProductDao.exists(new QueryWrapper().eq("relIdFk", relId)); + + } + } diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java index 8aebe0fd..87da4e0a 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java @@ -121,4 +121,10 @@ public class InvProductServiceImpl implements InvProductService { return invProductDao.filterProductNames(filterInvProductRequest); } + @Override + public boolean isExitByRelId(String relId) { + return invProductDao.exists(new QueryWrapper().eq("relIdFk", relId)); + + } + }