Browse Source

版本更新

lihui001 3 years ago
parent
commit
beeca6e83f
17 changed files with 215 additions and 95 deletions
  1. 1 1
      common/src/main/java/com/zcxk/util/DESUtil.java
  2. 2 9
      sms_water/src/main/java/com/zcxk/rabbitmq/ReceiveClearData.java
  3. 1 2
      sms_water/src/main/java/com/zcxk/service/DeviceTypeService.java
  4. 1 1
      zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/config/SwaggerConfig.java
  5. 7 6
      zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/AppDataService.java
  6. 4 0
      zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/SceneService.java
  7. 9 8
      zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/impl/OnlineMonitorImpl.java
  8. 20 0
      zoniot-charge/zoniot-charge-xxl-client/pom.xml
  9. 16 4
      zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/ZoniotChargeXxlJobClientApplication.java
  10. 1 3
      zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/config/RabbitConfig.java
  11. 22 15
      zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/mq/ReceiveClearData.java
  12. 2 2
      zoniot-charge/zoniot-charge-xxl-client/src/main/resources/bootstrap-dev.yml
  13. 18 0
      zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/enums/RespCodeEnum.java
  14. 9 9
      zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/pojo/AjaxMessage.java
  15. 1 1
      zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/util/ReqUtil.java
  16. 86 19
      zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/export/EasyExcelUtil.java
  17. 15 15
      zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/log/FormattedMessage.java

+ 1 - 1
common/src/main/java/com/zcxk/util/DESUtil.java

@@ -30,7 +30,7 @@ public class DESUtil {
 
     public static String decrypt(String message, String key) throws Exception {
 
-        byte [] bytesrc = decodeBase64(message); //convertHexString(message);
+        byte [] bytesrc = decodeBase64(message); //convertHexString(msg);
         Cipher cipher = Cipher.getInstance( "DES/CBC/PKCS5Padding" );
         DESKeySpec desKeySpec = new DESKeySpec(key.getBytes( "UTF-8" ));
         SecretKeyFactory keyFactory = SecretKeyFactory.getInstance( "DES" );

+ 2 - 9
sms_water/src/main/java/com/zcxk/rabbitmq/ReceiveClearData.java

@@ -38,7 +38,7 @@ public class ReceiveClearData {
     private AlarmDataHandler alarmDataHandler;
 
     @Autowired
-    private  ReportWaterPumpStateHandler reportWaterPumpStateHandler;
+    private ReportWaterPumpStateHandler reportWaterPumpStateHandler;
 
     @Resource
     private AlarmDetailMapper alarmDetailMapper;
@@ -49,7 +49,6 @@ public class ReceiveClearData {
     @Autowired
     private MonitorDataService monitorDataService;
 
-    private static final String ORIGINAL_DATA_STRING = "originalData";
 
     /**
      * 先注入,然后再通过SPEL取值
@@ -84,7 +83,6 @@ public class ReceiveClearData {
      * @return void
      **/
     public void receivedDataHandle(byte[] receivedData){
-        JSONObject originalData = new JSONObject();
         JSONObject jsonObject = JSONObject.parseObject(new String(receivedData));
         String eventTime      = jsonObject.getString("eventTime");
         String deviceCode     = jsonObject.getString("unitIdentifier");
@@ -99,23 +97,18 @@ public class ReceiveClearData {
             log.error("rabbitMq接收消息处理,code:{},查询不到设备或者设备属性为空,退出",deviceCode);
             return;
         }
-        // 英文版、中文版
         JSONObject receiveData  = JSONObject.parseObject(jsonObject .getString("parsedData"));
-        if (jsonObject.containsKey(ORIGINAL_DATA_STRING)){
-            originalData = JSONObject.parseObject(jsonObject .getString(ORIGINAL_DATA_STRING));
-        }
         List<MonitorDataValueEntity> monitorDataValueEntities = monitorDataEntity.getDataValues();
         Integer number = 0;
         for (MonitorDataValueEntity monitorDataValueEntity : monitorDataValueEntities) {
             BigDecimal bigDecimal = null;
             try {
                 Double doubleValue = receiveData.getDouble(monitorDataValueEntity.getIdentifier());
-                doubleValue = doubleValue == null ? originalData.getDouble(monitorDataValueEntity.getIdentifier()) : doubleValue;
                 if (doubleValue == null) {
                     continue;
                 }
                 bigDecimal = new BigDecimal(doubleValue);
-            } catch (NumberFormatException e) {
+            } catch (Exception e) {
                 log.error("double 转换 error ->", e);
                 continue;
             }

+ 1 - 2
sms_water/src/main/java/com/zcxk/service/DeviceTypeService.java

@@ -84,8 +84,7 @@ public class DeviceTypeService extends ServiceImpl<DeviceTypeMapper, DeviceTypeE
         return deviceTypeMapper.findDeviceTypeById(id);
     }
 
-    public List<TreeDataDto> getTreeData(String  name)
-    {
+    public List<TreeDataDto> getTreeData(String  name) {
         DeviceTypeEntity deviceTypeEntity = new DeviceTypeEntity();
         deviceTypeEntity.setManufacturerName(name);
         List<DeviceTypeEntity> list = deviceTypeMapper.findList(deviceTypeEntity);

+ 1 - 1
zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/config/SwaggerConfig.java

@@ -44,7 +44,7 @@ public class SwaggerConfig {
 
     private ApiInfo apiInfo() {
         return new ApiInfoBuilder()
-                .title("sms water Api")
+                .title("调度中心-api")
                 .description("调度中心接口")
                 .version("1.0")
                 .build();

+ 7 - 6
zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/AppDataService.java

@@ -6,6 +6,7 @@ import com.zcxk.charge.api.dto.SceneDataDto;
 import com.zcxk.charge.api.dto.SceneDataForAppDto;
 import com.zcxk.charge.api.vo.AlarmDetailsEntityVo;
 import com.zcxk.charge.core.entity.*;
+import com.zcxk.core.mongo.utils.StringUtil;
 import com.zcxk.core.utils.ByteArrayUtils;
 import com.zcxk.core.utils.util.RedisUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -131,24 +132,24 @@ public class AppDataService {
         Map<String, List<AlarmDetailsEntityVo>> alarms = new HashMap<>();
         Map<String, List<DeviceParmEntity>> parmMap = new HashMap<>();
         addDeviceCodes(id, deviceCodes, alarms, parmMap);
-        List<SceneDataDto> sceneDataDtos = new ArrayList<>();
+        List<SceneDataDto> dtoList = new ArrayList<>();
         for (String code : deviceCodes) {
-            byte[] bytes = redisUtil.get(("sms_water_" + code).getBytes());
+            String cacheString = redisUtil.get("sms_water_" + code);
             // 将报警信息放置map中
             List<AlarmDetailsEntityVo> alarmVos = alarms.get(code);
             Map<Integer, AlarmDetailsEntityVo> mapAlarm = alarmVos.stream().collect(Collectors.toMap(AlarmDetailsEntityVo::getAttributeId, a -> a, (k1, k2) -> k1));
             // 将缓存中的实时数据放到map中方便进行遍历
-            if (bytes != null && bytes.length > 0) {
-                addSceneDataDto(bytes, returnInfo, parmMap, code, mapAlarm, sceneDataDtos);
+            if (StringUtil.isNotEmpty(cacheString)) {
+                addSceneDataDto(cacheString.getBytes(), returnInfo, parmMap, code, mapAlarm, dtoList);
             } else {
                 for (DeviceParmEntity item : parmMap.get(code)) {
                     SceneDataDto sceneDataDto = new SceneDataDto();
                     sceneDataDto.setMonitorName(item.getAttributeName());
-                    sceneDataDtos.add(sceneDataDto);
+                    dtoList.add(sceneDataDto);
                 }
             }
         }
-        returnInfo.setInfos(sceneDataDtos);
+        returnInfo.setInfos(dtoList);
         return returnInfo;
     }
 

+ 4 - 0
zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/SceneService.java

@@ -360,7 +360,11 @@ public class SceneService extends ServiceImpl<SceneMapper, SceneEntity> {
      */
     public SceneEntity findSceneByIdForApp(Long id) {
         SceneEntity sceneEntity = sceneMapper.findSceneById(id);
+        if (sceneEntity == null) {
+            return null;
+        }
         SceneImageEntity sceneImageEntity = new SceneImageEntity();
+
         sceneImageEntity.setSceneId(id);
         sceneImageEntity.setImageType(3L);
         List<SceneImageEntity> sceneImageEntities = sceneImageService.findList(sceneImageEntity);

+ 9 - 8
zoniot-charge/zoniot-charge-web/src/main/java/com/zcxk/charge/web/service/impl/OnlineMonitorImpl.java

@@ -13,6 +13,7 @@ import com.zcxk.charge.web.common.Pagination;
 import com.zcxk.charge.web.service.DeviceAttributeSpecsService;
 import com.zcxk.charge.web.service.OnlineMonitorService;
 import com.zcxk.charge.web.util.OrgInfoUtil;
+import com.zcxk.core.mongo.utils.StringUtil;
 import com.zcxk.core.oauth2.pojo.LoginUser;
 import com.zcxk.core.oauth2.util.UserUtil;
 import com.zcxk.core.utils.ByteArrayUtils;
@@ -405,12 +406,12 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
         monitorDataCollectDto.setType(1);
         DispatchSummaryDto result=new DispatchSummaryDto();
 
-        monitorDataCollectDto.setSceneTypeName("水源");
+        monitorDataCollectDto.setSceneTypeName(SceneTypeEnum.WATER_SOURCE.getMessage());
         List<MonitorDataCollectVo> waterHead=onlineMonitorMapper.selectSceneParam(monitorDataCollectDto);
         MonitorDataCollectDto waterHeadRes= getCalTotalData(waterHead);
         result.setIntakeWaterUsage(waterHeadRes.getIntakeWaterUsage());
 
-        monitorDataCollectDto.setSceneTypeName("水厂");
+        monitorDataCollectDto.setSceneTypeName(SceneTypeEnum.WATER_WORKS.getMessage());
         List<MonitorDataCollectVo> waterWorks=onlineMonitorMapper.selectSceneParam(monitorDataCollectDto);
         MonitorDataCollectDto waterWorksRes= getCalTotalData(waterWorks);
         result.setYieldWaterUsage(waterWorksRes.getYieldWaterUsage());
@@ -420,17 +421,17 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
         result.setInvNameRate(invName!=null&&waterWorksRes.getYieldWaterUsage()!=null?waterWorksRes.getYieldWaterUsage()/invName*100:null);
 
         OnlineDataDto onlineDataDto=new OnlineDataDto();
-        onlineDataDto.setSceneTypeName("压力");
+        onlineDataDto.setSceneTypeName(PipeNetEnum.PRESSURE.getMessage());
         onlineDataDto.setSceneIds(monitorDataCollectDto.getSceneIds());
         List<DeviceCountStatsVo> pres=statsDeviceQualified(onlineDataDto);
         result.setPresQualifiedRate(pres.size()>0&&pres.get(0).getTotalCount()!=0&&pres.get(0).getParmQualified().size()>0?
                 (double)pres.get(0).getParmQualified().get(0).getNormalCount()/pres.get(0).getTotalCount()*100:100);
 
-        onlineDataDto.setSceneTypeName("水质");
+        onlineDataDto.setSceneTypeName(PipeNetEnum.WATER_QUALITY.getMessage());
         List<DeviceCountStatsVo> water=statsDeviceQualified(onlineDataDto);
         result.setWaterQualifiedRate(water.size()>0&&water.get(0).getTotalCount()!=0?(double)water.get(0).getNormalCount()/water.get(0).getTotalCount()*100:100);
 
-        //售水量造假 产销差率30%~40%
+        // 售水量造假 产销差率30%~40%
         if(result.getYieldWaterUsage()!=null){
             result.setNrwRate(Math.random()*10+30);
             result.setSellWaterUsage((1-result.getNrwRate()/100)*result.getYieldWaterUsage());
@@ -523,11 +524,11 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
     }
 
     private MonitorDataEntity getCacheData(String key){
-        byte[] bytes = redisUtil.get(("sms_water_" + key)).getBytes();
-        if (bytes == null || bytes.length == 0){
+        String str = redisUtil.get(("sms_water_" + key));
+        if (StringUtil.isEmpty(str)) {
             return null;
         }
-        return (MonitorDataEntity)ByteArrayUtils.bytesToObject(bytes).get();
+        return (MonitorDataEntity)ByteArrayUtils.bytesToObject(str.getBytes()).get();
     }
 
 

+ 20 - 0
zoniot-charge/zoniot-charge-xxl-client/pom.xml

@@ -12,6 +12,25 @@
     <artifactId>zoniot-charge-xxl-client</artifactId>
 
     <dependencies>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--spring-boot-starter-aop-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.xuxueli</groupId>
             <artifactId>xxl-job-core</artifactId>
@@ -45,6 +64,7 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-amqp</artifactId>
         </dependency>
+
     </dependencies>
 
 

+ 16 - 4
zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/ZoniotChargeXxlJobClientApplication.java

@@ -4,7 +4,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.web.client.RestTemplate;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 
@@ -12,17 +17,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
  * @author Andy
  * @version V1.0
  **/
-@SpringBootApplication
+@EnableDiscoveryClient
+@SpringBootApplication(scanBasePackages="com.zcxk")
 @EnableSwagger2
-@ComponentScan(basePackages = {"com.zcxk"})
 @MapperScan("com.zcxk.charge.core.dao")
+@EnableFeignClients
 @Slf4j
 public class ZoniotChargeXxlJobClientApplication {
 
 	public static void main(String[] args) {
-		log.info("=====================Create-XXJOB客户端START==============");
+		log.info("=====================Zoniot-Charge-XXJOB客户端START==============");
 		SpringApplication.run(ZoniotChargeXxlJobClientApplication.class, args);
-		log.info("=====================Create-XXJOB客户端END================");
+		log.info("=====================Zoniot-Charge-XXJOB客户端END================");
+	}
+
+	@Bean
+	@LoadBalanced
+	RestTemplate restTemplate(){
+		return new RestTemplate();
 	}
 
 }

+ 1 - 3
zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/config/RabbitConfig.java

@@ -1,7 +1,5 @@
 package com.zcxk.charge.xxl.config;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.amqp.core.AcknowledgeMode;
 import org.springframework.amqp.core.BindingBuilder;
 import org.springframework.amqp.core.QueueBuilder;
@@ -33,7 +31,6 @@ import org.springframework.context.annotation.Scope;
 @Configuration
 public class RabbitConfig {
 
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Value("${message.spring.rabbitmq.host}")
     private String messageHost;
@@ -67,6 +64,7 @@ public class RabbitConfig {
     private  String receiveExchangeName;
     @Value("${dispath.routing.key}")
     private  String dispathRoutingKey;
+
     @Value("${dispath.queue}")
     private  String dispathQueue;
 

+ 22 - 15
zoniot-charge/zoniot-charge-xxl-client/src/main/java/com/zcxk/charge/xxl/mq/ReceiveClearData.java

@@ -129,7 +129,6 @@ public class ReceiveClearData {
      * @return void
      **/
     public void receivedDataHandle(byte[] receivedData){
-        JSONObject originalData = new JSONObject();
         JSONObject jsonObject = JSONObject.parseObject(new String(receivedData));
         String eventTime      = jsonObject.getString("eventTime");
         String deviceCode     = jsonObject.getString("unitIdentifier");
@@ -155,7 +154,7 @@ public class ReceiveClearData {
                     continue;
                 }
                 bigDecimal = new BigDecimal(doubleValue);
-            } catch (NumberFormatException e) {
+            } catch (Exception e) {
                 log.error("double 转换 error ->", e);
                 continue;
             }
@@ -228,20 +227,28 @@ public class ReceiveClearData {
      * @param
      * @return
      */
-    public static String hexStr2Str(String hexStr) {
-           String str = "0123456789ABCDEF";
-           char[] hexs = hexStr.toCharArray();
-           byte[] bytes = new byte[hexStr.length() / 2];
-            int n;
-            for (int i = 0; i < bytes.length; i++) {
-                 n = str.indexOf(hexs[2 * i]) * 16;
-                 n += str.indexOf(hexs[2 * i + 1]);
-                 bytes[i] = (byte) (n & 0xff);
-             }
-            return new String(bytes);
+    public static String hexStringToString(String s) {
+        if (s == null || s.equals("")) {
+            return null;
         }
-
+        s = s.replace(" ", "");
+        byte[] baKeyword = new byte[s.length() / 2];
+        for (int i = 0; i < baKeyword.length; i++) {
+            try {
+                baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        try {
+            s = new String(baKeyword, "UTF-8");
+            new String();
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
+        return s;
+    }
     public static void main(String[] args) {
-        System.out.println(ReceiveClearData.hexStr2Str("ABCD0031EA892108220200010501FE0F7710443131333B322E313B352E302031392020202020000000FFFF58521704013EAEEAF02B0D0A"));
+        System.out.println(ReceiveClearData.hexStringToString("ABCD0031EA892108220200010501FE0F7710443131333B322E313B352E302031392020202020000000FFFF58521704013EAEEAF02B0D0A"));
     }
 }

+ 2 - 2
zoniot-charge/zoniot-charge-xxl-client/src/main/resources/bootstrap-dev.yml

@@ -1,6 +1,6 @@
 spring:
   application:
-    name: zoniot-charge
+    name: zoniot-xxljob-client
   profiles:
     active: dev
   cloud:
@@ -8,7 +8,7 @@ spring:
       config:
         namespace: 73da6876-408b-4850-9ef9-cd2c4ea831bf
         server-addr: 127.0.0.1:8848
-        prefix: zoniot-charge
+        prefix: zoniot-xxljob-client
         file-extension: properties
   main:
     allow-bean-definition-overriding: true

+ 18 - 0
zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/enums/RespCodeEnum.java

@@ -21,14 +21,32 @@ public enum RespCodeEnum implements RespCode {
      */
     OK(0, "成功"),
 
+    /**
+     * 系统错误
+     */
     ERROR_500(500, "系统错误"),
 
+    /**
+     * 缺少参数【%s】
+     */
     GLOBAL_PARAMETER_NOT_NULL(404, "缺少参数【%s】"),
 
+    /**
+     * 缺少参数【%s】
+     */
     GLOBAL_PARAMETER_NOT_EMPTY(404, "缺少参数【%s】"),
 
+    /**
+     * 获取redis锁失败
+     */
     GLOBAL_GET_DISTRIBUTED_LOCK_ERROR(505, "获取redis锁失败"),
+
+    /**
+     * 所选告警类型有规则不为0的,不能删除
+     */
     ALAM_TYPE_DELETION_ERROR(201001,"所选告警类型有规则不为0的,不能删除");
+
+
     private int status;
 
     private String message;

+ 9 - 9
zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/pojo/AjaxMessage.java

@@ -21,55 +21,55 @@ public class AjaxMessage<T> implements Serializable {
     private int status;
 
     @ApiModelProperty(value = "返回信息", position = 1)
-    private String message;
+    private String msg;
 
     @ApiModelProperty(value = "返回内容", position = 2)
     private T data;
 
     private AjaxMessage(RespCode respCode) {
         this.status = respCode.getStatus();
-        this.message = respCode.getMessage();
+        this.msg = respCode.getMessage();
     }
 
     private AjaxMessage(int status, String message) {
         this.status = status;
-        this.message = message;
+        this.msg = message;
         this.data = null;
     }
 
     public AjaxMessage(int status, String message, T data) {
         this.status = status;
-        this.message = message;
+        this.msg = message;
         this.data = data;
     }
 
     public AjaxMessage(RespCode resultStatus, T data) {
         this.status = resultStatus.getStatus();
-        this.message = resultStatus.getMessage();
+        this.msg = resultStatus.getMessage();
         this.data = data;
     }
 
     public void setMsg(int status, String msg, T data) {
         this.status = status;
-        this.message = msg;
+        this.msg = msg;
         this.data = data;
     }
 
     public void setMsg(int status, String msg) {
         this.status = status;
-        this.message = msg;
+        this.msg = msg;
         this.data = null;
     }
 
     public void setMsg(RespCode resultStatus, T data) {
         this.status = resultStatus.getStatus();
-        this.message = resultStatus.getMessage();
+        this.msg = resultStatus.getMessage();
         this.data = data;
     }
 
     public void setMsg(RespCode resultStatus) {
         this.status = resultStatus.getStatus();
-        this.message = resultStatus.getMessage();
+        this.msg = resultStatus.getMessage();
         this.data = null;
     }
 

+ 1 - 1
zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/util/ReqUtil.java

@@ -27,7 +27,7 @@ public class ReqUtil {
         if (RespCodeEnum.OK.getStatus() ==  response.getStatus()) {
             return response.getData();
         } else {
-            throw BusinessException.builder(response.getStatus(), response.getMessage());
+            throw BusinessException.builder(response.getStatus(), response.getMsg());
         }
     }
 

+ 86 - 19
zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/export/EasyExcelUtil.java

@@ -12,6 +12,7 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
 import com.alibaba.fastjson.JSON;
 import com.zcxk.core.common.pojo.AjaxMessage;
 import com.zcxk.core.utils.DateUtil;
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
@@ -31,13 +32,67 @@ import java.util.*;
 public  class EasyExcelUtil {
 
     /**
-     * @MethodName:Excel导出
-     * @Description: TODO
-     * @Param: path 导出基础路径 t实体名 excelName 文件名 data数据
-     * @Return:
-     * @Author: WYY
-     * @Date: 2020/10/28
-     **/
+    * 仅仅输出明细数据到excel文件, 增加自定义的头部
+    * @author Andy
+    * @date 15:02 2021/8/23
+    * @param response:
+    * @param excelName:
+    * @param head:
+    * @param list:
+    * @return void
+    **/
+    public static void excelWriteWithHeader(HttpServletResponse response, String excelName, List<List<String>> head, List list) throws IOException {
+        setHeader(excelName, response);
+        // 这里 需要指定写用哪个class去写,指定模板名称及数据
+        EasyExcel.write(response.getOutputStream())
+                .head(head)
+                .excelType(ExcelTypeEnum.XLSX)
+                .registerWriteHandler(new CustemhandlerUtils())
+                .registerWriteHandler(getStyleStrategy())
+                .sheet("sheet")
+                .doWrite(list);
+    }
+
+    /**
+    * 仅仅输出明细数据到excel文件, 增加自定义的头部
+    * @author Andy
+    * @date 15:02 2021/8/23
+    * @param path:
+    * @param excelName:
+    * @param head:
+    * @param list:
+    * @return java.lang.String
+    **/
+    public static String excelWriteWithHeader(String path, String excelName, List<List<String>> head, List list) {
+        String filePath = "";
+        String fileName = DateFormatUtils.format(new Date(), "yyyy/MM/dd") + File.separator;
+        fileName = fileName + excelName + System.currentTimeMillis() + ".xlsx";
+        try {
+            // 这里 需要指定写用哪个class去写,指定模板名称及数据
+            EasyExcel.write(path + fileName)
+                    .head(head)
+                    .excelType(ExcelTypeEnum.XLSX)
+                    .registerWriteHandler(new CustemhandlerUtils())
+                    .registerWriteHandler(getStyleStrategy())
+                    .sheet("sheet")
+                    .doWrite(list);
+            filePath = getPathFileName(path, fileName);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return filePath;
+    }
+
+    /**
+    * Excel导出
+    * @author Andy
+    * @date 10:05 2021/8/23
+    * @param path:
+    * @param t:
+    * @param excelName:
+    * @param data:
+    * @return java.lang.String
+    **/
     public static String excelWrite(String path,Class t, String excelName,List data) {
         String filePath = "";
         String fileName = DateUtil.format(new Date(), "yyyy/MM/dd") + File.separator;
@@ -59,17 +114,19 @@ public  class EasyExcelUtil {
         return filePath;
     }
 
-    public static void excelWrite(HttpServletResponse response,Class t, String excelName, List data) throws Exception {
-        String fileName =  excelName +"-"+ DateUtil.format(new Date(), "yyyyMMddHHmmss") ;
-        fileName = URLEncoder.encode(fileName, "UTF-8");
-        response.setContentType("application/vnd.ms-excel");
-        response.setCharacterEncoding("utf8");
-        response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xlsx");
-        response.setHeader("Pragma", "public");
-        response.setHeader("Cache-Control", "no-store");
-        response.addHeader("Cache-Control", "max-age=0");
-
-        EasyExcel.write(response.getOutputStream(), t)
+    /**
+    * 直接导出
+    * @author Andy
+    * @date 15:03 2021/8/23
+    * @param response:
+    * @param obj:
+    * @param excelName:
+    * @param data:
+    * @return void
+    **/
+    public static void excelWrite(HttpServletResponse response,Class obj, String excelName, List data) throws Exception {
+        setHeader(excelName, response);
+        EasyExcel.write(response.getOutputStream(), obj)
                 .excelType(ExcelTypeEnum.XLSX)
                 .registerWriteHandler(new CustemhandlerUtils())
                 .registerWriteHandler(EasyExcelUtil.getStyleStrategy())
@@ -131,6 +188,7 @@ public  class EasyExcelUtil {
         String pathFileName = uploadDir  + "/" + fileName;
         return ToolUtil.path(pathFileName);
     }
+
     private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
         File desc = new File(uploadDir + File.separator + fileName);
 
@@ -174,6 +232,15 @@ public  class EasyExcelUtil {
         return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
     }
 
-
+    private static void setHeader(String excelName, HttpServletResponse response) throws UnsupportedEncodingException {
+        String fileName =  excelName +"-"+ DateUtil.format(new Date(), "yyyyMMddHHmmss") ;
+        fileName = URLEncoder.encode(fileName, "UTF-8");
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xlsx");
+        response.setHeader("Pragma", "public");
+        response.setHeader("Cache-Control", "no-store");
+        response.addHeader("Cache-Control", "max-age=0");
+    }
 
 }

+ 15 - 15
zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/log/FormattedMessage.java

@@ -38,7 +38,7 @@ public class FormattedMessage implements Message {
      * Constructs with a locale, a pattern and a single parameter.
      *
      * @param locale The locale
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arg The parameter.
      * @since 2.6
      */
@@ -50,7 +50,7 @@ public class FormattedMessage implements Message {
      * Constructs with a locale, a pattern and two parameters.
      *
      * @param locale The locale
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arg1 The first parameter.
      * @param arg2 The second parameter.
      * @since 2.6
@@ -64,7 +64,7 @@ public class FormattedMessage implements Message {
      * Constructs with a locale, a pattern and a parameter array.
      *
      * @param locale The locale
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arguments The parameter.
      * @since 2.6
      */
@@ -77,7 +77,7 @@ public class FormattedMessage implements Message {
      * Constructs with a locale, a pattern, a parameter array, and a throwable.
      *
      * @param locale The Locale
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arguments The parameter.
      * @param throwable The throwable
      * @since 2.6
@@ -93,7 +93,7 @@ public class FormattedMessage implements Message {
     /**
      * Constructs with a pattern and a single parameter.
      *
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arg The parameter.
      */
     public FormattedMessage(final String messagePattern, final Object arg) {
@@ -103,7 +103,7 @@ public class FormattedMessage implements Message {
     /**
      * Constructs with a pattern and two parameters.
      *
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arg1 The first parameter.
      * @param arg2 The second parameter.
      */
@@ -114,7 +114,7 @@ public class FormattedMessage implements Message {
     /**
      * Constructs with a pattern and a parameter array.
      *
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arguments The parameter.
      */
     public FormattedMessage(final String messagePattern, final Object... arguments) {
@@ -124,7 +124,7 @@ public class FormattedMessage implements Message {
     /**
      * Constructs with a pattern, a parameter array, and a throwable.
      *
-     * @param messagePattern The message pattern.
+     * @param messagePattern The msg pattern.
      * @param arguments The parameter.
      * @param throwable The throwable
      */
@@ -160,9 +160,9 @@ public class FormattedMessage implements Message {
     }
 
     /**
-     * Gets the message pattern.
+     * Gets the msg pattern.
      *
-     * @return the message pattern.
+     * @return the msg pattern.
      */
     @Override
     public String getFormat() {
@@ -170,9 +170,9 @@ public class FormattedMessage implements Message {
     }
 
     /**
-     * Gets the formatted message.
+     * Gets the formatted msg.
      *
-     * @return the formatted message.
+     * @return the formatted msg.
      */
     @Override
     public String getFormattedMessage() {
@@ -194,7 +194,7 @@ public class FormattedMessage implements Message {
                 return new MessageFormatMessage(locale, msgPattern, args);
             }
         } catch (final Exception ignored) {
-            // Obviously, the message is not a proper pattern for MessageFormat.
+            // Obviously, the msg is not a proper pattern for MessageFormat.
         }
         try {
             if (MSG_PATTERN.matcher(msgPattern).find()) {
@@ -207,9 +207,9 @@ public class FormattedMessage implements Message {
     }
 
     /**
-     * Gets the message parameters.
+     * Gets the msg parameters.
      *
-     * @return the message parameters.
+     * @return the msg parameters.
      */
     @Override
     public Object[] getParameters() {