Merge branch 'master' of http://47.115.223.229:8888/yangjun/hldy_java_monomer
This commit is contained in:
commit
ba33c3487e
|
@ -31,6 +31,7 @@ public enum ApiEnum {
|
|||
SWITCH_REGION_ORDER("/tums/resource/v2/switchRegionOrder","移动区域信息"),
|
||||
DELETE_REGION("/tums/resource/v2/deleteRegion","删除区域信息"),
|
||||
GET_ROOT_REGIONS("/tums/resource/v2/getRootRegions","获取区域列表"),
|
||||
GET_ROOT_REGION_CHILDREN("/tums/resource/v2/getRegionChildren","获取子区域列表"),
|
||||
GET_DEVICE_LIST("/tums/deviceManager/v2/getDeviceList","获取设备列表"),
|
||||
MODIFY_DEVICE_DETAILS("/tums/deviceManager/v1/modifyDeviceDetails","修改设备信息"),
|
||||
REBOOT_DEVICE_LIST("/tums/deviceManager/v2/rebootDeviceList","重启设备"),
|
||||
|
|
|
@ -164,6 +164,7 @@
|
|||
project_name as projectName,
|
||||
institutional_id as institutionalId,
|
||||
create_time as createTime,
|
||||
DATE_FORMAT(FROM_UNIXTIME(create_time),'%Y-%m-%d %H:%i:%s') as createTimeStr,
|
||||
device_num as deviceNum,
|
||||
message_num as messageNum,
|
||||
sort as sort,
|
||||
|
@ -177,6 +178,7 @@
|
|||
offline_vms_dev_num as offlineVmsDevNum,
|
||||
offline_nbs_dev_num as offlineNbsDevNum,
|
||||
running_time as runningTime,
|
||||
running_time DIV 86400 AS runningTimeStr,
|
||||
status,
|
||||
iz_leaf as izLeaf
|
||||
from nu_iot_tplink_project
|
||||
|
|
|
@ -39,6 +39,20 @@ public class ProjectTreeModel implements Serializable{
|
|||
|
||||
private String projectName;
|
||||
|
||||
private String institutionalId;
|
||||
|
||||
private String createTimeStr;
|
||||
|
||||
private Integer deviceNum;
|
||||
|
||||
private Integer offlineNum;
|
||||
|
||||
private Integer abnormalNum;
|
||||
|
||||
private String runningTimeStr;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String order;
|
||||
|
||||
private Integer sort;
|
||||
|
@ -58,6 +72,13 @@ public class ProjectTreeModel implements Serializable{
|
|||
this.id = "0";
|
||||
this.projectId = projectInfo.getProjectId();
|
||||
this.projectName = projectInfo.getProjectName();
|
||||
this.institutionalId = projectInfo.getInstitutionalId();
|
||||
this.createTimeStr = projectInfo.getCreateTimeStr();
|
||||
this.deviceNum = projectInfo.getDeviceNum();
|
||||
this.offlineNum = projectInfo.getOfflineNum();
|
||||
this.abnormalNum = projectInfo.getAbnormalNum();
|
||||
this.runningTimeStr = projectInfo.getRunningTimeStr();
|
||||
this.status = projectInfo.getStatus();
|
||||
this.order = projectInfo.getOrder();
|
||||
this.sort = projectInfo.getSort();
|
||||
if(0 == projectInfo.getIzLeaf()){
|
||||
|
@ -146,6 +167,62 @@ public class ProjectTreeModel implements Serializable{
|
|||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getInstitutionalId() {
|
||||
return institutionalId;
|
||||
}
|
||||
|
||||
public void setInstitutionalId(String institutionalId) {
|
||||
this.institutionalId = institutionalId;
|
||||
}
|
||||
|
||||
public String getCreateTimeStr() {
|
||||
return createTimeStr;
|
||||
}
|
||||
|
||||
public void setCreateTimeStr(String createTimeStr) {
|
||||
this.createTimeStr = createTimeStr;
|
||||
}
|
||||
|
||||
public Integer getDeviceNum() {
|
||||
return deviceNum;
|
||||
}
|
||||
|
||||
public void setDeviceNum(Integer deviceNum) {
|
||||
this.deviceNum = deviceNum;
|
||||
}
|
||||
|
||||
public Integer getOfflineNum() {
|
||||
return offlineNum;
|
||||
}
|
||||
|
||||
public void setOfflineNum(Integer offlineNum) {
|
||||
this.offlineNum = offlineNum;
|
||||
}
|
||||
|
||||
public Integer getAbnormalNum() {
|
||||
return abnormalNum;
|
||||
}
|
||||
|
||||
public void setAbnormalNum(Integer abnormalNum) {
|
||||
this.abnormalNum = abnormalNum;
|
||||
}
|
||||
|
||||
public String getRunningTimeStr() {
|
||||
return runningTimeStr;
|
||||
}
|
||||
|
||||
public void setRunningTimeStr(String runningTimeStr) {
|
||||
this.runningTimeStr = runningTimeStr;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
@ -177,6 +254,13 @@ public class ProjectTreeModel implements Serializable{
|
|||
return Objects.equals(id, model.id) &&
|
||||
Objects.equals(projectId, model.projectId) &&
|
||||
Objects.equals(projectName, model.projectName) &&
|
||||
Objects.equals(institutionalId, model.institutionalId) &&
|
||||
Objects.equals(createTimeStr, model.createTimeStr) &&
|
||||
Objects.equals(deviceNum, model.deviceNum) &&
|
||||
Objects.equals(offlineNum, model.offlineNum) &&
|
||||
Objects.equals(abnormalNum, model.abnormalNum) &&
|
||||
Objects.equals(runningTimeStr, model.runningTimeStr) &&
|
||||
Objects.equals(status, model.status) &&
|
||||
Objects.equals(order, model.order) &&
|
||||
Objects.equals(sort, model.sort) &&
|
||||
Objects.equals(children, model.children);
|
||||
|
@ -187,7 +271,7 @@ public class ProjectTreeModel implements Serializable{
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, projectId, projectName, order, sort, children);
|
||||
return Objects.hash(id, projectId, projectName, institutionalId, createTimeStr, deviceNum ,offlineNum ,abnormalNum ,runningTimeStr ,status ,order, sort, children);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,10 +62,20 @@ public class RegionInfoController extends JeecgController<RegionInfo, IRegionInf
|
|||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/sync")
|
||||
public Result getUploadToServerProcess(RegionInfo regionInfo)throws Exception{
|
||||
public Result sync(RegionInfo regionInfo)throws Exception{
|
||||
return service.sync(regionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步子区域信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/syncChildren")
|
||||
public Result syncChildren(RegionInfo regionInfo)throws Exception{
|
||||
return service.syncChildren(regionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步查询区域list
|
||||
* @param parentId 父节点 异步加载时传递
|
||||
|
|
|
@ -95,7 +95,8 @@
|
|||
update_time,
|
||||
media_server_id,
|
||||
backup_media_server_id,
|
||||
bind_type
|
||||
bind_type,
|
||||
iz_leaf
|
||||
)
|
||||
values(
|
||||
#{regionId},
|
||||
|
@ -111,7 +112,8 @@
|
|||
#{updateTime},
|
||||
#{mediaServerId},
|
||||
#{backupMediaServerId},
|
||||
#{bindType}
|
||||
#{bindType},
|
||||
#{izLeaf}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
@ -131,7 +133,8 @@
|
|||
update_time = #{updateTime},
|
||||
media_server_id = #{mediaServerId},
|
||||
backup_media_server_id = #{backupMediaServerId},
|
||||
bind_type = #{bindType}
|
||||
bind_type = #{bindType},
|
||||
iz_leaf = #{izLeaf}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
@ -146,8 +149,9 @@
|
|||
a.region_level as regionLevel,
|
||||
a.sort,
|
||||
a.parent_id as parentId,
|
||||
b.project_name as projectName,
|
||||
a.project_id as projectId,
|
||||
ifnull(p.region_name,'无') as parentName,
|
||||
b.project_name as projectName,
|
||||
a.sys_type as sysType,
|
||||
a.stream_way as streamWay,
|
||||
a.has_children as hasChildren,
|
||||
|
@ -159,6 +163,7 @@
|
|||
a.iz_leaf as izLeaf
|
||||
from nu_iot_tplink_region a
|
||||
left join nu_iot_tplink_project b on a.project_id = b.project_id
|
||||
left join nu_iot_tplink_region p on a.parent_id = p.region_id
|
||||
where a.parent_id = #{parentId}
|
||||
and a.project_id = #{projectId}
|
||||
</select>
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface IRegionInfoService extends IService<RegionInfo> {
|
||||
Result sync(RegionInfo regionInfo);
|
||||
Result syncChildren(RegionInfo regionInfo);
|
||||
void sync(String jsonResponse);
|
||||
List<RegionInfo> findList(RegionInfo regionInfo);
|
||||
IPage<RegionInfo> findPage(Page<RegionInfo> page, RegionInfo regionInfo);
|
||||
|
|
|
@ -83,12 +83,15 @@ public class RegionInfoServiceImpl extends ServiceImpl<RegionInfoMapper, RegionI
|
|||
RegionInfo entity = baseMapper.getByRegionId(map);
|
||||
if(entity==null){
|
||||
//新增
|
||||
entity = new RegionInfo();
|
||||
entity.setRegionId(map.get("regionId"));
|
||||
baseMapper.add(map);
|
||||
}else{
|
||||
//修改
|
||||
map.put("id",String.valueOf(entity.getId()));
|
||||
baseMapper.updateById(map);
|
||||
}
|
||||
|
||||
String projectId = map.get("projectId");
|
||||
if(projectId!=null&&!("").equals(projectId)){
|
||||
Map<String, String> projectMap = new HashMap<>();
|
||||
|
@ -96,10 +99,63 @@ public class RegionInfoServiceImpl extends ServiceImpl<RegionInfoMapper, RegionI
|
|||
projectMap.put("izLeaf", "0");
|
||||
projectInfoMapper.updateLeafByPId(projectMap);
|
||||
}
|
||||
if(hasChildren.equals("1")){
|
||||
//同步子级
|
||||
syncChildren(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口返回数据同步子区域入库
|
||||
* @param regionInfo
|
||||
*/
|
||||
@Override
|
||||
public Result syncChildren(RegionInfo regionInfo){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"regionId\"").append(":").append("\"").append(regionInfo.getRegionId()).append("\"");
|
||||
sb.append("}");
|
||||
String jsonResponse = tumsApi.getRegionChildren(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
if(jsonObject.getInt("error_code").equals(0)){
|
||||
JSONArray list = jsonObject.getJSONArray("result");
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject voObject = (JSONObject)list.get(i);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (String key : voObject.keySet()) {
|
||||
map.put(key, voObject.getStr(key));
|
||||
}
|
||||
map.put("sort", map.get("order"));
|
||||
String hasChildren = map.get("hasChildren");
|
||||
if(hasChildren.equals("0")){
|
||||
map.put("izLeaf", "1");
|
||||
}else{
|
||||
map.put("izLeaf", "0");
|
||||
}
|
||||
RegionInfo entity = baseMapper.getByRegionId(map);
|
||||
if(entity==null){
|
||||
//新增
|
||||
entity = new RegionInfo();
|
||||
entity.setRegionId(map.get("regionId"));
|
||||
baseMapper.add(map);
|
||||
}else{
|
||||
//修改
|
||||
map.put("id",String.valueOf(entity.getId()));
|
||||
baseMapper.updateById(map);
|
||||
}
|
||||
if(hasChildren.equals("1")){
|
||||
//同步子级
|
||||
syncChildren(entity);
|
||||
}
|
||||
}
|
||||
return Result.OK("同步子区域成功!");
|
||||
}else{
|
||||
return Result.error(jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TPLINK项目信息列表查询
|
||||
*
|
||||
|
|
|
@ -91,8 +91,9 @@ public class TumsApi {
|
|||
*/
|
||||
public String getAllProjectInfo(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getAllProjectInfo:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.GET_ALL_PROJECT_INFO.getValue());
|
||||
// log.info("getAllProjectInfo:{}",jsonResponse);
|
||||
log.info("getAllProjectInfo:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
|
@ -194,8 +195,22 @@ public class TumsApi {
|
|||
*/
|
||||
public String getRootRegions(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getRootRegions:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.GET_ROOT_REGIONS.getValue());
|
||||
log.info("getAllProjectInfo:{}",jsonResponse);
|
||||
log.info("getRootRegions:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子区域列表
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String getRegionChildren(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getRegionChildren:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.GET_ROOT_REGION_CHILDREN.getValue());
|
||||
log.info("getRegionChildren:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue