update:修改bug

This commit is contained in:
qk
2022-05-17 09:06:58 +08:00
parent 70c53e7b1e
commit 84767315c8
7 changed files with 117 additions and 31 deletions
@@ -216,7 +216,7 @@ public class SarLawsDetailedListController extends BaseController<SarLawsDetaile
@PostMapping("/importData")
public ResponseMessage importData( @RequestParam(value = "file", required = false) MultipartFile file){
StringBuilder stringBuilder=new StringBuilder();
List<ExportEmptyModel> res=sarLawsDetailedListService.importData(file,stringBuilder);
List<ExportEmptyModelDto> res=sarLawsDetailedListService.importData(file,stringBuilder);
if (stringBuilder.toString().length()>0){
return Result.error("-1","",stringBuilder.toString());
}else {
@@ -0,0 +1,46 @@
package com.adc.da.slrs.sarLawsDetailedList.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @Author: qk
* @Date: 2022/5/10 0010 14:56
* @Version 1.0
*/
@Data
public class ExportEmptyModelDto {
@Excel(name = "标准编号(必填)",orderNum = "0" ,width = 20.0)
private String standNumber;
@Excel(name = "适用认证(必填,可多选)",orderNum = "1" ,width = 40.0)
private String syrz;
@Excel(name = "标准实施日期",orderNum = "2" ,width = 20.0)
// @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
private String ssrq;
@Excel(name = "新车型实施日期",orderNum = "3" ,width = 20.0)
// @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
private String xcxssrqgj;
@Excel(name = "在产车实施日期",orderNum = "4" ,width = 20.0)
// @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
private String zccssrqgj;
private String id;
private String compareFlag;
private String syrzCode;
//国内海外为1 企标为2 政策为3
private String standName;
private String standEnName;
private String sycx;
private String nylx;
private String zrbm;
private String sycpx;
}
@@ -32,7 +32,7 @@ public interface ISarLawsDetailedListService extends IService<SarLawsDetailedLis
void standardToLaws(String countryArea,TimeDto timeDto);
List<ExportEmptyModel> importData(MultipartFile file , StringBuilder stringBuilder);
List<ExportEmptyModelDto> importData(MultipartFile file , StringBuilder stringBuilder);
}
@@ -49,6 +49,8 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -649,11 +651,26 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
List<TimeDto> timeDto = new ArrayList<>();
if (detailedUpDto.getInforlist().contains(",")) {
String[] id = detailedUpDto.getInforlist().split(",");
String[] putTime = detailedUpDto.getInforlist1().split(";");
String[] zcc = detailedUpDto.getInforlist2().split(";");
String[] xcx = detailedUpDto.getInforlist3().split(";");
String[] syrz = detailedUpDto.getInforlist4().split(";");
String[] id = new String[]{};
String[] putTime = new String[]{};
String[] zcc = new String[]{};
String[] xcx = new String[]{};
String[] syrz = new String[]{};
if(StringUtils.isNotEmpty(detailedUpDto.getInforlist())){
id = detailedUpDto.getInforlist().split(",");
}
if(StringUtils.isNotEmpty(detailedUpDto.getInforlist1())){
putTime = detailedUpDto.getInforlist1().split(";");
}
if(StringUtils.isNotEmpty(detailedUpDto.getInforlist2())){
zcc = detailedUpDto.getInforlist2().split(";");
}
if(StringUtils.isNotEmpty(detailedUpDto.getInforlist3())){
xcx = detailedUpDto.getInforlist3().split(";");
}
if(StringUtils.isNotEmpty(detailedUpDto.getInforlist4())){
syrz=detailedUpDto.getInforlist4().split(";");
}
for (int a = 0; a < id.length; a++) {
TimeDto dto = new TimeDto();
dto.setStandId(id[a]);
@@ -825,8 +842,8 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
@Override
public List<ExportEmptyModel> importData(MultipartFile file, StringBuilder stringBuilder) {
List<ExportEmptyModel> res = ExcelImportUtilByWk.readExcelpublic(ExportEmptyModel.class, file, stringBuilder);
public List<ExportEmptyModelDto> importData(MultipartFile file, StringBuilder stringBuilder) {
List<ExportEmptyModelDto> res = ExcelImportUtilByWk.readExcelpublic(ExportEmptyModelDto.class, file, stringBuilder);
//数据字典数据组装
Map<String, Object> dicTypeEO = dicTypeEOService.getDicTypeListCode();
Map<String, String> dict = new HashMap<>();
@@ -840,7 +857,7 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
//先校验是否存在一堆空数据
if (null != res && "".equals(stringBuilder.toString())) {
int i = 1;
for (ExportEmptyModel e : res) {
for (ExportEmptyModelDto e : res) {
if (null == e.getStandNumber() || e.getStandNumber().isEmpty()) {
stringBuilder.append("" + i + "行标准编号不能为空;");
}
@@ -852,6 +869,27 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
}
//数据校验 先做重复交验+再做是否存在校验
if (null != res && "".equals(stringBuilder.toString())) {
for (ExportEmptyModelDto re:res) {
if(!(re.getSsrq().contains(",")||re.getSsrq().contains(""))) {
Date date = org.apache.poi.ss.usermodel.DateUtil
.getJavaDate(Double.valueOf(re.getSsrq()));
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
re.setSsrq(format.format(date));
}
if(!(re.getXcxssrqgj().contains(",")||re.getXcxssrqgj().contains(""))) {
Date date = org.apache.poi.ss.usermodel.DateUtil
.getJavaDate(Double.valueOf(re.getXcxssrqgj()));
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
re.setXcxssrqgj(format.format(date));
}
if(!(re.getZccssrqgj().contains(",")||re.getZccssrqgj().contains(""))) {
Date date = org.apache.poi.ss.usermodel.DateUtil
.getJavaDate(Double.valueOf(re.getZccssrqgj()));
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
re.setZccssrqgj(format.format(date));
}
}
for (int i = 0; i < res.size(); i++) {
for (int j = 0; j < res.size(); j++) {
String a = res.get(i).getStandNumber().replaceAll(" ", "").replaceAll(" ", "");
@@ -865,7 +903,7 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
//如果没有重复 那么错误提示标识应该为空 现在开始验证标准是否存在
if ("".equals(stringBuilder.toString())) {
int i = 1;
for (ExportEmptyModel exportEmptyModel : res) {
for (ExportEmptyModelDto exportEmptyModel : res) {
SearchStandContext searchStandContext = new SearchStandContext();
searchStandContext.setStandCode(exportEmptyModel.getStandNumber());
List<StandData> standData = standDateDao.searchStandDataThree(searchStandContext);
@@ -920,15 +958,15 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
}
}
public List<ExportEmptyModel> dealWithData(List<ExportEmptyModel> res) {
List<ExportEmptyModel> result = new ArrayList<>();
public List<ExportEmptyModelDto> dealWithData(List<ExportEmptyModelDto> res) {
List<ExportEmptyModelDto> result = new ArrayList<>();
//判定是不是存在于国内海外标准中
StringBuilder stringBuilder = new StringBuilder();
Map<String, ExportEmptyModel> map = new HashMap<>();
res.forEach(exportEmptyModel -> {
if (null != exportEmptyModel.getId() && !exportEmptyModel.getId().isEmpty()) {
stringBuilder.append(exportEmptyModel.getId() + ",");
map.put(exportEmptyModel.getId(), exportEmptyModel);
Map<String, ExportEmptyModelDto> map = new HashMap<>();
res.forEach(ExportEmptyModel -> {
if (null != ExportEmptyModel.getId() && !ExportEmptyModel.getId().isEmpty()) {
stringBuilder.append(ExportEmptyModel.getId() + ",");
map.put(ExportEmptyModel.getId(), ExportEmptyModel);
}
});
String[] ids = stringBuilder.toString().substring(0, stringBuilder.toString().length() - 1).split(",");
@@ -948,7 +986,7 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
}
if (null != infos && infos.size() > 0) {
infos.forEach(sarStandardsInfo -> {
ExportEmptyModel model = map.get(sarStandardsInfo.getId());
ExportEmptyModelDto model = map.get(sarStandardsInfo.getId());
model.setStandName(sarStandardsInfo.getStandName());
model.setStandEnName(sarStandardsInfo.getStandEnName());
model.setNylx(null!=sarStandardsInfo.getAttrInfoCaseMap().get("nylx") ?sarStandardsInfo.getAttrInfoCaseMap().get("nylx").toString():"");
@@ -975,7 +1013,7 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
}
if (null != sarBussionessStands && sarBussionessStands.size() > 0) {
sarBussionessStands.forEach(sarStandardsInfo -> {
ExportEmptyModel model = map.get(sarStandardsInfo.getId());
ExportEmptyModelDto model = map.get(sarStandardsInfo.getId());
model.setStandName(sarStandardsInfo.getStandName());
model.setStandEnName(sarStandardsInfo.getStandEnName());
model.setNylx(null!=sarStandardsInfo.getAttrInfoCaseMap().get("nylx") ?sarStandardsInfo.getAttrInfoCaseMap().get("nylx").toString():"");
@@ -1001,7 +1039,7 @@ public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedL
}
if (null != sarLawsStandInfos && sarLawsStandInfos.size() > 0) {
sarLawsStandInfos.forEach(sarStandardsInfo -> {
ExportEmptyModel model = map.get(sarStandardsInfo.getId());
ExportEmptyModelDto model = map.get(sarStandardsInfo.getId());
model.setStandName(sarStandardsInfo.getLawsName());
model.setStandEnName(sarStandardsInfo.getLawsEnName());
model.setNylx(null!=sarStandardsInfo.getAttrInfoCaseMap().get("nylxlaws") ?sarStandardsInfo.getAttrInfoCaseMap().get("nylxlaws").toString():"");
@@ -220,13 +220,15 @@ public class SarStandardComplianceAssessResultController {
for (SarStandardComplianceProductAssess s:sarStandardCompliance) {
if (null!=s.getStandardItem()) {
String[] as=(s.getStandardItem()+".").split("\\.");
if (orderKey.contains(Integer.valueOf(as[0].trim().toString()))) {
stringMap.get(Integer.valueOf(as[0].trim().toString())).add(s);
} else {
orderKey.add(Integer.valueOf(as[0].trim().toString()));
List<SarStandardComplianceProductAssess> assesses2 = new ArrayList<>();
assesses2.add(s);
stringMap.put(Integer.valueOf(as[0].trim().toString()), assesses2);
if(StringUtils.isNumeric(as[0].trim())){
if (orderKey.contains(Integer.valueOf(as[0].trim().toString()))) {
stringMap.get(Integer.valueOf(as[0].trim().toString())).add(s);
} else {
orderKey.add(Integer.valueOf(as[0].trim().toString()));
List<SarStandardComplianceProductAssess> assesses2 = new ArrayList<>();
assesses2.add(s);
stringMap.put(Integer.valueOf(as[0].trim().toString()), assesses2);
}
}
}else {
if (null!=stringMap.get(0)) {