Commit ada70ccf authored by hanbing's avatar hanbing

代码缩减

parent 4853d9f3
......@@ -5,23 +5,20 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.common.baseentity.BaseCrossInfo;
import net.wanji.utc.common.commonentity.HttpRequest;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.constant.RedisKeyConst;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.common.typeenum.HkControlModeEnum;
import net.wanji.utc.po.SignalStatusLogPO;
import net.wanji.utc.service.runninginfo.HkRunningStatusService;
import net.wanji.utc.util.PathUtil;
import net.wanji.utc.util.RedisUtil;
import net.wanji.utc.vo.LightsStatusVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,20 +28,17 @@ import java.util.Map;
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class HkRunningStatusServiceImpl implements HkRunningStatusService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
@Autowired
private ArtemisConfig artemisConfig;
@Autowired
private RedisUtil redisUtil;
private final ArtemisConfig artemisConfig;
private final RedisUtil redisUtil;
@Override
public List<SignalStatusLogPO> getHkRunningStatus(List<BaseCrossInfo> baseCrossInfoList) {
List<SignalStatusLogPO> result = new ArrayList<>();
SignalStatusLogPO po;
try {
Map<String, String> runningPath = getPathMapByApiCode("getWorkingStateBatch");
Map<String, String> runningPath = PathUtil.getPathMapByApiCode("getWorkingStateBatch");
for (BaseCrossInfo baseCrossInfo : baseCrossInfoList) {
JSONArray jsonBody = new JSONArray();
jsonBody.add(baseCrossInfo.getCode());
......@@ -81,13 +75,6 @@ public class HkRunningStatusServiceImpl implements HkRunningStatusService {
return result;
}
private Map<String, String> getPathMapByApiCode(String apiCode) {
Map<String, String> res = new HashMap<>();
HttpRequest httpRequest = new HttpRequest(BasicEnum.ManufacturerEnum.HK.getCode(), apiCode);
res.put("http://", artemisPath + httpRequest.getUrl());
return res;
}
/**
* 转换海康信号机运行状态,0 离线 1 在线
* @param state 海康信号机状态定义 0 在线 1 离线
......
......@@ -16,7 +16,6 @@ import net.wanji.utc.po.CrossInfoPO;
import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.staticinfo.HkCrossInfoService;
import net.wanji.utc.util.PathUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......
......@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.common.commonentity.HttpRequest;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.mapper.CrossInfoMapper;
......@@ -17,7 +16,7 @@ import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.CrossSchedulesPO;
import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.staticinfo.HkCrossSchedulesService;
import org.springframework.beans.factory.annotation.Value;
import net.wanji.utc.util.PathUtil;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -29,8 +28,6 @@ import java.util.*;
@Service
@RequiredArgsConstructor
public class HkCrossSchedulesServiceImpl implements HkCrossSchedulesService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
private final ArtemisConfig artemisConfig;
private final CrossInfoMapper crossInfoMapper;
private final CrossPlanMapper crossPlanMapper;
......@@ -40,7 +37,7 @@ public class HkCrossSchedulesServiceImpl implements HkCrossSchedulesService {
@Override
public void crossSchedules(List<String> crossIdList) throws Exception {
// 请求3.1.9接口,获取时间表
Map<String, String> path = getPathMapByApiCode("uploadDate");
Map<String, String> path = PathUtil.getPathMapByApiCode("uploadDate");
List<String> crossCodeList = crossInfoMapper.selectCrossCodesByIds(crossIdList);
String body = JSONArray.toJSONString(crossCodeList);
String responseStr = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, body, null,
......@@ -110,11 +107,4 @@ public class HkCrossSchedulesServiceImpl implements HkCrossSchedulesService {
Date parse = DateUtil.parse(dateStr);
return parse;
}
private Map<String, String> getPathMapByApiCode(String apiCode) {
Map<String, String> res = new HashMap<>();
HttpRequest httpRequest = new HttpRequest(BasicEnum.ManufacturerEnum.HK.getCode(), apiCode);
res.put("http://", artemisPath + httpRequest.getUrl());
return res;
}
}
......@@ -5,9 +5,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import net.wanji.utc.common.commonentity.HttpRequest;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.common.typeenum.HkPlanSectionControlTypeEnum;
import net.wanji.utc.mapper.CrossPlanMapper;
import net.wanji.utc.mapper.CrossSchemeMapper;
......@@ -16,12 +15,10 @@ import net.wanji.utc.po.CrossPlanPO;
import net.wanji.utc.po.CrossSchemePO;
import net.wanji.utc.po.CrossSectionPO;
import net.wanji.utc.service.staticinfo.HkPlanSectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import net.wanji.utc.util.PathUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -29,22 +26,17 @@ import java.util.Map;
* @date 2022/11/18 16:34
*/
@Service
@RequiredArgsConstructor
public class HkPlanSectionServiceImpl implements HkPlanSectionService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
@Autowired
private ArtemisConfig artemisConfig;
@Autowired
CrossPlanMapper crossPlanMapper;
@Autowired
CrossSchemeMapper crossSchemeMapper;
@Autowired
CrossSectionMapper crossSectionMapper;
private final ArtemisConfig artemisConfig;
private final CrossPlanMapper crossPlanMapper;
private final CrossSchemeMapper crossSchemeMapper;
private final CrossSectionMapper crossSectionMapper;
@Override
public void planSection(String crossCode, Integer planNo, String crossId) throws Exception {
// 请求3.1.6接口,获取信号机计划
Map<String, String> path = getPathMapByApiCode("uploadPlan");
Map<String, String> path = PathUtil.getPathMapByApiCode("uploadPlan");
JSONObject dataEle = new JSONObject();
dataEle.put("crossCode", crossCode);
dataEle.put("planNo", planNo);
......@@ -108,11 +100,4 @@ public class HkPlanSectionServiceImpl implements HkPlanSectionService {
}
}
}
private Map<String, String> getPathMapByApiCode(String apiCode) {
Map<String, String> res = new HashMap<>();
HttpRequest httpRequest = new HttpRequest(BasicEnum.ManufacturerEnum.HK.getCode(), apiCode);
res.put("http://", artemisPath + httpRequest.getUrl());
return res;
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.typeenum.*;
import net.wanji.utc.entity.cache.PhaseCache;
......@@ -12,7 +13,6 @@ import net.wanji.utc.mapper.*;
import net.wanji.utc.po.*;
import net.wanji.utc.service.staticinfo.HkSchemePhaseLightsService;
import net.wanji.utc.util.PathUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -24,17 +24,13 @@ import java.util.*;
* @date 2022/11/16 15:27
*/
@Service
@RequiredArgsConstructor
public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsService {
@Autowired
private ArtemisConfig artemisConfig;
@Autowired
CrossSchemeMapper crossSchemeMapper;
@Autowired
CrossPhaseMapper crossPhaseMapper;
@Autowired
CrossLightsMapper crossLightsMapper;
@Autowired
CrossPhaseLightsMapper crossPhaseLightsMapper;
private final ArtemisConfig artemisConfig;
private final CrossSchemeMapper crossSchemeMapper;
private final CrossPhaseMapper crossPhaseMapper;
private final CrossLightsMapper crossLightsMapper;
private final CrossPhaseLightsMapper crossPhaseLightsMapper;
@Override
public void hkSchemePhaseLights(String crossId, String crossCode) throws Exception {
......
......@@ -11,7 +11,6 @@ import net.wanji.utc.dto.PlanSectionDTO;
import net.wanji.utc.dto.SchemePhaseLightsDTO;
import net.wanji.utc.vo.PlanSectionVO;
import net.wanji.utc.vo.SchemePhaseLightsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -27,7 +26,6 @@ import java.util.Objects;
public class StaticInfoServiceImpl implements StaticInfoService {
private final HkCrossInfoService hkCrossInfoService;
private final CrossInfoMapper crossInfoMapper;
private final OthersStaticInfoService othersStaticInfoService;
private final ManufacturerInfoMapper manufacturerInfoMapper;
private final HkSchemePhaseLightsService hkSchemePhaseLightsService;
private final HkPlanSectionService hkPlanSectionService;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment