|
|
@ -11,6 +11,9 @@ import com.xujie.sys.modules.pms.service.QcService; |
|
|
import com.xujie.sys.modules.pms.util.ResponseData; |
|
|
import com.xujie.sys.modules.pms.util.ResponseData; |
|
|
import com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity; |
|
|
import com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
@ -22,6 +25,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -3294,8 +3298,11 @@ public class QcServiceImpl implements QcService { |
|
|
int rows = sheet.getPhysicalNumberOfRows(); |
|
|
int rows = sheet.getPhysicalNumberOfRows(); |
|
|
// 新建集合 |
|
|
// 新建集合 |
|
|
ArrayList<SubDetailValues> SubDetailList = new ArrayList<>(); |
|
|
ArrayList<SubDetailValues> SubDetailList = new ArrayList<>(); |
|
|
// 遍历每一行(从第二行开始) |
|
|
|
|
|
for (int j = 1; j < rows; j++) { |
|
|
|
|
|
|
|
|
// 创建集合存放错误信息 |
|
|
|
|
|
ArrayList<Integer> errInfo1 = new ArrayList<>(); |
|
|
|
|
|
ArrayList<Integer> errInfo2 = new ArrayList<>(); |
|
|
|
|
|
// 遍历每一行, 从第三行开始 |
|
|
|
|
|
for (int j = 2; j < rows; j++) { |
|
|
// 创建对象 |
|
|
// 创建对象 |
|
|
SubDetailValues task = new SubDetailValues(); |
|
|
SubDetailValues task = new SubDetailValues(); |
|
|
// 获得该行 |
|
|
// 获得该行 |
|
|
@ -3303,28 +3310,43 @@ public class QcServiceImpl implements QcService { |
|
|
// 为对象赋值 |
|
|
// 为对象赋值 |
|
|
task.setSite(data.getSite()); |
|
|
task.setSite(data.getSite()); |
|
|
task.setInspectionNo(data.getInspectionNo()); |
|
|
task.setInspectionNo(data.getInspectionNo()); |
|
|
if (row.getCell(0) == null) { |
|
|
|
|
|
task.setItemNo(null); |
|
|
|
|
|
|
|
|
if (row.getCell(0) == null || "".equals(row.getCell(0).getStringCellValue())) { |
|
|
|
|
|
// task.setItemNo(null); |
|
|
|
|
|
errInfo1.add(j + 1); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
row.getCell(0).setCellType(CellType.STRING); // 强转类型为String |
|
|
task.setItemNo(row.getCell(0).getStringCellValue()); |
|
|
task.setItemNo(row.getCell(0).getStringCellValue()); |
|
|
|
|
|
// 判断项目是否合规 |
|
|
|
|
|
task.setFlag(data.getFlag()); |
|
|
|
|
|
SubDetailValues itemData = qcMapper.checkItem(task); |
|
|
|
|
|
if (itemData == null) { // 明细中不存在该项目 |
|
|
|
|
|
errInfo2.add(j + 1); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (row.getCell(1) == null) { |
|
|
if (row.getCell(1) == null) { |
|
|
task.setSamplingLocation(null); |
|
|
task.setSamplingLocation(null); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
row.getCell(1).setCellType(CellType.STRING); |
|
|
task.setSamplingLocation(row.getCell(1).getStringCellValue()); |
|
|
task.setSamplingLocation(row.getCell(1).getStringCellValue()); |
|
|
} |
|
|
} |
|
|
if (row.getCell(2) == null) { |
|
|
if (row.getCell(2) == null) { |
|
|
task.setSamplingLocationB(null); |
|
|
task.setSamplingLocationB(null); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
row.getCell(2).setCellType(CellType.STRING); |
|
|
task.setSamplingLocationB(row.getCell(2).getStringCellValue()); |
|
|
task.setSamplingLocationB(row.getCell(2).getStringCellValue()); |
|
|
} |
|
|
} |
|
|
if (row.getCell(3) == null) { |
|
|
if (row.getCell(3) == null) { |
|
|
task.setSubDetailValue(null); |
|
|
task.setSubDetailValue(null); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
row.getCell(3).setCellType(CellType.STRING); |
|
|
task.setSubDetailValue(row.getCell(3).getStringCellValue()); |
|
|
task.setSubDetailValue(row.getCell(3).getStringCellValue()); |
|
|
} |
|
|
} |
|
|
SubDetailList.add(task); |
|
|
SubDetailList.add(task); |
|
|
} |
|
|
} |
|
|
|
|
|
// 查看错误信息 |
|
|
|
|
|
if (errInfo1.size() > 0 || errInfo2.size() > 0) { |
|
|
|
|
|
throw new RuntimeException("请检查:导入模板中的第 " + errInfo1.toString() + " 行项目编码为空;请检查:导入模板中的第 " + errInfo2.toString() + " 行项目编码不在本次检验单中"); |
|
|
|
|
|
} |
|
|
// 新增子明细 |
|
|
// 新增子明细 |
|
|
if ("IPQC".equals(data.getFlag())) { |
|
|
if ("IPQC".equals(data.getFlag())) { |
|
|
qcMapper.saveIPQCSubDetailed(SubDetailList); |
|
|
qcMapper.saveIPQCSubDetailed(SubDetailList); |
|
|
@ -3336,7 +3358,7 @@ public class QcServiceImpl implements QcService { |
|
|
qcMapper.saveIQCSubDetailed(SubDetailList); |
|
|
qcMapper.saveIQCSubDetailed(SubDetailList); |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RuntimeException("导入失败:"+e.getMessage()); |
|
|
|
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|