|
@@ -18,10 +18,7 @@ import com.bz.smart_city.excel.download.GdDeviceDownloadExcelTemplate;
|
|
|
import com.bz.smart_city.excel.download.GeneralDownloadExcelTemplate;
|
|
|
import com.bz.smart_city.excel.download.WaterDownloadExcelTemplate;
|
|
|
import com.bz.smart_city.service.*;
|
|
|
-import com.bz.smart_city.service.udip.EasylinkinUtils;
|
|
|
-import com.bz.smart_city.service.udip.GdAgentUtils;
|
|
|
-import com.bz.smart_city.service.udip.UdipEtlDataCommandService;
|
|
|
-import com.bz.smart_city.service.udip.UdipUnitService;
|
|
|
+import com.bz.smart_city.service.udip.*;
|
|
|
import com.bz.smart_city.service.valve.ValveContext;
|
|
|
import com.bz.smart_city.service.valve.impl.GdDeviceValveStrategy;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -120,6 +117,10 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
private WaterDownloadExcelTemplate waterDownloadExcelTemplate;
|
|
|
@Autowired
|
|
|
private GdAgentUtils gdAgentUtils;
|
|
|
+ @Autowired
|
|
|
+ private HlhtService hlhtService;
|
|
|
+ @Value("${sync.customer.linhe.id}")
|
|
|
+ private Integer linheCustomerId;
|
|
|
|
|
|
@Override
|
|
|
public int insert(Device device) {
|
|
@@ -198,41 +199,76 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
String title = "设备列表";
|
|
|
//判断是否是水表场景
|
|
|
WMeterType wMeterType = wMeterTypeMapper.getChannelIdAndLevel(sysId, 2);
|
|
|
+ Channel channel = channelMapper.findById(sysId);
|
|
|
if (wMeterType != null || sysId == -99) {
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- String[] rowsName = new String[]{"序号", "设备状态", "设备编号", "水表档案编号", "水表电子号", "集中器编码", "采集器编码", "水表厂商", "客户", "小区", "建筑", "安装地址", "故障类型", "连续故障天数", "水表当前读数", "最后一次更新时间","阀门控制","出厂时间","安装时间","验收时间"};
|
|
|
- List<Object[]> dataList = newArrayList();
|
|
|
- Object[] objs = null;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- DeviceDto deviceDto = list.get(i);
|
|
|
- objs = new Object[rowsName.length];
|
|
|
- objs[0] = i;
|
|
|
- objs[1] = this.getDeviceStatusName(deviceDto.getDeviceStatus());
|
|
|
- objs[2] = deviceDto.getDeviceNo();
|
|
|
- objs[3] = deviceDto.getWaterMeterFileNo();
|
|
|
- objs[4] = deviceDto.getWaterMeterNo();
|
|
|
- objs[5] = deviceDto.getConcentratorName();
|
|
|
- objs[6] = deviceDto.getCollectorName();
|
|
|
- objs[7] = deviceDto.getManufacturerName();
|
|
|
- objs[8] = deviceDto.getCustomerName();
|
|
|
- objs[9] = deviceDto.getCommunityName();
|
|
|
- objs[10] = deviceDto.getBuildingName();
|
|
|
- objs[11] = deviceDto.getLocDesc();
|
|
|
- objs[12] = deviceDto.getLastErrorType();
|
|
|
- objs[13] = deviceDto.getDays();
|
|
|
- objs[14] = deviceDto.getMeterReading();
|
|
|
- objs[15] = deviceDto.getLastReceiveTime()!=null?deviceDto.getLastReceiveTime().format(df):null;
|
|
|
- objs[16] = this.getValveStatusName(deviceDto.getIsValve(),deviceDto.getValveStatus());
|
|
|
- objs[17] = deviceDto.getPlanTime()!=null?deviceDto.getPlanTime().format(df):null;
|
|
|
- objs[18] = deviceDto.getInstallTime()!=null?deviceDto.getInstallTime().format(df):null;
|
|
|
- objs[19] = deviceDto.getAcceptTime()!=null?deviceDto.getAcceptTime().format(df):null;
|
|
|
- dataList.add(objs);
|
|
|
- }
|
|
|
- ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
|
|
|
- try {
|
|
|
- excelUtil.export(httpServletResponse);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new ServiceException(-900, "导出异常");
|
|
|
+ if(StringUtils.equals("photoelectricMeter",channel.getChannelCode())){
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String[] rowsName = new String[]{"序号", "水表电子号", "设备类型", "客户", "设备状态", "集中器编码", "采集器编码", "下发状态", "当前读数", "建筑", "安装地址", "阀门控制", "最后一次更新时间","出厂时间","安装时间","验收时间"};
|
|
|
+ List<Object[]> dataList = newArrayList();
|
|
|
+ Object[] objs = null;
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ DeviceDto deviceDto = list.get(i);
|
|
|
+ objs = new Object[rowsName.length];
|
|
|
+ objs[0] = i;
|
|
|
+ objs[1] = deviceDto.getWaterMeterNo();
|
|
|
+ objs[2] = deviceDto.getManufacturerName()+"/"+deviceDto.getEquipmentType()+"/"+deviceDto.getManufacturerName();
|
|
|
+ objs[3] = deviceDto.getCustomerName();
|
|
|
+ objs[4] = this.getDeviceStatusName(deviceDto.getDeviceStatus());
|
|
|
+ objs[5] = deviceDto.getConcentratorName();
|
|
|
+ objs[6] = deviceDto.getCollectorName();
|
|
|
+ objs[7] = this.getIssueStatusName(deviceDto.getIssueStatus());
|
|
|
+ objs[8] = deviceDto.getMeterReading();
|
|
|
+ objs[9] = deviceDto.getBuildingName();
|
|
|
+ objs[10] = deviceDto.getLocDesc();
|
|
|
+ objs[11] = this.getValveStatusName(deviceDto.getIsValve(),deviceDto.getValveStatus());
|
|
|
+ objs[12] = deviceDto.getLastReceiveTime()!=null?deviceDto.getLastReceiveTime().format(df):null;
|
|
|
+ objs[13] = deviceDto.getPlanTime()!=null?deviceDto.getPlanTime().format(df):null;
|
|
|
+ objs[14] = deviceDto.getInstallTime()!=null?deviceDto.getInstallTime().format(df):null;
|
|
|
+ objs[15] = deviceDto.getAcceptTime()!=null?deviceDto.getAcceptTime().format(df):null;
|
|
|
+ dataList.add(objs);
|
|
|
+ }
|
|
|
+ ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
|
|
|
+ try {
|
|
|
+ excelUtil.export(httpServletResponse);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException(-900, "导出异常");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String[] rowsName = new String[]{"序号", "设备状态", "设备编号", "水表档案编号", "水表电子号", "集中器编码", "采集器编码", "水表厂商", "客户", "小区", "建筑", "安装地址", "故障类型", "连续故障天数", "水表当前读数", "最后一次更新时间","阀门控制","出厂时间","安装时间","验收时间"};
|
|
|
+ List<Object[]> dataList = newArrayList();
|
|
|
+ Object[] objs = null;
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ DeviceDto deviceDto = list.get(i);
|
|
|
+ objs = new Object[rowsName.length];
|
|
|
+ objs[0] = i;
|
|
|
+ objs[1] = this.getDeviceStatusName(deviceDto.getDeviceStatus());
|
|
|
+ objs[2] = deviceDto.getDeviceNo();
|
|
|
+ objs[3] = deviceDto.getWaterMeterFileNo();
|
|
|
+ objs[4] = deviceDto.getWaterMeterNo();
|
|
|
+ objs[5] = deviceDto.getConcentratorName();
|
|
|
+ objs[6] = deviceDto.getCollectorName();
|
|
|
+ objs[7] = deviceDto.getManufacturerName();
|
|
|
+ objs[8] = deviceDto.getCustomerName();
|
|
|
+ objs[9] = deviceDto.getCommunityName();
|
|
|
+ objs[10] = deviceDto.getBuildingName();
|
|
|
+ objs[11] = deviceDto.getLocDesc();
|
|
|
+ objs[12] = deviceDto.getLastErrorType();
|
|
|
+ objs[13] = deviceDto.getDays();
|
|
|
+ objs[14] = deviceDto.getMeterReading();
|
|
|
+ objs[15] = deviceDto.getLastReceiveTime()!=null?deviceDto.getLastReceiveTime().format(df):null;
|
|
|
+ objs[16] = this.getValveStatusName(deviceDto.getIsValve(),deviceDto.getValveStatus());
|
|
|
+ objs[17] = deviceDto.getPlanTime()!=null?deviceDto.getPlanTime().format(df):null;
|
|
|
+ objs[18] = deviceDto.getInstallTime()!=null?deviceDto.getInstallTime().format(df):null;
|
|
|
+ objs[19] = deviceDto.getAcceptTime()!=null?deviceDto.getAcceptTime().format(df):null;
|
|
|
+ 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[]{"序号", "状态", "编号", "系列", "型号", "厂商", "所属建筑", "楼层", "位置"};
|
|
@@ -261,6 +297,17 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected String getIssueStatusName(Integer issueStatus){
|
|
|
+ String issueStatusName = "未下发";
|
|
|
+ if (issueStatus != null) {
|
|
|
+ if(issueStatus == 1){
|
|
|
+ issueStatusName = "已下发";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return issueStatusName;
|
|
|
+ }
|
|
|
+
|
|
|
protected String getValveStatusName(Integer isValve, Integer valveStatus){
|
|
|
String valveStatusName = "关阀";
|
|
|
if (isValve != null) {
|
|
@@ -410,6 +457,17 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
device.setCustomerId(deviceDataDto.getCustomerId());
|
|
|
device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
|
|
|
device.setRegisterStatus(0);
|
|
|
+
|
|
|
+ if(device.getCustomerId().equals(linheCustomerId)){
|
|
|
+ Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
|
|
|
+ if (syncStatus) {
|
|
|
+ device.setSyncStatus(1);
|
|
|
+ }else {
|
|
|
+ device.setSyncStatus(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ device.setSyncStatus(0);
|
|
|
+ }
|
|
|
//device.setUdipId(udipId);
|
|
|
int result = this.insert(device);
|
|
|
|
|
@@ -603,6 +661,17 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
device.setUdipId(udipId);
|
|
|
device.setRegisterStatus(1);
|
|
|
}
|
|
|
+
|
|
|
+ if(device.getCustomerId().equals(linheCustomerId)){
|
|
|
+ Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
|
|
|
+ if (syncStatus) {
|
|
|
+ device.setSyncStatus(1);
|
|
|
+ }else {
|
|
|
+ device.setSyncStatus(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ device.setSyncStatus(0);
|
|
|
+ }
|
|
|
int result = this.updateByPrimaryKeySelective(device);
|
|
|
|
|
|
|
|
@@ -1455,4 +1524,25 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
return deviceMapper.queryDeviceInfoList(loginUser.getSiteId(),deviceNo,waterMeterNo,UserUtil.getCurrentSiteProgramItems(loginUser));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer syncDevice(Long deviceId) {
|
|
|
+ Device device = deviceMapper.findByDeviceId(deviceId);
|
|
|
+ if(device.getCustomerId().equals(linheCustomerId)){
|
|
|
+ Device deviceUpdate = new Device();
|
|
|
+ deviceUpdate.setId(deviceId);
|
|
|
+ Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
|
|
|
+ if (syncStatus) {
|
|
|
+ deviceUpdate.setSyncStatus(1);
|
|
|
+ }else {
|
|
|
+ deviceUpdate.setSyncStatus(0);
|
|
|
+
|
|
|
+ }
|
|
|
+ deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
|
|
|
+ return deviceUpdate.getSyncStatus();
|
|
|
+
|
|
|
+ }else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|