|
@@ -107,6 +107,15 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
return deviceMapper.insert(device);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public int insertSynArchives(Device device) {
|
|
|
+ device.setCreateBy("admin");
|
|
|
+ device.setDateCreate(LocalDateTime.now());
|
|
|
+ device.setUpdateBy("admin");
|
|
|
+ device.setDateUpdate(LocalDateTime.now());
|
|
|
+ return deviceMapper.insert(device);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int insertSelective(Device device) {
|
|
|
device.setCreateBy(UserUtil.getCurrentUser().getUsername());
|
|
@@ -393,6 +402,95 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
log.info("end addDevice,result = " + result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public String synArchives(String jsonStirig){
|
|
|
+ log.info("begin addDevice,deviceDataDto = " + jsonStirig);
|
|
|
+ UserArchivesInfo userArchivesInfo = JSON.parseObject(jsonStirig.toString(),UserArchivesInfo.class);
|
|
|
+ int succ =0;//成功条数
|
|
|
+ int fail =0;//失败条数
|
|
|
+ String failMsg="";//返回失败消息体
|
|
|
+ for(int i=0; i<userArchivesInfo.getList().size(); i++){
|
|
|
+ DeviceDataDto deviceDataDto = userArchivesInfo.getList().get(i);
|
|
|
+ //查询设备类型
|
|
|
+ DeviceType deviceType = deviceTypeMapper.findByid(deviceDataDto.getDeviceType());
|
|
|
+
|
|
|
+ //1、添加设备
|
|
|
+ //LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ int resultDeviceNo = deviceMapper.findByDeviceNoUnique(null, deviceDataDto.getDeviceNo());
|
|
|
+ if (resultDeviceNo > 0) {
|
|
|
+ fail++;
|
|
|
+ failMsg += "【"+deviceDataDto.getDeviceNo()+"】设备编号已经存在";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* if (deviceDataDto.getWaterMeterNo() != null && !StringUtils.equals("",deviceDataDto.getWaterMeterNo())) {
|
|
|
+ int resultWaterMeterNo = deviceMapper.findByWaterMeterNoUnique(null, deviceDataDto.getWaterMeterNo());
|
|
|
+ if (resultWaterMeterNo > 0) {
|
|
|
+ fail++;
|
|
|
+ throw new ServiceException(-900, "水表电子号已经存在");
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //新增udip平台集成元
|
|
|
+ DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(deviceDataDto.getDeviceType());
|
|
|
+ String udipId = udipUnitService.saveUdipUnit(deviceDataDto.getDeviceNo(),deviceDataDto.getCustomerId(),deviceTypeDto);
|
|
|
+
|
|
|
+ Device device = new Device();
|
|
|
+ device.setId(idWorker.nextId());
|
|
|
+ device.setDeviceNo(StringUtils.lowerCase(deviceDataDto.getDeviceNo().trim()));
|
|
|
+ device.setDeviceType(deviceDataDto.getDeviceType());
|
|
|
+ device.setSysId(deviceDataDto.getSysId());
|
|
|
+ device.setSiteId(deviceDataDto.getSiteId());
|
|
|
+ device.setBuildingId(deviceDataDto.getBuildingId());
|
|
|
+ device.setFloor(deviceDataDto.getFloor());
|
|
|
+ device.setLocDesc(deviceDataDto.getLocDesc());
|
|
|
+ device.setManufacturerId(deviceType.getManufacturerId());
|
|
|
+ device.setDeviceStatus(5);//未启用
|
|
|
+ device.setStatus(1);
|
|
|
+ device.setXCoordinates(deviceDataDto.getXCoordinates());
|
|
|
+ device.setYCoordinates(deviceDataDto.getYCoordinates());
|
|
|
+ device.setIsTag(deviceDataDto.getXCoordinates() != null && deviceDataDto.getYCoordinates() != null ? 1 : 0);
|
|
|
+ device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
|
|
|
+ device.setWaterMeterFileNo(deviceDataDto.getWaterMeterFileNo());
|
|
|
+ device.setCustomerId(deviceDataDto.getCustomerId());
|
|
|
+ device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
|
|
|
+ device.setUdipId(udipId);
|
|
|
+ int result = this.insertSynArchives(device);
|
|
|
+
|
|
|
+
|
|
|
+ Building building = buildingMapper.getBuilding(device.getBuildingId());
|
|
|
+ //2、同步设备维度关系
|
|
|
+ DeviceDimension deviceDimension = new DeviceDimension();
|
|
|
+ deviceDimension.setDeviceId(device.getId());
|
|
|
+ deviceDimension.setProvince(String.valueOf(building.getProvince()));
|
|
|
+ deviceDimension.setCity(String.valueOf(building.getCity()));
|
|
|
+ deviceDimension.setRegion(String.valueOf(building.getRegion()));
|
|
|
+ deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
|
|
|
+ deviceDimension.setBuilding(String.valueOf(building.getId()));
|
|
|
+ deviceDimension.setFloor(String.valueOf(device.getFloor()));
|
|
|
+ deviceDimension.setDevice(device.getDeviceNo());
|
|
|
+ deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
|
|
|
+ deviceDimension.setStatus(1);
|
|
|
+ deviceDimension.setCreateBy("admin");
|
|
|
+ deviceDimension.setUpdateBy("admin");
|
|
|
+ deviceDimension.setDateCreate(LocalDateTime.now());
|
|
|
+ deviceDimension.setDateUpdate(LocalDateTime.now());
|
|
|
+
|
|
|
+ deviceDimensionMapper.insertSelective(deviceDimension);
|
|
|
+ succ++;
|
|
|
+ log.info("end addDevice,result = " + result);
|
|
|
+ }
|
|
|
+ String msg = "";
|
|
|
+ if(fail >0){
|
|
|
+ msg = "同步档案信息成功【"+succ+"】条,失败【"+fail+"】条,失败原因:"+failMsg+"";
|
|
|
+ }else{
|
|
|
+ msg = "同步档案信息成功【"+succ+"】条";
|
|
|
+ }
|
|
|
+ log.info("synArchives,result = "+msg);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void edit(DeviceDataDto deviceDataDto) {
|
|
@@ -1142,40 +1240,40 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int countDeviceNumber() {
|
|
|
- Device param = new Device();
|
|
|
- List<Integer> statusList = new ArrayList<Integer>();
|
|
|
- statusList.add(1); // 正常
|
|
|
- statusList.add(2); // 故障
|
|
|
- statusList.add(4); // 预警
|
|
|
- param.setDeviceStatusList(statusList);
|
|
|
- return deviceMapper.countDevice(param);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<DeviceDto> getDeviceList(int pageNum, int pageSize) {
|
|
|
- Device param = new Device();
|
|
|
- List<Integer> statusList = new ArrayList<Integer>();
|
|
|
- statusList.add(1); // 正常
|
|
|
- statusList.add(2); // 故障
|
|
|
- statusList.add(4); // 预警
|
|
|
- param.setDeviceStatusList(statusList);
|
|
|
- return deviceMapper.getDeviceList(param, pageNum, pageSize);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public DeviceDto getDeviceLastReceiveTime(Long deviceId) {
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
- @Override
|
|
|
- public Pagination<DeviceDto> simpleQueryDeviceList(Integer siteId, Integer channelId, String deviceNo,
|
|
|
- String waterMeterNo, int pageNum, int pageSize) {
|
|
|
- LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ public int countDeviceNumber() {
|
|
|
+ Device param = new Device();
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ statusList.add(1); // 正常
|
|
|
+ statusList.add(2); // 故障
|
|
|
+ statusList.add(4); // 预警
|
|
|
+ param.setDeviceStatusList(statusList);
|
|
|
+ return deviceMapper.countDevice(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DeviceDto> getDeviceList(int pageNum, int pageSize) {
|
|
|
+ Device param = new Device();
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ statusList.add(1); // 正常
|
|
|
+ statusList.add(2); // 故障
|
|
|
+ statusList.add(4); // 预警
|
|
|
+ param.setDeviceStatusList(statusList);
|
|
|
+ return deviceMapper.getDeviceList(param, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DeviceDto getDeviceLastReceiveTime(Long deviceId) {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public Pagination<DeviceDto> simpleQueryDeviceList(Integer siteId, Integer channelId, String deviceNo,
|
|
|
+ String waterMeterNo, int pageNum, int pageSize) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<DeviceDto> list = deviceMapper.queryDeviceByNo(siteId,channelId,deviceNo,waterMeterNo,UserUtil.getCurrentSiteProgramItems(loginUser));
|
|
|
- return new Pagination<>(list);
|
|
|
- }
|
|
|
+ return new Pagination<>(list);
|
|
|
+ }
|
|
|
@Override
|
|
|
public Device deviceDetail(Long deviceId) {
|
|
|
Device device = deviceMapper.findByDeviceId(deviceId);
|
|
@@ -1207,8 +1305,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
|
@Override
|
|
|
public List<Device> findByAccountId(BigInteger accountId) {
|
|
|
- List<Device> result = deviceMapper.findByAccountId(accountId);
|
|
|
- return result;
|
|
|
+ List<Device> result = deviceMapper.findByAccountId(accountId);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|