From ad548744b62d79bf1ba6fc919a61f8a203c6f2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A3=95=E8=B4=A2?= Date: Sat, 5 Mar 2022 03:41:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8A=82=E7=82=B9=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E3=80=81=E6=A0=87=E7=AD=BE=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xm/core/ctrl/XmProductController.java | 33 ++++++++++++------- .../com/xm/core/service/XmProductService.java | 17 ++++++++-- .../com/xm/core/service/XmProjectService.java | 4 +++ .../mapper/xm/core/dao/XmProductMapper.xml | 2 +- .../mapper/xm/core/dao/XmProjectMapper.xml | 2 +- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java index ee7af5f9..afe74787 100644 --- a/xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java @@ -225,22 +225,31 @@ public class XmProductController { Map m = new HashMap<>(); Tips tips=new Tips("成功新增一条数据"); try{ - if(StringUtils.isEmpty(xmProduct.getId())) { - xmProduct.setId(xmProductService.createKey("id")); + User user=LoginUtils.getCurrentUserInfo(); + if(StringUtils.isEmpty(xmProduct.getCode())) { + return ResponseHelper.failed("code-0","","产品代号不能为空"); }else{ - XmProduct xmProductQuery = new XmProduct(xmProduct.getId()); + XmProduct xmProductQuery = new XmProduct(); + xmProductQuery.setBranchId(user.getBranchId()); + xmProductQuery.setCode(xmProduct.getCode()); if(xmProductService.countByWhere(xmProductQuery)>0){ - tips.setFailureMsg("编号重复,请修改编号再提交"); + tips.setFailureMsg("产品代号已存在,请修改再提交"); m.put("tips", tips); return m; } } - User user=LoginUtils.getCurrentUserInfo(); + if(!StringUtils.hasText(xmProduct.getProductName())){ + return ResponseHelper.failed("productName-0","","产品名称不能为空"); + } if(StringUtils.isEmpty(xmProduct.getPmUserid())) { xmProduct.setPmUserid(user.getUserid()); xmProduct.setPmUsername(user.getUsername()); } + xmProduct.setId(this.xmProductService.createProductId(xmProduct.getCode())); xmProduct.setCtime(new Date()); + xmProduct.setLtime(new Date()); + xmProduct.setDel("0"); + xmProduct.setLocked("0"); xmProductService.insert(xmProduct); xmRecordService.addXmProductRecord(xmProduct.getId(),"创建产品","创建产品【"+xmProduct.getId()+"】【"+xmProduct.getProductName()+"】"); @@ -294,8 +303,8 @@ public class XmProductController { XmProduct xmProductDel=new XmProduct(); xmProductDel.setId(xmProductDb.getId()); xmProductDel.setDel("1"); - xmProductDb.setLtime(new Date()); - xmProductService.updateSomeFieldByPk(xmProductDb); + xmProductDel.setLtime(new Date()); + xmProductService.updateSomeFieldByPk(xmProductDel); xmProductService.clearCache(xmProduct.getId()); xmRecordService.addXmProductRecord(xmProduct.getId(),"删除产品",user.getUsername()+"删除产品【"+xmProductDb.getId()+"】【"+xmProductDb.getProductName()+"】","",JSON.toJSONString(xmProductDb)); @@ -330,7 +339,8 @@ public class XmProductController { if(groupService.checkUserIsProductAdm(xmProductDb,user.getUserid())){ return ResponseHelper.failed("no-qx-0","您无权修改该产品"); } - xmProductService.updateByPk(xmProduct); + xmProduct.setLtime(new Date()); + xmProductService.updateSomeFieldByPk(xmProduct); xmProductService.clearCache(xmProduct.getId()); xmRecordService.addXmProductRecord(xmProduct.getId(),"修改产品","修改产品【"+xmProductDb.getId()+"】【"+xmProductDb.getProductName()+"】",JSON.toJSONString(xmProduct),JSON.toJSONString(xmProductDb)); @@ -349,7 +359,7 @@ public class XmProductController { - /***/ + /** @ApiOperation( value = "根据主键列表批量删除产品表信息",notes="batchDelXmProduct,仅需要上传主键字段") @ApiResponses({ @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") @@ -396,7 +406,7 @@ public class XmProductController { } } if(canDelList.size()>0) { - xmProductService.doBatchDelete(canDelList); + //xmProductService.doBatchDelete(canDelList);//不允许批量删除 for (XmProduct xmProduct : canDelList) { xmProductService.clearCache(xmProduct.getId()); xmRecordService.addXmProductRecord(xmProduct.getId(),"批量删除产品","批量删除产品【"+xmProduct.getId()+"】【"+xmProduct.getProductName()+"】","",JSON.toJSONString(xmProduct)); @@ -427,6 +437,7 @@ public class XmProductController { } m.put("tips", tips); return m; - } + } + */ } diff --git a/xm-core/src/main/java/com/xm/core/service/XmProductService.java b/xm-core/src/main/java/com/xm/core/service/XmProductService.java index 2ecf6cf4..5280bc29 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmProductService.java +++ b/xm-core/src/main/java/com/xm/core/service/XmProductService.java @@ -89,7 +89,6 @@ public class XmProductService extends BaseService { @Transactional public XmProduct copyTo(User user, XmProductCopyVo xmProduct) { XmProduct pq=new XmProduct(); - pq.setId(xmProduct.getId()); XmProduct xmProductDb=this.selectOneObject(pq); if(xmProductDb==null){ throw new BizException("产品不存在"); @@ -109,12 +108,12 @@ public class XmProductService extends BaseService { String isTpl=xmProduct.getIsTpl(); XmProduct xmProductTo=new XmProduct(); BeanUtils.copyProperties(xmProductDb,xmProductTo); - xmProductTo.setId(this.createKey("id")); xmProductTo.setProductName(xmProduct.getProductName()); xmProductTo.setCode(xmProduct.getCode()); if(!StringUtils.hasText(xmProduct.getCode())){ xmProductTo.setCode(createProductCode(user.getBranchId())); } + xmProductTo.setId(this.createProductId(xmProductTo.getCode())); xmProductTo.setBranchId(user.getBranchId()); xmProductTo.setDeptid(user.getDeptid()); xmProductTo.setDeptName(user.getDeptName()); @@ -129,6 +128,9 @@ public class XmProductService extends BaseService { xmProductTo.setAssUsername(user.getUsername()); xmProductTo.setBizProcInstId(null); xmProductTo.setBizFlowState("0"); + xmProductTo.setLtime(new Date()); + xmProductTo.setDel("0"); + xmProductTo.setLocked("0"); if(xmProduct.getProductName().equals(xmProductDb.getProductName())){ xmProductTo.setProductName(xmProduct.getProductName()+"(复制)"); } @@ -261,7 +263,18 @@ public class XmProductService extends BaseService { return code; } + public String createProductId(String code){ + String id=sequenceService.getCommonNo(code+"-{rands:4}"); + XmProduct xmProduct=new XmProduct(id); + long idcount=this.countByWhere(xmProduct); + while (idcount>0){ + id=sequenceService.getCommonNo(code+"-{rands:4}"); + xmProduct=new XmProduct(id); + idcount=this.countByWhere(xmProduct); + } + return id; + } @Transactional public void doDeleteByPk(XmProduct xmProduct) { XmMenu xmMenu=new XmMenu(); diff --git a/xm-core/src/main/java/com/xm/core/service/XmProjectService.java b/xm-core/src/main/java/com/xm/core/service/XmProjectService.java index f6ae177d..bd45a2e4 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmProjectService.java +++ b/xm-core/src/main/java/com/xm/core/service/XmProjectService.java @@ -264,6 +264,7 @@ public class XmProjectService extends BaseService { if(StringUtils.isEmpty(xmProject.getCode())){ xmProject.setCode(this.createKey("code")); } + xmProject.setLtime(new Date()); this.updateByPk(xmProject); xmRecordService.addXmProjectRecord(xmProject.getId(), "项目-修改项目基础信息", "更新项目"+xmProject.getName(),JSONObject.toJSONString(xmProject),JSONObject.toJSONString(oldValue)); @@ -309,6 +310,9 @@ public class XmProjectService extends BaseService { if(!StringUtils.hasText(xmProjectVo.getIsTpl())){ xmProjectVo.setIsTpl("0"); } + xmProjectVo.setLocked("0"); + xmProjectVo.setDel("0"); + xmProjectVo.setLtime(new Date()); XmProject projectDb=new XmProject(); BeanUtils.copyProperties(xmProjectVo,projectDb); this.insert(projectDb); diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml index b7a61b06..c8c45580 100644 --- a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProductMapper.xml @@ -25,7 +25,7 @@ and ctime between #{ctimeStart} and #{ctimeEnd} - and res.del!='1' + and res.del!="1" diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml index e455305b..478c56d5 100644 --- a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMapper.xml @@ -65,7 +65,7 @@ and (res.branch_id in( #{platformBranchId},#{myBranchId}) and res.is_tpl='1') - and res.del!='1' + and res.del!="1"