From a2c3c7a3032ac93bbcfd83f055b036f7e8b6c20b Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: 星期三, 27 七月 2022 18:13:00 +0800
Subject: [PATCH] fix
---
equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/entity/EmergencyDrillEvaluationFileInfo.java | 117 +++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLog.java | 79 ++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/ExcApprove.java | 33 +
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyWorkApproveController.java | 2
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelUtil.java | 758 +++++++++++++++++++++++++
equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/enums/EquipmentResultCodes.java | 31 +
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelSheet.java | 66 ++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetMngExcel.java | 114 +++
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyWorkApproveServiceImpl.java | 4
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelCell.java | 81 ++
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyWorkApproveServiceImpl.java | 4
tmlog.lck | 0
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/TargetMngImportExcel.java | 100 +++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetDutySummaryExcel.java | 174 +++++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/DateUtils.java | 81 ++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLogs.java | 62 ++
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/FieldForSortting.java | 61 ++
17 files changed, 1,762 insertions(+), 5 deletions(-)
diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyWorkApproveController.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyWorkApproveController.java
index 00db525..96cf0cf 100644
--- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyWorkApproveController.java
+++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyWorkApproveController.java
@@ -16,7 +16,7 @@
import java.util.List;
@RestController
-@RequestMapping("/WorkApprove")
+@RequestMapping("/emergencyWorkApprove")
public class EmergencyWorkApproveController {
@Autowired
diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyEmergencyWorkApproveServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyWorkApproveServiceImpl.java
similarity index 89%
rename from emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyEmergencyWorkApproveServiceImpl.java
rename to emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyWorkApproveServiceImpl.java
index 571f55b..8c768c7 100644
--- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyEmergencyWorkApproveServiceImpl.java
+++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyWorkApproveServiceImpl.java
@@ -13,8 +13,8 @@
import java.util.List;
-@Service("workApproveInfoService")
-public class EmergencyEmergencyWorkApproveServiceImpl extends ServiceImpl<EmergencyWorkApproveInfoRepository, EmergencyWorkApproveInfo> implements EmergencyWorkApproveInfoService {
+@Service("emergencyWorkApproveInfoService")
+public class EmergencyWorkApproveServiceImpl extends ServiceImpl<EmergencyWorkApproveInfoRepository, EmergencyWorkApproveInfo> implements EmergencyWorkApproveInfoService {
@Autowired
private EmergencyWorkApproveInfoRepository EmergencyWorkApproveInfoRepository;
diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyEmergencyWorkApproveServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyWorkApproveServiceImpl.java
similarity index 97%
rename from emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyEmergencyWorkApproveServiceImpl.java
rename to emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyWorkApproveServiceImpl.java
index fcedc40..09acac0 100644
--- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyEmergencyWorkApproveServiceImpl.java
+++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyWorkApproveServiceImpl.java
@@ -25,8 +25,8 @@
import java.util.Date;
import java.util.List;
-@Service("workApproveService")
-public class EmergencyEmergencyWorkApproveServiceImpl implements EmergencyWorkApproveService {
+@Service("emergencyWorkApproveService")
+public class EmergencyWorkApproveServiceImpl implements EmergencyWorkApproveService {
@Autowired
private EmergencyWorkApproveInfoService workApproveInfoService;
diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/entity/EmergencyDrillEvaluationFileInfo.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/entity/EmergencyDrillEvaluationFileInfo.java
new file mode 100644
index 0000000..a9c3036
--- /dev/null
+++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/entity/EmergencyDrillEvaluationFileInfo.java
@@ -0,0 +1,117 @@
+package com.gkhy.safePlatform.equipment.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.util.Date;
+
+@TableName("emergency_drill_evaluation_file")
+public class EmergencyDrillEvaluationFileInfo {
+
+ @TableId(type = IdType.AUTO)
+ private Long id;
+
+ private Boolean delFlag;
+
+ private Date gmtCreate;
+
+ private Date gmtModitify;
+
+ private Long createUid;
+
+ private Long updateUid;
+
+ private Long drillEvaluationId;
+
+ private String fileUrl;
+
+ private String fileName;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Boolean getDelFlag() {
+ return delFlag;
+ }
+
+ public void setDelFlag(Boolean delFlag) {
+ this.delFlag = delFlag;
+ }
+
+ public Date getGmtCreate() {
+ return gmtCreate;
+ }
+
+ public void setGmtCreate(Date gmtCreate) {
+ this.gmtCreate = gmtCreate;
+ }
+
+ public Date getGmtModitify() {
+ return gmtModitify;
+ }
+
+ public void setGmtModitify(Date gmtModitify) {
+ this.gmtModitify = gmtModitify;
+ }
+
+ public Long getCreateUid() {
+ return createUid;
+ }
+
+ public void setCreateUid(Long createUid) {
+ this.createUid = createUid;
+ }
+
+ public Long getUpdateUid() {
+ return updateUid;
+ }
+
+ public void setUpdateUid(Long updateUid) {
+ this.updateUid = updateUid;
+ }
+
+ public Long getDrillEvaluationId() {
+ return drillEvaluationId;
+ }
+
+ public void setDrillEvaluationId(Long drillEvaluationId) {
+ this.drillEvaluationId = drillEvaluationId;
+ }
+
+ public String getFileUrl() {
+ return fileUrl;
+ }
+
+ public void setFileUrl(String fileUrl) {
+ this.fileUrl = fileUrl;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public String toString() {
+ return "EmergencyDrillEvaluationFileInfo{" +
+ "id=" + id +
+ ", delFlag=" + delFlag +
+ ", gmtCreate=" + gmtCreate +
+ ", gmtModitify=" + gmtModitify +
+ ", createUid=" + createUid +
+ ", updateUid=" + updateUid +
+ ", drillEvaluationId=" + drillEvaluationId +
+ ", fileUrl='" + fileUrl + '\'' +
+ ", fileName='" + fileName + '\'' +
+ '}';
+ }
+}
diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/enums/EquipmentResultCodes.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/enums/EquipmentResultCodes.java
new file mode 100644
index 0000000..fdf6802
--- /dev/null
+++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/enums/EquipmentResultCodes.java
@@ -0,0 +1,31 @@
+package com.gkhy.safePlatform.equipment.enums;
+
+public enum EquipmentResultCodes {
+
+
+ ERROR("A3000", "未知错误");
+
+ private String code;
+ private String desc;
+
+ private EquipmentResultCodes(String code, String desc) {
+ this.code = code;
+ this.desc = desc;
+ }
+
+ public String getCode() {
+ return this.code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getDesc() {
+ return this.desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/ExcApprove.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/ExcApprove.java
new file mode 100644
index 0000000..dd4af11
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/ExcApprove.java
@@ -0,0 +1,33 @@
+package com.gkhy.safePlatform.targetDuty.model.dto.req;
+
+import com.gkhy.safePlatform.targetDuty.entity.BaseDomain;
+
+/**
+ * (WorkApprove)表实体类
+ *
+ * @author xurui
+ * @since 2022-07-22 10:46:11
+ */
+@SuppressWarnings("serial")
+public class ExcApprove extends BaseDomain {
+
+ private Long id;
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+ //审批意见
+ private String approveMemo;
+
+ public String getApproveMemo() {
+ return approveMemo;
+ }
+
+ public void setApproveMemo(String approveMemo) {
+ this.approveMemo = approveMemo;
+ }
+
+}
\ No newline at end of file
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/TargetMngImportExcel.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/TargetMngImportExcel.java
new file mode 100644
index 0000000..4972d6d
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/req/TargetMngImportExcel.java
@@ -0,0 +1,100 @@
+package com.gkhy.safePlatform.targetDuty.model.dto.req;
+
+import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelCell;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+public class TargetMngImportExcel implements Serializable {
+
+ //安全目标指标
+ @ExcelCell(index = 1)
+ private String qName;
+ //目标指标编号
+ @ExcelCell(index = 2)
+ private String indexNum;
+ //年度
+ @ExcelCell(index = 3)
+ private String year;
+ //指标值
+ @ExcelCell(index = 4)
+ private String value;
+ //指标级别 1:公司级 2:部门分厂级 3:工段班组级
+ @ExcelCell(index = 5)
+ private Integer level;
+ //完成期限
+ @ExcelCell(index = 7)
+ private Timestamp completeDate;
+ //备注信息
+ @ExcelCell(index = 8)
+ private String memo;
+ //指标类型 1:年指标 2:月指标
+ @ExcelCell(index = 6)
+ private Integer targetType;
+
+
+ public String getqName() {
+ return qName;
+ }
+
+ public void setqName(String qName) {
+ this.qName = qName;
+ }
+
+ //目标指标编号
+ public String getIndexNum() {
+ return indexNum;
+ }
+
+ public void setIndexNum(String indexNum) {
+ this.indexNum = indexNum;
+ }
+ //年度
+ public String getYear() {
+ return year;
+ }
+
+ public void setYear(String year) {
+ this.year = year;
+ }
+ //指标值
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ //指标级别 1:公司级 2:部门分厂级 3:工段班组级
+ public Integer getLevel() {
+ return level;
+ }
+
+ public void setLevel(Integer level) {
+ this.level = level;
+ }
+ //完成期限
+ public Timestamp getCompleteDate() {
+ return completeDate;
+ }
+
+ public void setCompleteDate(Timestamp completeDate) {
+ this.completeDate = completeDate;
+ }
+ //备注信息
+ public String getMemo() {
+ return memo;
+ }
+
+ public void setMemo(String memo) {
+ this.memo = memo;
+ }
+ //指标类型 1:年指标 2:月指标
+ public Integer getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(Integer targetType) {
+ this.targetType = targetType;
+ }
+}
\ No newline at end of file
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetDutySummaryExcel.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetDutySummaryExcel.java
new file mode 100644
index 0000000..bb40b8d
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetDutySummaryExcel.java
@@ -0,0 +1,174 @@
+package com.gkhy.safePlatform.targetDuty.model.dto.resp;
+
+import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelCell;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+public class TargetDutySummaryExcel implements Serializable {
+ //责任部门名
+ @ExcelCell(index = 1)
+ private String departmentName;
+ //安全目标指标
+ @ExcelCell(index = 2)
+ private String targetValue;
+ //考核指标
+ @ExcelCell(index = 3)
+ private String examineValue;
+ //月份
+ @ExcelCell(index = 4)
+ private String yiYue;
+ @ExcelCell(index = 5)
+ private String erYue;
+ @ExcelCell(index = 6)
+ private String sanYue;
+ @ExcelCell(index = 7)
+ private String siYue;
+ @ExcelCell(index = 8)
+ private String wuYue;
+ @ExcelCell(index = 9)
+ private String liuYue;
+ @ExcelCell(index = 10)
+ private String qiYue;
+ @ExcelCell(index = 11)
+ private String baYue;
+ @ExcelCell(index = 12)
+ private String jiuYue;
+ @ExcelCell(index = 13)
+ private String shiYue;
+ @ExcelCell(index = 14)
+ private String shiyiYue;
+ @ExcelCell(index = 15)
+ private String shierYue;
+ //考核指标 1:合格 2:不合格
+ @ExcelCell(index = 16)
+ private Integer examineResult;
+
+ public String getDepartmentName() {
+ return departmentName;
+ }
+
+ public void setDepartmentName(String departmentName) {
+ this.departmentName = departmentName;
+ }
+
+ public String getTargetValue() {
+ return targetValue;
+ }
+
+ public void setTargetValue(String targetValue) {
+ this.targetValue = targetValue;
+ }
+
+ public String getExamineValue() {
+ return examineValue;
+ }
+
+ public void setExamineValue(String examineValue) {
+ this.examineValue = examineValue;
+ }
+
+ public String getYiYue() {
+ return yiYue;
+ }
+
+ public void setYiYue(String yiYue) {
+ this.yiYue = yiYue;
+ }
+
+ public String getErYue() {
+ return erYue;
+ }
+
+ public void setErYue(String erYue) {
+ this.erYue = erYue;
+ }
+
+ public String getSanYue() {
+ return sanYue;
+ }
+
+ public void setSanYue(String sanYue) {
+ this.sanYue = sanYue;
+ }
+
+ public String getSiYue() {
+ return siYue;
+ }
+
+ public void setSiYue(String siYue) {
+ this.siYue = siYue;
+ }
+
+ public String getWuYue() {
+ return wuYue;
+ }
+
+ public void setWuYue(String wuYue) {
+ this.wuYue = wuYue;
+ }
+
+ public String getLiuYue() {
+ return liuYue;
+ }
+
+ public void setLiuYue(String liuYue) {
+ this.liuYue = liuYue;
+ }
+
+ public String getQiYue() {
+ return qiYue;
+ }
+
+ public void setQiYue(String qiYue) {
+ this.qiYue = qiYue;
+ }
+
+ public String getBaYue() {
+ return baYue;
+ }
+
+ public void setBaYue(String baYue) {
+ this.baYue = baYue;
+ }
+
+ public String getJiuYue() {
+ return jiuYue;
+ }
+
+ public void setJiuYue(String jiuYue) {
+ this.jiuYue = jiuYue;
+ }
+
+ public String getShiYue() {
+ return shiYue;
+ }
+
+ public void setShiYue(String shiYue) {
+ this.shiYue = shiYue;
+ }
+
+ public String getShiyiYue() {
+ return shiyiYue;
+ }
+
+ public void setShiyiYue(String shiyiYue) {
+ this.shiyiYue = shiyiYue;
+ }
+
+ public String getShierYue() {
+ return shierYue;
+ }
+
+ public void setShierYue(String shierYue) {
+ this.shierYue = shierYue;
+ }
+
+ public Integer getExamineResult() {
+ return examineResult;
+ }
+
+ public void setExamineResult(Integer examineResult) {
+ this.examineResult = examineResult;
+ }
+}
\ No newline at end of file
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetMngExcel.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetMngExcel.java
new file mode 100644
index 0000000..e14bbc0
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/model/dto/resp/TargetMngExcel.java
@@ -0,0 +1,114 @@
+package com.gkhy.safePlatform.targetDuty.model.dto.resp;
+
+import com.gkhy.safePlatform.targetDuty.entity.TargetDivideDetail;
+import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelCell;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TargetMngExcel implements Serializable {
+
+ //安全目标指标
+ @ExcelCell(index = 1)
+ private String qName;
+ //目标指标编号
+ @ExcelCell(index = 2)
+ private String indexNum;
+ //年度
+ @ExcelCell(index = 3)
+ private String year;
+ //指标值
+ @ExcelCell(index = 4)
+ private String value;
+ //指标级别 1:公司级 2:部门分厂级 3:工段班组级
+ @ExcelCell(index = 5)
+ private Integer level;
+ //指标类型 1:年指标 2:月指标
+ @ExcelCell(index = 6)
+ private Integer targetType;
+ //完成期限
+ @ExcelCell(index = 7)
+ private Timestamp completeDate;
+ //分解状态 1:已分解 2:未分解
+ @ExcelCell(index = 8)
+ private Integer divideStatus;
+ //备注信息
+ @ExcelCell(index = 9)
+ private String memo;
+
+ public Integer getDivideStatus() {
+ return divideStatus;
+ }
+
+ public void setDivideStatus(Integer divideStatus) {
+ this.divideStatus = divideStatus;
+ }
+
+
+ public String getqName() {
+ return qName;
+ }
+
+ public void setqName(String qName) {
+ this.qName = qName;
+ }
+
+ //目标指标编号
+ public String getIndexNum() {
+ return indexNum;
+ }
+
+ public void setIndexNum(String indexNum) {
+ this.indexNum = indexNum;
+ }
+ //年度
+ public String getYear() {
+ return year;
+ }
+
+ public void setYear(String year) {
+ this.year = year;
+ }
+ //指标值
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ //指标级别 1:公司级 2:部门分厂级 3:工段班组级
+ public Integer getLevel() {
+ return level;
+ }
+
+ public void setLevel(Integer level) {
+ this.level = level;
+ }
+ //完成期限
+ public Timestamp getCompleteDate() {
+ return completeDate;
+ }
+
+ public void setCompleteDate(Timestamp completeDate) {
+ this.completeDate = completeDate;
+ }
+ //备注信息
+ public String getMemo() {
+ return memo;
+ }
+
+ public void setMemo(String memo) {
+ this.memo = memo;
+ }
+ //指标类型 1:年指标 2:月指标
+ public Integer getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(Integer targetType) {
+ this.targetType = targetType;
+ }
+}
\ No newline at end of file
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/DateUtils.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/DateUtils.java
new file mode 100644
index 0000000..b279591
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/DateUtils.java
@@ -0,0 +1,81 @@
+package com.gkhy.safePlatform.targetDuty.utils;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.util.Assert;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DateUtils {
+
+ public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss";
+
+ public static final String PATTERN_DATE = "yyyy-MM-dd";
+
+ public static final String PATTERN_DATE_MIN="yyyy-MM-dd HH:mm";
+ // 小时分钟格式 (分笔成交时间)
+ public static final String PATTERN_HOUR_MIN = "HH:mm";
+
+ public static final String PATTERN_DATE_HOUR="yyyy-MM-dd HH";
+
+ public static final String PATTERN_DATE_DATE_CHS="yyyy年MM月dd日";
+
+ public static final String PATTERN1_DATE = "yyyy/MM/dd";
+
+ public static final String PATTERN_CONNECT_DATE="yyyyMMddHHmmss";
+ public static final String PATTERN_CONNECT_DATE_YYYYMMDD="yyyyMMdd";
+ public static final String PATTERN_CONNECT_DATE_YYMMDD="yyMMdd";
+ public static final String PATTERN_ALLTIME_NOSIGN = "yyyyMMddHHmmssSSS";
+
+ public static final String PATTERN_MONTH = "yyyy-MM";
+
+ public static final String PATTERN_MONTH1 = "yyyyMM";
+
+ public static final String PATTERN2_STANDARD = "yyyy-MM-dd HH:mm:ss.SSS";
+
+ public static final String PATTERN_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+ public static String date2String(Date date, String pattern) {
+ if (date == null) {
+ throw new IllegalArgumentException("timestamp null illegal");
+ }
+ if (pattern == null || pattern.equals("")) {
+ pattern = PATTERN_STANDARD;
+ ;
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ return sdf.format(date);
+ }
+
+
+ public static Timestamp string2Timestamp(String strDateTime, String pattern) {
+ if (strDateTime == null || strDateTime.equals("")) {
+ throw new IllegalArgumentException("Date Time Null Illegal");
+ }
+ if (pattern == null || pattern.equals("")) {
+ pattern = PATTERN_STANDARD;
+ }
+
+ SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ Date date = null;
+ try {
+ date = sdf.parse(strDateTime);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return new Timestamp(date.getTime());
+ }
+
+
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelCell.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelCell.java
new file mode 100644
index 0000000..845449a
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelCell.java
@@ -0,0 +1,81 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * The <code>ExcelCell</code><br>
+ * 数值型的栏位只能使用Double
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface ExcelCell {
+ /**
+ * 顺序 default 100
+ *
+ * @return index
+ */
+ int index();
+
+ /**
+ * 当值为null时要显示的值 default StringUtils.EMPTY
+ *
+ * @return defaultValue
+ */
+ String defaultValue() default "";
+
+ /**
+ * 用于验证
+ *
+ * @return valid
+ */
+ Valid valid() default @Valid();
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ @interface Valid {
+ /**
+ * 必须与in中String相符,目前仅支持String类型
+ *
+ * @return e.g. {"key","value"}
+ */
+ String[] in() default {};
+
+ /**
+ * 是否允许为空,用于验证数据 default true
+ *
+ * @return allowNull
+ */
+ boolean allowNull() default true;
+
+ /**
+ * Apply a "greater than" constraint to the named property
+ *
+ * @return gt
+ */
+ double gt() default Double.NaN;
+
+ /**
+ * Apply a "less than" constraint to the named property
+ * @return lt
+ */
+ double lt() default Double.NaN;
+
+ /**
+ * Apply a "greater than or equal" constraint to the named property
+ *
+ * @return ge
+ */
+ double ge() default Double.NaN;
+
+ /**
+ * Apply a "less than or equal" constraint to the named property
+ *
+ * @return le
+ */
+ double le() default Double.NaN;
+ }
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLog.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLog.java
new file mode 100644
index 0000000..d21b65e
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLog.java
@@ -0,0 +1,79 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+/**
+ * The <code>ExcelLog</code>
+ *
+ */
+public class ExcelLog {
+ private Integer rowNum;
+ private Object object;
+ private String log;
+
+ /**
+ * @return the rowNum
+ */
+ public Integer getRowNum() {
+ return rowNum;
+ }
+
+ /**
+ * @param rowNum
+ * the rowNum to set
+ */
+ public void setRowNum(Integer rowNum) {
+ this.rowNum = rowNum;
+ }
+
+ /**
+ * @return the object
+ */
+ public Object getObject() {
+ return object;
+ }
+
+ /**
+ * @param object
+ * the object to set
+ */
+ public void setObject(Object object) {
+ this.object = object;
+ }
+
+ /**
+ * @return the log
+ */
+ public String getLog() {
+ return log;
+ }
+
+ /**
+ * @param object
+ * @param log
+ */
+ public ExcelLog(Object object, String log) {
+ super();
+ this.object = object;
+ this.log = log;
+ }
+
+ /**
+ * @param rowNum
+ * @param object
+ * @param log
+ */
+ public ExcelLog(Object object, String log, Integer rowNum) {
+ super();
+ this.rowNum = rowNum;
+ this.object = object;
+ this.log = log;
+ }
+
+ /**
+ * @param log
+ * the log to set
+ */
+ public void setLog(String log) {
+ this.log = log;
+ }
+
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLogs.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLogs.java
new file mode 100644
index 0000000..0e0f7ac
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelLogs.java
@@ -0,0 +1,62 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The <code>ExcelLogs</code>
+ *
+ */
+public class ExcelLogs {
+ private Boolean hasError;
+ private List<ExcelLog> logList;
+
+ /**
+ *
+ */
+ public ExcelLogs() {
+ super();
+ hasError = false;
+ }
+
+ /**
+ * @return the hasError
+ */
+ public Boolean getHasError() {
+ return hasError;
+ }
+
+ /**
+ * @param hasError
+ * the hasError to set
+ */
+ public void setHasError(Boolean hasError) {
+ this.hasError = hasError;
+ }
+
+ /**
+ * @return the logList
+ */
+ public List<ExcelLog> getLogList() {
+ return logList;
+ }
+
+ public List<ExcelLog> getErrorLogList() {
+ List<ExcelLog> errList = new ArrayList<>();
+ for (ExcelLog log : this.logList) {
+ if (log != null && ExcelUtil.isNotBlank(log.getLog())) {
+ errList.add(log);
+ }
+ }
+ return errList;
+ }
+
+ /**
+ * @param logList
+ * the logList to set
+ */
+ public void setLogList(List<ExcelLog> logList) {
+ this.logList = logList;
+ }
+
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelSheet.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelSheet.java
new file mode 100644
index 0000000..2f5e5bf
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelSheet.java
@@ -0,0 +1,66 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * 用于汇出多个sheet的Vo The <code>ExcelSheet</code>
+ *
+ */
+public class ExcelSheet<T> {
+ private String sheetName;
+ private Map<String,String> headers;
+ private Collection<T> dataset;
+
+ /**
+ * @return the sheetName
+ */
+ public String getSheetName() {
+ return sheetName;
+ }
+
+ /**
+ * Excel页签名称
+ *
+ * @param sheetName
+ * the sheetName to set
+ */
+ public void setSheetName(String sheetName) {
+ this.sheetName = sheetName;
+ }
+
+ /**
+ * Excel表头
+ *
+ * @return the headers
+ */
+ public Map<String,String> getHeaders() {
+ return headers;
+ }
+
+ /**
+ * @param headers
+ * the headers to set
+ */
+ public void setHeaders(Map<String,String> headers) {
+ this.headers = headers;
+ }
+
+ /**
+ * Excel数据集合
+ *
+ * @return the dataset
+ */
+ public Collection<T> getDataset() {
+ return dataset;
+ }
+
+ /**
+ * @param dataset
+ * the dataset to set
+ */
+ public void setDataset(Collection<T> dataset) {
+ this.dataset = dataset;
+ }
+
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelUtil.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelUtil.java
new file mode 100644
index 0000000..a8f9759
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/ExcelUtil.java
@@ -0,0 +1,758 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+import com.gkhy.safePlatform.targetDuty.utils.DateUtils;
+import org.apache.commons.beanutils.BeanComparator;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.ComparatorUtils;
+import org.apache.commons.collections.comparators.ComparableComparator;
+import org.apache.commons.collections.comparators.ComparatorChain;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * The <code>ExcelUtil</code> 与 {@link ExcelCell}搭配使用
+ *
+ */
+public class ExcelUtil {
+
+ private static Logger LG = LoggerFactory.getLogger(ExcelUtil.class);
+
+ /**
+ * 用来验证excel与Vo中的类型是否一致 <br>
+ * Map<栏位类型,只能是哪些Cell类型>
+ */
+ private static Map<Class<?>, CellType[]> validateMap = new HashMap<>();
+
+ static {
+ validateMap.put(String[].class, new CellType[]{CellType.STRING});
+ validateMap.put(Double[].class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(String.class, new CellType[]{CellType.STRING});
+ validateMap.put(Double.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Timestamp.class, new CellType[]{CellType.NUMERIC, CellType.STRING});
+ validateMap.put(Date.class, new CellType[]{CellType.NUMERIC, CellType.STRING});
+ validateMap.put(Integer.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Float.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Long.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Boolean.class, new CellType[]{CellType.BOOLEAN});
+ }
+
+ /**
+ * 获取cell类型的文字描述
+ *
+ * @param cellType <pre>
+ * CellType.BLANK
+ * CellType.BOOLEAN
+ * CellType.ERROR
+ * CellType.FORMULA
+ * CellType.NUMERIC
+ * CellType.STRING
+ * </pre>
+ * @return
+ */
+ private static String getCellTypeByInt(CellType cellType) {
+ if(cellType == CellType.BLANK)
+ return "Null type";
+ else if(cellType == CellType.BOOLEAN)
+ return "Boolean type";
+ else if(cellType == CellType.ERROR)
+ return "Error type";
+ else if(cellType == CellType.FORMULA)
+ return "Formula type";
+ else if(cellType == CellType.NUMERIC)
+ return "Numeric type";
+ else if(cellType == CellType.STRING)
+ return "String type";
+ else
+ return "Unknown type";
+ }
+
+ /**
+ * 获取单元格值
+ *
+ * @param cell
+ * @return
+ */
+ private static Object getCellValue(Cell cell) {
+ if (cell == null
+ || (cell.getCellTypeEnum() == CellType.STRING && isBlank(cell
+ .getStringCellValue()))) {
+ return null;
+ }
+ DataFormatter dataFormatter = new DataFormatter();
+ String s = dataFormatter.formatCellValue(cell);
+ return s;
+
+// CellType cellType = cell.getCellTypeEnum();
+// if(cellType == CellType.BLANK)
+// return null;
+// else if(cellType == CellType.BOOLEAN)
+// return cell.getBooleanCellValue();
+// else if(cellType == CellType.ERROR)
+// return cell.getErrorCellValue();
+// else if(cellType == CellType.FORMULA) {
+// try {
+// if (HSSFDateUtil.isCellDateFormatted(cell)) {
+// return cell.getDateCellValue();
+// } else {
+// return cell.getNumericCellValue();
+// }
+// } catch (IllegalStateException e) {
+// return cell.getRichStringCellValue();
+// }
+// }
+// else if(cellType == CellType.NUMERIC){
+// if (DateUtil.isCellDateFormatted(cell)) {
+// return cell.getDateCellValue();
+// } else {
+// return cell.getNumericCellValue();
+// }
+// }
+// else if(cellType == CellType.STRING)
+// return cell.getStringCellValue();
+// else
+// return null;
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上<br>
+ * 用于单个sheet
+ *
+ * @param <T>
+ * @param headers 表格属性列名数组
+ * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
+ * javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ */
+ public static <T> void exportExcel(Map<String,String> headers, Collection<T> dataset, OutputStream out) {
+ exportExcel(headers, dataset, out, null);
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上<br>
+ * 用于单个sheet
+ *
+ * @param <T>
+ * @param headers 表格属性列名数组
+ * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
+ * javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
+ */
+ public static <T> void exportExcel(Map<String,String> headers, Collection<T> dataset, OutputStream out,
+ String pattern) {
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ // 生成一个表格
+ HSSFSheet sheet = workbook.createSheet();
+
+ write2Sheet(workbook,sheet, headers, dataset, pattern);
+ try {
+ workbook.write(out);
+ } catch (IOException e) {
+ LG.error(e.toString(), e);
+ }
+ }
+
+ public static void exportExcel(String[][] datalist, OutputStream out,boolean autoColumnWidth) {
+ try {
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ // 生成一个表格
+ HSSFSheet sheet = workbook.createSheet();
+
+ for (int i = 0; i < datalist.length; i++) {
+ String[] r = datalist[i];
+ HSSFRow row = sheet.createRow(i);
+ for (int j = 0; j < r.length; j++) {
+ HSSFCell cell = row.createCell(j);
+ //cell max length 32767
+ if (r[j] != null && r[j].length() > 32767) {
+ r[j] = "--此字段过长(超过32767),已被截断--" + r[j];
+ r[j] = r[j].substring(0, 32766);
+ }
+ cell.setCellValue(r[j]);
+ }
+ }
+ //自动列宽
+ if(autoColumnWidth) {
+ if (datalist.length > 0) {
+ int colcount = datalist[0].length;
+ for (int i = 0; i < colcount; i++) {
+ sheet.autoSizeColumn(i);
+ }
+ }
+ }
+ workbook.write(out);
+ } catch (IOException e) {
+ LG.error(e.toString(), e);
+ }
+ }
+ public static void exportExcel(String[][] datalist, OutputStream out) {
+ exportExcel(datalist,out,true);
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上<br>
+ * 用于多个sheet
+ *
+ * @param <T>
+ * @param sheets {@link ExcelSheet}的集合
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ */
+ public static <T> void exportExcel(List<ExcelSheet<T>> sheets, OutputStream out) {
+ exportExcel(sheets, out, null);
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上<br>
+ * 用于多个sheet
+ *
+ * @param <T>
+ * @param sheets {@link ExcelSheet}的集合
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
+ */
+ public static <T> void exportExcel(List<ExcelSheet<T>> sheets, OutputStream out, String pattern) {
+ if (CollectionUtils.isEmpty(sheets)) {
+ return;
+ }
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ for (ExcelSheet<T> sheet : sheets) {
+ // 生成一个表格
+ HSSFSheet hssfSheet = workbook.createSheet(sheet.getSheetName());
+ write2Sheet(workbook,hssfSheet, sheet.getHeaders(), sheet.getDataset(), pattern);
+ }
+ try {
+ workbook.write(out);
+ } catch (IOException e) {
+ LG.error(e.toString(), e);
+ }
+ }
+
+ /**
+ * 每个sheet的写入
+ *
+ * @param sheet 页签
+ * @param headers 表头
+ * @param dataset 数据集合
+ * @param pattern 日期格式
+ */
+ private static <T> void write2Sheet(HSSFWorkbook workbook,HSSFSheet sheet, Map<String,String> headers, Collection<T> dataset,
+ String pattern) {
+ //时间格式默认"yyyy-MM-dd"
+ if (isBlank(pattern)){
+ pattern = "yyyy-MM-dd";
+ }
+ // 产生表格标题行
+ HSSFRow row = sheet.createRow(0);
+ // 标题行转中文
+ Set<String> keys = headers.keySet();
+ Iterator<String> it1 = keys.iterator();
+ String key = ""; //存放临时键变量
+ int c= 0; //标题列数
+ while (it1.hasNext()){
+ key = it1.next();
+ if (headers.containsKey(key)) {
+ HSSFCell cell = row.createCell(c);
+ cell.setCellStyle(getTopColumnStyle(workbook));
+ HSSFRichTextString text = new HSSFRichTextString(headers.get(key));
+ cell.setCellValue(text);
+ c++;
+ }
+ }
+
+ // 遍历集合数据,产生数据行
+ Iterator<T> it = dataset.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ index++;
+ row = sheet.createRow(index);
+ T t = it.next();
+ try {
+ if (t instanceof Map) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> map = (Map<String, Object>) t;
+ int cellNum = 0;
+ //遍历列名
+ Iterator<String> it2 = keys.iterator();
+ while (it2.hasNext()){
+ key = it2.next();
+ if (!headers.containsKey(key)) {
+ LG.error("Map 中 不存在 key [" + key + "]");
+ continue;
+ }
+ Object value = map.get(key);
+ HSSFCell cell = row.createCell(cellNum);
+ cell.setCellStyle(getColumnStyle(workbook));
+
+ cellNum = setCellValue(cell,value,pattern,cellNum,null,row);
+
+ cellNum++;
+ }
+ } else {
+ List<FieldForSortting> fields = sortFieldByAnno(t.getClass());
+ int cellNum = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ HSSFCell cell = row.createCell(cellNum);
+ cell.setCellStyle(getColumnStyle(workbook));
+ Field field = fields.get(i).getField();
+ field.setAccessible(true);
+ Object value = field.get(t);
+
+ cellNum = setCellValue(cell,value,pattern,cellNum,field,row);
+
+ cellNum++;
+ }
+ }
+ } catch (Exception e) {
+ LG.error(e.toString(), e);
+ }
+ }
+ // 设定自动宽度
+ for (int i = 0; i < headers.size(); i++) {
+ sheet.autoSizeColumn(i);
+ int cw = (int) (sheet.getColumnWidth(i) * 0.8);
+ // increase width to accommodate drop-down arrow in the header
+ sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 20 / 10);
+ }
+ }
+
+ private static int setCellValue(HSSFCell cell,Object value,String pattern,int cellNum,Field field,HSSFRow row){
+ String textValue = null;
+ if (value instanceof Integer) {
+ int intValue = (Integer) value;
+ cell.setCellValue(intValue);
+ } else if (value instanceof Float) {
+ float fValue = (Float) value;
+ cell.setCellValue(fValue);
+ } else if (value instanceof Double) {
+ double dValue = (Double) value;
+ cell.setCellValue(dValue);
+ } else if (value instanceof Long) {
+ long longValue = (Long) value;
+ cell.setCellValue(longValue);
+ } else if (value instanceof Boolean) {
+ boolean bValue = (Boolean) value;
+ cell.setCellValue(bValue);
+ } else if (value instanceof Date) {
+ Date date = (Date) value;
+ SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ textValue = sdf.format(date);
+ } else if (value instanceof String[]) {
+ String[] strArr = (String[]) value;
+ for (int j = 0; j < strArr.length; j++) {
+ String str = strArr[j];
+ cell.setCellValue(str);
+ if (j != strArr.length - 1) {
+ cellNum++;
+ cell = row.createCell(cellNum);
+ }
+ }
+ } else if (value instanceof Double[]) {
+ Double[] douArr = (Double[]) value;
+ for (int j = 0; j < douArr.length; j++) {
+ Double val = douArr[j];
+ // 值不为空则set Value
+ if (val != null) {
+ cell.setCellValue(val);
+ }
+
+ if (j != douArr.length - 1) {
+ cellNum++;
+ cell = row.createCell(cellNum);
+ }
+ }
+ } else {
+ // 其它数据类型都当作字符串简单处理
+ String empty = "";
+ if(field != null) {
+ ExcelCell anno = field.getAnnotation(ExcelCell.class);
+ if (anno != null) {
+ empty = anno.defaultValue();
+ }
+ }
+ textValue = value == null ? empty : value.toString();
+ }
+ if (textValue != null) {
+ HSSFRichTextString richString = new HSSFRichTextString(textValue);
+ cell.setCellValue(richString);
+ }
+ return cellNum;
+ }
+
+
+ /*
+ * 设置单元格样式
+ */
+ private static HSSFCellStyle getColumnStyle(HSSFWorkbook workbook) {
+
+ //设置样式;
+ HSSFCellStyle style = workbook.createCellStyle();
+ //设置自动换行;
+ style.setWrapText(false);
+ //设置水平对齐的样式为居中对齐;
+ style.setAlignment(HorizontalAlignment.CENTER);
+ //设置垂直对齐的样式为居中对齐;
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+
+ return style;
+ }
+
+ /*
+ * 设置单元格样式
+ */
+ private static HSSFCellStyle getTopColumnStyle(HSSFWorkbook workbook) {
+
+ //设置样式;
+ HSSFCellStyle style = workbook.createCellStyle();
+ //设置自动换行;
+ style.setWrapText(true);
+ //设置水平对齐的样式为居中对齐;
+ style.setAlignment(HorizontalAlignment.CENTER);
+ //设置垂直对齐的样式为居中对齐;
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());// 设置背景色
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+ // 设置字体
+ HSSFFont font = workbook.createFont();
+ //字体加粗
+ font.setBold(true);
+ font.setFontHeightInPoints((short) 14);//设置字体大小
+ font.setColor(IndexedColors.WHITE.index);
+ style.setFont(font);
+ return style;
+ }
+
+ /**
+ * 把Excel的数据封装成voList
+ *
+ * @param clazz vo的Class
+ * @param inputStream excel输入流
+ * @param pattern 如果有时间数据,设定输入格式。默认为"yyy-MM-dd"
+ * @param logs 错误log集合
+ * @param arrayCount 如果vo中有数组类型,那就按照index顺序,把数组应该有几个值写上.
+ * @return voList
+ * @throws RuntimeException
+ */
+ public static <T> Collection<T> importExcel(Class<T> clazz, InputStream inputStream,
+ String pattern, ExcelLogs logs, Integer... arrayCount) {
+ Workbook workBook;
+ try {
+ workBook = WorkbookFactory.create(inputStream);
+ } catch (Exception e) {
+ LG.error("load excel file error",e);
+ return null;
+ }
+ List<T> list = new ArrayList<>();
+ Sheet sheet = workBook.getSheetAt(0);
+ Iterator<Row> rowIterator = sheet.rowIterator();
+ try {
+ List<ExcelLog> logList = new ArrayList<>();
+ // Map<title,index>
+ Map<String, Integer> titleMap = new HashMap<>();
+
+ while (rowIterator.hasNext()) {
+ Row row = rowIterator.next();
+ if (row.getRowNum() == 0) {
+ if (clazz == Map.class) {
+ // 解析map用的key,就是excel标题行
+ Iterator<Cell> cellIterator = row.cellIterator();
+ Integer index = 0;
+ while (cellIterator.hasNext()) {
+ String value = cellIterator.next().getStringCellValue();
+ titleMap.put(value, index);
+ index++;
+ }
+ }
+ continue;
+ }
+ // 整行都空,就跳过
+ boolean allRowIsNull = true;
+ Iterator<Cell> cellIterator = row.cellIterator();
+ while (cellIterator.hasNext()) {
+ Object cellValue = getCellValue(cellIterator.next());
+ if (cellValue != null) {
+ allRowIsNull = false;
+ break;
+ }
+ }
+ if (allRowIsNull) {
+ LG.warn("Excel row " + row.getRowNum() + " all row value is null!");
+ continue;
+ }
+ StringBuilder log = new StringBuilder();
+ if (clazz == Map.class) {
+ Map<String, Object> map = new HashMap<>();
+ for (String k : titleMap.keySet()) {
+ Integer index = titleMap.get(k);
+ Cell cell = row.getCell(index);
+ // 判空
+ if (cell == null) {
+ map.put(k, null);
+ } else {
+ cell.setCellType(CellType.STRING);
+ String value = cell.getStringCellValue();
+ map.put(k, value);
+ }
+ }
+ list.add((T) map);
+
+ } else {
+ T t = clazz.newInstance();
+ int arrayIndex = 0;// 标识当前第几个数组了
+ int cellIndex = 0;// 标识当前读到这一行的第几个cell了
+ List<FieldForSortting> fields = sortFieldByAnno(clazz);
+ for (FieldForSortting ffs : fields) {
+ Field field = ffs.getField();
+ field.setAccessible(true);
+ if (field.getType().isArray()) {
+ Integer count = arrayCount[arrayIndex];
+ Object[] value;
+ if (field.getType().equals(String[].class)) {
+ value = new String[count];
+ } else {
+ // 目前只支持String[]和Double[]
+ value = new Double[count];
+ }
+ for (int i = 0; i < count; i++) {
+ Cell cell = row.getCell(cellIndex);
+ String errMsg = validateCell(cell, field, cellIndex);
+ if (isBlank(errMsg)) {
+ value[i] = getCellValue(cell);
+ } else {
+ log.append(errMsg);
+ log.append(";");
+ logs.setHasError(true);
+ }
+ cellIndex++;
+ }
+ field.set(t, value);
+ arrayIndex++;
+ } else {
+ Cell cell = row.getCell(cellIndex);
+ String errMsg = validateCell(cell, field, cellIndex);
+ if (isBlank(errMsg)) {
+ Object value = null;
+ // 处理特殊情况,Excel中的String,转换成Bean的Date
+ if (field.getType().equals(Timestamp.class)) {
+ Object strDate = getCellValue(cell);
+ value = DateUtils.string2Timestamp(strDate.toString(),pattern);
+ }else if (field.getType().equals(Integer.class)) {
+ Object data = getCellValue(cell);
+ if(data != null){
+ value = Integer.parseInt(String.valueOf(data));
+ }
+ } else {
+ value = getCellValue(cell);
+ // 处理特殊情况,excel的value为String,且bean中为其他,且defaultValue不为空,那就=defaultValue
+ ExcelCell annoCell = field.getAnnotation(ExcelCell.class);
+ if (value instanceof String && !field.getType().equals(String.class)
+ && isNotBlank(annoCell.defaultValue())) {
+ value = annoCell.defaultValue();
+ }
+ }
+ field.set(t, value);
+ }
+ if (isNotBlank(errMsg)) {
+ log.append(errMsg);
+ log.append(";");
+ logs.setHasError(true);
+ }
+ cellIndex++;
+ }
+ }
+ list.add(t);
+ logList.add(new ExcelLog(t, log.toString(), row.getRowNum() + 1));
+ }
+ }
+ logs.setLogList(logList);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(MessageFormat.format("can not instance class:{0}",
+ clazz.getSimpleName()), e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(MessageFormat.format("can not instance class:{0}",
+ clazz.getSimpleName()), e);
+ }
+ return list;
+ }
+
+ /**
+ * 驗證Cell類型是否正確
+ *
+ * @param cell cell單元格
+ * @param field 欄位
+ * @param cellNum 第幾個欄位,用於errMsg
+ * @return
+ */
+ private static String validateCell(Cell cell, Field field, int cellNum) {
+ String columnName = CellReference.convertNumToColString(cellNum);
+ String result = null;
+ CellType[] cellTypeArr = validateMap.get(field.getType());
+ if (cellTypeArr == null) {
+ result = MessageFormat.format("Unsupported type [{0}]", field.getType().getSimpleName());
+ return result;
+ }
+ ExcelCell annoCell = field.getAnnotation(ExcelCell.class);
+ if (cell == null
+ || (cell.getCellTypeEnum() == CellType.STRING && isBlank(cell
+ .getStringCellValue()))) {
+ if (annoCell != null && annoCell.valid().allowNull() == false) {
+ result = MessageFormat.format("the cell [{0}] can not null", columnName);
+ }
+ ;
+ }
+// else if (cell.getCellTypeEnum() == CellType.BLANK && annoCell.valid().allowNull()) {
+// return result;
+// }
+// else {
+// List<CellType> cellTypes = Arrays.asList(cellTypeArr);
+//
+// // 如果類型不在指定範圍內,並且沒有默認值
+// if (!(cellTypes.contains(cell.getCellTypeEnum()))
+// || isNotBlank(annoCell.defaultValue())
+// && cell.getCellTypeEnum() == CellType.STRING) {
+// StringBuilder strType = new StringBuilder();
+// for (int i = 0; i < cellTypes.size(); i++) {
+// CellType cellType = cellTypes.get(i);
+// strType.append(getCellTypeByInt(cellType));
+// if (i != cellTypes.size() - 1) {
+// strType.append(",");
+// }
+// }
+// result =
+// MessageFormat.format("the cell [{0}] type must [{1}]", columnName, strType.toString());
+// } else {
+// // 类型符合验证,但值不在要求范围内的
+// // String in
+// if (annoCell.valid().in().length != 0 && cell.getCellTypeEnum() == CellType.STRING) {
+// String[] in = annoCell.valid().in();
+// String cellValue = cell.getStringCellValue();
+// boolean isIn = false;
+// for (String str : in) {
+// if (str.equals(cellValue)) {
+// isIn = true;
+// }
+// }
+// if (!isIn) {
+// result = MessageFormat.format("the cell [{0}] value must in {1}", columnName, in);
+// }
+// }
+// // 数字型
+// if (cell.getCellTypeEnum() == CellType.NUMERIC) {
+// double cellValue = cell.getNumericCellValue();
+// // 小于
+// if (!Double.isNaN(annoCell.valid().lt())) {
+// if (!(cellValue < annoCell.valid().lt())) {
+// result =
+// MessageFormat.format("the cell [{0}] value must less than [{1}]", columnName,
+// annoCell.valid().lt());
+// }
+// }
+// // 大于
+// if (!Double.isNaN(annoCell.valid().gt())) {
+// if (!(cellValue > annoCell.valid().gt())) {
+// result =
+// MessageFormat.format("the cell [{0}] value must greater than [{1}]", columnName,
+// annoCell.valid().gt());
+// }
+// }
+// // 小于等于
+// if (!Double.isNaN(annoCell.valid().le())) {
+// if (!(cellValue <= annoCell.valid().le())) {
+// result =
+// MessageFormat.format("the cell [{0}] value must less than or equal [{1}]",
+// columnName, annoCell.valid().le());
+// }
+// }
+// // 大于等于
+// if (!Double.isNaN(annoCell.valid().ge())) {
+// if (!(cellValue >= annoCell.valid().ge())) {
+// result =
+// MessageFormat.format("the cell [{0}] value must greater than or equal [{1}]",
+// columnName, annoCell.valid().ge());
+// }
+// }
+// }
+// }
+// }
+ return result;
+ }
+
+ /**
+ * 根据annotation的seq排序后的栏位
+ *
+ * @param clazz
+ * @return
+ */
+ private static List<FieldForSortting> sortFieldByAnno(Class<?> clazz) {
+ Field[] fieldsArr = clazz.getDeclaredFields();
+ List<FieldForSortting> fields = new ArrayList<>();
+ List<FieldForSortting> annoNullFields = new ArrayList<>();
+ for (Field field : fieldsArr) {
+ ExcelCell ec = field.getAnnotation(ExcelCell.class);
+ if (ec == null) {
+ // 没有ExcelCell Annotation 视为不汇入
+ continue;
+ }
+ int id = ec.index();
+ fields.add(new FieldForSortting(field, id));
+ }
+ fields.addAll(annoNullFields);
+ sortByProperties(fields, true, false, "index");
+ return fields;
+ }
+
+ private static void sortByProperties(List<? extends Object> list, boolean isNullHigh,
+ boolean isReversed, String... props) {
+ if (CollectionUtils.isNotEmpty(list)) {
+ Comparator<?> typeComp = ComparableComparator.getInstance();
+ if (isNullHigh == true) {
+ typeComp = ComparatorUtils.nullHighComparator(typeComp);
+ } else {
+ typeComp = ComparatorUtils.nullLowComparator(typeComp);
+ }
+ if (isReversed) {
+ typeComp = ComparatorUtils.reversedComparator(typeComp);
+ }
+
+ List<Object> sortCols = new ArrayList<Object>();
+
+ if (props != null) {
+ for (String prop : props) {
+ sortCols.add(new BeanComparator(prop, typeComp));
+ }
+ }
+ if (sortCols.size() > 0) {
+ Comparator<Object> sortChain = new ComparatorChain(sortCols);
+ Collections.sort(list, sortChain);
+ }
+ }
+ }
+
+ private static boolean isBlank(String str){
+ if(str == null){
+ return true;
+ }
+ return str.length() == 0;
+ }
+
+ protected static boolean isNotBlank(String str){
+ return !isBlank(str);
+ }
+
+}
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/FieldForSortting.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/FieldForSortting.java
new file mode 100644
index 0000000..6ca14b0
--- /dev/null
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/utils/poihelper/FieldForSortting.java
@@ -0,0 +1,61 @@
+package com.gkhy.safePlatform.targetDuty.utils.poihelper;
+
+import java.lang.reflect.Field;
+
+/**
+ * The <code>FieldForSortting</code>
+ *
+ */
+public class FieldForSortting {
+ private Field field;
+ private int index;
+
+ /**
+ * @param field
+ */
+ public FieldForSortting(Field field) {
+ super();
+ this.field = field;
+ }
+
+ /**
+ * @param field
+ * @param index
+ */
+ public FieldForSortting(Field field, int index) {
+ super();
+ this.field = field;
+ this.index = index;
+ }
+
+ /**
+ * @return the field
+ */
+ public Field getField() {
+ return field;
+ }
+
+ /**
+ * @param field
+ * the field to set
+ */
+ public void setField(Field field) {
+ this.field = field;
+ }
+
+ /**
+ * @return the index
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * @param index
+ * the index to set
+ */
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+}
diff --git a/tmlog.lck b/tmlog.lck
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tmlog.lck
--
Gitblit v1.9.2