diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/EPassengerFlowInfo.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/EPassengerFlowInfo.java new file mode 100644 index 00000000..51c2dec9 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/EPassengerFlowInfo.java @@ -0,0 +1,227 @@ +package com.ruoyi.quartz.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 客流信息原始数据 对象 e_passenger_flow_info + * + * @author hehang + * @date 2023-05-19 + */ +public class EPassengerFlowInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 数据类型 1 按小时 2 按天 3 按周 4 按月 5 按年 */ + @Excel(name = "数据类型 1 按小时 2 按天 3 按周 4 按月 5 按年") + private String type; + + /** 项目id */ + @Excel(name = "项目id") + private String projectId; + + /** 时间精度 */ + @Excel(name = "时间精度") + private String accuracy; + + /** 查询开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "查询开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 查询结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "查询结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 进入的人数 */ + @Excel(name = "进入的人数") + private String inFlow; + + /** 出去的人数 */ + @Excel(name = "出去的人数") + private String outflow; + + /** 设备id */ + @Excel(name = "设备id") + private String deviceId; + + /** 设备名称 */ + @Excel(name = "设备名称") + private String deviceName; + + /** 所属分组id */ + @Excel(name = "所属分组id") + private Long relatedRegionId; + + /** 所属分组id */ + @Excel(name = "所属分组id") + private String relatedRegionName; + + /** 数据状态 0新增 1修改 2删除 */ + private String delFlag; + + /** 企业标识码 数据隔离使用的企业唯一标识 */ + @Excel(name = "企业标识码 数据隔离使用的企业唯一标识") + private Long organCode; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + public void setProjectId(String projectId) + { + this.projectId = projectId; + } + + public String getProjectId() + { + return projectId; + } + public void setAccuracy(String accuracy) + { + this.accuracy = accuracy; + } + + public String getAccuracy() + { + return accuracy; + } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + public void setInFlow(String inFlow) + { + this.inFlow = inFlow; + } + + public String getInFlow() + { + return inFlow; + } + public void setOutflow(String outflow) + { + this.outflow = outflow; + } + + public String getOutflow() + { + return outflow; + } + public void setDeviceId(String deviceId) + { + this.deviceId = deviceId; + } + + public String getDeviceId() + { + return deviceId; + } + public void setDeviceName(String deviceName) + { + this.deviceName = deviceName; + } + + public String getDeviceName() + { + return deviceName; + } + public void setRelatedRegionId(Long relatedRegionId) + { + this.relatedRegionId = relatedRegionId; + } + + public Long getRelatedRegionId() + { + return relatedRegionId; + } + public void setRelatedRegionName(String relatedRegionName) + { + this.relatedRegionName = relatedRegionName; + } + + public String getRelatedRegionName() + { + return relatedRegionName; + } + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getDelFlag() + { + return delFlag; + } + public void setOrganCode(Long organCode) + { + this.organCode = organCode; + } + + public Long getOrganCode() + { + return organCode; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("type", getType()) + .append("projectId", getProjectId()) + .append("accuracy", getAccuracy()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("inFlow", getInFlow()) + .append("outflow", getOutflow()) + .append("deviceId", getDeviceId()) + .append("deviceName", getDeviceName()) + .append("relatedRegionId", getRelatedRegionId()) + .append("relatedRegionName", getRelatedRegionName()) + .append("delFlag", getDelFlag()) + .append("updateTime", getUpdateTime()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("createBy", getCreateBy()) + .append("organCode", getOrganCode()) + .toString(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/EPassengerFlowInfoMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/EPassengerFlowInfoMapper.java new file mode 100644 index 00000000..953f1360 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/EPassengerFlowInfoMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.quartz.mapper; + +import com.ruoyi.quartz.domain.EPassengerFlowInfo; + +import java.util.List; + +/** + * 客流信息原始数据 Mapper接口 + * + * @author hehang + * @date 2023-05-19 + */ +public interface EPassengerFlowInfoMapper { + /** + * 查询客流信息原始数据 + * + * @param id 客流信息原始数据 主键 + * @return 客流信息原始数据 + */ + public EPassengerFlowInfo selectEPassengerFlowInfoById(Long id); + + /** + * 查询客流信息原始数据 列表 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 客流信息原始数据 集合 + */ + public List selectEPassengerFlowInfoList(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 新增客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + public int insertEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 修改客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + public int updateEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 删除客流信息原始数据 + * + * @param id 客流信息原始数据 主键 + * @return 结果 + */ + public int deleteEPassengerFlowInfoById(Long id); + + /** + * 批量删除客流信息原始数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEPassengerFlowInfoByIds(Long[] ids); +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/IEPassengerFlowInfoService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/IEPassengerFlowInfoService.java new file mode 100644 index 00000000..880d7301 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/IEPassengerFlowInfoService.java @@ -0,0 +1,61 @@ +package com.ruoyi.quartz.service; + +import com.ruoyi.quartz.domain.EPassengerFlowInfo; + +import java.util.List; + +/** + * 客流信息原始数据 Service接口 + * + * @author hehang + * @date 2023-05-19 + */ +public interface IEPassengerFlowInfoService { + /** + * 查询客流信息原始数据 + * + * @param id 客流信息原始数据 主键 + * @return 客流信息原始数据 + */ + public EPassengerFlowInfo selectEPassengerFlowInfoById(Long id); + + /** + * 查询客流信息原始数据 列表 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 客流信息原始数据 集合 + */ + public List selectEPassengerFlowInfoList(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 新增客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + public int insertEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 修改客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + public int updateEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo); + + /** + * 批量删除客流信息原始数据 + * + * @param ids 需要删除的客流信息原始数据 主键集合 + * @return 结果 + */ + public int deleteEPassengerFlowInfoByIds(Long[] ids); + + /** + * 删除客流信息原始数据 信息 + * + * @param id 客流信息原始数据 主键 + * @return 结果 + */ + public int deleteEPassengerFlowInfoById(Long id); +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EPassengerFlowInfoServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EPassengerFlowInfoServiceImpl.java new file mode 100644 index 00000000..3ae902a3 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EPassengerFlowInfoServiceImpl.java @@ -0,0 +1,97 @@ +package com.ruoyi.quartz.service.impl; + +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.quartz.domain.EPassengerFlowInfo; +import com.ruoyi.quartz.mapper.EPassengerFlowInfoMapper; +import com.ruoyi.quartz.service.IEPassengerFlowInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 客流信息原始数据 Service业务层处理 + * + * @author hehang + * @date 2023-05-19 + */ +@Service +public class EPassengerFlowInfoServiceImpl implements IEPassengerFlowInfoService +{ + @Autowired + private EPassengerFlowInfoMapper ePassengerFlowInfoMapper; + + /** + * 查询客流信息原始数据 + * + * @param id 客流信息原始数据 主键 + * @return 客流信息原始数据 + */ + @Override + public EPassengerFlowInfo selectEPassengerFlowInfoById(Long id) + { + return ePassengerFlowInfoMapper.selectEPassengerFlowInfoById(id); + } + + /** + * 查询客流信息原始数据 列表 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 客流信息原始数据 + */ + @Override + public List selectEPassengerFlowInfoList(EPassengerFlowInfo ePassengerFlowInfo) + { + return ePassengerFlowInfoMapper.selectEPassengerFlowInfoList(ePassengerFlowInfo); + } + + /** + * 新增客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + @Override + public int insertEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo) + { + ePassengerFlowInfo.setCreateTime(DateUtils.getNowDate()); + return ePassengerFlowInfoMapper.insertEPassengerFlowInfo(ePassengerFlowInfo); + } + + /** + * 修改客流信息原始数据 + * + * @param ePassengerFlowInfo 客流信息原始数据 + * @return 结果 + */ + @Override + public int updateEPassengerFlowInfo(EPassengerFlowInfo ePassengerFlowInfo) + { + ePassengerFlowInfo.setUpdateTime(DateUtils.getNowDate()); + return ePassengerFlowInfoMapper.updateEPassengerFlowInfo(ePassengerFlowInfo); + } + + /** + * 批量删除客流信息原始数据 + * + * @param ids 需要删除的客流信息原始数据 主键 + * @return 结果 + */ + @Override + public int deleteEPassengerFlowInfoByIds(Long[] ids) + { + return ePassengerFlowInfoMapper.deleteEPassengerFlowInfoByIds(ids); + } + + /** + * 删除客流信息原始数据 信息 + * + * @param id 客流信息原始数据 主键 + * @return 结果 + */ + @Override + public int deleteEPassengerFlowInfoById(Long id) + { + return ePassengerFlowInfoMapper.deleteEPassengerFlowInfoById(id); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EquipmentInfoServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EquipmentInfoServiceImpl.java index 20c5edd0..f2811d19 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EquipmentInfoServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/EquipmentInfoServiceImpl.java @@ -15,12 +15,14 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SnowflakeIdUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.UUID; +import com.ruoyi.quartz.domain.EPassengerFlowInfo; import com.ruoyi.quartz.domain.TpLinkConfig; import com.ruoyi.quartz.domain.dto.EquipmentResult; import com.ruoyi.quartz.domain.dto.GroupResult; import com.ruoyi.quartz.domain.dto.PassengerFlowResult; import com.ruoyi.quartz.domain.dto.TpLinkConfigExtend; import com.ruoyi.quartz.service.EquipmentInfoService; +import com.ruoyi.quartz.service.IEPassengerFlowInfoService; import com.ruoyi.quartz.service.ITpLinkConfigService; import com.ruoyi.quartz.util.TplinkGetXAuthorizationUtil; import org.springframework.beans.BeanUtils; @@ -48,6 +50,8 @@ public class EquipmentInfoServiceImpl implements EquipmentInfoService { private ITpLinkConfigService tpLinkConfigService; @Autowired private IIotInfoService iotInfoService; + @Autowired + private IEPassengerFlowInfoService passengerFlowInfoService; @Override public void selectEquipmentInfoList(String params) { @@ -220,37 +224,42 @@ public class EquipmentInfoServiceImpl implements EquipmentInfoService { List list = iotInfoService.selectIotInfoForList(iotInfo); if (!CollectionUtils.isEmpty(list)) { List DeviceIndexList = list.stream().map(IotInfo::getDeviceIndex).collect(Collectors.toList()); - try { - Map map = new HashMap<>(); - Map map1 = new HashMap<>(); - map.put("start",1); - map.put("limit",100); - - map1.put("queryCategory","device"); - map1.put("regionAccumulate",0); - map1.put("accuracy","hour"); - List timeList = new ArrayList<>(); - timeList.add(2023051800L); - timeList.add(2023051901L); - map1.put("timeList",timeList); - map1.put("projectId",t.getProjectId()); - map1.put("needExport",0); - map1.put("deviceIdList",DeviceIndexList); - map.put("filterAnd",map1); - - String passengerFlowInfo = getIotInfo(t, HttpMethod.POST.toString(), ApiConstants.QueryFlow, JSONObject.toJSONString(map)); - //保存 - JSONObject passengerFlowjson = JSONObject.parseObject(passengerFlowInfo); - if (passengerFlowjson.get("error_code").toString().equals("0")) { - JSONObject resultJson = JSONObject.parseObject(passengerFlowjson.get("result").toString()); - JSONArray jsonArray = JSONArray.parseArray(resultJson.get("list").toString()); - List passengerFlowList = JSON.parseArray(jsonArray.toJSONString(), PassengerFlowResult.class); + try { + Map map = new HashMap<>(); + Map map1 = new HashMap<>(); + map.put("start", 1); + map.put("limit", 100); + map1.put("queryCategory", "device"); + map1.put("regionAccumulate", 0); + map1.put("accuracy", "hour"); + List timeList = new ArrayList<>(); + timeList.add(2023051800L); + timeList.add(2023051901L); + map1.put("timeList", timeList); + map1.put("projectId", t.getProjectId()); + map1.put("needExport", 0); + map1.put("deviceIdList", DeviceIndexList); + map.put("filterAnd", map1); + String passengerFlowInfo = getIotInfo(t, HttpMethod.POST.toString(), ApiConstants.QueryFlow, JSONObject.toJSONString(map)); + //保存 + JSONObject passengerFlowjson = JSONObject.parseObject(passengerFlowInfo); + if (passengerFlowjson.get("error_code").toString().equals("0")) { + JSONObject resultJson = JSONObject.parseObject(passengerFlowjson.get("result").toString()); + JSONArray jsonArray = JSONArray.parseArray(resultJson.get("list").toString()); + List passengerFlowList = JSON.parseArray(jsonArray.toJSONString(), PassengerFlowResult.class); + if (!CollectionUtils.isEmpty(passengerFlowList)) { + passengerFlowList.stream().forEach(s-> { + EPassengerFlowInfo ePassengerFlowInfo = new EPassengerFlowInfo(); + BeanUtils.copyProperties(s, ePassengerFlowInfo); + passengerFlowInfoService.insertEPassengerFlowInfo(ePassengerFlowInfo); + }); } - } catch (Exception e) { - e.printStackTrace(); } + } catch (Exception e) { + e.printStackTrace(); + } } }); @@ -258,7 +267,6 @@ public class EquipmentInfoServiceImpl implements EquipmentInfoService { }); } - @Override public void selectGroupInfo(String params) { //根据第三方平台的信息 请求第三方 获取企业信息、项目、分组信息 根据信息查询设备列表 diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EquipmentInfoTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EquipmentInfoTask.java index 231bc607..67871c64 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EquipmentInfoTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EquipmentInfoTask.java @@ -49,4 +49,13 @@ public class EquipmentInfoTask { equipmentInfoService.selectGroupInfo(params); System.out.println("获取分组信息 end"); } + + /** + * 获取客流信息 + */ + public void getPassengerFlowInfoList(String params) { + System.out.println("获取分组信息 start"); + equipmentInfoService.selectPassengerFlowInfo(params); + System.out.println("获取分组信息 end"); + } } diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/EPassengerFlowInfoMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/EPassengerFlowInfoMapper.xml new file mode 100644 index 00000000..38529f3d --- /dev/null +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/EPassengerFlowInfoMapper.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, type, projectId, accuracy, startTime, endTime, inFlow, outflow, deviceId, deviceName, relatedRegionId, relatedRegionName, del_flag, update_time, create_time, update_by, create_by, organ_code from e_passenger_flow_info + + + + + + + + insert into e_passenger_flow_info + + type, + projectId, + accuracy, + startTime, + endTime, + inFlow, + outflow, + deviceId, + deviceName, + relatedRegionId, + relatedRegionName, + del_flag, + update_time, + create_time, + update_by, + create_by, + organ_code, + + + #{type}, + #{projectId}, + #{accuracy}, + #{startTime}, + #{endTime}, + #{inFlow}, + #{outflow}, + #{deviceId}, + #{deviceName}, + #{relatedRegionId}, + #{relatedRegionName}, + #{delFlag}, + #{updateTime}, + #{createTime}, + #{updateBy}, + #{createBy}, + #{organCode}, + + + + + update e_passenger_flow_info + + type = #{type}, + projectId = #{projectId}, + accuracy = #{accuracy}, + startTime = #{startTime}, + endTime = #{endTime}, + inFlow = #{inFlow}, + outflow = #{outflow}, + deviceId = #{deviceId}, + deviceName = #{deviceName}, + relatedRegionId = #{relatedRegionId}, + relatedRegionName = #{relatedRegionName}, + del_flag = #{delFlag}, + update_time = #{updateTime}, + create_time = #{createTime}, + update_by = #{updateBy}, + create_by = #{createBy}, + organ_code = #{organCode}, + + where id = #{id} + + + + delete from e_passenger_flow_info where id = #{id} + + + + delete from e_passenger_flow_info where id in + + #{id} + + +