|
|
|
@ -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; |
|
|
|
@ -93,6 +94,43 @@ public class RequirementItemController extends JeecgController<RequirementItem, |
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 我的需求 |
|
|
|
|
* |
|
|
|
|
* @param requirementItem |
|
|
|
|
* @param pageNo |
|
|
|
|
* @param pageSize |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "需求管理-分页列表查询") |
|
|
|
|
@ApiOperation(value="需求管理-分页列表查询", notes="需求管理-分页列表查询") |
|
|
|
|
@GetMapping(value = "/wdxqlist") |
|
|
|
|
public Result<?> wdxqlist(RequirementItem requirementItem, |
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
QueryWrapper<RequirementItem> queryWrapper = QueryGenerator.initQueryWrapper(requirementItem, req.getParameterMap()); |
|
|
|
|
queryWrapper.eq("create_by",principal.getUsername()); |
|
|
|
|
Page<RequirementItem> page = new Page<RequirementItem>(pageNo, pageSize); |
|
|
|
|
IPage<RequirementItem> pageList = requirementItemService.page(page, queryWrapper); |
|
|
|
|
for (int i = 0 ; i < pageList.getRecords().size();i++){ |
|
|
|
|
Projectx projectx = projectxService.getById(pageList.getRecords().get(i).getProjectId()); |
|
|
|
|
if(!principal.getUsername().equals("admin")){ |
|
|
|
|
if(projectx.getCreateBy().equals(principal.getUsername())){ |
|
|
|
|
pageList.getRecords().get(i).setXqflag("1"); |
|
|
|
|
}else{ |
|
|
|
|
pageList.getRecords().get(i).setXqflag("0"); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
pageList.getRecords().get(i).setXqflag("1"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加 |
|
|
|
|
* |
|
|
|
@ -103,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("添加成功!"); |
|
|
|
|
} |
|
|
|
@ -208,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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|