Browse Source

BUG修复

lin 3 years ago
parent
commit
4d39e92584

+ 72 - 0
smart-city-platform/src/main/java/com/bz/smart_city/async/AsyncInstallPlanDownloadTask.java

@@ -357,6 +357,78 @@ public class AsyncInstallPlanDownloadTask {
     }
 
 
+    public ZipStreamEntity createMachineryMeterTemplate(LoginUser loginUser, Integer planId){
+        String filePath = this.getFilePath();
+        log.info("filePath:" + filePath);
+        FileOutputStream out=null;
+        try {
+
+            //1、获取小区列表数据
+            List<Community> communityList = communityService.findBySiteId(loginUser.getSiteId());
+
+
+            //2、获取建筑列表数据
+            List<Building> buildingList = buildingMapper.findBySiteId(loginUser.getSiteId(),null, UserUtil.getCustomerIds());
+
+
+
+            //3、获取客户列表数据
+            List<Customer> customerList = customerService.getCustomerList(loginUser.getSiteId());
+
+
+            //4、获取水表类型数据
+            List<DeviceTypeDto> deviceTypeList = deviceTypeMapper.getWaterMeterType(23);
+
+            //获取集中器数据和采集器数据
+            List<ConcentratorDto> concentratorList = concentratorMapper.getLazyList(loginUser.getSiteId(),UserUtil.getCustomerIds());
+
+            //5、获取安装计划清单数据
+
+
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installMachineryMeterTemplate20201228.xlsx");   //得到文档的路径
+
+            //列表数据将存储到指定的excel文件路径
+            out = new FileOutputStream(filePath);
+            //这里的context是jxls框架上的context内容
+            Context context = new Context();
+            //将列表参数放入context中
+
+            List<InstallList> installListList = newArrayList();
+            InstallList installList = new InstallList();
+            installListList.add(installList);
+
+
+            context.putVar("installPlan", newArrayList());
+            context.putVar("communityList", communityList);
+            context.putVar("buildingList", buildingList);
+            context.putVar("customerList", customerList);
+            context.putVar("deviceTypeList", deviceTypeList);
+            context.putVar("installListList", installListList);
+            context.putVar("buildingName", null);
+            context.putVar("doorNum", null);
+            context.putVar("concentratorList", concentratorList);
+            //将List<Exam>列表数据按照模板文件中的格式生成到scoreOutput.xls文件中
+            JxlsHelper.getInstance().processTemplate(in, out, context);
+            log.info("save file success");
+
+        } catch (Exception e) {
+            log.info("createRemoteMeterTemplate Exception {}",e.getMessage());
+            e.printStackTrace();
+        }finally {
+            IOUtils.closeQuietly(out);
+        }
+        ZipStreamEntity zipStreamEntity = new ZipStreamEntity();
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        LocalDateTime date = LocalDateTime.now();
+        String fileName = "水表安装计划单模板" + "-" + date.format(f) + ".xlsx";
+        zipStreamEntity.setName(fileName);
+        zipStreamEntity.setFilePath(filePath);
+        return zipStreamEntity;
+
+
+    }
+
+
     public ZipStreamEntity createRemoteMeterTemplate(LoginUser loginUser, Integer planId){
         String filePath = this.getFilePath();
         log.info("filePath:" + filePath);

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallPlanController.java

@@ -139,7 +139,7 @@ public class InstallPlanController {
     @GetMapping("/downTemplate")
     @ApiOperation(value = "装表模板下载", notes = "装表模板下载")
     public void downTemplate(
-            @ApiParam(value = "场景id 40:lora水表 58:NB水表 55:远传", required = false) @RequestParam(required = false) Integer channelId,
+            @ApiParam(value = "场景id 40:lora水表 58:NB水表 55:远传 61:机械", required = false) @RequestParam(required = false) Integer channelId,
             @ApiParam(value = "安装计划id", required = false) @RequestParam(required = false) Integer id,
             @ApiParam(value = "token", required = true) @RequestParam(required = true) String token,
             HttpServletRequest request, HttpServletResponse response

+ 27 - 12
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallResolverExcelService.java

@@ -124,18 +124,31 @@ public class InstallResolverExcelService implements ResolverExcelService {
                     deviceNoCell.setCellType(CellType.STRING);
                     newMeterStartCell.setCellType(CellType.STRING);
 
-                    if (StringUtils.equals("", communityCell.getStringCellValue().trim()) &&
-                            StringUtils.equals("", buildingCell.getStringCellValue().trim()) &&
-                            StringUtils.equals("", doorNoCell.getStringCellValue()) &&
-                            StringUtils.equals("", deviceTypeCell.getStringCellValue().trim()) &&
-                            StringUtils.equals("", electronicNoCell.getStringCellValue().trim()) &&
-                            StringUtils.equals("", deviceNoCell.getStringCellValue().trim()) &&
-                            StringUtils.equals("", newMeterStartCell.getStringCellValue().trim())
-                    ) {
-                        continue;
+                    if(data.getSysId() != null && data.getSysId() != 61){
+                        if (StringUtils.equals("", communityCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", buildingCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", doorNoCell.getStringCellValue()) &&
+                                StringUtils.equals("", deviceTypeCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", electronicNoCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", deviceNoCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", newMeterStartCell.getStringCellValue().trim())
+                        ) {
+                            continue;
+                        }
+                    }else {
+                        if (StringUtils.equals("", communityCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", buildingCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", doorNoCell.getStringCellValue()) &&
+                                StringUtils.equals("", deviceTypeCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", deviceNoCell.getStringCellValue().trim()) &&
+                                StringUtils.equals("", newMeterStartCell.getStringCellValue().trim())
+                        ) {
+                            continue;
+                        }
                     }
 
 
+
                     if (StringUtils.equals("", communityCell.getStringCellValue().trim())) {
                         data.getFailTime().incrementAndGet();
                         continue;
@@ -195,9 +208,11 @@ public class InstallResolverExcelService implements ResolverExcelService {
 
 
                     String electronicNo = electronicNoCell.getStringCellValue().trim();
-                    if(StringUtils.isBlank(electronicNo)) {
-                        data.getFailTime().incrementAndGet();
-                        continue;
+                    if(data.getSysId() != null && data.getSysId() != 61){
+                        if(StringUtils.isBlank(electronicNo)) {
+                            data.getFailTime().incrementAndGet();
+                            continue;
+                        }
                     }
                     dto.setElectronicNo(electronicNo);
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -1368,6 +1368,9 @@ public  class DeviceServiceImpl implements DeviceService {
         if(58 == data.getChannelId()){
             filePath = generalDownload.export(title,"installNbiotMeter",rtnList,null);
         }
+        if(61 == data.getChannelId()){
+            filePath = generalDownload.export(title,"installMachineryMeter",rtnList,null);
+        }
 
         Task taskTemp = taskMapper.findById(data.getTaskId());
         try {

+ 87 - 30
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/MeterReadRecordServiceImpl.java

@@ -649,34 +649,91 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService{
 		log.info("begin MeterReadRecordService getMeterReadRecordExcel,param = "+JSON.toJSONString(condition));
 		List<MeterReadRecord> result = meterReadRecordMapper.queryMeterReadRecordWithCondtion(condition);
 		String title = "抄表记录";
-		String[] rowsName = new String[]{"序号","水表档案号","水表电子号","设备型号","客户","集中器编码","通道号","采集器编码","当前读数", "抄表状态", "抄表时间", "小区","建筑", "安装地址"};
-		List<Object[]> dataList = newArrayList();
-		Object[] objs = null;
-		for (int i = 0; i < result.size(); i++) {
-			MeterReadRecord meterReadRecord = result.get(i);
-			objs = new Object[rowsName.length];
-			objs[0] = i;
-			objs[1] = meterReadRecord.getMeterFileNo();
-			objs[2] = meterReadRecord.getMeterNo();
-			objs[3] = meterReadRecord.getFactoryName()+"/"+meterReadRecord.getEquipmentType()+"/"+meterReadRecord.getModel();
-			objs[4] = meterReadRecord.getCustomerName();
-			objs[5] = meterReadRecord.getConcentratorNo();
-			objs[6] = meterReadRecord.getChannelNumberName();
-			objs[7] = meterReadRecord.getCollectorNo();
-            objs[8] = meterReadRecord.getReadData();
-            objs[9] = MeterReadEnum.getName(meterReadRecord.getReadStatus()) ;
-			objs[10] = meterReadRecord.getReadTime() == null ?"":DateTimeUtil.formatDate(meterReadRecord.getReadTime(), DateTimeUtil.DATE_TIME_FORMAT);
-			objs[11] = meterReadRecord.getCommunityName();
-			objs[12] = meterReadRecord.getBuildingName();
-			objs[13] = meterReadRecord.getLocation();
-			dataList.add(objs);
-		}
-		ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
-		try {
-			excelUtil.export(httpServletResponse);
-		} catch (Exception e) {
-			throw new ServiceException(-900, "导出异常");
+
+		if(condition.getChannelId() == 55){
+			String[] rowsName = new String[]{"序号","水表档案号","水表电子号","设备型号","客户","集中器编码","通道号","采集器编码","当前读数", "抄表状态", "抄表时间", "小区","建筑", "安装地址"};
+			List<Object[]> dataList = newArrayList();
+			Object[] objs = null;
+			for (int i = 0; i < result.size(); i++) {
+				MeterReadRecord meterReadRecord = result.get(i);
+				objs = new Object[rowsName.length];
+				objs[0] = i;
+				objs[1] = meterReadRecord.getMeterFileNo();
+				objs[2] = meterReadRecord.getMeterNo();
+				objs[3] = meterReadRecord.getFactoryName()+"/"+meterReadRecord.getEquipmentType()+"/"+meterReadRecord.getModel();
+				objs[4] = meterReadRecord.getCustomerName();
+				objs[5] = meterReadRecord.getConcentratorNo();
+				objs[6] = meterReadRecord.getChannelNumberName();
+				objs[7] = meterReadRecord.getCollectorNo();
+				objs[8] = meterReadRecord.getReadData();
+				objs[9] = MeterReadEnum.getName(meterReadRecord.getReadStatus()) ;
+				objs[10] = meterReadRecord.getReadTime() == null ?"":DateTimeUtil.formatDate(meterReadRecord.getReadTime(), DateTimeUtil.DATE_TIME_FORMAT);
+				objs[11] = meterReadRecord.getCommunityName();
+				objs[12] = meterReadRecord.getBuildingName();
+				objs[13] = meterReadRecord.getLocation();
+				dataList.add(objs);
+			}
+			ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+			try {
+				excelUtil.export(httpServletResponse);
+			} catch (Exception e) {
+				throw new ServiceException(-900, "导出异常");
+			}
+		} else if (condition.getChannelId() == 61){
+			String[] rowsName = new String[]{"序号","水表档案号","设备编号","设备型号","客户","当前读数", "抄表状态", "抄表时间", "小区","建筑", "安装地址"};
+			List<Object[]> dataList = newArrayList();
+			Object[] objs = null;
+			for (int i = 0; i < result.size(); i++) {
+				MeterReadRecord meterReadRecord = result.get(i);
+				objs = new Object[rowsName.length];
+				objs[0] = i;
+				objs[1] = meterReadRecord.getMeterFileNo();
+				objs[2] = meterReadRecord.getDeviceNo();
+				objs[3] = meterReadRecord.getFactoryName()+"/"+meterReadRecord.getEquipmentType()+"/"+meterReadRecord.getModel();
+				objs[4] = meterReadRecord.getCustomerName();
+				objs[5] = meterReadRecord.getReadData();
+				objs[6] = MeterReadEnum.getName(meterReadRecord.getReadStatus()) ;
+				objs[7] = meterReadRecord.getReadTime() == null ?"":DateTimeUtil.formatDate(meterReadRecord.getReadTime(), DateTimeUtil.DATE_TIME_FORMAT);
+				objs[8] = meterReadRecord.getCommunityName();
+				objs[9] = meterReadRecord.getBuildingName();
+				objs[10] = meterReadRecord.getLocation();
+				dataList.add(objs);
+			}
+			ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+			try {
+				excelUtil.export(httpServletResponse);
+			} catch (Exception e) {
+				throw new ServiceException(-900, "导出异常");
+			}
+		}else {
+			String[] rowsName = new String[]{"序号","水表档案号","设备编号","水表电子号","设备型号","客户","当前读数", "抄表状态", "抄表时间", "小区","建筑", "安装地址"};
+			List<Object[]> dataList = newArrayList();
+			Object[] objs = null;
+			for (int i = 0; i < result.size(); i++) {
+				MeterReadRecord meterReadRecord = result.get(i);
+				objs = new Object[rowsName.length];
+				objs[0] = i;
+				objs[1] = meterReadRecord.getMeterFileNo();
+				objs[2] = meterReadRecord.getDeviceNo();
+				objs[3] = meterReadRecord.getMeterNo();
+				objs[4] = meterReadRecord.getFactoryName()+"/"+meterReadRecord.getEquipmentType()+"/"+meterReadRecord.getModel();
+				objs[5] = meterReadRecord.getCustomerName();
+				objs[6] = meterReadRecord.getReadData();
+				objs[7] = MeterReadEnum.getName(meterReadRecord.getReadStatus()) ;
+				objs[8] = meterReadRecord.getReadTime() == null ?"":DateTimeUtil.formatDate(meterReadRecord.getReadTime(), DateTimeUtil.DATE_TIME_FORMAT);
+				objs[9] = meterReadRecord.getCommunityName();
+				objs[10] = meterReadRecord.getBuildingName();
+				objs[11] = meterReadRecord.getLocation();
+				dataList.add(objs);
+			}
+			ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+			try {
+				excelUtil.export(httpServletResponse);
+			} catch (Exception e) {
+				throw new ServiceException(-900, "导出异常");
+			}
 		}
+
 		log.info("end MeterReadRecordService getMeterReadRecordExcel , result.size = "+result.size());
 	}
 
@@ -1261,11 +1318,11 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService{
 	@Override
 	public void updateReading(Long id, Double readData) {
 
-		Integer date = Integer.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
+		//Integer date = Integer.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
 		MeterReadRecord meterReadRecord = meterReadRecordMapper.getById(id);
-		if(!meterReadRecord.getReadDate().equals(date)){
+		/*if(!meterReadRecord.getReadDate().equals(date)){
 			throw new ServiceException(-900, "只能修改当天抄表数据");
-		}
+		}*/
 		Double lastCost = 0.0;
 		if (meterReadRecord.getLastValid() != null) {
 			lastCost = new BigDecimal((readData - Double.valueOf(meterReadRecord.getLastValid()))).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallPlanServiceImpl.java

@@ -820,6 +820,8 @@ public class InstallPlanServiceImpl implements InstallPlanService {
             try {
                 if(channelId != null && channelId == 55){
                     zipStreamEntity = asyncInstallPlanDownloadTask.createRemoteMeterTemplate(loginUser,planId);
+                }if(channelId != null && channelId == 61){
+                    zipStreamEntity = asyncInstallPlanDownloadTask.createMachineryMeterTemplate(loginUser,planId);
                 }else {
                     zipStreamEntity = asyncInstallPlanDownloadTask.createTemplate(loginUser,planId);
                 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -122,7 +122,7 @@ public class AsyncTaskImportService {
             template.resolver(null,null,record, null,"新装水表管理-批量添加水表");
         }else {
             ResolverExcelTemplate template = new ResolverExcelTemplate(installResolverExcelService,handleExcelService);
-            template.resolver(null,null,record,null, "新装水表管理-批量添加水表");
+            template.resolver(sysId,null,record,null, "新装水表管理-批量添加水表");
         }
         log.info("begin executeAsyncInstallTask!");
     }

BIN
smart-city-platform/src/main/resources/excel/installMachineryMeterTemplate20201228.xlsx


+ 2 - 0
smart-city-platform/src/main/resources/json/deviceCustomColumn.json

@@ -4,10 +4,12 @@
   "generalDeviceList": ["deviceNo", "waterMeterFileNo", "waterMeterNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading","communityName", "buildingName", "locDesc", "valveStatus","lastReceiveTime","installTime","userName","userPhone"],
   "photoelectricMeter": ["waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "concentratorName", "channelNumberName","collectorName", "issueStatus", "meterReading","communityName", "buildingName", "installTime","locDesc","valveStatus","lastReceiveTime","userName","userPhone"],
   "nbiotMeter": ["deviceNo", "waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading","communityName", "buildingName", "locDesc", "registerStatus", "valveStatus","lastReceiveTime","userName","userPhone"],
+  "machineryMeter": ["deviceNo", "waterMeterFileNo", "deviceModel", "customerName", "meterReading","communityName", "buildingName", "locDesc","userName","userPhone"],
   "waterQualityMeter": ["deviceNo", "deviceModel", "customerName", "deviceStatus", "buildingName", "locDesc", "lastReceiveTime"],
   "flowmeter": ["deviceNo", "deviceModel", "customerName", "deviceStatus", "buildingName", "locDesc", "lastReceiveTime"],
   "installLoraMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "oldMeterEnd", "communityName", "buildingName", "locDesc", "installTime", "lastReceiveTime", "userName","userPhone"],
   "installNbiotMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "oldMeterEnd", "registerStatus", "communityName", "buildingName", "locDesc", "installTime", "lastReceiveTime", "userName","userPhone"],
+  "installMachineryMeter": ["deviceNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus",  "meterReading", "oldMeterEnd", "communityName", "buildingName", "locDesc", "installTime", "lastReceiveTime", "userName","userPhone"],
   "installRemoteMeter": ["waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus","concentratorName","channelNumberName","collectorName","issueStatus", "meterReading", "oldMeterEnd", "communityName", "buildingName","locDesc", "installTime","lastReceiveTime", "userName","userPhone"],
   "rmcp_loraMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "buildingName", "locDesc", "deviceStatus", "meterReading", "lastReceiveTime", "valveStatus"],
   "rmcp_photoelectricMeter": ["waterMeterNo", "waterMeterFileNo", "deviceModel", "buildingName", "locDesc", "deviceStatus", "meterReading", "lastReceiveTime", "valveStatus"],