diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/controller/LawsPartPmmPartitionInfoController.java b/laws-modules/src/main/java/com/jero/modules/laws/part/controller/LawsPartPmmPartitionInfoController.java index 0d37d363..6cbbe6af 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/controller/LawsPartPmmPartitionInfoController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/controller/LawsPartPmmPartitionInfoController.java @@ -1,5 +1,6 @@ package com.jero.modules.laws.part.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.jero.common.api.vo.Result; import com.jero.common.aspect.annotation.AutoLog; @@ -10,6 +11,7 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -34,10 +36,13 @@ public class LawsPartPmmPartitionInfoController { */ @AutoLog(value = "业务支持-关键零部件名称-列表") @ApiOperation(value = "业务支持-关键零部件名称-列表", notes = "业务支持-关键零部件名称-列表") - @GetMapping(value = "/list") + @GetMapping(value = "/page") @ApiOperationSupport(order = 1) - public Result> list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, - HttpServletRequest req) { - return Result.OK(lawsPartPmmPartitionInfoService.list(lawsPartPmmPartitionInfo,req)); + public Result> page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + IPage page = lawsPartPmmPartitionInfoService.page(lawsPartPmmPartitionInfo,pageNo,pageSize,req); + return Result.OK(page); } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartPmmPartitionInfo.java b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartPmmPartitionInfo.java index 3baba60b..5108f6ac 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartPmmPartitionInfo.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartPmmPartitionInfo.java @@ -71,4 +71,13 @@ public class LawsPartPmmPartitionInfo implements Serializable { @Dict(dicCode = "法规件名称(关键零部件名称)") @ApiModelProperty(value = "法规件名称(关键零部件名称)") private String regPartNameCn; + + + /** + * 绑定状态 1已绑定 2未绑定 + */ + @ApiModelProperty(value = "绑定状态 1已绑定 2未绑定") + @TableField(exist = false) + @Dict(dicCode = "binding_state") + private String status; } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java index 614f0cdd..8ed6771d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java @@ -60,9 +60,7 @@ public class LawsPartRelevance implements Serializable { * 关键零部件名称 */ @ApiModelProperty(value = "关键零部件名称") - @Excel(name = "关键零部件名称", width = 15, dictTable = "laws_part_pmm_partition_info", dicCode = "fnd_gpc", dicText = "reg_part_name_cn") - @TableField(exist = false) - @Dict(dictTable = "laws_part_pmm_partition_info", dicCode = "fnd_gpc", dicText = "reg_part_name_cn") + @Excel(name = "关键零部件名称", width = 15) private String regPartNameCn; /** * 关键零部件名称(英文) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/LawsPartPmmPartitionInfoMapper.java b/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/LawsPartPmmPartitionInfoMapper.java index 5418220b..42e5349a 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/LawsPartPmmPartitionInfoMapper.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/LawsPartPmmPartitionInfoMapper.java @@ -1,10 +1,17 @@ package com.jero.modules.laws.part.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo; +import org.apache.ibatis.annotations.Param; public interface LawsPartPmmPartitionInfoMapper extends BaseMapper { + IPage pageList(Page page, + @Param(Constants.WRAPPER) QueryWrapper queryWrapper); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/xml/LawsPartPmmPartitionInfoMapper.xml b/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/xml/LawsPartPmmPartitionInfoMapper.xml index f45763eb..b359a75a 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/xml/LawsPartPmmPartitionInfoMapper.xml +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/mapper/xml/LawsPartPmmPartitionInfoMapper.xml @@ -4,4 +4,10 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/service/ILawsPartPmmPartitionInfoService.java b/laws-modules/src/main/java/com/jero/modules/laws/part/service/ILawsPartPmmPartitionInfoService.java index da52ef2a..46905b39 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/service/ILawsPartPmmPartitionInfoService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/service/ILawsPartPmmPartitionInfoService.java @@ -1,5 +1,6 @@ package com.jero.modules.laws.part.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo; @@ -9,5 +10,6 @@ import java.util.List; public interface ILawsPartPmmPartitionInfoService extends IService { - List list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, HttpServletRequest req); + IPage page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo,Integer pageNo, + Integer pageSize, HttpServletRequest req); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartPmmPartitionInfoServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartPmmPartitionInfoServiceImpl.java index 444d98a3..6b2a813d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartPmmPartitionInfoServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartPmmPartitionInfoServiceImpl.java @@ -1,6 +1,8 @@ package com.jero.modules.laws.part.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.system.query.QueryGenerator; import com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo; @@ -8,8 +10,10 @@ import com.jero.modules.laws.part.entity.LawsPartRelevance; import com.jero.modules.laws.part.mapper.LawsPartPmmPartitionInfoMapper; import com.jero.modules.laws.part.service.ILawsPartPmmPartitionInfoService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -17,12 +21,22 @@ import java.util.List; @Slf4j public class LawsPartPmmPartitionInfoServiceImpl extends ServiceImpl implements ILawsPartPmmPartitionInfoService { + @Resource + private LawsPartPmmPartitionInfoMapper lawsPartPmmPartitionInfoMapper; @Override - public List list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, HttpServletRequest req) { - QueryWrapper queryWrapper = - QueryGenerator.initQueryWrapper(lawsPartPmmPartitionInfo, req.getParameterMap()); - return list(queryWrapper); + public IPage page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, Integer pageNo, + Integer pageSize, HttpServletRequest req) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if(!StringUtils.isBlank(lawsPartPmmPartitionInfo.getStatus())){ + queryWrapper.eq("IF(l2.id is null,'2','1')",lawsPartPmmPartitionInfo.getStatus()); + } + if(!StringUtils.isBlank(lawsPartPmmPartitionInfo.getRegPartNameCn())){ + queryWrapper.eq("reg_part_name_cn",lawsPartPmmPartitionInfo.getRegPartNameCn()); + } + Page page = new Page<>(pageNo, pageSize); + IPage re = lawsPartPmmPartitionInfoMapper.pageList(page, queryWrapper); + return re; } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java index 0d244746..5f34281d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java @@ -58,32 +58,8 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl queryWrapper = QueryGenerator.initQueryWrapper(lawsPartRelevance, req.getParameterMap()); - if(!StringUtils.isBlank(lawsPartRelevance.getRegPartNameCn())){ - LambdaQueryWrapper queryLawsPartPmmPartitionInfo = new LambdaQueryWrapper<>(); - queryLawsPartPmmPartitionInfo.like(LawsPartPmmPartitionInfo::getRegPartNameCn,lawsPartRelevance.getRegPartNameCn()); - List list = lawsPartPmmPartitionInfoService.list(queryLawsPartPmmPartitionInfo); - if(!CollectionUtils.isEmpty(list)){ - List listFndGpc = list.stream().map(LawsPartPmmPartitionInfo::getFndGpc).collect(Collectors.toList()); - queryWrapper.and(o->{ - for (int i = 0; i < listFndGpc.size(); i++) { - o.like("fnd_gpc",listFndGpc.get(i)); - if(listFndGpc.size() - 1 != i){ - o.or(); - } - } - }); - }else{ - queryWrapper.eq("id",""); - } - } Page page = new Page<>(pageNo, pageSize); IPage re = page(page, queryWrapper); - List list = re.getRecords(); - if(!CollectionUtils.isEmpty(list)){ - list.parallelStream().forEach(p->{ - p.setRegPartNameCn(p.getFndGpc()); - }); - } return re; } @@ -122,63 +98,47 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl formType = Arrays.asList(lawsPartRelevance.getFormType().split(",")); - if(formType.contains("1")){ - if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){ - throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? - "功能系统码 cannot be empty" : "功能系统码不能为空")); - } - if(StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())){ - throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? - "技术特性判定要求 cannot be empty" : "技术特性判定要求不能为空")); - } - } + checkData(lawsPartRelevance); + // 需要做名称+功能系统码唯一性校验 - List list = Arrays.asList(lawsPartRelevance.getFndGpc().split(",")); - list.sort(null); - String fndGpc = String.join(",", list); - String systemCode = lawsPartRelevance.getSystemCode(); - lawsPartRelevance.setFndGpc(fndGpc); LambdaQueryWrapper queryLawsPartRelevance = new LambdaQueryWrapper<>(); - queryLawsPartRelevance.eq(LawsPartRelevance::getFndGpc,fndGpc); - queryLawsPartRelevance.eq(LawsPartRelevance::getSystemCode,systemCode); + queryLawsPartRelevance.eq(LawsPartRelevance::getRegPartNameCn,lawsPartRelevance.getRegPartNameCn()); + queryLawsPartRelevance.eq(LawsPartRelevance::getSystemCode,lawsPartRelevance.getSystemCode()); long l = count(queryLawsPartRelevance); if(l > 0){ throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? - "名称与功能系统码 already exists" : "名称与功能系统码已存在")); + "关键零部件名称与功能系统码 already exists" : "关键零部件名称与功能系统码已存在")); } save(lawsPartRelevance); } - @Override - public void edit(LawsPartRelevance lawsPartRelevance) { + private void checkData(LawsPartRelevance lawsPartRelevance) { // todo 是奇瑞型号的型号型式必填功能系统码和技术特性判定要求,不是奇瑞型号的不用填写 List formType = Arrays.asList(lawsPartRelevance.getFormType().split(",")); - if(formType.contains("1")){ - if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){ - throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? + if (formType.contains("1")) { + if (StringUtils.isBlank(lawsPartRelevance.getSystemCode())) { + throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(), Locale.ENGLISH) ? "功能系统码 cannot be empty" : "功能系统码不能为空")); } - if(StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())){ - throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? + if (StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())) { + throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(), Locale.ENGLISH) ? "技术特性判定要求 cannot be empty" : "技术特性判定要求不能为空")); } } + } + + @Override + public void edit(LawsPartRelevance lawsPartRelevance) { + checkData(lawsPartRelevance); // 需要做名称+功能系统码唯一性校验 - List list = Arrays.asList(lawsPartRelevance.getFndGpc().split(",")); - list.sort(null); - String fndGpc = String.join(",", list); - String systemCode = lawsPartRelevance.getSystemCode(); - lawsPartRelevance.setFndGpc(fndGpc); LambdaQueryWrapper queryLawsPartRelevance = new LambdaQueryWrapper<>(); - queryLawsPartRelevance.eq(LawsPartRelevance::getFndGpc,fndGpc); - queryLawsPartRelevance.eq(LawsPartRelevance::getSystemCode,systemCode); + queryLawsPartRelevance.eq(LawsPartRelevance::getRegPartNameCn,lawsPartRelevance.getRegPartNameCn()); + queryLawsPartRelevance.eq(LawsPartRelevance::getSystemCode,lawsPartRelevance.getSystemCode()); queryLawsPartRelevance.ne(LawsPartRelevance::getId,lawsPartRelevance.getId()); long l = count(queryLawsPartRelevance); if(l > 0){ throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? - "名称与功能系统码 already exists" : "名称与功能系统码已存在")); + "关键零部件名称与功能系统码 already exists" : "关键零部件名称与功能系统码已存在")); } updateById(lawsPartRelevance); } @@ -204,26 +164,17 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl list = Arrays.asList(lawsPartRelevance.getRegPartNameCn().split(",")); - list.sort(null); - String fndGpc = String.join(",", list); - lawsPartRelevance.setRegPartNameCn(fndGpc); - lawsPartRelevance.setFndGpc(fndGpc); - } - List listCode = listLawsPartRelevance.stream().map(o->o.getFndGpc() + "_" +o.getSystemCode()).collect(Collectors.toList()); - QueryWrapper queryLawsPartRelevance = new QueryWrapper<>(); - queryLawsPartRelevance.select("CONCAT(fnd_gpc,'_',system_code) as fnd_gpc"); - queryLawsPartRelevance.in("CONCAT(fnd_gpc,'_',system_code)",listCode); + List listRegPartNameCn = listLawsPartRelevance.stream().map(LawsPartRelevance::getRegPartNameCn).collect(Collectors.toList()); + LambdaQueryWrapper queryLawsPartRelevance = new LambdaQueryWrapper<>(); + queryLawsPartRelevance.in(LawsPartRelevance::getRegPartNameCn,listRegPartNameCn); List listOld = list(queryLawsPartRelevance); - List listNotNull = listLawsPartRelevance.stream().filter(o->!StringUtils.isBlank(o.getFndGpc())).collect(Collectors.toList()); + List listNotNull = listLawsPartRelevance.stream().filter(o->!StringUtils.isBlank(o.getRegPartNameCn())).collect(Collectors.toList()); List lawsPartPmmPartitionInfoList = new ArrayList<>(); if(!CollectionUtils.isEmpty(listNotNull)){ - List listFndGpc = listLawsPartRelevance.stream().map(LawsPartRelevance::getFndGpc).collect(Collectors.toList()); - String fndGpc = String.join(",", listFndGpc); - listFndGpc = Arrays.asList(fndGpc.split(",")); LambdaQueryWrapper queryLawsPartPmmPartitionInfo = new LambdaQueryWrapper<>(); - queryLawsPartPmmPartitionInfo.in(LawsPartPmmPartitionInfo::getFndGpc,listFndGpc); + queryLawsPartPmmPartitionInfo.select(LawsPartPmmPartitionInfo::getRegPartNameCn); + queryLawsPartPmmPartitionInfo.in(LawsPartPmmPartitionInfo::getRegPartNameCn,listRegPartNameCn); + queryLawsPartPmmPartitionInfo.groupBy(LawsPartPmmPartitionInfo::getRegPartNameCn); lawsPartPmmPartitionInfoList = lawsPartPmmPartitionInfoService .list(queryLawsPartPmmPartitionInfo); } @@ -264,10 +215,9 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl listFndGpc = Arrays.asList(lawsPartRelevance.getFndGpc().split(",")); - long l = lawsPartPmmPartitionInfoList - .stream().filter(o->listFndGpc.contains(o.getFndGpc())).count(); - if(l != listFndGpc.size()){ + long l = lawsPartPmmPartitionInfoList.stream().filter(o-> + Objects.equals(lawsPartRelevance.getRegPartNameCn(),o.getRegPartNameCn())).count(); + if(l == 0){ s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? "关键零部件名称 does not exist," : "关键零部件名称不存在,"); } @@ -285,9 +235,11 @@ public class LawsPartRelevanceServiceImpl extends ServiceImplObjects.equals(o.getFndGpc(), code)).count(); + long l = listOld.stream().filter(o-> + Objects.equals(o.getRegPartNameCn() + "_" + lawsPartRelevance.getSystemCode(), code)) + .count(); if(l > 0){ s.append((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ? "关键零部件名称与功能系统码 already exists," : "关键零部件名称与功能系统码已存在,"));