From 5486e431751397cfde79a59824080d870a320fa3 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Fri, 21 Apr 2023 15:54:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=90=8E=E7=94=9F=E6=88=90=E9=9A=8F=E6=9C=BAID=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9B=B8=E4=BA=92=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/auth/RegisterController.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/auth/RegisterController.java b/src/main/java/com/glxp/api/controller/auth/RegisterController.java index a97d972c..71db3a7f 100644 --- a/src/main/java/com/glxp/api/controller/auth/RegisterController.java +++ b/src/main/java/com/glxp/api/controller/auth/RegisterController.java @@ -10,6 +10,7 @@ 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.constant.BusinessType; +import com.glxp.api.dao.auth.AuthAdminDao; import com.glxp.api.entity.auth.AuthAdmin; import com.glxp.api.entity.auth.CustomerInfoEntity; import com.glxp.api.entity.auth.UserRegisterEntity; @@ -250,12 +251,12 @@ public class RegisterController { if (StrUtil.isNotBlank(company_check) && company_check.equals("1")) { //新用户注册时根据往来单位字典进行企业名称校验 CustomerInfoEntity customerInfoEntity = customerInfoService.selectById(userRegisterEntity.getCompanyId()); - if (customerInfoEntity != null ) { + if (customerInfoEntity != null) { return ResultVOUtils.error(500, "该企业已被注册!"); } } UserRegisterEntity userRegisterEntity2 = userRegisterService.selectByCname(userRegisterEntity.getCompanyName()); - if (userRegisterEntity2 !=null ) { + if (userRegisterEntity2 != null) { return ResultVOUtils.error(500, "该企业已被注册!"); } @@ -275,8 +276,8 @@ public class RegisterController { } userRegisterEntity.setUserName(userName); UserRegisterEntity userRegisterEntity1 = userRegisterService.selectByMobile(userRegisterEntity.getMobile()); - if(userRegisterEntity1!=null){ - userRegisterService.deleteByMobile(userRegisterEntity.getMobile(),2); + if (userRegisterEntity1 != null) { + userRegisterService.deleteByMobile(userRegisterEntity.getMobile(), 2); } boolean b = userRegisterService.insertUserRegister(userRegisterEntity); if (!b) { @@ -327,6 +328,9 @@ public class RegisterController { return ResultVOUtils.success("密码修改成功"); } + @Resource + AuthAdminDao authAdminDao; + @AuthRuleAnnotation("") @PostMapping("salewarehouse/register/check") @Log(title = "用户管理", businessType = BusinessType.INSERT) @@ -383,18 +387,20 @@ public class RegisterController { } //创建新用户 AuthAdmin authAdmin = new AuthAdmin(); - authAdmin.setCustomerId(customerId+""); + authAdmin.setId(generateUserId()); + authAdmin.setCustomerId(customerId + ""); authAdmin.setPassWord(userRegisterEntity.getPassword()); authAdmin.setCreateTime(DateUtil.parseDate(userRegisterEntity.getCheckTime())); authAdmin.setUserName(userRegisterEntity.getUserName()); //用手机号当用户名,通过手机号登录 authAdmin.setEmployeeName(userRegisterEntity.getNickName()); authAdmin.setCustomerId(userRegisterEntity.getCompanyId()); - //默认给部门、仓库 + //默认给部门、仓库 默认给随机用户ID,避免数据同步时出错覆盖 authAdmin.setLocDeptCode("1000"); authAdmin.setLocInvCode("1000000"); authAdmin.setUserFlag(1); authAdmin.setLastModifyTime(new Date()); - authAdminService.insertAuthAdmin(authAdmin); + authAdminDao.insert(authAdmin); +// authAdminService.insertAuthAdmin(authAdmin); authAdmin = authAdminService.findByUserName(authAdmin.getUserName()); //分配角色 @@ -431,13 +437,13 @@ public class RegisterController { customerContactEntity.setMobile(userRegisterEntity.getMobile()); customerContactEntity.setTel(userRegisterEntity.getTel()); CustomerContactEntity customerContactEntity1 = customerContactService.selectById(customerId); - if(customerContactEntity1==null){ + if (customerContactEntity1 == null) { customerContactService.insertCustomerContact(customerContactEntity); } //生产本企业信息 CompanyEntity companyEntity = new CompanyEntity(); - companyEntity.setCustomerId(customerId+""); + companyEntity.setCustomerId(customerId + ""); companyEntity.setArea(userRegisterEntity.getArea()); companyEntity.setAreaCode(userRegisterEntity.getAreaCode()); companyEntity.setDetailAddr(userRegisterEntity.getDetailAddr()); @@ -465,21 +471,18 @@ public class RegisterController { CustomerInfoFilterRequest request = new CustomerInfoFilterRequest(); request.setCompanyName(registerCheckRequest.getCompanyName()); List customerInfoEntities = customerInfoService.filterCustomerInfo(request); - int i=0; + int i = 0; for (CustomerInfoEntity infoEntity : customerInfoEntities) { - if(registerCheckRequest.getCompanyName().equals(infoEntity.getCompanyName())){ + if (registerCheckRequest.getCompanyName().equals(infoEntity.getCompanyName())) { i++; } } - if(i<=0){ + if (i <= 0) { customerInfoService.insertCustomerInfo(customerInfoEntity); companyService.insertCompany(companyEntity);//TODO !!!!!!!!!!! } - - - if (!b) { return ResultVOUtils.error(ResultEnum.NOT_NETWORK); } From a0daf79e3dacda9af37d408d5cca9d11260b65d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Fri, 21 Apr 2023 16:42:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B5=84=E8=B4=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase/SupCertController.java | 172 +++++++++++------- 1 file changed, 103 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java index 80730ada..4d484458 100644 --- a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java +++ b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java @@ -84,6 +84,63 @@ public class SupCertController { } + + + private BaseResponse insertCompanyCert(String customerId, PostSelCertRequest request) { + if (CollUtil.isEmpty(request.getSupCertSetEntities())) { + return ResultVOUtils.error(500, "请选入资质证书!"); + } + if (request.getCertType() == null) { + return ResultVOUtils.error(500, "参数错误!"); + } + + int certType = request.getCertType(); + String productIdFk = request.getProductIdFk(); + String manufacturerIdFk = request.getManufacturerIdFk(); + + String errMsg = ""; + ArrayList list = new ArrayList<>(); + int i = request.getSupCertSetEntities().size(); + for (SupCertSetEntity supCertSetEntity : request.getSupCertSetEntities()) { + i--; + FilterSupCertRequest supCertRequest = new FilterSupCertRequest(); + supCertRequest.setName(supCertSetEntity.getName()); + supCertRequest.setCustomerId(customerId); + supCertRequest.setManufacturerIdFk(manufacturerIdFk); + if (productIdFk != null) { + supCertRequest.setProductIdFk(productIdFk); + supCertRequest.setType(3); + } else { + supCertRequest.setType(2); + } + + List supCertEntities = supCertService.selectCompanyCert(supCertRequest); + if (!supCertEntities.isEmpty()) { + list.add(supCertEntities.get(0).getName()); + if (i == 0) { + errMsg = list.stream().map(s -> "," + s).collect(Collectors.joining()); + return ResultVOUtils.error(999, errMsg.substring(1) + "已存在!"); + } + } + } + + for (SupCertSetEntity supCertSetEntity : request.getSupCertSetEntities()) { + SupCertEntity supCertEntity = new SupCertEntity(); + supCertEntity.setName(supCertSetEntity.getName()); + supCertEntity.setManufacturerIdFk(manufacturerIdFk); + supCertEntity.setProductIdFk(productIdFk); + supCertEntity.setCustomerId(customerId); + supCertEntity.setType(certType); + supCertEntity.setCreateTime(new Date()); + supCertEntity.setStatus(0); + supCertEntity.setAuditStatus(ConstantStatus.AUDIT_DRAFT); + supCertEntity.setUpdateTime(new Date()); + boolean b = supCertService.insertCompanyCert(supCertEntity); + } + return ResultVOUtils.success("成功"); + } + + @AuthRuleAnnotation("") @PostMapping("/sup/info/selectAllCert") @Log(title = "资质证书", businessType = BusinessType.INSERT) @@ -100,76 +157,11 @@ public class SupCertController { if (postSelCertRequest.getCertType() == null) { return ResultVOUtils.error(500, "参数错误!"); } - if (postSelCertRequest.getManufacturerIdFk() == null) { - String errMsg = ""; - ArrayList list = new ArrayList<>(); - int i = postSelCertRequest.getSupCertSetEntities().size(); - for (SupCertSetEntity supCertSetEntity : postSelCertRequest.getSupCertSetEntities()) { - i--; - FilterSupCertRequest supCertRequest = new FilterSupCertRequest(); - supCertRequest.setName(supCertSetEntity.getName()); - supCertRequest.setCustomerId(customerId); - List supCertEntities = supCertService.selectCompanyCert(supCertRequest); - if (supCertEntities.size() != 0) { - list.add(supCertEntities.get(0).getName()); - if (supCertEntities.size() != 0 && i == 0) { - for (String s : list) { - errMsg = errMsg + "," + s; - } - return ResultVOUtils.error(999, errMsg.substring(1) + "已存在!"); - } - } - } - }else{ - if(postSelCertRequest.getProductIdFk()==null) { - String errMsg = ""; - ArrayList list = new ArrayList<>(); - int i = postSelCertRequest.getSupCertSetEntities().size(); - for (SupCertSetEntity supCertSetEntity : postSelCertRequest.getSupCertSetEntities()) { - i--; - FilterSupCertRequest supCertRequest = new FilterSupCertRequest(); - supCertRequest.setName(supCertSetEntity.getName()); - supCertRequest.setCustomerId(customerId); - supCertRequest.setManufacturerIdFk(postSelCertRequest.getManufacturerIdFk()); - supCertRequest.setType(2); - List supCertEntities = supCertService.selectCompanyCert(supCertRequest); - if (supCertEntities.size() != 0) { - list.add(supCertEntities.get(0).getName()); - if (supCertEntities.size() != 0 && i == 0) { - for (String s : list) { - errMsg = errMsg + "," + s; - } - return ResultVOUtils.error(999, errMsg.substring(1) + "已存在!"); - } - } - } - }else{ - String errMsg = ""; - ArrayList list = new ArrayList<>(); - int i = postSelCertRequest.getSupCertSetEntities().size(); - for (SupCertSetEntity supCertSetEntity : postSelCertRequest.getSupCertSetEntities()) { - i--; - FilterSupCertRequest supCertRequest = new FilterSupCertRequest(); - supCertRequest.setName(supCertSetEntity.getName()); - supCertRequest.setCustomerId(customerId); - supCertRequest.setManufacturerIdFk(postSelCertRequest.getManufacturerIdFk()); - supCertRequest.setProductIdFk(postSelCertRequest.getProductIdFk()); - supCertRequest.setType(3); - List supCertEntities = supCertService.selectCompanyCert(supCertRequest); - if (supCertEntities.size() != 0) { - list.add(supCertEntities.get(0).getName()); - if (supCertEntities.size() != 0 && i == 0) { - for (String s : list) { - errMsg = errMsg + "," + s; - } - return ResultVOUtils.error(999, errMsg.substring(1) + "已存在!"); - } - } - } - } - } - + String errMsg=checkCert(postSelCertRequest,customerId); + if(StrUtil.isNotEmpty(errMsg)){ + return ResultVOUtils.error(999, errMsg.substring(1) + "已存在!"); + } for (SupCertSetEntity supCertSetEntity : postSelCertRequest.getSupCertSetEntities()) { SupCertEntity supCertEntity = new SupCertEntity(); supCertEntity.setName(supCertSetEntity.getName()); @@ -187,6 +179,48 @@ public class SupCertController { } + + public String checkCert(PostSelCertRequest postSelCertRequest,String customerId){ + + String errMsg = ""; + ArrayList list = new ArrayList<>(); + int i = postSelCertRequest.getSupCertSetEntities().size(); + for (SupCertSetEntity supCertSetEntity : postSelCertRequest.getSupCertSetEntities()) { + i--; + FilterSupCertRequest supCertRequest = new FilterSupCertRequest(); + supCertRequest.setName(supCertSetEntity.getName()); + supCertRequest.setCustomerId(customerId); + if(StrUtil.isEmpty(postSelCertRequest.getProductIdFk()) && StrUtil.isNotEmpty(postSelCertRequest.getManufacturerIdFk())) { + supCertRequest.setManufacturerIdFk(postSelCertRequest.getManufacturerIdFk()); + supCertRequest.setType(2); + } + if(StrUtil.isNotEmpty(postSelCertRequest.getProductIdFk()) && StrUtil.isNotEmpty(postSelCertRequest.getManufacturerIdFk())) { + supCertRequest.setManufacturerIdFk(postSelCertRequest.getManufacturerIdFk()); + supCertRequest.setProductIdFk(postSelCertRequest.getProductIdFk()); + supCertRequest.setType(3); + } + List supCertEntities = supCertService.selectCompanyCert(supCertRequest); + if (supCertEntities.size() != 0) { + list.add(supCertEntities.get(0).getName()); + if (supCertEntities.size() != 0 && i == 0) { + for (String s : list) { + errMsg = errMsg + "," + s; + } + return errMsg; + } + }else{ + if(i == 0 && list.size()>0){ + for (String s : list) { + errMsg = errMsg + "," + s; + } + return errMsg; + } + } + } + return errMsg; + } + + @AuthRuleAnnotation("") @GetMapping("/sale/info/getCompanyCert") public BaseResponse getCompanyCert(FilterSupCertRequest filterSupCertRequest) {