|
@@ -7,6 +7,7 @@ import com.platform.common.util.*;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
import com.platform.dao.entity.check.CheckJob;
|
|
|
import com.platform.dao.entity.check.CheckStandard;
|
|
|
+import com.platform.dao.entity.part.PartInfo;
|
|
|
import com.platform.dao.entity.purchase.*;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
@@ -954,6 +955,156 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public static List<SbInfoVO> importSbInfoListStandard(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
+ if (inputstream == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ Workbook book = null;
|
|
|
+ if (!(inputstream.markSupported())) {
|
|
|
+ inputstream = new PushbackInputStream(inputstream, 8);
|
|
|
+ }
|
|
|
+ if (POIFSFileSystem.hasPOIFSHeader(inputstream)) {
|
|
|
+ book = new HSSFWorkbook(inputstream);
|
|
|
+ } else if (POIXMLDocument.hasOOXMLHeader(inputstream)) {
|
|
|
+ book = new XSSFWorkbook(OPCPackage.open(inputstream));
|
|
|
+ }
|
|
|
+ Sheet sheet = book.getSheetAt(0);
|
|
|
+ int rowCounts = sheet.getLastRowNum();
|
|
|
+ List<SbInfoVO> result = new ArrayList<>(rowCounts);
|
|
|
+ SbInfoVO record = null;
|
|
|
+
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
+ for (int i = 1; i <= rowCounts; i++) {
|
|
|
+ record = new SbInfoVO();
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if(isRowEmpty(row)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String index = row.getCell(1).getStringCellValue() + "";
|
|
|
+ try {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ record.setName(StringUtils.getExcelString(row.getCell(0)).replace("'", ""));
|
|
|
+ record.setNo(StringUtils.getExcelString(row.getCell(1)));
|
|
|
+ record.setPositionName(getCellValue(row.getCell(2)));
|
|
|
+ record.setModel(getCellValue(row.getCell(3)).trim());
|
|
|
+ String level = getCellValue(row.getCell(4));
|
|
|
+ if(StringUtils.isBlank(level)){
|
|
|
+ record.setLevel(1);
|
|
|
+ }else{
|
|
|
+ record.setLevel(getLevel(level));
|
|
|
+ }
|
|
|
+ record.setTypeName(StringUtils.getExcelString(row.getCell(5)));
|
|
|
+ record.setUseType(getUseType(StringUtils.getExcelString(row.getCell(6))));
|
|
|
+ record.setStatus(SbInfoStatusEnum.IN_USE.getValue());
|
|
|
+ record.setBuyDate(DateUtils.strToLocalDate((getCellValue(row.getCell(7))), DateUtils.PATTERN_YMD));
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate((getCellValue(row.getCell(8))), DateUtils.PATTERN_YMD));
|
|
|
+ record.setWorkYear(Double.valueOf(getCellValue(row.getCell(9))));
|
|
|
+ record.setIsChild((getCellValue(row.getCell(10)).isEmpty()||getCellValue(row.getCell(10)).equals("否"))?0:1);
|
|
|
+ record.setParentSbNo(getCellValue(row.getCell(11)));
|
|
|
+ record.setCreatedTime(now);
|
|
|
+ record.setCreatedUserId("1");
|
|
|
+
|
|
|
+ PartInfo partInfo = new PartInfo();
|
|
|
+ partInfo.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ partInfo.setSbId(record.getId());
|
|
|
+ partInfo.setTypeName(getCellValue(row.getCell(12)));
|
|
|
+ partInfo.setName(getCellValue(row.getCell(13)));
|
|
|
+ partInfo.setNo(getCellValue(row.getCell(14)));
|
|
|
+ String partInfoLevel = row.getCell(15).getStringCellValue();
|
|
|
+ if(partInfoLevel.equals("一级")){
|
|
|
+ partInfo.setLevel(1);
|
|
|
+ }else if(partInfoLevel.equals("二级")){
|
|
|
+ partInfo.setLevel(2);
|
|
|
+ }else if(partInfoLevel.equals("三级")){
|
|
|
+ partInfo.setLevel(3);
|
|
|
+ }else {
|
|
|
+ partInfo.setLevel(1);
|
|
|
+ }
|
|
|
+ partInfo.setCreatedTime(now);
|
|
|
+ partInfo.setCreatedUserId("1");
|
|
|
+ CheckStandard checkStandard = new CheckStandard();
|
|
|
+ checkStandard.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ checkStandard.setSbId(record.getId());
|
|
|
+ checkStandard.setPart(partInfo.getId());
|
|
|
+ checkStandard.setNo(getCellValue(row.getCell(16)));
|
|
|
+ checkStandard.setName(getCellValue(row.getCell(17)));
|
|
|
+ checkStandard.setType(CheckStandardTypeEnum.SPOT.getValue());
|
|
|
+ String checkStandardLevel = row.getCell(18).getStringCellValue();
|
|
|
+ if(checkStandardLevel.equals("一级")){
|
|
|
+ checkStandard.setLevel(1);
|
|
|
+ }else if(checkStandardLevel.equals("二级")){
|
|
|
+ checkStandard.setLevel(2);
|
|
|
+ }else if(checkStandardLevel.equals("三级")){
|
|
|
+ checkStandard.setLevel(3);
|
|
|
+ }else {
|
|
|
+ checkStandard.setLevel(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ String checkUserType = row.getCell(19).getStringCellValue();
|
|
|
+ if(checkUserType.equals("设备使用人")){
|
|
|
+ checkStandard.setCheckUserType(1);
|
|
|
+ }else if(checkUserType.equals("设备维修人")){
|
|
|
+ checkStandard.setCheckUserType(2);
|
|
|
+ }else if(checkUserType.equals("指定人员")){
|
|
|
+ checkStandard.setCheckUserType(3);
|
|
|
+ }else {
|
|
|
+ checkStandard.setCheckUserType(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ checkStandard.setCheckUserId(getCellValue(row.getCell(20)));
|
|
|
+ checkStandard.setPeriod(Integer.valueOf(getCellValue(row.getCell(21))));
|
|
|
+ String periodType = row.getCell(22).getStringCellValue();
|
|
|
+ if(periodType.equals("天")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.DAY.getValue());
|
|
|
+ }else if(periodType.equals("周")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.WEEK.getValue());
|
|
|
+ }else if(periodType.equals("月")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.MONTH.getValue());
|
|
|
+ }else if(periodType.equals("季度")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.SEASON.getValue());
|
|
|
+ }else if(periodType.equals("年")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
|
|
|
+ }else if(periodType.equals("公里")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.MILES.getValue());
|
|
|
+ }else if(periodType.equals("台时")){
|
|
|
+ checkStandard.setPeriodType(CheckPlanPeriodTypeEnum.TAISHI.getValue());
|
|
|
+ }
|
|
|
+ checkStandard.setStandardHours(getCellValue(row.getCell(23)));
|
|
|
+ String actionType = row.getCell(24).getStringCellValue();
|
|
|
+ if(actionType.equals("检查紧固")){
|
|
|
+ checkStandard.setActionType(1);
|
|
|
+ }else if(actionType.equals("清洁")){
|
|
|
+ checkStandard.setActionType(2);
|
|
|
+ }else if(actionType.equals("更换")){
|
|
|
+ checkStandard.setActionType(3);
|
|
|
+ }else if(actionType.equals("测量调整")){
|
|
|
+ checkStandard.setActionType(4);
|
|
|
+ }else {
|
|
|
+ checkStandard.setActionType(1);
|
|
|
+ }
|
|
|
+ checkStandard.setLastDate(DateUtils.strToLocalDate((getCellValue(row.getCell(25))), DateUtils.PATTERN_YMD));
|
|
|
+ checkStandard.setRequirement(getCellValue(row.getCell(26)));
|
|
|
+ checkStandard.setRemark(getCellValue(row.getCell(27)));
|
|
|
+ checkStandard.setCreatedTime(now);
|
|
|
+ checkStandard.setCreatedUserId("1");
|
|
|
+ record.setCheckStandard(checkStandard);
|
|
|
+ record.setPartInfo(partInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ error.append(index).append("错误地址:第"+i+"行");
|
|
|
+ }
|
|
|
+ result.add(record);
|
|
|
+ }
|
|
|
+
|
|
|
+ String errorStr = error.toString();
|
|
|
+ if (StringUtils.isNotEmpty(errorStr)) {
|
|
|
+ throw new BusinessException(String.format("导入异常,以下行数据有问题:%s", errorStr.substring(0, errorStr.length())));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static List<SbInfoMeasureVO> importSbInfoMeasureList(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
if (inputstream == null) {
|
|
|
return Collections.emptyList();
|