Sfoglia il codice sorgente

导出时间格式转换3

jichaobo 3 anni fa
parent
commit
f13a4998df

+ 83 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/CorrespondDeviceTwoVO.java

@@ -0,0 +1,83 @@
+package com.bizmatics.model.vo;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @author yq
+ * @date 2021/7/8 14:30
+ * 公用的图标VO
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class CorrespondDeviceTwoVO {
+
+    /**
+     * 设备表主键ID
+     */
+    private Integer id;
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+    /**
+     * 设备地址
+     */
+    private String deviceAddress;
+    /**
+     * 安装时间
+     */
+    private String installTime;
+    /**
+     * 设备状态
+     */
+    private Integer deviceStatus;
+    /**
+     * 最后通信时间
+     */
+    private String statusTime;
+
+    /**
+     * 站点ID
+     */
+    private int siteId;
+    /**
+     * 站点名称
+     */
+    private String siteName;
+
+    /**
+     * 离线时长
+     */
+    private Integer offlineDuration;
+    /**
+     * 在线时长
+     */
+    private Integer onlineDuration;
+
+    /**
+     * sim卡号
+     */
+    private String sim;
+
+    /**
+     * 楼层
+     */
+    private Integer floor;
+
+    /**
+     * 设备类型
+     */
+    private Integer deviceType;
+
+
+}

+ 22 - 5
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -17,10 +17,7 @@ import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.model.*;
 import com.bizmatics.model.system.SysUser;
-import com.bizmatics.model.vo.CorrespondDeviceListVO;
-import com.bizmatics.model.vo.CorrespondDeviceVO;
-import com.bizmatics.model.vo.DeviceOneVo;
-import com.bizmatics.model.vo.ProcessingTimeVo;
+import com.bizmatics.model.vo.*;
 import com.bizmatics.persistence.mapper.DeviceMapper;
 import com.bizmatics.service.DeviceAnalogVariableListService;
 import com.bizmatics.service.DeviceAttributeService;
@@ -425,15 +422,35 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
 
     @Override
     public String correspondDeviceExport(String deviceName) {
+        SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Workbook workbook = null;
         File file = null;
         try {
             ExportParams params = new ExportParams(null, "通信设备列表");
             workbook = ExcelExportUtil.exportBigExcel(params, CorrespondDeviceExportVO.class,
                     (o, i) -> {
+                        List<CorrespondDeviceTwoVO> Active = new ArrayList<CorrespondDeviceTwoVO>();
                         int startCurrent = (i - 1) * 30;
                         List<CorrespondDeviceVO> correspondDeviceList = baseMapper.CorrespondDeviceList(deviceName, startCurrent, 30);
-                        return new ArrayList<>(BeanMapperUtils.mapList(correspondDeviceList, CorrespondDeviceVO.class, CorrespondDeviceExportVO.class));
+                        for (int j = 0; j <correspondDeviceList.size(); j++){
+                            CorrespondDeviceTwoVO correspondDeviceTwoVO = new CorrespondDeviceTwoVO();
+                            correspondDeviceTwoVO.setDeviceCode(correspondDeviceList.get(j).getDeviceCode());
+                            correspondDeviceTwoVO.setDeviceName(correspondDeviceList.get(j).getDeviceName());
+                            correspondDeviceTwoVO.setDeviceAddress(correspondDeviceList.get(j).getDeviceAddress());
+                            correspondDeviceTwoVO.setInstallTime(longSdf.format(correspondDeviceList.get(j).getInstallTime()));
+                            correspondDeviceTwoVO.setDeviceStatus(correspondDeviceList.get(j).getDeviceStatus());
+                            correspondDeviceTwoVO.setStatusTime(longSdf.format(correspondDeviceList.get(j).getStatusTime()));
+                            correspondDeviceTwoVO.setSiteId(correspondDeviceList.get(j).getSiteId());
+                            correspondDeviceTwoVO.setSiteName(correspondDeviceList.get(j).getSiteName());
+                            correspondDeviceTwoVO.setOfflineDuration(correspondDeviceList.get(j).getOfflineDuration());
+                            correspondDeviceTwoVO.setOnlineDuration(correspondDeviceList.get(j).getOnlineDuration());
+                            correspondDeviceTwoVO.setSim(correspondDeviceList.get(j).getSim());
+                            correspondDeviceTwoVO.setFloor(correspondDeviceList.get(j).getFloor());
+                            correspondDeviceTwoVO.setDeviceType(correspondDeviceList.get(j).getDeviceType());
+                            Active.add(correspondDeviceTwoVO);
+                        }
+
+                        return new ArrayList<>(BeanMapperUtils.mapList(Active, CorrespondDeviceTwoVO.class, CorrespondDeviceExportVO.class));
                     }, null);
             if (null != workbook) {
                 file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", System.currentTimeMillis() + ""));