1.解决mysql语句关键字问题
2.mysql台账同步oracle
This commit is contained in:
@@ -21,17 +21,22 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.api.NodeClient;
|
||||
import com.njcn.device.pq.api.TerminalBaseClient;
|
||||
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
||||
import com.njcn.device.pq.pojo.param.*;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import com.njcn.device.pq.pojo.po.Node;
|
||||
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
||||
import com.njcn.supervision.enums.SupervisionResponseEnum;
|
||||
import com.njcn.supervision.enums.UserNatureEnum;
|
||||
import com.njcn.supervision.mapper.device.SupervisionTempLineDebugPOMapper;
|
||||
import com.njcn.supervision.mapper.user.UserReportNormalMapper;
|
||||
import com.njcn.supervision.pojo.param.device.SupervisionTempLineDebugParam;
|
||||
import com.njcn.supervision.pojo.param.oracle.*;
|
||||
import com.njcn.supervision.pojo.po.device.SupervisionTempDeviceReport;
|
||||
import com.njcn.supervision.pojo.po.device.SupervisionTempLineDebugPO;
|
||||
import com.njcn.supervision.pojo.po.device.SupervisionTempLineReport;
|
||||
@@ -47,17 +52,22 @@ import com.njcn.supervision.service.user.UserReportProjectPOService;
|
||||
import com.njcn.supervision.service.user.UserReportSensitivePOService;
|
||||
import com.njcn.supervision.service.user.UserReportSubstationPOService;
|
||||
import com.njcn.supervision.utils.InstanceUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -91,6 +101,15 @@ public class SupervisionTempLineDebugPOServiceImpl extends ServiceImpl<Supervisi
|
||||
private final UserReportSensitivePOService userReportSensitivePOService;
|
||||
private final UserReportNormalMapper userReportNormalMapper;
|
||||
private final TerminalBaseClient terminalBaseClient;
|
||||
private final AreaFeignClient areaFeignClient;
|
||||
private final NodeClient nodeClient;
|
||||
|
||||
@Value("${oracle.isSync}")
|
||||
private Boolean isSync;
|
||||
|
||||
@Value("${oracle.syncLedgerLineUrl}")
|
||||
private String url;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -403,7 +422,15 @@ public class SupervisionTempLineDebugPOServiceImpl extends ServiceImpl<Supervisi
|
||||
syncTerminalParam.setSubVoltageParam(subVoltageParam);
|
||||
syncTerminalParam.setLineParam(lineParam);
|
||||
|
||||
if(isSync){
|
||||
/***
|
||||
* oracle http远程调用接口
|
||||
*/
|
||||
SyncLedger syncLedger = oracleSyncLedger(syncTerminalParam);
|
||||
ResponseEntity<String> userEntity = RestTemplateUtil.post(url, syncLedger, String.class);
|
||||
}
|
||||
String substation = terminalBaseClient.terminalSync(syncTerminalParam).getData();
|
||||
|
||||
this.updateProcessStatus(id, 5);
|
||||
tempDevice.setSubstation(substation);
|
||||
supervisionTempDeviceReportService.updateById(tempDevice);
|
||||
@@ -438,8 +465,165 @@ public class SupervisionTempLineDebugPOServiceImpl extends ServiceImpl<Supervisi
|
||||
.in(SupervisionTempLineDebugPO::getId, supervisionId));
|
||||
|
||||
}
|
||||
private SyncLedger oracleSyncLedger(SyncTerminalParam param) {
|
||||
SyncLedger ledger = new SyncLedger();
|
||||
List<Line> data = lineFeignClient.getBaseLineList(Arrays.asList(param.getProjectIndex(),
|
||||
param.getProvinceIndex(),
|
||||
param.getGdIndex()
|
||||
)).getData();
|
||||
|
||||
//项目信息表
|
||||
PqProject pqProject=new PqProject();
|
||||
List<Line> project = data.stream().filter(x -> x.getId().equals(param.getProjectIndex())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(project)){
|
||||
pqProject.setName(project.get(0).getName());
|
||||
}else{
|
||||
throw new BusinessException(SupervisionResponseEnum.PROJECT_OR_NOT);
|
||||
}
|
||||
ledger.setPqProject(pqProject);
|
||||
|
||||
|
||||
//省级项目表
|
||||
PqProvince pqProvince=new PqProvince();
|
||||
List<Line> province = data.stream().filter(x -> x.getId().equals(param.getProvinceIndex())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(province)){
|
||||
Area area = areaFeignClient.selectIdArea(province.get(0).getName()).getData();
|
||||
pqProvince.setName(area.getName());
|
||||
}else {
|
||||
throw new BusinessException(SupervisionResponseEnum.PROVINCE_OR_NOT);
|
||||
}
|
||||
ledger.setPqProvince(pqProvince);
|
||||
|
||||
//供电公司表
|
||||
PqGdinformation pqGdinformation=new PqGdinformation();
|
||||
List<Line> gd = data.stream().filter(x -> x.getId().equals(param.getGdIndex())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(gd)){
|
||||
pqGdinformation.setName(gd.get(0).getName());
|
||||
}else{
|
||||
throw new BusinessException(SupervisionResponseEnum.GD_OR_NOT);
|
||||
}
|
||||
ledger.setPqGdinformation(pqGdinformation);
|
||||
|
||||
//变电站
|
||||
PqSubstation pqSubstation=new PqSubstation();
|
||||
SubStationParam subStation = param.getSubStationParam();
|
||||
if(ObjectUtil.isNull(subStation)){
|
||||
PollutionSubstationDTO sub = lineFeignClient.getSubstationInfo(param.getSubIndex()).getData();
|
||||
subStation =new SubStationParam();
|
||||
subStation.setName(sub.getName());
|
||||
subStation.setScale(sub.getVoltageLevel());
|
||||
subStation.setLng(sub.getLng());
|
||||
subStation.setLat(sub.getLat());
|
||||
}
|
||||
pqSubstation.setName(subStation.getName());
|
||||
pqSubstation.setScale(subStation.getScale());
|
||||
ledger.setPqSubstation(pqSubstation);
|
||||
PqsMap pqsMap=new PqsMap();
|
||||
pqsMap.setLongitude(subStation.getLng().doubleValue());
|
||||
pqsMap.setLatitude(subStation.getLat().doubleValue());
|
||||
pqsMap.setState(1);
|
||||
ledger.setPqsMap(pqsMap);
|
||||
|
||||
//终端
|
||||
PqDevice pqDevice=new PqDevice();
|
||||
DeviceParam device = param.getDeviceParam();
|
||||
pqDevice.setName(device.getName());
|
||||
pqDevice.setStatus(1);
|
||||
pqDevice.setDevtype(dictName(device.getDevType()));
|
||||
pqDevice.setLogontime(device.getLoginTime());
|
||||
pqDevice.setUpdatetime(device.getLoginTime());
|
||||
Node node = nodeClient.getNodeById(device.getNodeId()).getData();
|
||||
if(ObjectUtil.isNotNull(node)){
|
||||
pqDevice.setNodeName(node.getName());
|
||||
}
|
||||
pqDevice.setPortid(device.getPort());
|
||||
pqDevice.setDevflag(0);
|
||||
pqDevice.setDevSeries(device.getSeries());
|
||||
pqDevice.setDevKey(device.getDevKey());
|
||||
pqDevice.setIp(device.getIp());
|
||||
pqDevice.setDevmodel(device.getDevModel());
|
||||
pqDevice.setCallflag(device.getCallFlag());
|
||||
pqDevice.setDatatype(device.getDevDataType());
|
||||
ledger.setPqDevice(pqDevice);
|
||||
|
||||
PqDevicedetail pqDevicedetail=new PqDevicedetail();
|
||||
pqDevicedetail.setManufacturer(dictName(device.getManufacturer()));
|
||||
pqDevicedetail.setThistimecheck(device.getThisTimeCheck());
|
||||
pqDevicedetail.setNexttimecheck(device.getNextTimeCheck());
|
||||
pqDevicedetail.setElectroplate(device.getElectroplate());
|
||||
pqDevicedetail.setContract(device.getContract());
|
||||
pqDevicedetail.setSim(device.getSim());
|
||||
pqDevicedetail.setDevCatena(device.getDevSeries());
|
||||
pqDevicedetail.setDevLocation(device.getDevLocation());
|
||||
pqDevicedetail.setDevNo(device.getDevNo());
|
||||
pqDevicedetail.setIsAlarm(device.getIsAlarm());
|
||||
// pqDevicedetail.setOnlineratetj();
|
||||
// pqDevicedetail.setDataplan();
|
||||
// pqDevicedetail.setNewtraffic();
|
||||
// pqDevicedetail.setOntime();
|
||||
// pqDevicedetail.setCheckflag();
|
||||
ledger.setPqDevicedetail(pqDevicedetail);
|
||||
|
||||
//母线
|
||||
PqSubvoltage pqSubvoltage=new PqSubvoltage();
|
||||
SubVoltageParam subVoltage = param.getSubVoltageParam();
|
||||
pqSubvoltage.setName(subVoltage.getName());
|
||||
pqSubvoltage.setSubvNum(subVoltage.getNum());
|
||||
pqSubvoltage.setScale(dictName(subVoltage.getScale()));
|
||||
pqSubvoltage.setSubvmodel(subVoltage.getModel());
|
||||
ledger.setPqSubvoltage(pqSubvoltage);
|
||||
|
||||
//监测点
|
||||
PqLine pqLine=new PqLine();
|
||||
LineParam line = param.getLineParam();
|
||||
pqLine.setName(line.getName());
|
||||
pqLine.setPt1(line.getPt1().doubleValue());
|
||||
pqLine.setPt2(line.getPt2().doubleValue());
|
||||
pqLine.setCt1(line.getCt1().doubleValue());
|
||||
pqLine.setCt2(line.getCt2().doubleValue());
|
||||
pqLine.setDevcmp(line.getDevCapacity().doubleValue());
|
||||
pqLine.setDlcmp(line.getShortCapacity().doubleValue());
|
||||
pqLine.setJzcmp(line.getStandardCapacity().doubleValue());
|
||||
pqLine.setXycmp(line.getDealCapacity().doubleValue());
|
||||
pqLine.setScale(dictName(subVoltage.getScale()));
|
||||
pqLine.setStatus(1);
|
||||
ledger.setPqLine(pqLine);
|
||||
PqLinedetail pqLinedetail=new PqLinedetail();
|
||||
pqLinedetail.setLineName(line.getName());
|
||||
pqLinedetail.setPttype(line.getPtType());
|
||||
pqLinedetail.setLastTime(device.getLoginTime());
|
||||
pqLinedetail.setTinterval(line.getTimeInterval());
|
||||
pqLinedetail.setLoadtype(dictName(line.getLoadType()));
|
||||
pqLinedetail.setBusinesstype(dictName(line.getBusinessType()));
|
||||
pqLinedetail.setRemark(line.getRemark());
|
||||
pqLinedetail.setMonitorId(line.getMonitorId());
|
||||
pqLinedetail.setPowerid(line.getPowerFlag());
|
||||
pqLinedetail.setObjname(line.getObjName());
|
||||
pqLinedetail.setStatflag(line.getStatFlag());
|
||||
pqLinedetail.setPowerSubstationName(line.getPowerSubstationName());
|
||||
pqLinedetail.setHangLine(line.getHangLine());
|
||||
pqLinedetail.setOwner(line.getOwner());
|
||||
pqLinedetail.setOwnerDuty(line.getOwnerDuty());
|
||||
pqLinedetail.setOwnerTel(line.getOwnerTel());
|
||||
pqLinedetail.setSuperiorsSubstation(line.getSuperiorsSubstation());
|
||||
pqLinedetail.setClassificationGrade(line.getCalssificationGrade());
|
||||
pqLinedetail.setIsGridPoint(1);
|
||||
// pqLinedetail.setLineGrade();
|
||||
// pqLinedetail.setWiringDiagram();
|
||||
ledger.setPqLinedetail(pqLinedetail);
|
||||
ledger.setLineNum(line.getNum());
|
||||
return ledger;
|
||||
}
|
||||
|
||||
private String dictName(String dicId) {
|
||||
try {
|
||||
DictData data = dicDataFeignClient.getDicDataById(dicId).getData();
|
||||
return data.getName();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("字典转换异常");
|
||||
}
|
||||
|
||||
}
|
||||
private void assembleSyncTerminalParam(DeviceParam deviceParam, SupervisionTempDeviceReport tempDevice, SubVoltageParam subVoltageParam, LineParam lineParam, SupervisionTempLineReport tempLine) {
|
||||
//包装device
|
||||
deviceParam.setDevIndex(tempDevice.getId());
|
||||
|
||||
Reference in New Issue
Block a user