Browse Source

导出时间格式转换2

jichaobo 3 years ago
parent
commit
021e25b562

+ 23 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -20,6 +20,7 @@ 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.persistence.mapper.DeviceMapper;
 import com.bizmatics.service.DeviceAnalogVariableListService;
 import com.bizmatics.service.DeviceAttributeService;
@@ -40,6 +41,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -354,12 +356,14 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
 
     @Override
     public String deviceExport(String deviceName, Integer deviceType, Integer siteId) {
+        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, DeviceExportVO.class,
                     (o, i) -> {
+                        List<DeviceOne> Active = new ArrayList<DeviceOne>();
                         Page<Device> page = new Page<>(i, 30);
                         LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
                         queryWrapper.eq(Device::getEnable, 1);
@@ -375,8 +379,26 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
                         }
 
                         page = this.page(page, queryWrapper);
+
+                        for (int j = 0; j < page.getRecords().size(); j++){
+                            DeviceOne deviceOne = new DeviceOne();
+                            deviceOne.setDeviceCode(page.getRecords().get(j).getDeviceCode());
+                            deviceOne.setDeviceName(page.getRecords().get(j).getDeviceName());
+                            deviceOne.setFloor(page.getRecords().get(j).getFloor());
+                            deviceOne.setSiteId(page.getRecords().get(j).getSiteId());
+                            deviceOne.setDeviceAddress(page.getRecords().get(j).getDeviceAddress());
+                            deviceOne.setDeviceType(page.getRecords().get(j).getDeviceType());
+                            deviceOne.setInstallTime(longSdf.format(page.getRecords().get(j).getInstallTime()));
+                            deviceOne.setCreator(page.getRecords().get(j).getCreator());
+                            deviceOne.setEnable(page.getRecords().get(j).getEnable());
+                            deviceOne.setSim(page.getRecords().get(j).getSim());
+                            deviceOne.setDeviceStatus(page.getRecords().get(j).getDeviceStatus());
+                            deviceOne.setInstalledCapacity(page.getRecords().get(j).getInstalledCapacity());
+                            Active.add(deviceOne);
+                        }
+
 //                        this.ToCommonPage(page);
-                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), Device.class, DeviceExportVO.class));
+                        return new ArrayList<>(BeanMapperUtils.mapList(Active, DeviceOne.class, DeviceExportVO.class));
                     }, null);
             if (null != workbook) {
                 file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", System.currentTimeMillis() + ""));