|
@@ -4,11 +4,13 @@ import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
+import com.platform.dao.entity.check.CheckStandard;
|
|
|
import com.platform.dao.entity.purchase.*;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
import com.platform.dao.entity.store.SpareStore;
|
|
|
+import com.platform.dao.enums.CheckStandardTypeEnum;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -478,15 +480,13 @@ public class CustomExcelImportUtil {
|
|
|
"C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls",
|
|
|
"C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-坦桑尼亚.xls",
|
|
|
"C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls"};*/
|
|
|
- String[] files = {"C:\\Users\\cyz\\Desktop\\2021.5.31 注塑设备台账导入文件.xls"};
|
|
|
+ String[] files = {"C:\\Users\\cyz\\Desktop\\C-001 (OS-M235) - 副本.xls"};
|
|
|
InputStream inputstream = new FileInputStream(files[0]);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
// List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
|
|
|
- List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
|
- // List<SbModel> list = importModelList(inputstream);
|
|
|
- //List<SbInfo> list = importSbInfoListForUpdateValue(inputstream);
|
|
|
+ // List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
|
+ List<CheckStandard> list = importCheckStandardList(inputstream);
|
|
|
|
|
|
- //List<SparePartInfoVO> list = importSparePartInfoListForUpdate(LocalDateTime.now(), inputstream);
|
|
|
list.forEach(item -> {
|
|
|
System.out.println(item.toString());
|
|
|
});
|
|
@@ -862,7 +862,7 @@ public class CustomExcelImportUtil {
|
|
|
}else{
|
|
|
record.setInitialValue(new Double(value));
|
|
|
}
|
|
|
- record.setTypeId(row.getCell(7).getStringCellValue().trim());
|
|
|
+ record.setTypeName(row.getCell(7).getStringCellValue().trim());
|
|
|
record.setUseType(getUseType(row.getCell(8).getStringCellValue().trim()));
|
|
|
record.setZz(getCellValue(row.getCell(9)));
|
|
|
record.setCph(getCellValue(row.getCell(10)));
|
|
@@ -923,6 +923,107 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入点检标准
|
|
|
+ *
|
|
|
+ * @param inputstream
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws InvalidFormatException
|
|
|
+ */
|
|
|
+ public static List<CheckStandard> importCheckStandardList(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<CheckStandard> result = new ArrayList<>(rowCounts);
|
|
|
+ CheckStandard record = null;
|
|
|
+ String sbNo = sheet.getRow(4).getCell(13).getStringCellValue();
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
+ for (int i = 12; i <= rowCounts; i++) {
|
|
|
+ record = new CheckStandard();
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if(isRowEmpty(row)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String index = row.getCell(1).getStringCellValue() + "";
|
|
|
+ try {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ setPeriod(row, record);
|
|
|
+ String sort = getCellValue(row.getCell(11)).trim();
|
|
|
+ System.out.println(sort.substring(0,sort.length()-2 ));
|
|
|
+ record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
|
|
|
+ record.setRequirement(row.getCell(12).getStringCellValue().trim());
|
|
|
+ record.setName(record.getRequirement().substring(0,4));
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ record.setType(CheckStandardTypeEnum.POLLING.getValue());
|
|
|
+ record.setSbId(sbNo);// 需要根据no来判断设备的id
|
|
|
+ record.setStandardHours("20");
|
|
|
+ record.setEnable(1);
|
|
|
+ setRemark(row, record);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException("导入异常,行号:"+ i + ", 错误信息" + e.getMessage() + ", 错误原因" + e.getCause());
|
|
|
+ }
|
|
|
+ result.add(record);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setRemark(Row row, CheckStandard record) {
|
|
|
+ if(StringUtils.isNotEmpty(row.getCell(7).getStringCellValue())){
|
|
|
+ record.setCheckUserType(1);
|
|
|
+ record.setRemark("车间");
|
|
|
+ }else if(StringUtils.isNotEmpty(row.getCell(7).getStringCellValue())){
|
|
|
+ record.setCheckUserType(2);
|
|
|
+ record.setRemark("维修");
|
|
|
+ }else if(StringUtils.isNotEmpty(row.getCell(7).getStringCellValue())){
|
|
|
+ record.setCheckUserType(3);
|
|
|
+ record.setRemark("厂家");
|
|
|
+ }else{
|
|
|
+ record.setCheckUserType(1);
|
|
|
+ record.setRemark("车间");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setPeriod(Row row, CheckStandard record) {
|
|
|
+ if(StringUtils.isNotBlank(row.getCell(0).getStringCellValue())){
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(1);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(1).getStringCellValue())){
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(2);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(2).getStringCellValue())){
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(3);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(3).getStringCellValue())){
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(4);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(4).getStringCellValue())){
|
|
|
+ record.setPeriod(2);
|
|
|
+ record.setPeriodType(4);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(5).getStringCellValue())){
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(5);
|
|
|
+ }else if(StringUtils.isNotBlank(row.getCell(6).getStringCellValue())){
|
|
|
+ record.setPeriod(3);
|
|
|
+ record.setPeriodType(5);
|
|
|
+ }else{
|
|
|
+ record.setPeriod(1);
|
|
|
+ record.setPeriodType(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static List<SbInfo> importSbInfoListForUpdateValue(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
if (inputstream == null) {
|
|
|
return Collections.emptyList();
|