关键零部件绑定关系管理完善导入
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ public class ESPlanQueryDTO {
|
||||
@ApiModelProperty(value = "主起草单位")
|
||||
private String mainDraftingUnit;
|
||||
|
||||
@ApiModelProperty(value = "主起草单位责任人")
|
||||
@ApiModelProperty(value = "主起草单位业务支持-关键零部件绑定关系管理")
|
||||
private String mainDraftingUnitResponsiblePerson;
|
||||
|
||||
@ApiModelProperty(value = "项目状态")
|
||||
|
||||
+1
-2
@@ -157,8 +157,7 @@ public class LawsPartRelevanceController {
|
||||
@PostMapping(value = "/importExcel")
|
||||
// @RequiresPermissions("marketStandard:detail:operate")
|
||||
public Result<?> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
|
||||
lawsPartRelevanceService.importExcel(file);
|
||||
return Result.OK(ResultCommon.OK);
|
||||
return lawsPartRelevanceService.importExcel(file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ public class LawsPartRelevance implements Serializable {
|
||||
* 关键零部件名称
|
||||
*/
|
||||
@ApiModelProperty(value = "关键零部件名称")
|
||||
@Excel(name = "关键零部件名称", width = 15)
|
||||
@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")
|
||||
private String regPartNameCn;
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package com.jero.modules.laws.part.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.laws.part.entity.LawsPartRelevance;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -25,7 +26,7 @@ public interface ILawsPartRelevanceService extends IService<LawsPartRelevance> {
|
||||
|
||||
void edit(LawsPartRelevance lawsPartRelevance);
|
||||
|
||||
void importExcel(MultipartFile file);
|
||||
Result<?> importExcel(MultipartFile file);
|
||||
|
||||
ModelAndView downloadTemplate(HttpServletResponse response);
|
||||
}
|
||||
|
||||
+32
-24
@@ -5,6 +5,7 @@ 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.api.vo.Result;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
@@ -165,10 +166,10 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importExcel(MultipartFile file) {
|
||||
public Result<?> importExcel(MultipartFile file) {
|
||||
// 校验文件是否为excel
|
||||
if (!ImportExcelUtil.checkExcelFile(file)) {
|
||||
throw new JeroBootException(ResultCommon.IMPORT_THE_EXCEL_FILE);
|
||||
return Result.error(ResultCommon.IMPORT_THE_EXCEL_FILE);
|
||||
}
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
@@ -176,13 +177,13 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
boolean b = ImportExcelUtil.
|
||||
checkTemplateTitle(file, LawsPartRelevance.class, 0, 0);
|
||||
if (!b) {
|
||||
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
|
||||
return Result.error(ResultCommon.IMPORT_TEMPLATE_ERROR);
|
||||
}
|
||||
try {
|
||||
List<LawsPartRelevance> listLawsPartRelevance = ExcelImportUtil.importExcel(
|
||||
file.getInputStream(), LawsPartRelevance.class, params);
|
||||
if(CollectionUtils.isEmpty(listLawsPartRelevance)){
|
||||
throw new JeroBootException(ResultCommon.IMPORT_DATA_CANNOT_BE_EMPTY);
|
||||
return Result.error(ResultCommon.IMPORT_DATA_CANNOT_BE_EMPTY);
|
||||
}
|
||||
StringBuilder m = new StringBuilder();
|
||||
for (LawsPartRelevance lawsPartRelevance : listLawsPartRelevance) {
|
||||
@@ -197,8 +198,18 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
queryLawsPartRelevance.select("CONCAT(fnd_gpc,'_',system_code) as fnd_gpc");
|
||||
queryLawsPartRelevance.in("CONCAT(fnd_gpc,'_',system_code)",listCode);
|
||||
List<LawsPartRelevance> listOld = list(queryLawsPartRelevance);
|
||||
List<LawsPartRelevance> listNotNull = listLawsPartRelevance.stream().filter(o->!StringUtils.isBlank(o.getFndGpc())).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);
|
||||
lawsPartPmmPartitionInfoList = lawsPartPmmPartitionInfoService
|
||||
.list(queryLawsPartPmmPartitionInfo);
|
||||
}
|
||||
|
||||
List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoList = lawsPartPmmPartitionInfoService.list();
|
||||
Set<String> setAlready = new HashSet<>();
|
||||
// 校验数据
|
||||
for (int i = 0; i < listLawsPartRelevance.size(); i++) {
|
||||
@@ -213,16 +224,14 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
// 验证关键零部件名称是否正确
|
||||
if(CollectionUtils.isEmpty(lawsPartPmmPartitionInfoList)){
|
||||
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"关键零部件名称 does not exist" : "关键零部件名称不存在");
|
||||
"关键零部件名称 does not exist," : "关键零部件名称不存在,");
|
||||
}else{
|
||||
List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoListSub = lawsPartPmmPartitionInfoList
|
||||
.stream().filter(o->Objects.equals(o.getRegPartNameCn(),
|
||||
lawsPartRelevance.getRegPartNameCn())).collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(lawsPartPmmPartitionInfoListSub)){
|
||||
lawsPartRelevance.setFndGpc(lawsPartPmmPartitionInfoListSub.get(0).getFndGpc());
|
||||
}else{
|
||||
List<String> listFndGpc = Arrays.asList(lawsPartRelevance.getFndGpc().split(","));
|
||||
long l = lawsPartPmmPartitionInfoList
|
||||
.stream().filter(o->listFndGpc.contains(o.getFndGpc())).count();
|
||||
if(l != listFndGpc.size()){
|
||||
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"关键零部件名称 does not exist" : "关键零部件名称不存在");
|
||||
"关键零部件名称 does not exist," : "关键零部件名称不存在,");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,29 +239,28 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
if(formType.contains("1")){
|
||||
if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){
|
||||
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"功能系统码 cannot be empty" : "功能系统码不能为空");
|
||||
"功能系统码 cannot be empty," : "功能系统码不能为空,");
|
||||
}
|
||||
if(StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())){
|
||||
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"技术特性判定要求 cannot be empty" : "技术特性判定要求不能为空");
|
||||
"技术特性判定要求 cannot be empty," : "技术特性判定要求不能为空,");
|
||||
}
|
||||
}
|
||||
// 校验是否存在
|
||||
String code = lawsPartRelevance.getFndGpc() + "_" + lawsPartRelevance.getSystemCode();
|
||||
if(!CollectionUtils.isEmpty(listOld)){
|
||||
long l = listOld.stream().filter(o->Objects.equals(o.getFndGpc() + "_" + o.getSystemCode(),
|
||||
code)).count();
|
||||
long l = listOld.stream().filter(o->Objects.equals(o.getFndGpc(), code)).count();
|
||||
if(l > 0){
|
||||
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"名称与功能系统码 already exists" : "名称与功能系统码已存在"));
|
||||
s.append((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"名称与功能系统码 already exists," : "名称与功能系统码已存在,"));
|
||||
}
|
||||
}
|
||||
// 校验重复
|
||||
if(!CollectionUtils.isEmpty(setAlready) && !StringUtils.isBlank(code)){
|
||||
long l = setAlready.stream().filter(o->Objects.equals(o,code)).count();
|
||||
if(l > 0){
|
||||
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"名称与功能系统码 duplicate" : "名称与功能系统码重复"));
|
||||
s.append((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"名称与功能系统码 duplicate," : "名称与功能系统码重复,"));
|
||||
}
|
||||
}
|
||||
setAlready.add(code);
|
||||
@@ -263,13 +271,13 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isBlank(m.toString())){
|
||||
throw new JeroBootException(m.toString());
|
||||
return Result.error(m.toString());
|
||||
}
|
||||
|
||||
saveBatch(listLawsPartRelevance);
|
||||
return Result.OK(ResultCommon.OK);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
throw new JeroBootException(ResultCommon.ERROR);
|
||||
return Result.error(ResultCommon.ERROR);
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
|
||||
Reference in New Issue
Block a user