diff --git a/src/main/java/com/glxp/api/common/enums/ResultEnum.java b/src/main/java/com/glxp/api/common/enums/ResultEnum.java index f19fc0ed6..42ebe9512 100644 --- a/src/main/java/com/glxp/api/common/enums/ResultEnum.java +++ b/src/main/java/com/glxp/api/common/enums/ResultEnum.java @@ -17,6 +17,7 @@ public enum ResultEnum { DATA_CHANGE(6, "数据没有任何更改"), DATA_REPEAT(7, "数据已存在"), DATA_ERROR(8, "参数错误"), + ; private Integer code; diff --git a/src/main/java/com/glxp/api/controller/purchase/SupProductController.java b/src/main/java/com/glxp/api/controller/purchase/SupProductController.java index acd248ad6..9f52f29b3 100644 --- a/src/main/java/com/glxp/api/controller/purchase/SupProductController.java +++ b/src/main/java/com/glxp/api/controller/purchase/SupProductController.java @@ -86,11 +86,10 @@ public class SupProductController { @PostMapping("/sup/product/addRegistration") @Log(title = "资质证书", businessType = BusinessType.INSERT) public BaseResponse addRegistration(@RequestBody SupProductEntity supProductEntity) { - + System.out.println(supProductEntity.toString()); //提交审核 if (supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_UN) { //判断是否上级供应商是否审核通过 - SupManufacturerEntity supManufacturerEntity = supManufacturerService.findManufacturer(supProductEntity.getManufacturerIdFk()); if (supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_UN || supManufacturerEntity.getAuditStatus() == ConstantStatus.AUDIT_DRAFT) { @@ -135,15 +134,22 @@ public class SupProductController { return ResultVOUtils.error(500, errMsg.substring(1) + "等证书未上传,无法提交审核!"); } } - supProductEntity.setCreateTime(new Date()); - supProductEntity.setUpdateTime(new Date()); - supProductEntity.setId(IdUtil.getSnowflakeNextId()); - boolean b = supProductService.insertRegistration(supProductEntity); - if (b) { - return ResultVOUtils.success("添加成功"); + int i = supProductService.findProduct(supProductEntity); + System.out.println(i); + if (i == 0) { + supProductEntity.setCreateTime(new Date()); + supProductEntity.setUpdateTime(new Date()); + supProductEntity.setId(IdUtil.getSnowflakeNextId()); + boolean b = supProductService.insertRegistration(supProductEntity); + if (b) { + return ResultVOUtils.success("添加成功"); + } else { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } } else { - return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + return ResultVOUtils.error(ResultEnum.DATA_REPEAT); } + } @@ -153,27 +159,27 @@ public class SupProductController { UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectUdiId(Long.valueOf(selectProductBindRequest.getRelIdFk())); SupProductEntity supProductEntity = supProductService.findByManufactury(udiRelevanceResponse.getCpmctymc(), udiRelevanceResponse.getManufactory(), selectProductBindRequest.getManufacturerId()); - if (supProductEntity != null) { - return ResultVOUtils.error(500, "该产品资质已存在,请勿重复添加!"); - } else { - supProductEntity = new SupProductEntity(); - BeanUtils.copyProperties(udiRelevanceResponse, supProductEntity); - supProductEntity.setProductId(selectProductBindRequest.getProductId()); - supProductEntity.setRecordCode(udiRelevanceResponse.getZczbhhzbapzbh()); - supProductEntity.setRelIdFk(udiRelevanceResponse.getId() + ""); - supProductEntity.setRecordProductName(udiRelevanceResponse.getCpmctymc()); - supProductEntity.setProductType(udiRelevanceResponse.getQxlb()); - supProductEntity.setProductDirectoryCode(udiRelevanceResponse.getFlbm()); - supProductEntity.setRecordPeopleName(udiRelevanceResponse.getYlqxzcrbarmc()); - supProductEntity.setSpecification(udiRelevanceResponse.getGgxh()); - supProductEntity.setCreateTime(new Date()); - supProductEntity.setUpdateTime(new Date()); - supProductEntity.setManufacturerIdFk(selectProductBindRequest.getManufacturerId()); - supProductEntity.setCustomerId(selectProductBindRequest.getCustomerId()); - supProductEntity.setHchzsb(udiRelevanceResponse.getCplb()); +// if (supProductEntity != null) { +//// return ResultVOUtils.error(500, "该产品资质已存在,请勿重复添加!"); +// } else { + supProductEntity = new SupProductEntity(); + BeanUtils.copyProperties(udiRelevanceResponse, supProductEntity); + supProductEntity.setProductId(selectProductBindRequest.getProductId()); + supProductEntity.setRecordCode(udiRelevanceResponse.getZczbhhzbapzbh()); + supProductEntity.setRelIdFk(udiRelevanceResponse.getId() + ""); + supProductEntity.setRecordProductName(udiRelevanceResponse.getCpmctymc()); + supProductEntity.setProductType(udiRelevanceResponse.getQxlb()); + supProductEntity.setProductDirectoryCode(udiRelevanceResponse.getFlbm()); + supProductEntity.setRecordPeopleName(udiRelevanceResponse.getYlqxzcrbarmc()); + supProductEntity.setSpecification(udiRelevanceResponse.getGgxh()); + supProductEntity.setCreateTime(new Date()); + supProductEntity.setUpdateTime(new Date()); + supProductEntity.setManufacturerIdFk(selectProductBindRequest.getManufacturerId()); + supProductEntity.setCustomerId(selectProductBindRequest.getCustomerId()); + supProductEntity.setHchzsb(udiRelevanceResponse.getCplb()); // supProductEntity.setCompanyName(selectProductBindRequest.getCompanyName()); - supProductEntity.setAuditStatus(selectProductBindRequest.getAuditStatus()); - } + supProductEntity.setAuditStatus(selectProductBindRequest.getAuditStatus()); +// } return ResultVOUtils.success(supProductEntity); diff --git a/src/main/java/com/glxp/api/dao/purchase/SupProductDao.java b/src/main/java/com/glxp/api/dao/purchase/SupProductDao.java index 14483eb33..052bf63b4 100644 --- a/src/main/java/com/glxp/api/dao/purchase/SupProductDao.java +++ b/src/main/java/com/glxp/api/dao/purchase/SupProductDao.java @@ -26,7 +26,7 @@ public interface SupProductDao extends BaseMapperPlus { SupProductEntity findByRelIdFk(String relIdFk); - SupProductEntity findByManufactury(String cpmctymc, String manufactory,String manufacturerIdFk); + SupProductEntity findByManufactury(String cpmctymc, String manufactory, String manufacturerIdFk); SupProductResponse findByPassByReCert(String registerCert); @@ -34,6 +34,8 @@ public interface SupProductService extends IService { boolean insertRegistration(SupProductEntity supProductEntity); + int findProduct(SupProductEntity supProductEntity); + boolean deleteById(@Param("id") String id); boolean deleteByEnterpriseId(@Param("enterpriseId") String enterpriseId); diff --git a/src/main/java/com/glxp/api/service/purchase/impl/SupProductServiceImpl.java b/src/main/java/com/glxp/api/service/purchase/impl/SupProductServiceImpl.java index c1fac32a5..414bfd757 100644 --- a/src/main/java/com/glxp/api/service/purchase/impl/SupProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/purchase/impl/SupProductServiceImpl.java @@ -143,6 +143,10 @@ public class SupProductServiceImpl extends ServiceImpl 0 ? true : false; } + @Override + public int findProduct(SupProductEntity supProductEntity) { + return supProductDao.findProduct(supProductEntity); + } @Override public boolean deleteById(String id) { return supProductDao.deleteById(id); diff --git a/src/main/resources/mybatis/mapper/purchase/SupProductDao.xml b/src/main/resources/mybatis/mapper/purchase/SupProductDao.xml index 8fe545e1c..c3cbd0e0b 100644 --- a/src/main/resources/mybatis/mapper/purchase/SupProductDao.xml +++ b/src/main/resources/mybatis/mapper/purchase/SupProductDao.xml @@ -389,4 +389,18 @@ FROM sup_product WHERE enterpriseId = #{enterpriseId} + + +