需求管理

master
Gitea 1 year ago
parent 631e7237e7
commit cea713eec3
  1. 15
      ant-design-vue-jeecg/src/views/requirementitem/RequirementItemList.vue
  2. 79
      ant-design-vue-jeecg/src/views/requirementitem/modules/RequirementItemForm.vue
  3. 109
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementitem/controller/RequirementItemController.java

@ -99,12 +99,12 @@
</template>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a @click="checkqx(record)">编辑</a>
<a-divider type="vertical" />
<a @click="handleDetail(record)">详情</a>
<a-divider type="vertical" />
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteQx(record)">
<a>删除</a>
</a-popconfirm>
<a-divider type="vertical" />
@ -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();
},

@ -5,7 +5,7 @@
<a-row>
<a-col :span="24">
<a-form-model-item label="项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectId">
<j-dict-select-tag type="list" v-model="model.projectId" dictCode="projectx,project_name,id" placeholder="请选择项目" :disabled="disablecol"/>
<j-dict-select-tag type="list" v-model="model.projectId" dictCode="projectx,project_name,id" placeholder="请选择项目" :disabled="disablecol" @change="getxqbm"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
@ -15,12 +15,12 @@
</a-col>
<a-col :span="24" v-if="num===0">
<a-form-model-item label="上级需求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperId">
<j-dict-select-tag type="list" v-model="model.upperId" dictCode="requirement_item,requirement_name,id" placeholder="请选择上级需求" :disabled="disablecol"/>
<j-dict-select-tag type="list" v-model="model.upperId" dictCode="requirement_item,requirement_name,id" placeholder="请选择上级需求" :disabled="disablecol" @change="getxqbm"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="需求编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="requirementCode">
<a-input v-model="model.requirementCode" placeholder="请输入需求编码" ></a-input>
<a-input v-model="model.requirementCode" placeholder="请输入需求编码" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
@ -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;
})
});
}
})

@ -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<RequirementItem,
@ApiOperation(value="需求管理-添加", notes="需求管理-添加")
@PostMapping(value = "/add")
public Result<?> 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<RequirementItem,
return super.importExcel(request, response, RequirementItem.class);
}
/**
* 需求名称重复校验
*
* @param projectid,typename
* @return
*/
@AutoLog(value = "需求名称重复校验")
@ApiOperation(value="需求名称重复校验", notes="需求名称重复校验")
@GetMapping(value = "/checkname")
public Result<?> 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<RequirementItem> queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap());
queryWrapper.eq("project_id",projectid);
queryWrapper.eq("requirement_name",requirementName);
queryWrapper.eq("upper_id",upperId);
List<RequirementItem> 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<RequirementItem> queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap());
queryWrapper.eq("project_id",projectid);
queryWrapper.eq("requirement_name",requirementName);
queryWrapper.eq("upper_id",upperId);
List<RequirementItem> 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<RequirementItem> queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap());
queryWrapper.eq("requirement_hira",(Integer.valueOf(requirementItem.getRequirementHira())+1)+"");
List<RequirementItem> list = requirementItemService.list(queryWrapper);
List<String> 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<RequirementItem> queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap());
queryWrapper.eq("requirement_hira",0);
List<RequirementItem> list = requirementItemService.list(queryWrapper);
List<String> 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<String> stringList, int digits) {
if (ObjectUtils.isEmpty(stringList)){
return 1L;
}
List<Long> 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;
}
}

Loading…
Cancel
Save