Browse Source

fix bug:修复校验非必填项
优化:优化/object/equip/import接口

lijie 3 years ago
parent
commit
5ac4c9674e

+ 2 - 1
src/main/java/com/persagy/proxy/adm/constant/AdmCommonConstant.java

@@ -67,11 +67,12 @@ public interface AdmCommonConstant {
     String MIDDLEWARE_GROUP_CODE = "middleware.group.code";
     
     /** 识别码类型 */
-	static Map<String, String> codeColMap = new HashMap<String,String>(){
+	Map<String, String> codeColMap = new HashMap<String,String>(){
 		private static final long serialVersionUID = 1L;
 		{
             put("EquipLocalID", "localId");
             put("ClassCode", "classCode");
+            put("DigitalDeliveryID", "digitalDeliveryID");
         }
     };
 

+ 2 - 1
src/main/java/com/persagy/proxy/adm/utils/AdmExcelUtil.java

@@ -7,6 +7,7 @@ import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.util.ResourceUtils;
 
@@ -40,7 +41,7 @@ public class AdmExcelUtil {
 	 * @param orgFileName
 	 * @return 
 	 */
-	public static String writeFile2Local(XSSFWorkbook workbook, String projectId, String path, String orgFileName) {
+	public static String writeFile2Local(Workbook workbook, String projectId, String path, String orgFileName) {
 		FileOutputStream fileOutputStream = null;
 		String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
 		// 重组文件名

+ 13 - 4
src/main/java/com/persagy/proxy/dictionary/controller/AdmDictController.java

@@ -9,13 +9,10 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmDictQueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.dictionary.model.*;
 import com.persagy.proxy.dictionary.service.IAdmDictService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
-import com.persagy.proxy.dictionary.model.AdmDefFuncIdGather;
-import com.persagy.proxy.dictionary.model.AdmDict;
-import com.persagy.proxy.dictionary.model.AdmDictBatch;
-import com.persagy.proxy.dictionary.model.AdmObjectType;
 import com.persagy.proxy.object.model.AdmObjectInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -205,5 +202,17 @@ public class AdmDictController {
     public AdmResponse syncProjectObjectInfo() throws Exception {
         return AdmResponse.success(new ArrayList<>());
     }
+    /***
+     * Description:统计-根据条件统计返回信息点
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/11/15 14:02
+     * Update By lijie 2021/11/15 14:02
+     */
+    @PostMapping("/delivered/infos")
+    @Deprecated
+    public AdmResponse equipDictInfos(@RequestBody AdmEquipDictInfos admEquipDictInfos) throws Exception {
+        return service.queryEquipDictInfos(admEquipDictInfos);
+    }
 
 }

+ 22 - 0
src/main/java/com/persagy/proxy/dictionary/model/AdmEquipDictInfos.java

@@ -0,0 +1,22 @@
+package com.persagy.proxy.dictionary.model;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@Data
+@ToString
+@EqualsAndHashCode
+public class AdmEquipDictInfos {
+
+    /**模式: all(全部),gather(只看采集)*/
+    private String model;
+    /**设备类型*/
+    private String classCode;
+    /**全部: 不用传值,未明确建筑传建筑(isNull)*/
+    private String buildingId;
+    /**全部: 不用传值,未明确楼层(isNull)*/
+    private String floorId;
+    /**对象类型:设备(equipment),系统(system),空间(space),竖井(shaft)*/
+    private String objType;
+}

+ 9 - 1
src/main/java/com/persagy/proxy/dictionary/service/IAdmDictService.java

@@ -6,6 +6,7 @@ import com.persagy.proxy.adm.request.AdmDictQueryCriteria;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.dictionary.model.AdmEquipDictInfos;
 
 import java.util.List;
 
@@ -66,5 +67,12 @@ public interface IAdmDictService<T> extends IAdmDictBaseService<T>{
      * @return
      */
     AdmResponse query(InstanceUrlParam context, AdmDictQueryCriteria request,String fieldName, Class<T> clazz);
-
+    /***
+     * Description:统计-根据条件统计返回信息点
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/11/15 14:02
+     * Update By lijie 2021/11/15 14:02
+     */
+    AdmResponse queryEquipDictInfos(AdmEquipDictInfos admEquipDictInfos);
 }

+ 19 - 0
src/main/java/com/persagy/proxy/dictionary/service/impl/AdmDictServiceImpl.java

@@ -14,6 +14,7 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmDictQueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.dictionary.model.AdmEquipDictInfos;
 import com.persagy.proxy.dictionary.service.IAdmDictService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.dictionary.model.AdmDefFuncIdGather;
@@ -428,6 +429,24 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
         admResponse.setContent(admObjectInfos);
         return admResponse;
     }
+    /***
+     * Description:统计-根据条件统计返回信息点
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/11/15 14:02
+     * Update By lijie 2021/11/15 14:02
+     */
+    @Override
+    public AdmResponse queryEquipDictInfos(AdmEquipDictInfos admEquipDictInfos) {
+        if (StrUtil.isBlank(admEquipDictInfos.getClassCode())){
+            //设备类型为空 直接返回
+            return AdmResponse.success(new ArrayList<>());
+        }
+        if (StrUtil.isBlank(admEquipDictInfos.getObjType())){
+            return AdmResponse.success("对象类型不可以为空");
+        }
+        return null;
+    }
 
     /**
      * 转换排序字段

+ 597 - 185
src/main/java/com/persagy/proxy/object/controller/AdmEquipmentController.java

@@ -3,24 +3,36 @@ package com.persagy.proxy.object.controller;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import cn.hutool.poi.excel.ExcelReader;
 import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.RowUtil;
+import cn.hutool.poi.excel.WorkbookUtil;
+import cn.hutool.poi.excel.cell.CellEditor;
+import cn.hutool.poi.excel.cell.CellUtil;
+import cn.hutool.poi.excel.editors.TrimEditor;
+import cn.hutool.poi.excel.style.StyleUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Sets;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
+import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.exception.BusinessException;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.entity.BaseEntity;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.define.client.DigitalDefineFacade;
+import com.persagy.dmp.define.client.DigitalObjectInfoFacade;
 import com.persagy.dmp.define.entity.ObjectInfoDefine;
 import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
@@ -44,20 +56,24 @@ import com.persagy.proxy.object.model.AdmEquipment;
 import com.persagy.proxy.object.service.IAdmEquipmentService;
 import com.persagy.proxy.report.service.IRelationReportService;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.usermodel.CellType;
-import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.SheetUtil;
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import sun.plugin2.util.ColorUtil;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.*;
+import java.awt.Color;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.util.List;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Adm 楼层 API
@@ -387,6 +403,258 @@ public class AdmEquipmentController {
 	 * @param request
 	 * @param response
 	 */
+//	@RequestMapping("/import")
+//	public AdmResponse importFile(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
+//		if (file == null) {
+//			return AdmResponse.failure("未选择文件");
+//		}
+//		String path = AdmCommonConstant.SERVER_ROOT_PATH + AdmExcelUtil.TEMP_UPLOAD_PAHT;
+//
+//		int failurNum = 0;
+//		int successCount = 0;
+//		String failure = null;
+//		String primaryKey = null;
+//		String classCodeCloumn = null;
+//		XSSFWorkbook workbook = null;
+//		FileOutputStream fileOutputStream = null;
+//		String groupCode = AppContext.getContext().getGroupCode();
+//		String projectId = AppContext.getContext().getProjectId();
+//		try {
+//
+//			workbook = new XSSFWorkbook(file.getInputStream());
+//			XSSFSheet sheet = workbook.getSheetAt(0);	// 第一个sheet
+//			XSSFRow row1 = sheet.getRow(1);
+//			if (row1 == null) {
+//				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//				return AdmExcelUtil.getImportFailResult("数据不存在", "2", 0, ++failurNum);
+//			}
+//
+//			/** 获取识别码 */
+//			XSSFCell markCell = row1.getCell(0);
+//			if (markCell == null) {
+//				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//				return AdmExcelUtil.getImportFailResult("未填写识别码", "2", 0, ++failurNum);
+//			}
+//			primaryKey = markCell.getStringCellValue().trim(); 	// 识别码
+//			boolean containsKey = AdmCommonConstant.codeColMap.containsKey(primaryKey);
+//			if (!containsKey) {
+//				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//				return AdmExcelUtil.getImportFailResult("未找到识别码", "2", 0, ++failurNum);
+//			}
+//			primaryKey = AdmCommonConstant.codeColMap.get(primaryKey);
+//
+//			/** 获取类型 */
+//			XSSFCell cell = row1.getCell(1);
+//			if (cell == null) {
+//				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//				return AdmExcelUtil.getImportFailResult("未填写设备类型", "2", 0, ++failurNum);
+//			}
+//			classCodeCloumn = cell.getStringCellValue().trim();
+//			if (!"ClassCode".equals(classCodeCloumn)) {
+//				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//				return AdmExcelUtil.getImportFailResult("缺少设备类型(ClassCode)", "2", 0, ++failurNum);
+//			}
+//
+//			// 存取所有的信息点
+//			Map<Integer, String> infoMap = new HashMap<Integer, String>();
+//			short lastCellNum = row1.getLastCellNum();
+//			for (int i = 1; i <= lastCellNum; i++) {
+//				XSSFCell xssfCell = row1.getCell(i);
+//				if (xssfCell != null && xssfCell.getStringCellValue() != null) {
+//					infoMap.put(i, xssfCell.getStringCellValue().trim());
+//				}
+//			}
+//
+//			// 录入数据获取
+//			int lastRowNum = sheet.getLastRowNum();
+//			boolean isClassCode = "classCode".equals(primaryKey);
+//			for (int i = 2; i <= lastRowNum; i++) {
+//				XSSFRow xssfRow = sheet.getRow(i);
+//				if (xssfRow == null) {
+//					continue;
+//				}
+//
+//				String value = null;
+//				String classCode = null;
+//				ObjectNode equipment = null;
+//				List<ObjectNode> equipmentList = null;
+//				Map<String, Object> tempMap = new HashMap<String, Object>();
+//
+//				lastCellNum = xssfRow.getLastCellNum();
+//				for (int j = 0; j <= lastCellNum; j++) {
+//					cell = xssfRow.getCell(j);
+//					if (cell == null || StrUtil.isBlank(cell.getRawValue())) {
+//						xssfRow.createCell(j);
+//						if (j == 0) {
+//							this.setColor(workbook, 252, 255, 77, xssfRow.getCell(j));
+//						} else {
+//							this.setColor(workbook, 77, 178, 255, xssfRow.getCell(j));
+//						}
+//						continue;
+//					}
+//					if (j == 0) {
+//						cell.setCellType(CellType.STRING);
+//						value = cell.getStringCellValue().trim();
+//						String codeType = isClassCode ? xssfRow.getCell(0).toString().trim() : xssfRow.getCell(1).toString().trim();
+//						// 获取类型定义
+//						ObjectTypeDefine define = this.getObjectTypeDefine(groupCode, projectId, codeType);
+//						if (define == null) {
+//							this.setColor(workbook, 56, 94, 15, cell);
+//							continue;
+//						}
+//						classCode = define.getCode();
+//						equipmentList = isClassCode ? this.getEquipmentList(groupCode, projectId, null, null, classCode)
+//								: this.getEquipmentList(groupCode, projectId, primaryKey, value, classCode);
+//
+//						if (CollectionUtil.isEmpty(equipmentList)) {
+//							failurNum++;
+//							this.setColor(workbook, 153, 225, 77, cell);
+//							continue;
+//						}
+//
+//						if (isClassCode) {
+//							equipment = equipmentList.get(0);
+//						} else {
+//							if (equipmentList.size() > 1) {
+//								failurNum++;
+//								this.setColor(workbook, 249, 203, 77, cell);
+//							} else {
+//								equipment = equipmentList.get(0);
+//							}
+//						}
+//
+//						continue;
+//					}
+//					// 剩余列数据处理
+//					if (j != 1 && equipment != null && infoMap.containsKey(j)) {
+//						// 获取设备类的信息点
+//						List<ObjectInfoDefine> funidList = this.relationReportService.queryFunidList(groupCode, projectId, Sets.newHashSet(classCode), infoMap.get(j), "STATIC");
+//						if (CollectionUtil.isEmpty(funidList)) {
+//							failurNum++;
+//							this.setColor(workbook, 77, 178, 255, cell);
+//							continue;
+//						}
+//						ObjectInfoDefine define = funidList.get(0);
+//						if ("STRING".equalsIgnoreCase(define.getDataType())) {
+//							cell.setCellType(CellType.STRING);
+//							tempMap.put(define.getCode(), cell.getStringCellValue().trim());
+//						} else if ("INTEGER".equalsIgnoreCase(define.getDataType())) {
+//							try {
+//								if (!CellType.NUMERIC.equals(cell.getCellTypeEnum()) || StrUtil.isBlank(cell.getRawValue())) {
+//									failurNum++;
+//									this.setColor(workbook, 155, 227, 255, cell);
+//									continue;
+//								}
+//								cell.setCellType(CellType.STRING);
+//								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
+//							} catch (Exception e) {
+//								failurNum++;
+//								this.setColor(workbook, 155, 227, 255, cell);
+//								continue;
+//							}
+//						} else if ("ENUM".equalsIgnoreCase(define.getDataType())) {
+//							if (CellType.NUMERIC.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
+//								cell.setCellType(CellType.STRING);
+//								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
+//							} else if (CellType.STRING.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
+//								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
+//							} else {
+//								failurNum++;
+//								this.setColor(workbook, 155, 227, 255, cell);
+//								continue;
+//							}
+//						} else if ("DATETIME".equalsIgnoreCase(define.getDataType())) {
+//							try {
+//								cell.setCellType(CellType.STRING);
+//								String trim = cell.getStringCellValue().trim();
+//								tempMap.put(define.getCode(), DateUtil.parseByPatterns(trim, "yyyyMMdd"));
+//							} catch (Exception e) {
+//								failurNum++;
+//								this.setColor(workbook, 155, 227, 255, cell);
+//								continue;
+//							}
+//						} else if ("DOUBLE".equalsIgnoreCase(define.getDataType())) {
+//							try {
+//								cell.setCellType(CellType.STRING);
+//								String trim = cell.getStringCellValue().trim();
+//								tempMap.put(define.getCode(), Double.parseDouble(trim));
+//							} catch (Exception e) {
+//								failurNum++;
+//								this.setColor(workbook, 155, 227, 255, cell);
+//								continue;
+//							}
+//						} else if ("BOOLEAN".equalsIgnoreCase(define.getDataType())) {
+//							cell.setCellType(CellType.STRING);
+//							String trim = cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
+//							if ("1".equals(trim) || "0".equals(trim)) {
+//								tempMap.put(define.getCode(), Double.parseDouble(trim));
+//							} else {
+//								failurNum++;
+//								this.setColor(workbook, 155, 227, 255, cell);
+//								continue;
+//							}
+//						} else {
+//							failurNum++;
+//							this.setColor(workbook, 204, 99, 233, cell);
+//							continue;
+//						}
+//					}
+//				}
+//
+//				if (isClassCode) {
+//					if (CollectionUtil.isNotEmpty(equipmentList) && tempMap.size() > 0) {
+//						for (ObjectNode equipNode : equipmentList) {
+//							int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipNode.get("id").asText());
+//							if (success == 0) {
+//								failurNum++;
+//							} else {
+//								successCount++;
+//							}
+//						}
+//					}
+//				} else {
+//					if (StrUtil.isNotBlank(value) && equipment != null && tempMap.size() > 0) {
+//						int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipment.get("id").asText());
+//						if (success == 0) {
+//							failurNum++;
+//						} else {
+//							successCount++;
+//						}
+//					}
+//				}
+//			}
+//
+//			// 写入错误报告对比值颜色
+//			this.wirteReport(workbook, sheet);
+//
+//			// 返回正确结果
+//			String fileName = AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+//			return AdmExcelUtil.getImportSuccessResult(fileName, successCount, failurNum);
+//		} catch (Exception e) {
+//			log.error("台账信息导入失败", e);
+//			failure = e.getMessage();
+//		} finally {
+//			if (fileOutputStream != null) {
+//				try {
+//					fileOutputStream.flush();
+//					fileOutputStream.close();
+//				} catch (IOException e) {}
+//			}
+//			if (workbook != null) {
+//				try {
+//					workbook.close();
+//				} catch (IOException e) {}
+//			}
+//		}
+//		return AdmResponse.failure(failure);
+//	}
+	/**
+	 * 设备上传excel识别静态信息点
+	 *
+	 * @param file
+	 * @param request
+	 * @param response
+	 */
 	@RequestMapping("/import")
 	public AdmResponse importFile(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
 		if (file == null) {
@@ -399,36 +667,29 @@ public class AdmEquipmentController {
 		String failure = null;
 		String primaryKey = null;
 		String classCodeCloumn = null;
-		XSSFWorkbook workbook = null;
+		Workbook workbook = null;
 		FileOutputStream fileOutputStream = null;
 		String groupCode = AppContext.getContext().getGroupCode();
 		String projectId = AppContext.getContext().getProjectId();
 		try {
-
-			workbook = new XSSFWorkbook(file.getInputStream());
-			XSSFSheet sheet = workbook.getSheetAt(0);	// 第一个sheet
-			XSSFRow row1 = sheet.getRow(1);
-			if (row1 == null) {
-				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
-				return AdmExcelUtil.getImportFailResult("数据不存在", "2", 0, ++failurNum);
-			}
-
+			byte[] bytes = IoUtil.readBytes(file.getInputStream());
+			workbook = WorkbookUtil.createBook(IoUtil.toStream(bytes));
+			Sheet sheet = WorkbookUtil.getOrCreateSheet(workbook, 0);
+			Row row1 = RowUtil.getOrCreateRow(sheet, 1);
 			/** 获取识别码 */
-			XSSFCell markCell = row1.getCell(0);
+			Cell markCell = CellUtil.getCell(row1, 0);
 			if (markCell == null) {
 				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
 				return AdmExcelUtil.getImportFailResult("未填写识别码", "2", 0, ++failurNum);
 			}
-			primaryKey = markCell.getStringCellValue().trim(); 	// 识别码
-			boolean containsKey = AdmCommonConstant.codeColMap.containsKey(primaryKey);
-			if (!containsKey) {
+			primaryKey = StrUtil.toString(CellUtil.getCellValue(markCell,true)); 	// 识别码
+			if (!AdmCommonConstant.codeColMap.containsKey(primaryKey)) {
 				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
 				return AdmExcelUtil.getImportFailResult("未找到识别码", "2", 0, ++failurNum);
 			}
 			primaryKey = AdmCommonConstant.codeColMap.get(primaryKey);
-
 			/** 获取类型 */
-			XSSFCell cell = row1.getCell(1);
+			Cell cell = CellUtil.getCell(row1,1);
 			if (cell == null) {
 				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
 				return AdmExcelUtil.getImportFailResult("未填写设备类型", "2", 0, ++failurNum);
@@ -438,180 +699,215 @@ public class AdmEquipmentController {
 				AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
 				return AdmExcelUtil.getImportFailResult("缺少设备类型(ClassCode)", "2", 0, ++failurNum);
 			}
-
+			// 写入错误报告对比值颜色
+			this.wirteReport(workbook, sheet);
 			// 存取所有的信息点
-			Map<Integer, String> infoMap = new HashMap<Integer, String>();
-			short lastCellNum = row1.getLastCellNum();
-			for (int i = 1; i <= lastCellNum; i++) {
-				XSSFCell xssfCell = row1.getCell(i);
-				if (xssfCell != null && xssfCell.getStringCellValue() != null) {
-					infoMap.put(i, xssfCell.getStringCellValue().trim());
-				}
+			Map<Integer, String> infoMap = new HashMap<>();
+			List<Object> row1List = RowUtil.readRow(row1, new TrimEditor());
+			for (int i = 1; i < row1List.size(); i++) {
+				infoMap.put(i,StrUtil.toString(row1List.get(i)));
 			}
-
-			// 录入数据获取
-			int lastRowNum = sheet.getLastRowNum();
 			boolean isClassCode = "classCode".equals(primaryKey);
-			for (int i = 2; i <= lastRowNum; i++) {
-				XSSFRow xssfRow = sheet.getRow(i);
-				if (xssfRow == null) {
+			ExcelReader excelReader = ExcelUtil.getReader(IoUtil.toStream(bytes), 0);
+			List<List<Object>> listList = excelReader.read();
+			// 1.存储设备类型code
+			Set<String> classCodes = CollUtil.newHashSet();
+			// 2.存储primaryKey对应的值
+			Set<String> primaryMess = CollUtil.newHashSet();
+			for (int i = 2; i < listList.size(); i++) {
+				List<Object> objects = listList.get(i);
+				if (CollUtil.isEmpty(objects)){
 					continue;
 				}
-
-				String value = null;
-				String classCode = null;
-				ObjectNode equipment = null;
-				List<ObjectNode> equipmentList = null;
-				Map<String, Object> tempMap = new HashMap<String, Object>();
-
-				lastCellNum = xssfRow.getLastCellNum();
-				for (int j = 0; j <= lastCellNum; j++) {
-					cell = xssfRow.getCell(j);
-					if (cell == null || StrUtil.isBlank(cell.getRawValue())) {
-						xssfRow.createCell(j);
-						if (j == 0) {
-							this.setColor(workbook, 252, 255, 77, xssfRow.getCell(j));
-						} else {
-							this.setColor(workbook, 77, 178, 255, xssfRow.getCell(j));
-						}
+				if (null==objects.get(0) || StrUtil.isBlank(StrUtil.toString(objects.get(0)))){
+					this.setColor(workbook, 252, 255, 77,
+							CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(sheet,i),0));
+					continue;
+				}
+				if (!isClassCode && (null==objects.get(1) || StrUtil.isBlank(StrUtil.toString(objects.get(1))))){
+					// 第一个cell为空或者非classCode上传并且第二个cell为空
+					this.setColor(workbook, 252, 255, 77,
+							CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(sheet,i),0));
+					continue;
+				}
+				if (isClassCode){
+					classCodes.add(StrUtil.toString(objects.get(0)));
+					continue;
+				}
+				classCodes.add(StrUtil.toString(objects.get(1)));
+				primaryMess.add(StrUtil.toString(objects.get(0)));
+			}
+			if (isClassCode && CollUtil.isEmpty(classCodes)){
+				// 设备类型code集合为空
+				String fileName = AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+				return AdmExcelUtil.getImportSuccessResult(fileName, successCount, listList.size());
+			}
+			if (!isClassCode && (CollUtil.isEmpty(primaryMess) || CollUtil.isEmpty(classCodes))){
+				// 设备类型code集合或唯一标识为空
+				String fileName = AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
+				return AdmExcelUtil.getImportSuccessResult(fileName, successCount, listList.size());
+			}
+			// 1.根据设备类型code集合查询定义
+			Map<String,ObjectTypeDefine> defineMap = queryDefineTypeMapByClassCodes(classCodes);
+			// 2.根据设备类型code集合查询设备类的信息点
+			Map<String,List<ObjectInfoDefine>> defineInfoMap = queryDefineInfoMapByClassCodes(classCodes);
+			// 3.根据是否根据设备类型code上传来区分处理
+			Map<String,List<ObjectNode>> objectDigitalMap = CollUtil.newHashMap();
+			if (isClassCode){
+				objectDigitalMap=queryEquipsByClassCodes(classCodes);
+			}else {
+				objectDigitalMap=queryEquipsByConditions(primaryKey,primaryMess,classCodes);
+			}
+			List<ObjectNode> updateObjs = new ArrayList<>();
+			ObjectNode equipment = null;
+			List<ObjectNode> equipmentList = null;
+			for (int i = 2; i < listList.size(); i++) {
+				List<Object> objects = listList.get(i);
+				if (CollUtil.isEmpty(objects)){
+					continue;
+				}
+				if ((null==objects.get(0) || StrUtil.isBlank(StrUtil.toString(objects.get(0))))
+						|| (!isClassCode && (null==objects.get(1) || StrUtil.isBlank(StrUtil.toString(objects.get(1)))))){
+					failurNum++;
+					continue;
+				}
+				String classCode = isClassCode?StrUtil.toString(objects.get(0)):StrUtil.toString(objects.get(1));
+				if (!defineMap.containsKey(classCode)){
+					failurNum++;
+					this.setColor(workbook, 56, 94, 15, CellUtil.getCell(RowUtil.getOrCreateRow(sheet, i), isClassCode?0:1));
+					continue;
+				}
+				classCode = defineMap.get(classCode).getCode();
+				equipmentList = isClassCode ? objectDigitalMap.get(classCode)
+						: objectDigitalMap.get(StrUtil.toString(objects.get(0)) + StrUtil.UNDERLINE + classCode);
+				if (CollectionUtil.isEmpty(equipmentList)) {
+					failurNum++;
+					this.setColor(workbook, 153, 225, 77, CellUtil.getCell(RowUtil.getOrCreateRow(sheet, i), 0));
+					continue;
+				}
+				if (isClassCode) {
+					equipment = equipmentList.get(0);
+				} else {
+					if (equipmentList.size() > 1) {
+						failurNum++;
+						this.setColor(workbook, 249, 203, 77, CellUtil.getCell(RowUtil.getOrCreateRow(sheet, i), 1));
+						continue;
+					} else {
+						equipment = equipmentList.get(0);
+					}
+				}
+				boolean changeFlag = true;
+				for (int j = 0; j < objects.size(); j++) {
+					// 剩余列数据处理
+					if (!infoMap.containsKey(j)) {
+						continue;
+					}
+					Cell tempCell = CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(sheet, i), j);
+					// 如果值为空直接跳过
+					if (StrUtil.isBlank(StrUtil.toString(CellUtil.getCellValue(tempCell,true)))){
 						continue;
 					}
-					if (j == 0) {
-						cell.setCellType(CellType.STRING);
-						value = cell.getStringCellValue().trim();
-						String codeType = isClassCode ? xssfRow.getCell(0).toString().trim() : xssfRow.getCell(1).toString().trim();
-						// 获取类型定义
-						ObjectTypeDefine define = this.getObjectTypeDefine(groupCode, projectId, codeType);
-						if (define == null) {
-							this.setColor(workbook, 56, 94, 15, cell);
+					// 获取设备类的信息点
+					String code = infoMap.get(j);
+					List<ObjectInfoDefine> funidList = defineInfoMap.getOrDefault(classCode,new ArrayList<>())
+							.stream().filter(func->code.equals(func.getAliasCode()) && "STATIC".equals(func.getCategory()))
+							.collect(Collectors.toList());
+					if (CollectionUtil.isEmpty(funidList)) {
+						failurNum++;
+						this.setColor(workbook, 77, 178, 255, tempCell);
+						changeFlag=false;
+						continue;
+					}
+					ObjectInfoDefine define = funidList.get(0);
+					if ("STRING".equalsIgnoreCase(define.getDataType())) {
+						tempCell.setCellType(CellType.STRING);
+						equipment.put(define.getCode(), tempCell.getStringCellValue().trim());
+					} else if ("INTEGER".equalsIgnoreCase(define.getDataType())) {
+						try {
+							if (!CellType.NUMERIC.equals(tempCell.getCellTypeEnum())
+									|| StrUtil.isBlank(StrUtil.toString(CellUtil.getCellValue(tempCell,true)))) {
+								failurNum++;
+								this.setColor(workbook, 155, 227, 255, tempCell);
+								changeFlag=false;
+								continue;
+							}
+							tempCell.setCellType(CellType.STRING);
+							equipment.put(define.getCode(), tempCell.getStringCellValue().trim());
+						} catch (Exception e) {
+							failurNum++;
+							this.setColor(workbook, 155, 227, 255, tempCell);
+							changeFlag=false;
 							continue;
 						}
-						classCode = define.getCode();
-						equipmentList = isClassCode ? this.getEquipmentList(groupCode, projectId, null, null, classCode)
-								: this.getEquipmentList(groupCode, projectId, primaryKey, value, classCode);
-
-						if (CollectionUtil.isEmpty(equipmentList)) {
+					} else if ("ENUM".equalsIgnoreCase(define.getDataType())) {
+						if (CellType.NUMERIC.equals(tempCell.getCellTypeEnum())
+								&& StrUtil.isNotBlank(StrUtil.toString(CellUtil.getCellValue(tempCell,true)))) {
+							tempCell.setCellType(CellType.STRING);
+							equipment.put(define.getCode(), tempCell.getStringCellValue().trim());
+						} else if (CellType.STRING.equals(tempCell.getCellTypeEnum())
+								&& StrUtil.isNotBlank(StrUtil.toString(CellUtil.getCellValue(tempCell,true)))) {
+							equipment.put(define.getCode(), tempCell.getStringCellValue().trim());
+						} else {
 							failurNum++;
-							this.setColor(workbook, 153, 225, 77, cell);
+							this.setColor(workbook, 155, 227, 255, tempCell);
+							changeFlag=false;
 							continue;
 						}
-
-						if (isClassCode) {
-							equipment = equipmentList.get(0);
-						} else {
-							if (equipmentList.size() > 1) {
-								failurNum++;
-								this.setColor(workbook, 249, 203, 77, cell);
-							} else {
-								equipment = equipmentList.get(0);
-							}
+					} else if ("DATETIME".equalsIgnoreCase(define.getDataType())) {
+						try {
+							tempCell.setCellType(CellType.STRING);
+							String trim = tempCell.getStringCellValue().trim();
+							DateUtil.parseByPatterns(trim, "yyyyMMdd");
+							equipment.put(define.getCode(), trim);
+						} catch (Exception e) {
+							failurNum++;
+							this.setColor(workbook, 155, 227, 255, tempCell);
+							changeFlag=false;
+							continue;
 						}
-
-						continue;
-					}
-					// 剩余列数据处理
-					if (j != 1 && equipment != null && infoMap.containsKey(j)) {
-						// 获取设备类的信息点
-						List<ObjectInfoDefine> funidList = this.relationReportService.queryFunidList(groupCode, projectId, Sets.newHashSet(classCode), infoMap.get(j), "STATIC");
-						if (CollectionUtil.isEmpty(funidList)) {
+					} else if ("DOUBLE".equalsIgnoreCase(define.getDataType())) {
+						try {
+							tempCell.setCellType(CellType.STRING);
+							String trim = tempCell.getStringCellValue().trim();
+							equipment.put(define.getCode(), Double.parseDouble(trim));
+						} catch (Exception e) {
 							failurNum++;
-							this.setColor(workbook, 77, 178, 255, cell);
+							this.setColor(workbook, 155, 227, 255, tempCell);
+							changeFlag=false;
 							continue;
 						}
-						ObjectInfoDefine define = funidList.get(0);
-						if ("STRING".equalsIgnoreCase(define.getDataType())) {
-							cell.setCellType(CellType.STRING);
-							tempMap.put(define.getCode(), cell.getStringCellValue().trim());
-						} else if ("INTEGER".equalsIgnoreCase(define.getDataType())) {
-							try {
-								if (!CellType.NUMERIC.equals(cell.getCellTypeEnum()) || StrUtil.isBlank(cell.getRawValue())) {
-									failurNum++;
-									this.setColor(workbook, 155, 227, 255, cell);
-									continue;
-								}
-								cell.setCellType(CellType.STRING);
-								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
-							} catch (Exception e) {
-								failurNum++;
-								this.setColor(workbook, 155, 227, 255, cell);
-								continue;
-							}
-						} else if ("ENUM".equalsIgnoreCase(define.getDataType())) {
-							if (CellType.NUMERIC.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
-								cell.setCellType(CellType.STRING);
-								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
-							} else if (CellType.STRING.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
-								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
-							} else {
-								failurNum++;
-								this.setColor(workbook, 155, 227, 255, cell);
-								continue;
-							}
-						} else if ("DATETIME".equalsIgnoreCase(define.getDataType())) {
-							try {
-								cell.setCellType(CellType.STRING);
-								String trim = cell.getStringCellValue().trim();
-								tempMap.put(define.getCode(), DateUtil.parseByPatterns(trim, "yyyyMMdd"));
-							} catch (Exception e) {
-								failurNum++;
-								this.setColor(workbook, 155, 227, 255, cell);
-								continue;
-							}
-						} else if ("DOUBLE".equalsIgnoreCase(define.getDataType())) {
-							try {
-								cell.setCellType(CellType.STRING);
-								String trim = cell.getStringCellValue().trim();
-								tempMap.put(define.getCode(), Double.parseDouble(trim));
-							} catch (Exception e) {
-								failurNum++;
-								this.setColor(workbook, 155, 227, 255, cell);
-								continue;
-							}
-						} else if ("BOOLEAN".equalsIgnoreCase(define.getDataType())) {
-							cell.setCellType(CellType.STRING);
-							String trim = cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
-							if ("1".equals(trim) || "0".equals(trim)) {
-								tempMap.put(define.getCode(), Double.parseDouble(trim));
-							} else {
-								failurNum++;
-								this.setColor(workbook, 155, 227, 255, cell);
-								continue;
-							}
+					} else if ("BOOLEAN".equalsIgnoreCase(define.getDataType())) {
+						tempCell.setCellType(CellType.STRING);
+						String trim = tempCell.getStringCellValue() == null ? null : tempCell.getStringCellValue().trim();
+						if ("1".equals(trim) || "0".equals(trim)) {
+							equipment.put(define.getCode(), Double.parseDouble(trim));
 						} else {
 							failurNum++;
-							this.setColor(workbook, 204, 99, 233, cell);
+							this.setColor(workbook, 155, 227, 255, tempCell);
+							changeFlag=false;
 							continue;
 						}
+					} else {
+						failurNum++;
+						this.setColor(workbook, 204, 99, 233, tempCell);
+						changeFlag=false;
+						continue;
 					}
 				}
-
-				if (isClassCode) {
-					if (CollectionUtil.isNotEmpty(equipmentList) && tempMap.size() > 0) {
-						for (ObjectNode equipNode : equipmentList) {
-							int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipNode.get("id").asText());
-							if (success == 0) {
-								failurNum++;
-							} else {
-								successCount++;
-							}
-						}
-					}
-				} else {
-					if (StrUtil.isNotBlank(value) && equipment != null && tempMap.size() > 0) {
-						int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipment.get("id").asText());
-						if (success == 0) {
-							failurNum++;
-						} else {
-							successCount++;
-						}
-					}
+				if (changeFlag){
+					updateObjs.add(equipment);
 				}
 			}
-
-			// 写入错误报告对比值颜色
-			this.wirteReport(workbook, sheet);
-
-			// 返回正确结果
+			// 5.更新对象数据
+			if (CollUtil.isNotEmpty(updateObjs)){
+				successCount=updateObjs.size();
+				DigitalObjectFacade.update(AppContext.getContext().getGroupCode(),
+						AppContext.getContext().getProjectId(),
+						AppContext.getContext().getAppId(),
+						AppContext.getContext().getAccountId(),
+						updateObjs);
+			}
+			// 设备类型code集合或唯一标识为空
 			String fileName = AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
 			return AdmExcelUtil.getImportSuccessResult(fileName, successCount, failurNum);
 		} catch (Exception e) {
@@ -632,6 +928,122 @@ public class AdmEquipmentController {
 		}
 		return AdmResponse.failure(failure);
 	}
+	/***
+	 * Description:
+	 * @param primaryKey :
+	 * @param primaryMess :
+     * @param classCodes :
+	 * @return : java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.node.ObjectNode>>
+	 * @author : lijie
+	 * @date :2021/11/16 16:34
+	 * Update By lijie 2021/11/16 16:34
+	 */
+	private Map<String, List<ObjectNode>> queryEquipsByConditions(String primaryKey, Set<String> primaryMess,
+																  Set<String> classCodes) throws Exception{
+		if (CollUtil.isEmpty(primaryMess) || CollUtil.isEmpty(classCodes)){
+			return new HashMap<>();
+		}
+		QueryCriteria queryCriteria = new QueryCriteria();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		ObjectNode criteria = objectMapper.createObjectNode();
+		criteria.put(ObjectTypeDefine.PROP_VALID,Boolean.TRUE);
+		criteria.put(ObjectDigital.CLASS_CODE_HUM,objectMapper.readTree(objectMapper.writeValueAsString(classCodes)));
+		criteria.put(primaryKey,objectMapper.readTree(objectMapper.writeValueAsString(primaryMess)));
+		queryCriteria.setCriteria(criteria);
+		List<ObjectNode> objectNodes = DigitalObjectFacade.query(AppContext.getContext().getGroupCode(),
+				AppContext.getContext().getProjectId(), AppContext.getContext().getAppId(),
+				AppContext.getContext().getAccountId(), queryCriteria);
+		if (CollUtil.isEmpty(objectNodes)){
+			return new HashMap<>();
+		}
+		return objectNodes.stream().filter(obj->obj.has("classCode")
+				&& obj.has(primaryKey)
+				&& obj.get("classCode").isTextual()
+				&& obj.get(primaryKey).isTextual())
+				.collect(Collectors.groupingBy(obj->obj.get(primaryKey).asText()+StrUtil.UNDERLINE+obj.get("classCode").asText()));
+	}
+
+	/***
+	 * Description: 根据设备类型编码集合查询映射关系
+	 * @param classCodes : 设备类型编码集合
+	 * @return : java.util.Map<java.lang.String,java.util.List<com.persagy.dmp.digital.entity.ObjectDigital>>
+	 * @author : lijie
+	 * @date :2021/11/16 16:25
+	 * Update By lijie 2021/11/16 16:25
+	 */
+	private Map<String, List<ObjectNode>> queryEquipsByClassCodes(Set<String> classCodes) {
+		if (CollUtil.isEmpty(classCodes)){
+			return new HashMap<>();
+		}
+		Map<String, List<ObjectNode>> result = new HashMap<>();
+		for (String classCode : classCodes) {
+			QueryCriteria queryCriteria = new QueryCriteria();
+			ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+			ObjectNode criteria = objectMapper.createObjectNode();
+			criteria.put(ObjectTypeDefine.PROP_VALID,Boolean.TRUE);
+			criteria.put(ObjectDigital.CLASS_CODE_HUM,classCode);
+			List<ObjectNode> objectNodes = DigitalObjectFacade.query(AppContext.getContext().getGroupCode(),
+					AppContext.getContext().getProjectId(),
+					AppContext.getContext().getAppId(), AppContext.getContext().getAccountId(), queryCriteria);
+			result.put(classCode,CollUtil.defaultIfEmpty(objectNodes,
+					CollUtil.newArrayList()));
+		}
+		return result;
+	}
+
+	/***
+	 * Description: 根据设备类型code集合查询信息点定义
+	 * @param classCodes : 设备类型code集合
+	 * @return : java.util.Map<java.lang.String,java.util.List<com.persagy.dmp.define.entity.ObjectInfoDefine>>
+	 * @author : lijie
+	 * @date :2021/11/16 16:18
+	 * Update By lijie 2021/11/16 16:18
+	 */
+	private Map<String, List<ObjectInfoDefine>> queryDefineInfoMapByClassCodes(Set<String> classCodes) throws Exception {
+		if (CollUtil.isEmpty(classCodes)){
+			return new HashMap<>();
+		}
+		QueryCriteria queryCriteria = new QueryCriteria();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		ObjectNode criteria = objectMapper.createObjectNode();
+		criteria.put(ObjectTypeDefine.PROP_VALID,Boolean.TRUE);
+		criteria.set(ObjectDigital.CLASS_CODE_HUM,objectMapper.readTree(objectMapper.writeValueAsString(classCodes)));
+		queryCriteria.setCriteria(criteria);
+		List<ObjectInfoDefine> objectInfoDefines = DigitalObjectInfoFacade.query(AppContext.getContext().getGroupCode(),
+				AppContext.getContext().getProjectId(), AppContext.getContext().getAppId(),
+				AppContext.getContext().getAccountId(), queryCriteria);
+		if (CollUtil.isEmpty(objectInfoDefines)){
+			return new HashMap<>();
+		}
+		return objectInfoDefines.stream().collect(Collectors.groupingBy(ObjectInfoDefine::getClassCode));
+	}
+
+	/***
+	 * Description: 根据设备类型code集合查询类型定义
+	 * @param classCodes : 设备类型code集合
+	 * @return : java.util.Map<java.lang.String,com.persagy.dmp.define.entity.ObjectTypeDefine>
+	 * @author : lijie
+	 * @date :2021/11/16 16:00
+	 * Update By lijie 2021/11/16 16:00
+	 */
+	private Map<String, ObjectTypeDefine> queryDefineTypeMapByClassCodes(Set<String> classCodes) throws Exception {
+		if (CollUtil.isEmpty(classCodes)){
+			return new HashMap<>();
+		}
+		QueryCriteria queryCriteria = new QueryCriteria();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		ObjectNode criteria = objectMapper.createObjectNode();
+		criteria.put(ObjectTypeDefine.PROP_VALID,Boolean.TRUE);
+		criteria.set("code",objectMapper.readTree(objectMapper.writeValueAsString(classCodes)));
+		queryCriteria.setCriteria(criteria);
+		List<ObjectTypeDefine> objectTypeDefines = DigitalDefineFacade.queryObjectType(AppContext.getContext().getGroupCode(),
+				AppContext.getContext().getProjectId(), AppContext.getContext().getAppId(),
+				AppContext.getContext().getAccountId(), queryCriteria);
+		if (CollUtil.isEmpty(objectTypeDefines)){
+			return new HashMap<>();
+		}
+		return objectTypeDefines.stream().collect(Collectors.toMap(ObjectTypeDefine::getCode, def->def,(k1, k2)->k1));
+	}
 
 	/**
 	 * 更新设备信息
@@ -716,11 +1128,11 @@ public class AdmEquipmentController {
 	 * @param b
 	 * @param cell
 	 */
-	private void setColor(XSSFWorkbook workbook, int r, int g, int b, XSSFCell cell) {
-		XSSFCellStyle createCellStyle = workbook.createCellStyle();
-		createCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-		createCellStyle.setFillForegroundColor(new XSSFColor(new Color(r, g, b)));
-		cell.setCellStyle(createCellStyle);
+	private void setColor(Workbook workbook, int r, int g, int b, Cell cell) {
+		XSSFCellStyle cellStyle = (XSSFCellStyle) workbook.createCellStyle();
+		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+		cellStyle.setFillForegroundColor(new XSSFColor(new Color(r, g, b)));
+		cell.setCellStyle(cellStyle);
 	}
 
 	/**
@@ -729,19 +1141,19 @@ public class AdmEquipmentController {
 	 * @param workbook
 	 * @param sheet
 	 */
-	private void wirteReport(XSSFWorkbook workbook, XSSFSheet sheet) {
-		XSSFRow row = sheet.getRow(1);
+	private void wirteReport(Workbook workbook, Sheet sheet) {
+		Row row = sheet.getRow(1);
 		short column = (short) (row.getLastCellNum() + 2);
-		XSSFRow row4 = sheet.getRow(4);
+		Row row4 = sheet.getRow(4);
 		if (row4 == null) {
 			row4 = sheet.createRow(4);
 		}
-		XSSFCell createCell = row4.createCell(column);
+		Cell createCell = row4.createCell(column);
 		createCell.setCellValue("导入失败,识别码超出范围(本地编码,设备类型)");
 		createCell = row4.createCell(column + 1);
 		this.setColor(workbook,233,99,99,createCell);
 
-		XSSFRow row5 = sheet.getRow(5);
+		Row row5 = sheet.getRow(5);
 		if (row5 == null) {
 			row5 = sheet.createRow(5);
 		}
@@ -750,7 +1162,7 @@ public class AdmEquipmentController {
 		createCell = row5.createCell(column + 1);
 		this.setColor(workbook,252,147,77,createCell);
 
-		XSSFRow row6 = sheet.getRow(6);
+		Row row6 = sheet.getRow(6);
 		if (row6 == null) {
 			row6 = sheet.createRow(6);
 		}
@@ -759,7 +1171,7 @@ public class AdmEquipmentController {
 		createCell = row6.createCell(column + 1);
 		this.setColor(workbook,249,203,77,createCell);
 
-		XSSFRow row7 = sheet.getRow(7);
+		Row row7 = sheet.getRow(7);
 		if (row7 == null) {
 			row7 = sheet.createRow(7);
 		}
@@ -768,7 +1180,7 @@ public class AdmEquipmentController {
 		createCell = row7.createCell(column + 1);
 		this.setColor(workbook,153,225,77,createCell);
 
-		XSSFRow row8 = sheet.getRow(8);
+		Row row8 = sheet.getRow(8);
 		if (row8 == null) {
 			row8 = sheet.createRow(8);
 		}
@@ -777,7 +1189,7 @@ public class AdmEquipmentController {
 		createCell = row8.createCell(column + 1);
 		this.setColor(workbook,252,255,77,createCell);
 
-		XSSFRow row9 = sheet.getRow(9);
+		Row row9 = sheet.getRow(9);
 		if (row9 == null) {
 			row9 = sheet.createRow(9);
 		}
@@ -786,7 +1198,7 @@ public class AdmEquipmentController {
 		createCell = row9.createCell(column + 1);
 		this.setColor(workbook,155,227,255,createCell);
 
-		XSSFRow row10 = sheet.getRow(10);
+		Row row10 = sheet.getRow(10);
 		if (row10 == null) {
 			row10 = sheet.createRow(10);
 		}
@@ -795,7 +1207,7 @@ public class AdmEquipmentController {
 		createCell = row10.createCell(column + 1);
 		this.setColor(workbook,204,99,233,createCell);
 
-		XSSFRow row11 = sheet.getRow(11);
+		Row row11 = sheet.getRow(11);
 		if (row11 == null) {
 			row11 = sheet.createRow(11);
 		}
@@ -804,7 +1216,7 @@ public class AdmEquipmentController {
 		createCell = row11.createCell(column + 1);
 		this.setColor(workbook,77,178,255,createCell);
 
-		XSSFRow row12 = sheet.getRow(12);
+		Row row12 = sheet.getRow(12);
 		if (row12 == null) {
 			row12 = sheet.createRow(12);
 		}