关键零部件数据修改

This commit is contained in:
梁琦涛
2024-09-26 16:06:20 +08:00
parent bcf4e8f935
commit 452bbf6778
8 changed files with 86 additions and 93 deletions
@@ -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>> list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo,
public Result<IPage<LawsPartPmmPartitionInfo>> page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
return Result.OK(lawsPartPmmPartitionInfoService.list(lawsPartPmmPartitionInfo,req));
IPage<LawsPartPmmPartitionInfo> page = lawsPartPmmPartitionInfoService.page(lawsPartPmmPartitionInfo,pageNo,pageSize,req);
return Result.OK(page);
}
}
@@ -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;
}
@@ -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;
/**
* 关键零部件名称(英文)
@@ -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<LawsPartPmmPartitionInfo> {
IPage<LawsPartPmmPartitionInfo> pageList(Page<LawsPartPmmPartitionInfo> page,
@Param(Constants.WRAPPER) QueryWrapper<LawsPartPmmPartitionInfo> queryWrapper);
}
@@ -4,4 +4,10 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.laws.part.mapper.LawsPartPmmPartitionInfoMapper">
<select id="pageList" resultType="com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo">
select l1.reg_part_name_cn,IF(l2.id is null,'2','1') as status from laws_part_pmm_partition_info l1
left join laws_part_relevance l2 on l1.reg_part_name_cn = l2.reg_part_name_cn and l2.del_flag = 0
${ew.customSqlSegment}
group by l1.reg_part_name_cn
</select>
</mapper>
@@ -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<LawsPartPmmPartitionInfo> {
List<LawsPartPmmPartitionInfo> list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, HttpServletRequest req);
IPage<LawsPartPmmPartitionInfo> page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo,Integer pageNo,
Integer pageSize, HttpServletRequest req);
}
@@ -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<LawsPartPmmPartitionInfoMapper,
LawsPartPmmPartitionInfo> implements ILawsPartPmmPartitionInfoService {
@Resource
private LawsPartPmmPartitionInfoMapper lawsPartPmmPartitionInfoMapper;
@Override
public List<LawsPartPmmPartitionInfo> list(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, HttpServletRequest req) {
QueryWrapper<LawsPartPmmPartitionInfo> queryWrapper =
QueryGenerator.initQueryWrapper(lawsPartPmmPartitionInfo, req.getParameterMap());
return list(queryWrapper);
public IPage<LawsPartPmmPartitionInfo> page(LawsPartPmmPartitionInfo lawsPartPmmPartitionInfo, Integer pageNo,
Integer pageSize, HttpServletRequest req) {
QueryWrapper<LawsPartPmmPartitionInfo> 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<LawsPartPmmPartitionInfo> page = new Page<>(pageNo, pageSize);
IPage<LawsPartPmmPartitionInfo> re = lawsPartPmmPartitionInfoMapper.pageList(page, queryWrapper);
return re;
}
}
@@ -58,32 +58,8 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
Integer pageSize, HttpServletRequest req) {
QueryWrapper<LawsPartRelevance> queryWrapper =
QueryGenerator.initQueryWrapper(lawsPartRelevance, req.getParameterMap());
if(!StringUtils.isBlank(lawsPartRelevance.getRegPartNameCn())){
LambdaQueryWrapper<LawsPartPmmPartitionInfo> queryLawsPartPmmPartitionInfo = new LambdaQueryWrapper<>();
queryLawsPartPmmPartitionInfo.like(LawsPartPmmPartitionInfo::getRegPartNameCn,lawsPartRelevance.getRegPartNameCn());
List<LawsPartPmmPartitionInfo> list = lawsPartPmmPartitionInfoService.list(queryLawsPartPmmPartitionInfo);
if(!CollectionUtils.isEmpty(list)){
List<String> 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<LawsPartRelevance> page = new Page<>(pageNo, pageSize);
IPage<LawsPartRelevance> re = page(page, queryWrapper);
List<LawsPartRelevance> 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<LawsPartRelevanceM
@Override
public void add(LawsPartRelevance lawsPartRelevance) {
// todo 是奇瑞型号的型号型式必填功能系统码和技术特性判定要求,不是奇瑞型号的不用填写
List<String> 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<String> list = Arrays.asList(lawsPartRelevance.getFndGpc().split(","));
list.sort(null);
String fndGpc = String.join(",", list);
String systemCode = lawsPartRelevance.getSystemCode();
lawsPartRelevance.setFndGpc(fndGpc);
LambdaQueryWrapper<LawsPartRelevance> 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<String> 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<String> list = Arrays.asList(lawsPartRelevance.getFndGpc().split(","));
list.sort(null);
String fndGpc = String.join(",", list);
String systemCode = lawsPartRelevance.getSystemCode();
lawsPartRelevance.setFndGpc(fndGpc);
LambdaQueryWrapper<LawsPartRelevance> 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<LawsPartRelevanceM
return Result.error(ResultCommon.IMPORT_DATA_CANNOT_BE_EMPTY);
}
StringBuilder m = new StringBuilder();
for (LawsPartRelevance lawsPartRelevance : listLawsPartRelevance) {
List<String> list = Arrays.asList(lawsPartRelevance.getRegPartNameCn().split(","));
list.sort(null);
String fndGpc = String.join(",", list);
lawsPartRelevance.setRegPartNameCn(fndGpc);
lawsPartRelevance.setFndGpc(fndGpc);
}
List<String> listCode = listLawsPartRelevance.stream().map(o->o.getFndGpc() + "_" +o.getSystemCode()).collect(Collectors.toList());
QueryWrapper<LawsPartRelevance> queryLawsPartRelevance = new QueryWrapper<>();
queryLawsPartRelevance.select("CONCAT(fnd_gpc,'_',system_code) as fnd_gpc");
queryLawsPartRelevance.in("CONCAT(fnd_gpc,'_',system_code)",listCode);
List<String> listRegPartNameCn = listLawsPartRelevance.stream().map(LawsPartRelevance::getRegPartNameCn).collect(Collectors.toList());
LambdaQueryWrapper<LawsPartRelevance> queryLawsPartRelevance = new LambdaQueryWrapper<>();
queryLawsPartRelevance.in(LawsPartRelevance::getRegPartNameCn,listRegPartNameCn);
List<LawsPartRelevance> listOld = list(queryLawsPartRelevance);
List<LawsPartRelevance> listNotNull = listLawsPartRelevance.stream().filter(o->!StringUtils.isBlank(o.getFndGpc())).collect(Collectors.toList());
List<LawsPartRelevance> listNotNull = listLawsPartRelevance.stream().filter(o->!StringUtils.isBlank(o.getRegPartNameCn())).collect(Collectors.toList());
List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoList = new ArrayList<>();
if(!CollectionUtils.isEmpty(listNotNull)){
List<String> listFndGpc = listLawsPartRelevance.stream().map(LawsPartRelevance::getFndGpc).collect(Collectors.toList());
String fndGpc = String.join(",", listFndGpc);
listFndGpc = Arrays.asList(fndGpc.split(","));
LambdaQueryWrapper<LawsPartPmmPartitionInfo> 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<LawsPartRelevanceM
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"关键零部件名称 does not exist," : "关键零部件名称不存在,");
}else{
List<String> 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 ServiceImpl<LawsPartRelevanceM
}
}
// 校验是否存在
String code = lawsPartRelevance.getFndGpc() + "_" + lawsPartRelevance.getSystemCode();
String code = lawsPartRelevance.getRegPartNameCn() + "_" + lawsPartRelevance.getSystemCode();
if(!CollectionUtils.isEmpty(listOld)){
long l = listOld.stream().filter(o->Objects.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," : "关键零部件名称与功能系统码已存在,"));