温湿度同步
This commit is contained in:
parent
9245e75ed2
commit
239fb64949
|
@ -2,7 +2,6 @@ package com.nu.modules.yiweilian.humid.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.tq.water.entity.WaterMeter;
|
||||
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -14,6 +13,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
|
@ -175,4 +175,111 @@ public class HumidDeviceController extends JeecgController<HumidDevice, IHumidDe
|
|||
return Result.error("其他错误,请联系管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 温湿度源数据查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/sourceList")
|
||||
public Result<IPage<HumidDevice>> sourceList(HumidDevice humidDevice,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||
IPage<HumidDevice> pageList = service.findSourcePage(page, humidDevice);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 温湿度数据中机构列表查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/departList")
|
||||
public Result<List<HumidDevice>> departList(HumidDevice humidDevice) {
|
||||
List<HumidDevice> list = service.findDepartList(humidDevice);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 温湿度数据中区域列表查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/nuList")
|
||||
public Result<List<HumidDevice>> nuList(HumidDevice humidDevice) {
|
||||
List<HumidDevice> list = service.findNuList(humidDevice);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 温湿度数据中已同步列表查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/businessList")
|
||||
public Result<IPage<HumidDevice>> businessList(HumidDevice humidDevice,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||
IPage<HumidDevice> pageList = service.findBusinessPage(page,humidDevice);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以设备维度同步温湿度到业务
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/syncDevices")
|
||||
public Result<String> syncDevices(@RequestBody List<HumidDevice> list) {
|
||||
String result = service.syncDevices(list);
|
||||
if(StringUtils.equals(result,"0")){
|
||||
return Result.OK("操作成功!");
|
||||
}else if (StringUtils.equals(result,"1")){
|
||||
return Result.error("参数为空!");
|
||||
}else if (StringUtils.equals(result,"2")){
|
||||
return Result.error("设备ID为空!");
|
||||
}else{
|
||||
return Result.error("其他错误,请联系管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 温湿度同步日志列表查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/syncLogList")
|
||||
public Result<IPage<HumidDevice>> syncLogList(HumidDevice humidDevice,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||
IPage<HumidDevice> pageList = service.findSyncLogPage(page, humidDevice);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定完摄像头的区域列表查询
|
||||
*
|
||||
* @param humidDevice
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/nuSyncList")
|
||||
public Result<IPage<HumidDevice>> nuSyncList(HumidDevice humidDevice,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||
IPage<HumidDevice> pageList = service.findNuSyncPage(page, humidDevice);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Class:易维联-温湿度计Entity
|
||||
|
@ -107,14 +109,22 @@ public class HumidDevice implements Serializable {
|
|||
|
||||
private String nuId;//护理单元ID
|
||||
private String nuName;//护理单元
|
||||
@Dict(dicCode = "nu_type")
|
||||
@TableField(exist = false)
|
||||
private String areaFlag;//区域标签
|
||||
@TableField(exist = false)
|
||||
private Integer deviceNum;//已绑定设备数
|
||||
private String departId;//机构ID
|
||||
private String departName;//机构名称
|
||||
private String departServerUrl;//机构服务地址
|
||||
@TableField(exist = false)
|
||||
private String orgCode;//机构编码
|
||||
private String oldServerUrl;//原机构服务地址
|
||||
private String syncType;//是否同步 0 未同步 1已同步
|
||||
private String oldDepartId;//原机构id
|
||||
private String oldDepartName;//原机构名称
|
||||
|
||||
@TableField(exist = false)
|
||||
private String oldOrgCode;//原机构编码
|
||||
private String delFlag;//停用标识 0正常 1停用
|
||||
|
||||
@TableField(exist = false)
|
||||
|
@ -122,4 +132,18 @@ public class HumidDevice implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private String paramsRequestTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String viewType;//选择,未选择 用于设备同步功能
|
||||
@TableField(exist = false)
|
||||
private String dataType;//数据类型
|
||||
@TableField(exist = false)
|
||||
private String actionType;//操作类型
|
||||
@TableField(exist = false)
|
||||
private String serverType;//服务类型
|
||||
@TableField(exist = false)
|
||||
private String oldNuId;//原护理单元ID
|
||||
@TableField(exist = false)
|
||||
private String createTime;//时间
|
||||
@TableField(exist = false)
|
||||
private List<HumidDevice> seedList;//子列表
|
||||
}
|
|
@ -3,9 +3,12 @@ package com.nu.modules.yiweilian.humid.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.tq.electricity.entity.ElectricityMeter;
|
||||
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HumidDeviceMapper extends BaseMapper<HumidDevice> {
|
||||
IPage<HumidDevice> findPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
HumidDevice getHumidDevice(HumidDevice humidDevice);
|
||||
|
@ -17,4 +20,16 @@ public interface HumidDeviceMapper extends BaseMapper<HumidDevice> {
|
|||
IPage<HumidDevice> findLogPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
|
||||
void updateDepartById(HumidDevice humidInfo);
|
||||
HumidDevice getHumidInfo(HumidDevice humidDevice);
|
||||
|
||||
void updateSync(HumidDevice humidDevice);
|
||||
IPage<HumidDevice> findSourcePage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
List<HumidDevice> findDepartList(HumidDevice humidDevice);
|
||||
List<HumidDevice> findNuList(HumidDevice humidDevice);
|
||||
IPage<HumidDevice> findBusinessPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
|
||||
IPage<HumidDevice> findSyncLogMainPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
List<HumidDevice> findSyncLogSeedList(HumidDevice humidDevice);
|
||||
|
||||
IPage<HumidDevice> findNuSyncPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
depart_id as departId,
|
||||
depart_name as departName,
|
||||
depart_server_url as departServerUrl,
|
||||
old_server_url ,
|
||||
old_server_url as oldServerUrl,
|
||||
sync_type,
|
||||
del_flag as delFlag,
|
||||
(select count(*) from nu_iot_yiweilian_humid_alarm b where a.sn = b.sn and b.status = '0') as alarmCn
|
||||
|
@ -89,11 +89,13 @@
|
|||
depart_id as departId,
|
||||
depart_name as departName,
|
||||
depart_server_url as departServerUrl,
|
||||
old_server_url ,
|
||||
old_depart_id as oldDepartId,
|
||||
old_depart_name as oldDepartName,
|
||||
old_server_url as oldServerUrl,
|
||||
sync_type,
|
||||
del_flag as delFlag,
|
||||
(select count(*) from nu_iot_yiweilian_humid_alarm b where a.sn = b.sn and b.status = '0') as alarmCn
|
||||
from nu_iot_yiweilian_humid_device
|
||||
from nu_iot_yiweilian_humid_device a
|
||||
<where>
|
||||
<if test="sn != null and sn != ''">
|
||||
AND sn = #{sn}
|
||||
|
@ -351,9 +353,268 @@
|
|||
order by id desc
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateDepartById" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
update nu_iot_yiweilian_humid_device set nu_id = null,nu_name = null,depart_id = null,depart_name = null,depart_server_url=null where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getHumidInfo" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
id,
|
||||
sn,
|
||||
device_name as deviceName,
|
||||
device_types as deviceTypes,
|
||||
reporting_interval as reportingInterval,
|
||||
record_interval as recordInterval,
|
||||
history_report_time as historyReportTime,
|
||||
history_interval as historyInterval,
|
||||
temperature_high as temperatureHigh,
|
||||
temperature_low as temperatureLow,
|
||||
temperature_buffer as temperatureBuffer,
|
||||
humidity_high as humidityHigh,
|
||||
humidity_low as humidityLow,
|
||||
humidity_buffer as humidityBuffer,
|
||||
iz_outages as izOutages,
|
||||
iz_low_battery as izLowBattery,
|
||||
iz_online as izOnline,
|
||||
time_code as timeCode,
|
||||
temperature,
|
||||
humidity,
|
||||
status,
|
||||
reporting_time as reportingTime,
|
||||
electricity,
|
||||
nu_id as nuId,
|
||||
nu_name as nuName,
|
||||
depart_id as departId,
|
||||
depart_name as departName,
|
||||
depart_server_url as departServerUrl,
|
||||
old_depart_id as oldDepartId,
|
||||
old_depart_name as oldDepartName,
|
||||
old_server_url as oldServerUrl,
|
||||
sync_type,
|
||||
del_flag as delFlag
|
||||
from nu_iot_yiweilian_humid_device a
|
||||
where sn = #{sn}
|
||||
</select>
|
||||
|
||||
<update id="updateSync" parameterType="com.nu.modules.tq.electricity.entity.ElectricityMeter">
|
||||
update nu_iot_yiweilian_humid_device
|
||||
set
|
||||
sync_type = #{syncType},
|
||||
nu_id = #{nuId},
|
||||
nu_name = #{nuName},
|
||||
depart_server_url = #{departServerUrl},
|
||||
depart_id = #{departId},
|
||||
depart_name = #{departName},
|
||||
old_server_url = #{oldServerUrl},
|
||||
old_depart_id = #{oldDepartId},
|
||||
old_depart_name = #{oldDepartName}
|
||||
where sn = #{sn}
|
||||
</update>
|
||||
|
||||
<select id="findSourcePage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
a.id,
|
||||
sn,
|
||||
device_name as deviceName,
|
||||
device_types as deviceTypes,
|
||||
reporting_interval as reportingInterval,
|
||||
record_interval as recordInterval,
|
||||
history_report_time as historyReportTime,
|
||||
history_interval as historyInterval,
|
||||
temperature_high as temperatureHigh,
|
||||
temperature_low as temperatureLow,
|
||||
temperature_buffer as temperatureBuffer,
|
||||
humidity_high as humidityHigh,
|
||||
humidity_low as humidityLow,
|
||||
humidity_buffer as humidityBuffer,
|
||||
iz_outages as izOutages,
|
||||
iz_low_battery as izLowBattery,
|
||||
iz_online as izOnline,
|
||||
time_code as timeCode,
|
||||
temperature,
|
||||
humidity,
|
||||
a.status,
|
||||
reporting_time as reportingTime,
|
||||
electricity,
|
||||
a.nu_id as nuId,
|
||||
a.nu_name as nuName,
|
||||
a.depart_id as departId,
|
||||
a.depart_name as departName,
|
||||
a.depart_server_url as departServerUrl,
|
||||
a.old_depart_id as oldDepartId,
|
||||
a.old_depart_name as oldDepartName,
|
||||
a.old_server_url as oldServerUrl,
|
||||
sync_type as syncType,
|
||||
c.area_flag as areaFlag
|
||||
from nu_iot_yiweilian_humid_device a
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
where a.del_flag = '0'
|
||||
<if test="params.sn != null and params.sn != ''">
|
||||
AND a.sn LIKE concat('%',#{params.sn},'%')
|
||||
</if>
|
||||
<if test="params.viewType != null and params.viewType == 'unselected'">
|
||||
AND ifnull(a.nu_id,'') = ''
|
||||
</if>
|
||||
<if test="params.viewType != null and params.viewType == 'selected'">
|
||||
AND ifnull(a.nu_id,'') != ''
|
||||
<if test="params.nuId != null and params.nuId != ''">
|
||||
AND a.nu_id = #{params.nuId}
|
||||
</if>
|
||||
<if test="params.departId != null and params.departId != ''">
|
||||
AND a.depart_id = #{params.departId}
|
||||
</if>
|
||||
<if test="params.status != null and params.status != ''">
|
||||
AND c.del_flag = #{params.status}
|
||||
</if>
|
||||
<if test="params.departServerUrl != null and params.departServerUrl != ''">
|
||||
AND a.depart_server_url != #{params.departServerUrl}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findDepartList" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select distinct
|
||||
depart_id as departId,
|
||||
depart_name as departName
|
||||
from nu_iot_yiweilian_humid_device
|
||||
where depart_id is not null
|
||||
and del_flag = '0'
|
||||
<if test="departServerUrl != null and departServerUrl != ''">
|
||||
<if test="dataType != null and dataType == 'source'">
|
||||
AND depart_server_url != #{departServerUrl}
|
||||
</if>
|
||||
<if test="dataType != null and dataType == 'business'">
|
||||
AND depart_server_url = #{departServerUrl}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findNuList" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select distinct
|
||||
nu_id as nuId,
|
||||
nu_name as nuName
|
||||
from nu_iot_yiweilian_humid_device
|
||||
where nu_id is not null
|
||||
and del_flag = '0'
|
||||
<if test="departId != null and departId != ''">
|
||||
AND depart_id = #{departId}
|
||||
</if>
|
||||
<if test="departServerUrl != null and departServerUrl != ''">
|
||||
<if test="dataType != null and dataType == 'source'">
|
||||
AND depart_server_url != #{departServerUrl}
|
||||
</if>
|
||||
<if test="dataType != null and dataType == 'business'">
|
||||
AND depart_server_url = #{departServerUrl}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findBusinessPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
a.id,
|
||||
sn,
|
||||
device_name as deviceName,
|
||||
device_types as deviceTypes,
|
||||
reporting_interval as reportingInterval,
|
||||
record_interval as recordInterval,
|
||||
history_report_time as historyReportTime,
|
||||
history_interval as historyInterval,
|
||||
temperature_high as temperatureHigh,
|
||||
temperature_low as temperatureLow,
|
||||
temperature_buffer as temperatureBuffer,
|
||||
humidity_high as humidityHigh,
|
||||
humidity_low as humidityLow,
|
||||
humidity_buffer as humidityBuffer,
|
||||
iz_outages as izOutages,
|
||||
iz_low_battery as izLowBattery,
|
||||
iz_online as izOnline,
|
||||
time_code as timeCode,
|
||||
temperature,
|
||||
humidity,
|
||||
a.status,
|
||||
reporting_time as reportingTime,
|
||||
electricity,
|
||||
a.nu_id as nuId,
|
||||
a.nu_name as nuName,
|
||||
a.depart_id as departId,
|
||||
a.depart_name as departName,
|
||||
a.depart_server_url as departServerUrl,
|
||||
a.old_depart_id as oldDepartId,
|
||||
a.old_depart_name as oldDepartName,
|
||||
a.old_server_url as oldServerUrl,
|
||||
sync_type as syncType,
|
||||
c.area_flag as areaFlag
|
||||
from nu_iot_yiweilian_humid_device a
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
where a.depart_server_url = #{params.departServerUrl}
|
||||
and a.del_flag = '0'
|
||||
<if test="params.sn != null and params.sn != ''">
|
||||
AND a.sn LIKE concat('%',#{params.sn},'%')
|
||||
</if>
|
||||
<if test="params.nuId != null and params.nuId != ''">
|
||||
AND a.nu_id = #{params.nuId}
|
||||
</if>
|
||||
<if test="params.departId != null and params.departId != ''">
|
||||
AND a.depart_id = #{params.departId}
|
||||
</if>
|
||||
<if test="params.status != null and params.status != ''">
|
||||
AND c.del_flag = #{params.status}
|
||||
</if>
|
||||
order by a.nu_id
|
||||
</select>
|
||||
|
||||
<select id="findSyncLogMainPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
main_id as sn,
|
||||
main_name as deviceName,
|
||||
server_type as serverType,
|
||||
max(create_time) as createTime
|
||||
from nu_iot_sync_log
|
||||
where server_type = '温湿度计'
|
||||
and (org_code = #{params.departServerUrl} or new_org_code = #{params.departServerUrl})
|
||||
<if test="params.sn != null and params.sn != ''">
|
||||
AND main_id LIKE concat('%',#{params.sn},'%')
|
||||
</if>
|
||||
group by main_id,main_name,server_type
|
||||
order by createTime desc
|
||||
</select>
|
||||
|
||||
<select id="findSyncLogSeedList" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
main_id as sn,
|
||||
main_name as deviceName,
|
||||
sync_type as syncType,
|
||||
server_type as serverType,
|
||||
status,
|
||||
org_id as oldDepartId,
|
||||
org_name as oldDepartName,
|
||||
org_code as oldServerUrl,
|
||||
nu_id as oldNuId,
|
||||
new_org_id as departId,
|
||||
new_org_name as departName,
|
||||
new_org_code as departServerUrl,
|
||||
new_nu_id as nuId,
|
||||
create_time as createTime
|
||||
from nu_iot_sync_log
|
||||
where server_type = '温湿度计'
|
||||
AND main_id = #{sn}
|
||||
order by createTime desc
|
||||
</select>
|
||||
|
||||
<select id="findNuSyncPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||
select
|
||||
a.nu_id as nuId,
|
||||
a.nu_name as nuName,
|
||||
a.area_flag as areaFlag,
|
||||
(select count(*) from nu_iot_yiweilian_humid_device m where a.nu_id = m.nu_id) as deviceNum
|
||||
from nu_base_info a
|
||||
inner join nu_iot_tplink_camera b on a.nu_id = b.nu_id
|
||||
where a.del_flag = '0'
|
||||
and a.iz_sync = '0'
|
||||
<if test="params.orgCode != null and params.orgCode != ''">
|
||||
and a.sys_org_code = #{params.orgCode}
|
||||
</if>
|
||||
order by a.nu_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IHumidDeviceService extends IService<HumidDevice> {
|
||||
|
@ -23,4 +24,12 @@ public interface IHumidDeviceService extends IService<HumidDevice> {
|
|||
void editHldy(HumidDevice humidDevice);
|
||||
|
||||
String syncHumidList(Map<String, Object> humidList);
|
||||
|
||||
IPage<HumidDevice> findSourcePage(Page<HumidDevice> page, HumidDevice humidDevice);
|
||||
List<HumidDevice> findDepartList(HumidDevice humidDevice);
|
||||
List<HumidDevice> findNuList(HumidDevice humidDevice);
|
||||
IPage<HumidDevice> findBusinessPage(Page<HumidDevice> page,HumidDevice humidDevice);
|
||||
String syncDevices(List<HumidDevice> list);
|
||||
IPage<HumidDevice> findSyncLogPage(Page<HumidDevice> page,HumidDevice humidDevice);
|
||||
IPage<HumidDevice> findNuSyncPage(Page<HumidDevice> page,HumidDevice humidDevice);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.syncLog.entity.SyncLog;
|
||||
import com.nu.modules.syncLog.service.ISyncLogService;
|
||||
import com.nu.modules.tq.electricity.entity.ElectricityMeter;
|
||||
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||
import com.nu.modules.yiweilian.humid.mapper.HumidDeviceMapper;
|
||||
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||
|
@ -643,5 +642,286 @@ public class HumidDeviceServiceImpl extends ServiceImpl<HumidDeviceMapper, Humid
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<HumidDevice> findSourcePage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||
return baseMapper.findSourcePage(page,humidDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumidDevice> findDepartList(HumidDevice humidDevice){
|
||||
return baseMapper.findDepartList(humidDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumidDevice> findNuList(HumidDevice humidDevice){
|
||||
return baseMapper.findNuList(humidDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<HumidDevice> findBusinessPage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||
return baseMapper.findBusinessPage(page,humidDevice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以设备维度同步温湿度到业务
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String syncDevices(List<HumidDevice> list){
|
||||
|
||||
for (HumidDevice humidDevice : list) {
|
||||
HumidDevice humidInfo = baseMapper.getHumidInfo(humidDevice);
|
||||
String actionType = humidDevice.getActionType();//操作类型
|
||||
if(actionType.equals("添加")){
|
||||
String orgCode = humidDevice.getOrgCode();
|
||||
if(!StringUtils.isNotBlank(orgCode)){
|
||||
return "1";
|
||||
}
|
||||
humidInfo.setSyncType("1");
|
||||
humidInfo.setNuId(humidDevice.getNuId());
|
||||
humidInfo.setNuName(humidDevice.getNuName());
|
||||
humidInfo.setDepartServerUrl(orgCode);
|
||||
humidInfo.setDepartId(humidDevice.getDepartId());
|
||||
humidInfo.setDepartName(humidDevice.getDepartName());
|
||||
humidInfo.setOldServerUrl(null);
|
||||
humidInfo.setOldDepartId(null);
|
||||
humidInfo.setOldDepartName(null);
|
||||
|
||||
boolean flag = syncImpl.syncDevice(orgCode,"更新",humidInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(humidDevice.getSn());
|
||||
syncLog.setMainName(humidDevice.getDeviceName());
|
||||
syncLog.setSyncType("添加");
|
||||
syncLog.setNewOrgId(humidDevice.getDepartId());
|
||||
syncLog.setNewOrgCode(orgCode);
|
||||
syncLog.setNewOrgName(humidDevice.getDepartName());
|
||||
if(flag){
|
||||
syncLog.setStatus("成功");
|
||||
}else{
|
||||
syncLog.setStatus("失败");
|
||||
}
|
||||
syncLog.setContent("添加业务机构温湿度计数据");
|
||||
syncLog.setServerType("温湿度计");
|
||||
syncLog.setNewNuId(humidDevice.getNuId());
|
||||
nuIotTqElectricitySyncLogService.save(syncLog);
|
||||
if(flag){
|
||||
//更新同步
|
||||
baseMapper.updateSync(humidInfo);
|
||||
}
|
||||
}
|
||||
if(actionType.equals("删除")){
|
||||
String oldOrgCode = humidDevice.getOldOrgCode();
|
||||
if(!StringUtils.isNotBlank(oldOrgCode)){
|
||||
return "1";
|
||||
}
|
||||
humidInfo.setSyncType("1");
|
||||
humidInfo.setNuId(null);
|
||||
humidInfo.setNuName(null);
|
||||
humidInfo.setDepartServerUrl(null);
|
||||
humidInfo.setDepartId(null);
|
||||
humidInfo.setDepartName(null);
|
||||
humidInfo.setOldServerUrl(oldOrgCode);
|
||||
humidInfo.setOldDepartId(humidDevice.getOldDepartId());
|
||||
humidInfo.setOldDepartName(humidDevice.getOldDepartName());
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",humidInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(humidDevice.getSn());
|
||||
syncLog.setMainName(humidDevice.getDeviceName());
|
||||
syncLog.setSyncType("删除");
|
||||
syncLog.setOrgId(humidDevice.getOldDepartId());
|
||||
syncLog.setOrgCode(oldOrgCode);
|
||||
syncLog.setOrgName(humidDevice.getOldDepartName());
|
||||
if(flag){
|
||||
syncLog.setStatus("成功");
|
||||
}else{
|
||||
syncLog.setStatus("失败");
|
||||
}
|
||||
syncLog.setContent("删除原来业务机构温湿度计数据");
|
||||
syncLog.setServerType("温湿度计");
|
||||
syncLog.setNuId(humidDevice.getNuId());
|
||||
nuIotTqElectricitySyncLogService.save(syncLog);
|
||||
if(flag){
|
||||
//更新同步
|
||||
baseMapper.updateSync(humidInfo);
|
||||
}
|
||||
}
|
||||
if(actionType.equals("调整")){
|
||||
String oldNuId = humidInfo.getNuId();//原护理单元ID
|
||||
String nuId = humidDevice.getNuId();//新护理单元ID
|
||||
if(!oldNuId.equals(nuId)){
|
||||
String oldOrgCode = humidDevice.getOldOrgCode();
|
||||
humidInfo.setNuId(humidDevice.getNuId());
|
||||
humidInfo.setNuName(humidDevice.getNuName());
|
||||
humidInfo.setDepartServerUrl(oldOrgCode);
|
||||
humidInfo.setDepartId(humidDevice.getOldDepartId());
|
||||
humidInfo.setDepartName(humidDevice.getOldDepartName());
|
||||
humidInfo.setOldServerUrl(null);
|
||||
humidInfo.setOldDepartId(null);
|
||||
humidInfo.setOldDepartName(null);
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"更新",humidInfo);
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(humidDevice.getSn());
|
||||
syncLog.setMainName(humidDevice.getDeviceName());
|
||||
syncLog.setSyncType("调整");
|
||||
syncLog.setNewOrgId(humidDevice.getOldDepartId());
|
||||
syncLog.setNewOrgCode(oldOrgCode);
|
||||
syncLog.setNewOrgName(humidDevice.getOldDepartName());
|
||||
if(flag){
|
||||
syncLog.setStatus("成功");
|
||||
}else{
|
||||
syncLog.setStatus("失败");
|
||||
}
|
||||
syncLog.setContent("调整业务机构温湿度计数据");
|
||||
syncLog.setServerType("温湿度计");
|
||||
syncLog.setNewNuId(nuId);
|
||||
syncLog.setNuId(oldNuId);
|
||||
nuIotTqElectricitySyncLogService.save(syncLog);
|
||||
if(flag){
|
||||
//更新同步
|
||||
baseMapper.updateSync(humidInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(actionType.equals("变更")){
|
||||
String oldOrgCode = humidDevice.getOldOrgCode();
|
||||
String orgCode = humidDevice.getOrgCode();
|
||||
String oldNuId = humidInfo.getNuId();//原护理单元ID
|
||||
if(!StringUtils.isNotBlank(oldOrgCode)){
|
||||
return "1";
|
||||
}
|
||||
if(!StringUtils.isNotBlank(orgCode)){
|
||||
return "1";
|
||||
}
|
||||
|
||||
boolean flag = syncImpl.syncDevice(oldOrgCode,"删除",humidInfo);
|
||||
if(!flag){
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(humidDevice.getSn());
|
||||
syncLog.setMainName(humidDevice.getDeviceName());
|
||||
syncLog.setSyncType("删除");
|
||||
syncLog.setOrgId(humidDevice.getOldDepartId());
|
||||
syncLog.setOrgCode(oldOrgCode);
|
||||
syncLog.setOrgName(humidDevice.getOldDepartName());
|
||||
syncLog.setStatus("失败");
|
||||
syncLog.setContent("删除业务机构温湿度计数据");
|
||||
syncLog.setServerType("温湿度计");
|
||||
syncLog.setNuId(oldNuId);
|
||||
nuIotTqElectricitySyncLogService.save(syncLog);
|
||||
}
|
||||
boolean flag2 = false;
|
||||
if(flag){
|
||||
humidInfo.setSyncType("1");
|
||||
humidInfo.setNuId(humidDevice.getNuId());
|
||||
humidInfo.setNuName(humidDevice.getNuName());
|
||||
humidInfo.setDepartServerUrl(orgCode);
|
||||
humidInfo.setDepartId(humidDevice.getDepartId());
|
||||
humidInfo.setDepartName(humidDevice.getDepartName());
|
||||
humidInfo.setOldServerUrl(null);
|
||||
humidInfo.setOldDepartId(null);
|
||||
humidInfo.setOldDepartName(null);
|
||||
flag2 = syncImpl.syncDevice(orgCode,"更新",humidInfo);
|
||||
|
||||
SyncLog syncLog = new SyncLog();
|
||||
syncLog.setId(null);
|
||||
syncLog.setMainId(humidDevice.getSn());
|
||||
syncLog.setMainName(humidDevice.getDeviceName());
|
||||
syncLog.setSyncType("更新");
|
||||
syncLog.setOrgId(humidDevice.getOldDepartId());
|
||||
syncLog.setOrgCode(oldOrgCode);
|
||||
syncLog.setOrgName(humidDevice.getOldDepartName());
|
||||
syncLog.setNewOrgId(humidDevice.getDepartId());
|
||||
syncLog.setNewOrgCode(orgCode);
|
||||
syncLog.setNewOrgName(humidDevice.getDepartName());
|
||||
if(flag2){
|
||||
syncLog.setStatus("成功");
|
||||
}else{
|
||||
syncLog.setStatus("失败");
|
||||
}
|
||||
syncLog.setContent("更新业务机构温湿度计数据");
|
||||
syncLog.setServerType("温湿度计");
|
||||
syncLog.setNewNuId(humidInfo.getNuId());
|
||||
syncLog.setNuId(oldNuId);
|
||||
nuIotTqElectricitySyncLogService.save(syncLog);
|
||||
}
|
||||
if(flag2){
|
||||
//更新同步
|
||||
humidInfo.setSyncType("1");
|
||||
humidInfo.setNuId(humidDevice.getNuId());
|
||||
humidInfo.setNuName(humidDevice.getNuName());
|
||||
humidInfo.setDepartServerUrl(orgCode);
|
||||
humidInfo.setDepartId(humidDevice.getDepartId());
|
||||
humidInfo.setDepartName(humidDevice.getDepartName());
|
||||
humidInfo.setOldServerUrl(oldOrgCode);
|
||||
humidInfo.setOldDepartId(humidDevice.getOldDepartId());
|
||||
humidInfo.setOldDepartName(humidDevice.getOldDepartName());
|
||||
baseMapper.updateSync(humidInfo);
|
||||
}else{
|
||||
if(flag){
|
||||
//更新同步
|
||||
humidInfo.setSyncType("1");
|
||||
humidInfo.setNuId(null);
|
||||
humidInfo.setNuName(null);
|
||||
humidInfo.setDepartServerUrl(null);
|
||||
humidInfo.setDepartId(null);
|
||||
humidInfo.setDepartName(null);
|
||||
humidInfo.setOldServerUrl(oldOrgCode);
|
||||
humidInfo.setOldDepartId(humidDevice.getOldDepartId());
|
||||
humidInfo.setOldDepartName(humidDevice.getOldDepartName());
|
||||
baseMapper.updateSync(humidInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
//业务系统保存或者修改命令
|
||||
@DS("#dataSourceCode")
|
||||
public boolean syncDevice(String dataSourceCode,String type,HumidDevice humidDevice) {
|
||||
try {
|
||||
QueryWrapper<HumidDevice> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("sn",humidDevice.getSn());
|
||||
HumidDevice oldParam = baseMapper.selectOne(queryWrapper);//查询数据库中该表号数据原始数据
|
||||
if(type.equals("更新")){
|
||||
if(oldParam == null){
|
||||
baseMapper.insert(humidDevice);
|
||||
}else{
|
||||
humidDevice.setId(oldParam.getId());
|
||||
baseMapper.updateById(humidDevice);
|
||||
}
|
||||
}
|
||||
if(type.equals("删除")){
|
||||
baseMapper.deleteById(oldParam);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<HumidDevice> findSyncLogPage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||
IPage<HumidDevice> mainPage = baseMapper.findSyncLogMainPage(page,humidDevice);
|
||||
List<HumidDevice> records = mainPage.getRecords();
|
||||
for(int i=0;i<records.size();i++){
|
||||
HumidDevice record = records.get(i);
|
||||
List<HumidDevice> seedList = baseMapper.findSyncLogSeedList(record);
|
||||
record.setSeedList(seedList);
|
||||
}
|
||||
return mainPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<HumidDevice> findNuSyncPage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||
return baseMapper.findNuSyncPage(page,humidDevice);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue