1.台账业务修改
2.变电站-母线接口获取 3.各部门下,变电站母线数据获取
This commit is contained in:
@@ -4,6 +4,8 @@ import cn.hutool.core.date.DateTime;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.njcn.syncdata.pojo.po.*;
|
import com.njcn.syncdata.pojo.po.*;
|
||||||
|
import com.njcn.syncdata.service.IPmsCountLedgerService;
|
||||||
|
import com.njcn.syncdata.service.IPmsMidLedgerService;
|
||||||
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -14,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -23,6 +24,8 @@ import java.util.stream.Collectors;
|
|||||||
public class DataImportController {
|
public class DataImportController {
|
||||||
|
|
||||||
private final IPowerDistributionareaService service;
|
private final IPowerDistributionareaService service;
|
||||||
|
private final IPmsMidLedgerService iPmsMidLedgerService;
|
||||||
|
private final IPmsCountLedgerService iPmsCountLedgerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录获取token
|
* 登录获取token
|
||||||
@@ -62,9 +65,6 @@ public class DataImportController {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取中台日报表数据
|
* 获取中台日报表数据
|
||||||
*
|
*
|
||||||
@@ -121,18 +121,43 @@ public class DataImportController {
|
|||||||
return aas;
|
return aas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 台账导入
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/insertData")
|
@PostMapping("/insertData")
|
||||||
public String insertData() {
|
public String insertData() {
|
||||||
String s = service.insertData();
|
return service.insertData();
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日表数据导入
|
||||||
|
* @param ds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/insertDataDi")
|
@PostMapping("/insertDataDi")
|
||||||
public String insertDataDi(String ds) {
|
public String insertDataDi(String ds) {
|
||||||
String s = service.insertDataDi(ds);
|
return service.insertDataDi(ds);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录获取token
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/insertMidLedger")
|
||||||
|
public Boolean insertMidLedger() {
|
||||||
|
return iPmsMidLedgerService.insertMidLedger();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 登录获取token
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/insertCountLedger")
|
||||||
|
public void insertCountLedger(String date) {
|
||||||
|
iPmsCountLedgerService.insertCountLedger(date);
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 30 17 * * ?")
|
@Scheduled(cron = "0 30 17 * * ?")
|
||||||
public void insert() {
|
public void insert() {
|
||||||
@@ -145,4 +170,15 @@ public class DataImportController {
|
|||||||
log.info(Thread.currentThread().getName() + "2.定时器执行数据成功 "+ds+"----!");
|
log.info(Thread.currentThread().getName() + "2.定时器执行数据成功 "+ds+"----!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 30 0 * * ?")
|
||||||
|
public void insertCountLedgerDate() {
|
||||||
|
log.info(Thread.currentThread().getName() + "1.定时器启动----!");
|
||||||
|
DateTime dateTime = DateUtil.offsetDay(new Date(), 0);
|
||||||
|
String s=dateTime.toString();
|
||||||
|
String ds = s.substring(0, s.indexOf(" "));
|
||||||
|
log.info(Thread.currentThread().getName() + "2.变电站母线定时器执行数据日期 "+ds+"----!");
|
||||||
|
iPmsCountLedgerService.insertCountLedger(ds);
|
||||||
|
log.info(Thread.currentThread().getName() + "2.变电站母线定时器执行数据成功 "+ds+"----!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.syncdata.mapper;
|
||||||
|
|
||||||
|
import com.njcn.db.mapper.BatchBaseMapper;
|
||||||
|
import com.njcn.syncdata.pojo.po.PmsCountLedger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 每日变电站-母线数据总条目表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
public interface PmsCountLedgerMapper extends BatchBaseMapper<PmsCountLedger> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.syncdata.mapper;
|
||||||
|
|
||||||
|
import com.njcn.db.mapper.BatchBaseMapper;
|
||||||
|
import com.njcn.syncdata.pojo.po.PmsMidLedger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 变电站-母线数据中间表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
public interface PmsMidLedgerMapper extends BatchBaseMapper<PmsMidLedger> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.syncdata.mapper.PmsCountLedgerMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.syncdata.mapper.PmsMidLedgerMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -83,7 +83,7 @@ public enum DicDataTypeEnum {
|
|||||||
INPUT_SIGNAL("测量信号输入形式","Signal_form"),
|
INPUT_SIGNAL("测量信号输入形式","Signal_form"),
|
||||||
VOLTAGE_TRANSFORMER("电压互感器类型","Voltage_Transformer"),
|
VOLTAGE_TRANSFORMER("电压互感器类型","Voltage_Transformer"),
|
||||||
Neutral_Point("中性点接地方式","Neutral_Point"),
|
Neutral_Point("中性点接地方式","Neutral_Point"),
|
||||||
DEVICE_REGIONLYPE("设备地区特征","Device_RegionLype"),
|
DEVICE_REGIONLYPE("设备地区特征","Area"),
|
||||||
DEVICE_USERNATURE("设备使用性质代码","Device_UseNature");
|
DEVICE_USERNATURE("设备使用性质代码","Device_UseNature");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class AdsAstXbjcptGetFctgDi {
|
|||||||
/**
|
/**
|
||||||
* 计量点号
|
* 计量点号
|
||||||
*/
|
*/
|
||||||
private Integer id;
|
private String id;
|
||||||
/**
|
/**
|
||||||
* 台区名称
|
* 台区名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
35
src/main/java/com/njcn/syncdata/pojo/po/BusbarPSR.java
Normal file
35
src/main/java/com/njcn/syncdata/pojo/po/BusbarPSR.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package com.njcn.syncdata.pojo.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description 母线台账获取
|
||||||
|
* @date 2023/11/10 14:44
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BusbarPSR {
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
private String ID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行单位
|
||||||
|
*/
|
||||||
|
private String depart;
|
||||||
|
/**
|
||||||
|
* 根设备
|
||||||
|
*/
|
||||||
|
private String root_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
private String RUN_STATUS;
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ public class PWOPTransformerPSR {
|
|||||||
/**
|
/**
|
||||||
* 外部系统id
|
* 外部系统id
|
||||||
*/
|
*/
|
||||||
private String ACCOUNT_ID;
|
private String ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根设备id
|
* 根设备id
|
||||||
|
|||||||
51
src/main/java/com/njcn/syncdata/pojo/po/PmsCountLedger.java
Normal file
51
src/main/java/com/njcn/syncdata/pojo/po/PmsCountLedger.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.syncdata.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 每日变电站-母线数据总条目表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("pms_count_ledger")
|
||||||
|
public class PmsCountLedger {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期
|
||||||
|
*/
|
||||||
|
@TableField("Date")
|
||||||
|
private LocalDateTime date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行单位
|
||||||
|
*/
|
||||||
|
@TableField("Section")
|
||||||
|
private String section;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变电站总数
|
||||||
|
*/
|
||||||
|
@TableField("Sub_Count")
|
||||||
|
private Integer subCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 母线总数
|
||||||
|
*/
|
||||||
|
@TableField("Subv_Count")
|
||||||
|
private Integer subvCount;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
122
src/main/java/com/njcn/syncdata/pojo/po/PmsMidLedger.java
Normal file
122
src/main/java/com/njcn/syncdata/pojo/po/PmsMidLedger.java
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package com.njcn.syncdata.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
|
||||||
|
import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 变电站-母线数据中间表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("pms_mid_ledger")
|
||||||
|
public class PmsMidLedger {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Id
|
||||||
|
*/
|
||||||
|
@TableId(value = "Id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父节点(0为根节点)
|
||||||
|
*/
|
||||||
|
@TableField("Pid")
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上层所有节点
|
||||||
|
*/
|
||||||
|
@TableField("Pids")
|
||||||
|
private String pids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行单位
|
||||||
|
*/
|
||||||
|
@TableField("SectionId")
|
||||||
|
private String SectionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行单位
|
||||||
|
*/
|
||||||
|
@TableField("Section")
|
||||||
|
private String section;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@TableField("Name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等级:0-变电站;1-母线;
|
||||||
|
*/
|
||||||
|
@TableField("Level")
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序(默认为0,有特殊排序需要时候人为输入)
|
||||||
|
*/
|
||||||
|
@TableField("Sort")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@TableField("Remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 0-删除;1-正常;默认正常
|
||||||
|
*/
|
||||||
|
@TableField("State")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
@TableField("Run_Status")
|
||||||
|
private String runStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建用户
|
||||||
|
*/
|
||||||
|
@TableField("Create_By")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField("Create_Time")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户
|
||||||
|
*/
|
||||||
|
@TableField("Update_By")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField("Update_Time")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
* @description
|
* @description 变电站获取
|
||||||
* @date 2023/6/7 11:15
|
* @date 2023/6/7 11:15
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@@ -20,5 +20,16 @@ public class Substation {
|
|||||||
*/
|
*/
|
||||||
private String NAME;
|
private String NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行单位
|
||||||
|
*/
|
||||||
|
private String depart;
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
private String RUN_STATUS;
|
||||||
|
/**
|
||||||
|
* 电压等级
|
||||||
|
*/
|
||||||
|
private String VOLTAGELEVEL_ID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.syncdata.service;
|
||||||
|
|
||||||
|
import com.njcn.db.service.IReplenishMybatisService;
|
||||||
|
import com.njcn.syncdata.pojo.po.PmsCountLedger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 每日变电站-母线数据总条目表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
public interface IPmsCountLedgerService extends IReplenishMybatisService<PmsCountLedger> {
|
||||||
|
|
||||||
|
|
||||||
|
void insertCountLedger(String date);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.njcn.syncdata.service;
|
||||||
|
|
||||||
|
import com.njcn.db.service.IReplenishMybatisService;
|
||||||
|
import com.njcn.syncdata.pojo.po.PmsMidLedger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 变电站-母线数据中间表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
public interface IPmsMidLedgerService extends IReplenishMybatisService<PmsMidLedger> {
|
||||||
|
/**
|
||||||
|
* 变电站-母线中间表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean insertMidLedger();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package com.njcn.syncdata.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.njcn.db.service.impl.ReplenishMybatisServiceImpl;
|
||||||
|
import com.njcn.syncdata.mapper.DictDataMapper;
|
||||||
|
import com.njcn.syncdata.mapper.PmsCountLedgerMapper;
|
||||||
|
import com.njcn.syncdata.pojo.po.Dept;
|
||||||
|
import com.njcn.syncdata.pojo.po.PmsCountLedger;
|
||||||
|
import com.njcn.syncdata.service.IPmsCountLedgerService;
|
||||||
|
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
||||||
|
import com.njcn.syncdata.utils.RestTemplateUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 每日变电站-母线数据总条目表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class PmsCountLedgerServiceImpl extends ReplenishMybatisServiceImpl<PmsCountLedgerMapper, PmsCountLedger> implements IPmsCountLedgerService {
|
||||||
|
|
||||||
|
private final IPowerDistributionareaService powerService;
|
||||||
|
private final DictDataMapper dictDataMapper;
|
||||||
|
@Override
|
||||||
|
public void insertCountLedger(String date) {
|
||||||
|
List<PmsCountLedger> info=new ArrayList<>();
|
||||||
|
List<Dept> deptInfos = dictDataMapper.selectUserList();
|
||||||
|
|
||||||
|
PmsCountLedger countLedger;
|
||||||
|
for (Dept deptDTO : deptInfos) {
|
||||||
|
//筛选上级部门pids包含该id的所有部门
|
||||||
|
List<Dept> descendantDeptDTO = deptInfos.stream()
|
||||||
|
.filter(d -> d.getPids().contains(deptDTO.getId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
//形成需要查询监测点的部门索引
|
||||||
|
List<String> deptIdList = descendantDeptDTO.stream()
|
||||||
|
.map(Dept::getCode)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
deptIdList.add(deptDTO.getCode());
|
||||||
|
countLedger=new PmsCountLedger();
|
||||||
|
countLedger.setSection(deptDTO.getCode());
|
||||||
|
countLedger.setDate(LocalDateTimeUtil.parse(date, DatePattern.NORM_DATE_PATTERN));
|
||||||
|
String join = String.join(",", deptIdList);
|
||||||
|
countLedger.setSubCount(getResourceCount("Substation", join));
|
||||||
|
countLedger.setSubvCount(getResourceCount("BusbarPSR", join));
|
||||||
|
info.add(countLedger);
|
||||||
|
}
|
||||||
|
this.remove(new LambdaQueryWrapper<PmsCountLedger>()
|
||||||
|
.eq(PmsCountLedger::getDate,date)
|
||||||
|
);
|
||||||
|
this.insertBatchBySlice(info,1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getResourceCount(String psrType, String orgID) {
|
||||||
|
Integer count=0;
|
||||||
|
String userUrl = "http://dwzyywzt.com/PSRCenter/queryServices/"+psrType+"/count";
|
||||||
|
Map<String, String> mapHeader = new HashMap<>();
|
||||||
|
mapHeader.put("Content-Type", "application/json; charset=utf-8");
|
||||||
|
mapHeader.put("x-token", powerService.LoginToken());
|
||||||
|
mapHeader.put("x-date", System.currentTimeMillis() + "");
|
||||||
|
mapHeader.put("x-signature", "123");
|
||||||
|
Map<String, Object> map1 = new HashMap<>();
|
||||||
|
Map<String, Object> mapSubset = new HashMap<>();
|
||||||
|
//sql查询
|
||||||
|
List<Map<String, Object>> info = new ArrayList<>();
|
||||||
|
Map<String, Object> mapSubsets = new HashMap<>();
|
||||||
|
mapSubsets.put("fieldName", "depart");
|
||||||
|
mapSubsets.put("compare", "in");
|
||||||
|
mapSubsets.put("fieldValue", orgID);
|
||||||
|
info.add(mapSubsets);
|
||||||
|
mapSubset.put("filters", info);
|
||||||
|
map1.put("params", mapSubset);
|
||||||
|
log.info(Thread.currentThread().getName() + "获取返回体 mapHeader:" + mapHeader + "结束----!");
|
||||||
|
ResponseEntity<Map> userEntity = RestTemplateUtil.post(userUrl, mapHeader, map1, Map.class, new ArrayList<>());
|
||||||
|
if (userEntity.getStatusCodeValue() == 200) {
|
||||||
|
//获取返回体
|
||||||
|
Map body = userEntity.getBody();
|
||||||
|
log.info(Thread.currentThread().getName() + "获取返回体 getResourceData:" + body + "结束----!");
|
||||||
|
Map data = (Map) body.get("result");
|
||||||
|
count = Integer.valueOf(data.get("count").toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
package com.njcn.syncdata.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.njcn.db.service.impl.ReplenishMybatisServiceImpl;
|
||||||
|
import com.njcn.syncdata.mapper.DictDataMapper;
|
||||||
|
import com.njcn.syncdata.mapper.PmsMidLedgerMapper;
|
||||||
|
import com.njcn.syncdata.pojo.enums.DicDataTypeEnum;
|
||||||
|
import com.njcn.syncdata.pojo.po.*;
|
||||||
|
import com.njcn.syncdata.service.IPmsMidLedgerService;
|
||||||
|
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
||||||
|
import com.njcn.syncdata.utils.RestTemplateUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 变电站-母线数据中间表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-11-13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class PmsMidLedgerServiceImpl extends ReplenishMybatisServiceImpl<PmsMidLedgerMapper, PmsMidLedger> implements IPmsMidLedgerService {
|
||||||
|
|
||||||
|
|
||||||
|
private final IPowerDistributionareaService powerService;
|
||||||
|
private final DictDataMapper dictDataMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean insertMidLedger() {
|
||||||
|
List<PmsMidLedger> info=new ArrayList<>();
|
||||||
|
//部门
|
||||||
|
List<Dept> depts = dictDataMapper.selectUserList();
|
||||||
|
//2运行状态
|
||||||
|
List<DictData> state = dictDataMapper.selectList(DicDataTypeEnum.LINE_STATE.getCode());
|
||||||
|
Integer numPum = 1;
|
||||||
|
//定义每页返回数据条数
|
||||||
|
Integer size = 20000;
|
||||||
|
List<Substation> substations=new ArrayList<>();
|
||||||
|
while (true) {
|
||||||
|
Map substation = this.getResourceData("Substation", numPum, size, null);
|
||||||
|
List<Substation> subList = JSONArray.parseArray(JSONArray.toJSONString(substation.get("result")), Substation.class);
|
||||||
|
substations.addAll(subList);
|
||||||
|
if (subList.size() < size) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
numPum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PmsMidLedger mid;
|
||||||
|
for (Substation sub : substations) {
|
||||||
|
mid=new PmsMidLedger();
|
||||||
|
mid.setId(sub.getID());
|
||||||
|
mid.setPid("0");
|
||||||
|
mid.setPids("0");
|
||||||
|
mid.setSectionId(sub.getDepart());
|
||||||
|
mid.setSection(getDeptName(sub.getDepart(), depts));
|
||||||
|
mid.setName(sub.getNAME());
|
||||||
|
mid.setLevel(0);
|
||||||
|
mid.setSort(0);
|
||||||
|
mid.setState(1);
|
||||||
|
mid.setRunStatus(getValue(sub.getRUN_STATUS(),state));
|
||||||
|
mid.setCreateTime(LocalDateTime.now());
|
||||||
|
mid.setUpdateTime(LocalDateTime.now());
|
||||||
|
info.add(mid);
|
||||||
|
}
|
||||||
|
Map<String, String> subMap = info.stream().collect(Collectors.toMap(PmsMidLedger::getId, PmsMidLedger::getId));
|
||||||
|
|
||||||
|
Map<String,Object> map;
|
||||||
|
List<String> subID = substations.stream().map(Substation::getID).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
log.info(Thread.currentThread().getName() + "变电站数量返回体 getResourceData:" + subID.size() + "结束----!");
|
||||||
|
log.info(Thread.currentThread().getName() + "变电站数量ids返回体 getResourceData:" + subID + "结束----!");
|
||||||
|
|
||||||
|
List<List<String>> subIdList = ListUtil.split(subID, 1000);
|
||||||
|
List<BusbarPSR> bars=new ArrayList<>();
|
||||||
|
for (List<String> list : subIdList) {
|
||||||
|
map=new HashMap<>();
|
||||||
|
map.put("fieldName", "root_id");
|
||||||
|
map.put("compare", "in");
|
||||||
|
map.put("fieldValue", String.join(",", list));
|
||||||
|
Map busbarPSR = this.getResourceData("BusbarPSR", 1, size, map);
|
||||||
|
List<BusbarPSR> result = JSONArray.parseArray(JSONArray.toJSONString(busbarPSR.get("result")), BusbarPSR.class);
|
||||||
|
bars.addAll(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BusbarPSR bar : bars) {
|
||||||
|
if(subMap.containsKey(bar.getRoot_id())){
|
||||||
|
String pidSub = subMap.get(bar.getRoot_id());
|
||||||
|
mid=new PmsMidLedger();
|
||||||
|
mid.setId(bar.getID());
|
||||||
|
mid.setPid(pidSub);
|
||||||
|
mid.setPids("0,"+pidSub);
|
||||||
|
mid.setSectionId(bar.getDepart());
|
||||||
|
mid.setSection(getDeptName(bar.getDepart(), depts));
|
||||||
|
mid.setName(bar.getNAME());
|
||||||
|
mid.setLevel(1);
|
||||||
|
mid.setSort(0);
|
||||||
|
mid.setState(1);
|
||||||
|
mid.setRunStatus(getValue(bar.getRUN_STATUS(),state));
|
||||||
|
mid.setCreateTime(LocalDateTime.now());
|
||||||
|
mid.setUpdateTime(LocalDateTime.now());
|
||||||
|
info.add(mid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<PmsMidLedger> collect = info.stream().filter(x -> StrUtil.isNotBlank(x.getName())).collect(Collectors.toList());
|
||||||
|
this.remove(null);
|
||||||
|
this.insertBatchBySlice(collect,1000);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取变电信息
|
||||||
|
* @param psrType
|
||||||
|
* @param num
|
||||||
|
* @param size
|
||||||
|
* @param mapSubsets
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map getResourceData(String psrType, Integer num, Integer size, Map<String, Object> mapSubsets) {
|
||||||
|
Map body = new HashMap();
|
||||||
|
String userUrl = "http://dwzyywzt.com/PSRCenter/queryServices/commonQuery";
|
||||||
|
Map<String, String> mapHeader = new HashMap<>();
|
||||||
|
mapHeader.put("Content-Type", "application/json; charset=utf-8");
|
||||||
|
String token = powerService.LoginToken();
|
||||||
|
mapHeader.put("x-token", token);
|
||||||
|
log.info(Thread.currentThread().getName() + "条件参数获取返回体 token:" + token + "结束----!");
|
||||||
|
mapHeader.put("x-date", System.currentTimeMillis() + "");
|
||||||
|
mapHeader.put("x-signature", "123");
|
||||||
|
|
||||||
|
Map<String, Object> map1 = new HashMap<>();
|
||||||
|
map1.put("psrType", psrType);
|
||||||
|
map1.put("distribution", 1);
|
||||||
|
|
||||||
|
Map<String, Object> mapSubset = new HashMap<>();
|
||||||
|
mapSubset.put("outCaseName", true);
|
||||||
|
mapSubset.put("page", num);
|
||||||
|
mapSubset.put("perPage", size);
|
||||||
|
//sql查询
|
||||||
|
List<Map<String, Object>> info = new ArrayList<>();
|
||||||
|
if(CollUtil.isNotEmpty(mapSubsets)){
|
||||||
|
info.add(mapSubsets);
|
||||||
|
mapSubset.put("filters", info);
|
||||||
|
}
|
||||||
|
map1.put("params", mapSubset);
|
||||||
|
String s = JSONObject.toJSONString(map1);
|
||||||
|
log.info(Thread.currentThread().getName() + "条件参数获取返回体 getResourceData:" + s + "结束----!");
|
||||||
|
log.info(Thread.currentThread().getName() + "条件参数获取返回体 mapHeader:" + mapHeader + "结束----!");
|
||||||
|
ResponseEntity<Map> userEntity = RestTemplateUtil.post(userUrl, mapHeader, map1, Map.class, new ArrayList<>());
|
||||||
|
if (userEntity.getStatusCodeValue() == 200) {
|
||||||
|
//获取返回体
|
||||||
|
body = userEntity.getBody();
|
||||||
|
log.info(Thread.currentThread().getName() + "获取返回体 getResourceData:" + body + "结束----!");
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeptName(String name, List<Dept> depts) {
|
||||||
|
Map<String, String> deptMap = depts.stream().collect(Collectors.toMap(Dept::getCode, Dept::getName, (key1, key2) -> key1));
|
||||||
|
if (deptMap.containsKey(name)) {
|
||||||
|
return deptMap.get(name);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String name, List<DictData> voltageLevel) {
|
||||||
|
Map<String, String> voltageMap = voltageLevel.stream().filter(x -> x.getValue() != null).collect(Collectors.toMap(DictData::getValue, DictData::getId, (key1, key2) -> key1));
|
||||||
|
if (voltageMap.containsKey(name)) {
|
||||||
|
return voltageMap.get(name);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@@ -364,7 +363,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, PWOPTransformerPSR> transformerMap = transformer.stream().collect(Collectors.toMap(PWOPTransformerPSR::getACCOUNT_ID, Function.identity(), (key1, kye2) -> key1));
|
Map<String, PWOPTransformerPSR> transformerMap = transformer.stream().collect(Collectors.toMap(PWOPTransformerPSR::getID, Function.identity(), (key1, kye2) -> key1));
|
||||||
Map<String, PWFeederLinePSR> lineMap = line.stream().collect(Collectors.toMap(PWFeederLinePSR::getID, Function.identity(), (key1, kye2) -> key1));
|
Map<String, PWFeederLinePSR> lineMap = line.stream().collect(Collectors.toMap(PWFeederLinePSR::getID, Function.identity(), (key1, kye2) -> key1));
|
||||||
Map<String, Substation> substationMap = substation.stream().collect(Collectors.toMap(Substation::getID, Function.identity(), (key1, kye2) -> key1));
|
Map<String, Substation> substationMap = substation.stream().collect(Collectors.toMap(Substation::getID, Function.identity(), (key1, kye2) -> key1));
|
||||||
|
|
||||||
@@ -407,7 +406,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setVoltageLevel(getAlgoDescribe(pwopTransformerPSR.getVOLTAGELEVEL_ID(), devVoltage));
|
area.setVoltageLevel(getAlgoDescribe(pwopTransformerPSR.getVOLTAGELEVEL_ID(), devVoltage));
|
||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setDevRegionalism(getAlgoDescribe(pwopTransformerPSR.getREGION_TYPE(), regional));
|
area.setRegionalism(getAlgoDescribe(pwopTransformerPSR.getREGION_TYPE(), regional));
|
||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setNatureOfUse(getAlgoDescribe(pwopTransformerPSR.getUse_nature(), userNature));
|
area.setNatureOfUse(getAlgoDescribe(pwopTransformerPSR.getUse_nature(), userNature));
|
||||||
//判断数据是否为空
|
//判断数据是否为空
|
||||||
@@ -416,6 +415,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
pwFeederLinePSR.getLENGTH(),
|
pwFeederLinePSR.getLENGTH(),
|
||||||
fctgDi.getFc_sum_cap())
|
fctgDi.getFc_sum_cap())
|
||||||
){
|
){
|
||||||
|
log.info(Thread.currentThread().getName() + "3.数据添加 AdsAstXbjcptGetFctgDi:" + fctgDi + "数据属性存在!馈线",pwFeederLinePSR + "结束----!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
area.setPCapacity(fctgDi.getTg_cap().floatValue());
|
area.setPCapacity(fctgDi.getTg_cap().floatValue());
|
||||||
@@ -675,7 +675,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
switch (a) {
|
switch (a) {
|
||||||
case 1:
|
case 1:
|
||||||
//查询户外变
|
//查询户外变
|
||||||
Map transformerData = getResourceData(token, "PWOPTransformerPSR", num, "ACCOUNT_ID", ids);
|
Map transformerData = getResourceData(token, "PWOPTransformerPSR", num, "ID", ids);
|
||||||
aas = JSONArray.parseArray(JSONArray.toJSONString(transformerData.get("result")), t);
|
aas = JSONArray.parseArray(JSONArray.toJSONString(transformerData.get("result")), t);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user