From cea713eec3892015431bda3ddac2d47efafb2165 Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 4 Jul 2023 15:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../requirementitem/RequirementItemList.vue | 15 ++- .../modules/RequirementItemForm.vue | 79 +++++++++---- .../controller/RequirementItemController.java | 109 +++++++++++++++++- 3 files changed, 175 insertions(+), 28 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/requirementitem/RequirementItemList.vue b/ant-design-vue-jeecg/src/views/requirementitem/RequirementItemList.vue index 9a22be7..83eb3de 100644 --- a/ant-design-vue-jeecg/src/views/requirementitem/RequirementItemList.vue +++ b/ant-design-vue-jeecg/src/views/requirementitem/RequirementItemList.vue @@ -99,12 +99,12 @@ - 编辑 + 编辑 详情 - + 删除 @@ -244,6 +244,17 @@ }, }, methods: { + checkqx(record){ + getAction(this.url.checkqx,{createBy:record.createBy}).then((res)=>{ + if (res.success) { + this.$refs.modalForm.edit(record); + this.$refs.modalForm.title = "编辑"; + this.$refs.modalForm.disableSubmit = false; + }else{ + this.$message.warning(res.message); + } + }); + }, wdxq(){ this.searchQuerywdxq(); }, diff --git a/ant-design-vue-jeecg/src/views/requirementitem/modules/RequirementItemForm.vue b/ant-design-vue-jeecg/src/views/requirementitem/modules/RequirementItemForm.vue index ce0ef74..3e06c82 100644 --- a/ant-design-vue-jeecg/src/views/requirementitem/modules/RequirementItemForm.vue +++ b/ant-design-vue-jeecg/src/views/requirementitem/modules/RequirementItemForm.vue @@ -5,7 +5,7 @@ - + @@ -15,12 +15,12 @@ - + - + @@ -103,7 +103,7 @@ ],*/ requirementCode: [ { required: true, message: '请输入需求编码!'}, - { validator: (rule, value, callback) => validateDuplicateValue('requirement_item', 'requirement_code', value, this.model.id, callback)}, +/* { validator: (rule, value, callback) => validateDuplicateValue('requirement_item', 'requirement_code', value, this.model.id, callback)},*/ ], requirementName: [ { required: true, message: '请输入中文名称!'}, @@ -112,7 +112,9 @@ url: { add: "/requirementitem/requirementItem/add", edit: "/requirementitem/requirementItem/edit", - queryById: "/requirementitem/requirementItem/queryById" + queryById: "/requirementitem/requirementItem/queryById", + checkname:"/requirementitem/requirementItem/checkname", + requirementcode:"/requirementitem/requirementItem/requirementcode", } } }, @@ -125,6 +127,23 @@ //备份model原始值 }, methods: { + getxqbm(){ + if(this.model.upperId===undefined||this.model.upperId===null){ + this.model.upperId = ""; + } + if(this.model.projectId===undefined||this.model.projectId===null){ + this.model.projectId = ""; + } + if(this.model.projectId!==""){ + getAction(this.url.requirementcode,{projectId:this.model.projectId,upperId:this.model.upperId}).then((res)=>{ + if (res.success) { + this.$set(this.model, 'requirementCode', res.result); + }else{ + this.$message.warning(res.message); + } + }); + } + }, add (num,record) { this.num = num; this.model = Object.assign({}, record); @@ -133,8 +152,10 @@ if(record===''){ this.disablecol = false; }else{ + this.getxqbm(); this.disablecol = true; } + this.model.id = ""; this.modelDefault = JSON.parse(JSON.stringify(this.model)); this.edit(this.modelDefault); }, @@ -155,30 +176,42 @@ this.visible = true; }, submitForm () { + if(this.model.id === undefined){ + this.model.id = ""; + } + if(this.model.upperId === undefined){ + this.model.upperId = ""; + } const that = this; // 触发表单验证 this.$refs.form.validate(valid => { if (valid) { - that.confirmLoading = true; - let httpurl = ''; - let method = ''; - if(!this.model.id){ - httpurl+=this.url.add; - method = 'post'; - }else{ - httpurl+=this.url.edit; - method = 'put'; - } - httpAction(httpurl,this.model,method).then((res)=>{ - if(res.success){ - that.$message.success(res.message); - that.$emit('ok'); + getAction(this.url.checkname,{projectid:this.model.projectId,requirementName:this.model.requirementName,id:this.model.id,upperId:this.model.upperId}).then((res)=>{ + if (res.success) { + that.confirmLoading = true; + let httpurl = ''; + let method = ''; + if(!this.model.id){ + httpurl+=this.url.add; + method = 'post'; + }else{ + httpurl+=this.url.edit; + method = 'put'; + } + httpAction(httpurl,this.model,method).then((res)=>{ + if(res.success){ + that.$message.success(res.message); + that.$emit('ok'); + }else{ + that.$message.warning(res.message); + } + }).finally(() => { + that.confirmLoading = false; + }) }else{ - that.$message.warning(res.message); + this.$message.warning(res.message); } - }).finally(() => { - that.confirmLoading = false; - }) + }); } }) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementitem/controller/RequirementItemController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementitem/controller/RequirementItemController.java index 4d5c3d9..e4e53cc 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementitem/controller/RequirementItemController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementitem/controller/RequirementItemController.java @@ -1,8 +1,7 @@ package org.jeecg.modules.demo.requirementitem.controller; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -32,6 +31,8 @@ import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -140,6 +141,10 @@ public class RequirementItemController extends JeecgController add(@RequestBody RequirementItem requirementItem) { + if(requirementItem.getUpperId()!=""){ + RequirementItem requirementItem1 = requirementItemService.getById(requirementItem.getUpperId()); + requirementItem.setRequirementHira((Integer.valueOf(requirementItem1.getRequirementHira())+1)+""); + } requirementItemService.save(requirementItem); return Result.OK("添加成功!"); } @@ -245,4 +250,102 @@ public class RequirementItemController extends JeecgController checkname(@RequestParam(name="projectid",required=true) String projectid,@RequestParam(name="requirementName",required=true) String requirementName, + @RequestParam(name="id",required=true) String id,@RequestParam(name="upperId",required=true) String upperId,HttpServletRequest req) { + if(id==""){ + RequirementItem requirementItem = new RequirementItem(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap()); + queryWrapper.eq("project_id",projectid); + queryWrapper.eq("requirement_name",requirementName); + queryWrapper.eq("upper_id",upperId); + List list = requirementItemService.list(queryWrapper); + if(list.size()>0) { + return Result.error("需求名称重复"); + } + }else { + RequirementItem requirementItemcheck = requirementItemService.getById(id); + if(!requirementItemcheck.getRequirementName().equals(requirementName)){ + RequirementItem requirementItem = new RequirementItem(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap()); + queryWrapper.eq("project_id",projectid); + queryWrapper.eq("requirement_name",requirementName); + queryWrapper.eq("upper_id",upperId); + List list = requirementItemService.list(queryWrapper); + if(list.size()>0) { + return Result.error("需求名称重复"); + } + } + + } + + return Result.OK(""); + } + + /** + * 需求编码 + * + * @param projectId,upperId + * @return + */ + @AutoLog(value = "需求编码") + @ApiOperation(value="需求编码", notes="需求编码") + @GetMapping(value = "/requirementcode") + public Result requirementcode(@RequestParam(name="projectId",required=true) String projectId,@RequestParam(name="upperId",required=true) String upperId,HttpServletRequest req) { + String requirementcode = ""; + Projectx projectx = projectxService.getById(projectId); + if(upperId!=""){ + RequirementItem requirementItem=requirementItemService.getById(upperId); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap()); + queryWrapper.eq("requirement_hira",(Integer.valueOf(requirementItem.getRequirementHira())+1)+""); + List list = requirementItemService.list(queryWrapper); + List collect = list.stream().map(RequirementItem::getRequirementCode).collect(Collectors.toList()); + String OrdersNum = String.format("%04d", getListMax(collect, 4)); + requirementcode = projectx.getProjectCode()+requirementItem.getRequirementCode()+OrdersNum; + }else{ + RequirementItem requirementItem = new RequirementItem(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap()); + queryWrapper.eq("requirement_hira",0); + List list = requirementItemService.list(queryWrapper); + List collect = list.stream().map(RequirementItem::getRequirementCode).collect(Collectors.toList()); + String OrdersNum = String.format("%04d", getListMax(collect, 4)); + requirementcode = projectx.getProjectCode()+OrdersNum; + } + return Result.OK(requirementcode); + } + + public Long getListMax(List stringList, int digits) { + if (ObjectUtils.isEmpty(stringList)){ + return 1L; + } + List longList = new ArrayList<>(); + String REGEX = "[^0-9]"; + for (String nums : stringList) { + //只要数字.trim()去空格 + String newNums = Pattern.compile(REGEX).matcher(nums).replaceAll("").trim(); + if (StringUtils.isEmpty(newNums)) continue; + if (newNums.length() <= digits) longList.add(Long.valueOf(newNums)); + else { + //拿到后6位 substring(4) 截掉前4位 + String substring = newNums.substring(newNums.length() - digits); + longList.add(Long.valueOf(substring)); + } + } + long max = Collections.max(longList) + 1; + if (Long.toString(max).length() > digits) { + String toString = Long.toString(max); + String substring = toString.substring(toString.length() - digits); + return Long.valueOf(substring); + } + return max; + } + }