|
@@ -9,10 +9,14 @@ 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.remote.RemoteDegree;
|
|
|
+import com.platform.dao.entity.remote.RemoteMeasure;
|
|
|
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.entity.upms.SysConfig;
|
|
|
+import com.platform.dao.entity.upms.SysDict;
|
|
|
import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
@@ -956,6 +960,144 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入电度对应表
|
|
|
+ * @param inputstream
|
|
|
+ * @param sysDictList
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws InvalidFormatException
|
|
|
+ */
|
|
|
+ public static List<RemoteDegree> importRemoteDegreeList(InputStream inputstream, List<SysDict> sysDictList) 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<RemoteDegree> result = new ArrayList<>(rowCounts);
|
|
|
+ RemoteDegree record = null;
|
|
|
+
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
+ for (int i = 1; i <= rowCounts; i++) {
|
|
|
+ record = new RemoteDegree();
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if(isRowEmpty(row)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String index = row.getCell(0).getStringCellValue() + "";
|
|
|
+ try {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ record.setPositionNum(Integer.valueOf(getCellValue(row.getCell(0))));
|
|
|
+ record.setSbName(getCellValue(row.getCell(1)));
|
|
|
+ record.setDesc(StringUtils.getExcelString(row.getCell(2)));
|
|
|
+ String type = getCellValue(row.getCell(3)).trim();
|
|
|
+ if(StringUtils.isNotEmpty(type)){
|
|
|
+ boolean find = false;
|
|
|
+ for(SysDict sysDict: sysDictList){
|
|
|
+ if(sysDict.getLabel().equals(type)){
|
|
|
+ record.setType(Integer.valueOf(sysDict.getValue()));
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!find){
|
|
|
+ throw new BusinessException("点位类型未配置,请配置数据字典:" + type );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setUnit(getCellValue(row.getCell(4)).trim());
|
|
|
+ } 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入遥测对应表-新增
|
|
|
+ * @param inputstream
|
|
|
+ * @param sysDictList
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws InvalidFormatException
|
|
|
+ */
|
|
|
+ public static List<RemoteMeasure> importRemoteMeasureList(InputStream inputstream, List<SysDict> sysDictList) 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<RemoteMeasure> result = new ArrayList<>(rowCounts);
|
|
|
+ RemoteMeasure record = null;
|
|
|
+
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
+ for (int i = 1; i <= rowCounts; i++) {
|
|
|
+ record = new RemoteMeasure();
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if(isRowEmpty(row)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String index = row.getCell(0).getStringCellValue() + "";
|
|
|
+ try {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ record.setPositionNum(Integer.valueOf(getCellValue(row.getCell(0))));
|
|
|
+ record.setSbName(getCellValue(row.getCell(1)));
|
|
|
+ String desc = getCellValue(row.getCell(2)).trim();
|
|
|
+ record.setDesc(desc);
|
|
|
+ if(StringUtils.isNotEmpty(desc)){
|
|
|
+ boolean find = false;
|
|
|
+ for(SysDict sysDict: sysDictList){
|
|
|
+ if(sysDict.getLabel().equals(desc)){
|
|
|
+ record.setType(Integer.valueOf(sysDict.getValue()));
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!find){
|
|
|
+ throw new BusinessException("点位类型未配置,请配置电度数据字典:" + desc );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setUnit(getCellValue(row.getCell(3)).trim());
|
|
|
+ } 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<SbInfoVO> importSbInfoListStandard(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
if (inputstream == null) {
|
|
|
return Collections.emptyList();
|
|
@@ -1098,6 +1240,9 @@ public class CustomExcelImportUtil {
|
|
|
if(StringUtils.isNotBlank(tempInfo)){
|
|
|
record.setCheckPeriod(Integer.valueOf(tempInfo));
|
|
|
}
|
|
|
+ if(record.getCheckDate() != null && record.getCheckPeriod() != null){
|
|
|
+ record.setNextCheckDate(record.getCheckDate().minusMonths(-record.getCheckPeriod()));
|
|
|
+ }
|
|
|
checkStandard.setCreatedUserId("1");
|
|
|
record.setCheckStandard(checkStandard);
|
|
|
record.setPartInfo(partInfo);
|