Commit 4cb0716d authored by duanruiming's avatar duanruiming

[update] 静态数据和下发数据优化

parent c5634561
...@@ -10,6 +10,7 @@ import java.util.List; ...@@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Component @Component
@SuppressWarnings("all")
public class Constants { public class Constants {
/** /**
* 厂商接口地址 * 厂商接口地址
......
...@@ -4,7 +4,6 @@ import io.swagger.annotations.Api; ...@@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.entity.JsonViewObject; import net.wanji.utc.entity.JsonViewObject;
import net.wanji.utc.service.control.ControlCommandStrategyService; import net.wanji.utc.service.control.ControlCommandStrategyService;
...@@ -12,6 +11,8 @@ import net.wanji.utc.vo.*; ...@@ -12,6 +11,8 @@ import net.wanji.utc.vo.*;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static net.wanji.utc.common.constant.Constants.*; import static net.wanji.utc.common.constant.Constants.*;
/** /**
...@@ -23,12 +24,11 @@ import static net.wanji.utc.common.constant.Constants.*; ...@@ -23,12 +24,11 @@ import static net.wanji.utc.common.constant.Constants.*;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/controlCommand") @RequestMapping("/controlCommand")
@RequiredArgsConstructor
@Api(value = "控制指令接口", description = "控制指令接口") @Api(value = "控制指令接口", description = "控制指令接口")
public class ControlCommandController { public class ControlCommandController {
private final ControlCommandStrategyService controlCommandStrategyService; @Resource
private ControlCommandStrategyService controlCommandStrategyService;
/** /**
* 信号机方案下发 * 信号机方案下发
......
package net.wanji.utc.controller; package net.wanji.utc.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.utc.entity.JsonViewObject;
import net.wanji.utc.po.*;
import net.wanji.utc.service.staticinfo.StaticInfoService;
import net.wanji.utc.dto.CrossInfoDTO; import net.wanji.utc.dto.CrossInfoDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.wanji.utc.dto.CrossSchedulesDTO; import net.wanji.utc.dto.CrossSchedulesDTO;
import net.wanji.utc.dto.PlanSectionDTO; import net.wanji.utc.dto.PlanSectionDTO;
import net.wanji.utc.dto.SchemePhaseLightsDTO; import net.wanji.utc.dto.SchemePhaseLightsDTO;
import net.wanji.utc.entity.JsonViewObject;
import net.wanji.utc.po.CrossInfoPO;
import net.wanji.utc.po.CrossSchedulesPO;
import net.wanji.utc.service.staticinfo.StaticInfoService;
import net.wanji.utc.vo.PlanSectionVO; import net.wanji.utc.vo.PlanSectionVO;
import net.wanji.utc.vo.SchemePhaseLightsVO; import net.wanji.utc.vo.SchemePhaseLightsVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 静态信息接口 * 静态信息接口
...@@ -77,7 +82,7 @@ public class StaticInfoController { ...@@ -77,7 +82,7 @@ public class StaticInfoController {
String crossId = planSectionDTO.getCrossId(); String crossId = planSectionDTO.getCrossId();
Integer planNo = planSectionDTO.getPlanNo(); Integer planNo = planSectionDTO.getPlanNo();
PlanSectionVO planSectionVO = new PlanSectionVO(); PlanSectionVO planSectionVO = new PlanSectionVO();
if (planNo == -1) { if (Objects.isNull(planNo) || planNo == -1) {
// 返回所有 // 返回所有
planSectionVO = staticInfoService.buildPlanSectionResponse(crossId); planSectionVO = staticInfoService.buildPlanSectionResponse(crossId);
} else { } else {
......
...@@ -11,7 +11,8 @@ import java.util.List; ...@@ -11,7 +11,8 @@ import java.util.List;
*/ */
public interface CrossSectionMapper { public interface CrossSectionMapper {
void deleteOne(@Param("crossId") String crossId, void deleteOne(@Param("crossId") String crossId,
@Param("timeSecNo") Integer timeSecNo); @Param("timeSecNo") Integer timeSecNo,
@Param("planId") Integer planId);
void insertOne(CrossSectionPO crossSectionPO); void insertOne(CrossSectionPO crossSectionPO);
......
package net.wanji.utc.po.hk.request;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/02/16 15:28
*/
@Data
public class PlanSectionInfoQueryPO {
private List<PlanSectionQueryPO> data;
@Data
public static class PlanSectionQueryPO {
private String crossCode;
private Integer planNo;
}
}
package net.wanji.utc.po.hk.response;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/02/16 15:56
*/
@Data
public class PlanPO {
private Integer planNo;
private String planName;
private List<SectionPO> sectionList;
}
package net.wanji.utc.po.hk.response;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/02/16 15:38
*/
@Data
public class PlanSectionResponseListPO {
private String crossCode;
private List<PlanPO> planList;
}
package net.wanji.utc.po.hk.response;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/02/16 15:56
*/
@Data
public class SectionPO {
private Integer timeSecNo;
private String beginTime;
private Integer patternNo;
private Integer controlType;
}
...@@ -6,8 +6,8 @@ import net.wanji.utc.common.typeenum.DateStyle; ...@@ -6,8 +6,8 @@ import net.wanji.utc.common.typeenum.DateStyle;
import net.wanji.utc.entity.JsonViewObject; import net.wanji.utc.entity.JsonViewObject;
import net.wanji.utc.mapper.*; import net.wanji.utc.mapper.*;
import net.wanji.utc.po.*; import net.wanji.utc.po.*;
import net.wanji.utc.service.control.ControlCommandStrategyService;
import net.wanji.utc.service.control.ControlCommandService; import net.wanji.utc.service.control.ControlCommandService;
import net.wanji.utc.service.control.ControlCommandStrategyService;
import net.wanji.utc.util.StringUtils; import net.wanji.utc.util.StringUtils;
import net.wanji.utc.vo.*; import net.wanji.utc.vo.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -40,29 +40,24 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -40,29 +40,24 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
private final CrossPlanMapper crossPlanMapper; private final CrossPlanMapper crossPlanMapper;
private final CrossSchedulesMapper crossSchedulesMapper; private final CrossSchedulesMapper crossSchedulesMapper;
/** /**
* 通过路口编号获取厂商编码 * 通过路口编号获取厂商编码
* *
* @param crossId * @param crossId
* @return * @return
*/ */
public String getManufacturerCodeByCrossId(String crossId) throws Exception{ public String getManufacturerCodeByCrossId(String crossId) throws Exception {
// 获取厂商ID和信号机ID
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.isNull(crossInfoPO)) { if (Objects.isNull(crossInfoPO)) {
throw new Exception("当前路口编号不存在!"); throw new Exception("当前路口信息不存在!");
} }
String signalId = crossInfoPO.getCode();
Integer manufacturerId = crossInfoPO.getManufacturerId(); Integer manufacturerId = crossInfoPO.getManufacturerId();
// 获取厂商代码
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerId); ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerId);
return manufacturerInfoPO.getCode(); return manufacturerInfoPO.getCode();
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
@Transactional(rollbackFor = Exception.class)
public JsonViewObject schemeSendStrategy(SchemeSendVO schemeSendVO) throws Exception { public JsonViewObject schemeSendStrategy(SchemeSendVO schemeSendVO) throws Exception {
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
String manufacturerIdCode = getManufacturerCodeByCrossId(schemeSendVO.getCrossCode()); String manufacturerIdCode = getManufacturerCodeByCrossId(schemeSendVO.getCrossCode());
...@@ -120,9 +115,30 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -120,9 +115,30 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
crossSchemeMapper.insertBatch(crossSchemePOList); crossSchemeMapper.insertBatch(crossSchemePOList);
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
@Transactional(rollbackFor = Exception.class)
public JsonViewObject planSendStrategy(PlanSendVO planSendVO) throws Exception { public JsonViewObject planSendStrategy(PlanSendVO planSendVO) throws Exception {
PlanSendVO.Plan plan = new PlanSendVO.Plan();
plan.setPlanNo("1");
plan.setPlanDescribe("date1111");
List<PlanSendVO.Plan.Section> sectionList = new ArrayList<>();
PlanSendVO.Plan.Section section = new PlanSendVO.Plan.Section();
section.setPatternNo("1");
section.setSectionNo("1");
section.setControlMode("4"); // runMode
section.setBeginTime("7:00");
section.setEndTime("18:00");
sectionList.add(section);
plan.setSectionList(sectionList);
List<PlanSendVO.Plan> plans = new ArrayList<>();
plans.add(plan);
planSendVO.setPlanList(plans);
planSendVO.setCrossCode("14Q1409IRF0");
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
String manufacturerIdCode = getManufacturerCodeByCrossId(planSendVO.getCrossCode()); String manufacturerIdCode = getManufacturerCodeByCrossId(planSendVO.getCrossCode());
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) { if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
...@@ -161,8 +177,8 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -161,8 +177,8 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
crossPlanMapper.insertBatch(crossPlanPOList); crossPlanMapper.insertBatch(crossPlanPOList);
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
@Transactional(rollbackFor = Exception.class)
public JsonViewObject scheduleSendStrategy(ScheduleSendVO scheduleSendVO) throws Exception { public JsonViewObject scheduleSendStrategy(ScheduleSendVO scheduleSendVO) throws Exception {
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
String manufacturerIdCode = getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode()); String manufacturerIdCode = getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode());
......
...@@ -46,29 +46,26 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -46,29 +46,26 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
@Resource @Resource
private HkLightsStatusService hkLightsStatusService; private HkLightsStatusService hkLightsStatusService;
@Resource @Resource
private ArtemisConfig artemisConfig; private ArtemisConfig artemisConfig;
@Resource @Resource
private CrossPhaseMapper crossPhaseMapper; private CrossPhaseMapper crossPhaseMapper;
@Resource @Resource
private CrossInfoMapper crossInfoMapper; private CrossInfoMapper crossInfoMapper;
@Resource @Resource
private ManufacturerInfoMapper manufacturerInfoMapper; private ManufacturerInfoMapper manufacturerInfoMapper;
@Override @Override
public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception { public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
// 厂商 HK CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(schemeSendVO.getCrossCode());
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(schemeSendVO.getCrossCode()); if (Objects.isNull(crossInfoPO)) {
return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
}
// 1、组装参数, 下发海康信号机 // 1、组装参数, 下发海康信号机
DownloadPlanSpandsDTO dto = new DownloadPlanSpandsDTO(); DownloadPlanSpandsDTO dto = new DownloadPlanSpandsDTO();
// 将路口code转换为信号机code // 将路口code转换为信号机code
//dto.setCrossCode(schemeSendVO.getCrossCode()); dto.setCrossCode(crossInfoPO.getCode());
dto.setCrossCode(manufacturerInfoPO.getName());
List<DownloadPlanSpandsDTO.Pattern> patternList = new ArrayList<>(); List<DownloadPlanSpandsDTO.Pattern> patternList = new ArrayList<>();
schemeSendVO.getPatternList().forEach(pattern -> { schemeSendVO.getPatternList().forEach(pattern -> {
DownloadPlanSpandsDTO.Pattern pattern1 = new DownloadPlanSpandsDTO.Pattern(); DownloadPlanSpandsDTO.Pattern pattern1 = new DownloadPlanSpandsDTO.Pattern();
...@@ -99,30 +96,28 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -99,30 +96,28 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
}); });
dto.setPatternList(patternList); dto.setPatternList(patternList);
// 下发信号机方案 // 下发信号机方案
Map<String, Object> fieldMap = FieldUtil.fieldMethod(dto); // Map<String, Object> fieldMap = FieldUtil.fieldMethod(dto);
Map<String, String> path = PathUtil.getPathMapByApiCode("downloadPlanSpands"); Map<String, String> path = PathUtil.getPathMapByApiCode("downloadPlanSpands");
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, JSONObject.toJSONString(dto), null, null, "application/json", null);
path, HKResponse hkResponse = JSONObject.parseObject(strResult, HKResponse.class);
JSON.toJSONString(fieldMap), null, null, "application/json", null); if (Objects.nonNull(hkResponse) && Objects.equals(HK_SUCCESS_STRING_CODE, hkResponse.getCode())) {
JSONObject obj = JSON.parseObject(strResult);
if (obj.get(HK_CODE_KEY).equals(HK_SUCCESS_STRING_CODE)) {
return jsonViewObject.success("海康下发信号机方案成功"); return jsonViewObject.success("海康下发信号机方案成功");
} }
return jsonViewObject.fail(obj.getString("msg")); return jsonViewObject.fail("海康下发信号机方案失败,".concat(hkResponse.getMsg()));
} }
@Override @Override
public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception { public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
// 厂商 HK CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(planSendVO.getCrossCode());
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(planSendVO.getCrossCode()); if (Objects.isNull(crossInfoPO)) {
return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
}
// 1、下发信号机计划拼接参数 // 1、下发信号机计划拼接参数
DownloadTimeSpandsDTO downloadTimeSpandsDTO = new DownloadTimeSpandsDTO(); DownloadTimeSpandsDTO downloadTimeSpandsDTO = new DownloadTimeSpandsDTO();
List<DownloadTimeSpandsDTO.Data> dataList = new ArrayList<>(); List<DownloadTimeSpandsDTO.Data> dataList = new ArrayList<>();
DownloadTimeSpandsDTO.Data data = new DownloadTimeSpandsDTO.Data(); DownloadTimeSpandsDTO.Data data = new DownloadTimeSpandsDTO.Data();
//data.setCrossCode(planSendVO.getCrossCode()); data.setCrossCode(crossInfoPO.getCode());
data.setCrossCode(manufacturerInfoPO.getName());
List<DownloadTimeSpandsDTO.Data.Plan> planList = new ArrayList<>(); List<DownloadTimeSpandsDTO.Data.Plan> planList = new ArrayList<>();
planSendVO.getPlanList().forEach(plan -> { planSendVO.getPlanList().forEach(plan -> {
DownloadTimeSpandsDTO.Data.Plan plan1 = new DownloadTimeSpandsDTO.Data.Plan(); DownloadTimeSpandsDTO.Data.Plan plan1 = new DownloadTimeSpandsDTO.Data.Plan();
...@@ -147,22 +142,21 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -147,22 +142,21 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
Map<String, Object> fieldMap = FieldUtil.fieldMethod(downloadTimeSpandsDTO); Map<String, Object> fieldMap = FieldUtil.fieldMethod(downloadTimeSpandsDTO);
Map<String, String> path = PathUtil.getPathMapByApiCode("downloadTimeSpands"); Map<String, String> path = PathUtil.getPathMapByApiCode("downloadTimeSpands");
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, JSON.toJSONString(fieldMap), null, null, "application/json", null); String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, JSON.toJSONString(fieldMap), null, null, "application/json", null);
JSONObject obj = JSON.parseObject(strResult); HKResponse hkResponse = JSONObject.parseObject(strResult, HKResponse.class);
if (obj.get(HK_CODE_KEY).equals(HK_SUCCESS_STRING_CODE)) { if (Objects.nonNull(hkResponse) && Objects.equals(HK_SUCCESS_STRING_CODE, hkResponse.getCode())) {
return jsonViewObject.success("下发信号机计划成功"); return jsonViewObject.success("海康下发信号机计划成功");
} }
return jsonViewObject.fail(obj.getString("msg")); return jsonViewObject.fail("海康下发信号机计划失败,".concat(hkResponse.getMsg()));
} }
@Override @Override
public JsonViewObject scheduleSend(ScheduleSendVO param) throws Exception { public JsonViewObject scheduleSend(ScheduleSendVO param) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(param.getCrossCode()); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(param.getCrossCode());
String signalCode = null; if (Objects.isNull(crossInfoPO)) {
if (Objects.nonNull(crossInfoPO)) { return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
signalCode = crossInfoPO.getCode();
} }
int id = 0; String signalCode = crossInfoPO.getCode();
// 下发信号机日期拼接参数 // 下发信号机日期拼接参数
DownloadScheduleDTO dto = new DownloadScheduleDTO(); DownloadScheduleDTO dto = new DownloadScheduleDTO();
dto.setCrossCode(signalCode); dto.setCrossCode(signalCode);
...@@ -177,15 +171,8 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -177,15 +171,8 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
if (null != scheduleDays && scheduleDays.size() > 0) { if (null != scheduleDays && scheduleDays.size() > 0) {
scheduleDays.forEach(specialDay -> planNos.add(specialDay.getPlanNo())); scheduleDays.forEach(specialDay -> planNos.add(specialDay.getPlanNo()));
} }
int num = 0;
for (Integer planNo : planNos) { for (Integer planNo : planNos) {
DownloadScheduleDTO.Schedule schedule1 = new DownloadScheduleDTO.Schedule(); DownloadScheduleDTO.Schedule schedule1 = new DownloadScheduleDTO.Schedule();
// scheduleNo 日期号 ,支持返回【1~128】
if (id + planNos.size() > 128) {
schedule1.setScheduleId(128 - planNos.size() - (++num));
} else {
schedule1.setScheduleId(id + (++num));
}
// 0 说明 dates 内的日期是日期集合,1 说明是dates 内的数据是日期范围 // 0 说明 dates 内的日期是日期集合,1 说明是dates 内的数据是日期范围
schedule1.setIsPeriod(0); schedule1.setIsPeriod(0);
// 特殊日期列表 // 特殊日期列表
...@@ -229,23 +216,25 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -229,23 +216,25 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
return jsonViewObject.success("时间表下发成功"); return jsonViewObject.success("时间表下发成功");
} }
return jsonViewObject.fail("时间表下发成功"); return jsonViewObject.fail("时间表下发失败".concat(hkResponse.getMsg()));
} }
@Override @Override
public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception { public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(commandVO.getCrossCode()); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(commandVO.getCrossCode());
if (Objects.isNull(crossInfoPO)) {
return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
}
String signalCode = crossInfoPO.getCode();
if (commandVO.getCommand().equals(TRUE)) { if (commandVO.getCommand().equals(TRUE)) {
Map<String, Object> param = new HashMap<String, Object>() { Map<String, Object> param = new HashMap<String, Object>();
{ param.put("crossCode", signalCode);
put("crossCode", manufacturerInfoPO.getName()); param.put("controlType", LOCK_RUNNING_CONTROL);
put("controlType", LOCK_RUNNING_CONTROL);
}
};
// 获取某一路口下海康相位和车道关系 // 获取某一路口下海康相位和车道关系
//Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(commandVO.getCrossCode()); //Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(commandVO.getCrossCode());
Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(manufacturerInfoPO.getName()); Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(signalCode);
// 控制命令为灯态锁定时,设置相关车道参数信息 // 控制命令为灯态锁定时,设置相关车道参数信息
//List<SignalRunring> runrings = getSignalInfoVos(commandVO.getCrossCode()).get(0).getRunrings(); //List<SignalRunring> runrings = getSignalInfoVos(commandVO.getCrossCode()).get(0).getRunrings();
...@@ -254,7 +243,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -254,7 +243,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
Integer phaseId; Integer phaseId;
List<Map<String, Object>> laneList = new ArrayList<>(); List<Map<String, Object>> laneList = new ArrayList<>();
if (CollectionUtils.isEmpty(commandVO.getPhaseList())) { if (CollectionUtils.isEmpty(commandVO.getPhaseList())) {
LightsStatusVO statusVO = getSignalInfoVos(manufacturerInfoPO.getName()).get(0); LightsStatusVO statusVO = getSignalInfoVos(signalCode).get(0);
phaseId = Integer.valueOf(statusVO.getPhaseId()); phaseId = Integer.valueOf(statusVO.getPhaseId());
JSONArray jsonArray = laneArrayMap.get(phaseId); JSONArray jsonArray = laneArrayMap.get(phaseId);
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
...@@ -289,17 +278,16 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -289,17 +278,16 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
// 控制时长,单位 s,0 则持续控制 // 控制时长,单位 s,0 则持续控制
param.put("duration", Objects.isNull(commandVO.getDuration()) || commandVO.getDuration() == 0 ? 999 : commandVO.getDuration()); param.put("duration", Objects.isNull(commandVO.getDuration()) || commandVO.getDuration() == 0 ? 999 : commandVO.getDuration());
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, PathUtil.getPathMapByApiCode("setSignalControl"),
PathUtil.getPathMapByApiCode("setSignalControl"),
JSON.toJSONString(param), null, null, "application/json", null); JSON.toJSONString(param), null, null, "application/json", null);
JSONObject obj = JSON.parseObject(strResult); HKResponse hkResponse = JSONObject.parseObject(strResult, HKResponse.class);
if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) { if (Objects.nonNull(hkResponse) && Objects.equals(HK_SUCCESS_STRING_CODE, hkResponse.getCode())) {
return jsonViewObject.success("相位锁定成功"); return jsonViewObject.success("海康下发信号机控制成功");
} }
return jsonViewObject.fail(obj.getString("msg")); return jsonViewObject.fail("海康下发信号机控制失败,".concat(hkResponse.getMsg()));
} else { } else {
//return controlSignal(commandVO.getCrossCode(), UNLOCK_RUNNING_CONTROL); //return controlSignal(commandVO.getCrossCode(), UNLOCK_RUNNING_CONTROL);
return controlSignal(manufacturerInfoPO.getName(), UNLOCK_RUNNING_CONTROL); return controlSignal(signalCode, UNLOCK_RUNNING_CONTROL);
} }
} }
...@@ -338,21 +326,22 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -338,21 +326,22 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
@Override @Override
public JsonViewObject stepControl(String code, Integer command, Integer stepNum) throws Exception { public JsonViewObject stepControl(String code, Integer command, Integer stepNum) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(code); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(code);
if (Objects.isNull(crossInfoPO)) {
return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
}
String signalCode = crossInfoPO.getCode();
if (command.equals(TRUE)) { if (command.equals(TRUE)) {
Map<String, Object> param = new HashMap<String, Object>() { Map<String, Object> param = new HashMap<>();
{ param.put("crossCode", signalCode);
//put("crossCode", code); param.put("controlType", STEP_CONTROL);
put("crossCode", manufacturerInfoPO.getName());
put("controlType", STEP_CONTROL);
}
};
int controlNo = 0; int controlNo = 0;
if (0 != stepNum) { if (0 != stepNum) {
//根据当前实时灯态获取运行的相位 //根据当前实时灯态获取运行的相位
//LightsStatusVO lightsStatusVO = getSignalInfoVos(code).get(0); //LightsStatusVO lightsStatusVO = getSignalInfoVos(code).get(0);
LightsStatusVO lightsStatusVO = getSignalInfoVos(manufacturerInfoPO.getName()).get(0); LightsStatusVO lightsStatusVO = getSignalInfoVos(signalCode).get(0);
//暂时按单环处理 //暂时按单环处理
String phaseId = lightsStatusVO.getPhaseId(); String phaseId = lightsStatusVO.getPhaseId();
//获取方案数据列表 //获取方案数据列表
...@@ -375,47 +364,45 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -375,47 +364,45 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
} }
} }
param.put("controlNo", controlNo); param.put("controlNo", controlNo);
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, Map<String, String> controlPathMap = PathUtil.getPathMapByApiCode("setSignalControl");
PathUtil.getPathMapByApiCode("setSignalControl"), String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, controlPathMap, JSON.toJSONString(param), null, null, "application/json", null);
JSON.toJSONString(param), null, null, "application/json", null);
JSONObject obj = JSON.parseObject(strResult); JSONObject obj = JSON.parseObject(strResult);
if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) { if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) {
return jsonViewObject.success(); return jsonViewObject.success();
} }
return jsonViewObject.fail(obj.getString("msg")); return jsonViewObject.fail(obj.getString("msg"));
} else { } else {
//return controlSignal(code, CANCEL_STEP_CONTROL); return controlSignal(signalCode, CANCEL_STEP_CONTROL);
return controlSignal(manufacturerInfoPO.getName(), CANCEL_STEP_CONTROL);
} }
} }
@Override @Override
public JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception { public JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception {
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(code); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(code);
Integer runningMode = command.equals(TRUE) ? commandType : NORMAL_RUNNING_CONTROL; Integer runningMode = command.equals(TRUE) ? commandType : NORMAL_RUNNING_CONTROL;
//return controlSignal(code, runningMode); return controlSignal(crossInfoPO.getCode(), runningMode);
return controlSignal(manufacturerInfoPO.getName(), runningMode);
} }
@Override @Override
public JsonViewObject recoverSchedule(String code) throws Exception { public JsonViewObject recoverSchedule(String code) throws Exception {
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(code); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(code);
//return controlSignal(code, NORMAL_RUNNING_CONTROL); return controlSignal(crossInfoPO.getCode(), NORMAL_RUNNING_CONTROL);
return controlSignal(manufacturerInfoPO.getName(), NORMAL_RUNNING_CONTROL);
} }
@Override @Override
public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception { public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
ManufacturerInfoPO manufacturerInfoPO = checkCrossCode(phaseTimingSendVO.getCrossCode()); CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(phaseTimingSendVO.getCrossCode());
if (Objects.isNull(crossInfoPO)) {
return jsonViewObject.fail("当前路口编号有误,路口信息不存在");
}
String signalCode = crossInfoPO.getCode();
// 将路口code转换为信号机code // 将路口code转换为信号机code
phaseTimingSendVO.setCrossCode(manufacturerInfoPO.getName()); phaseTimingSendVO.setCrossCode(signalCode);
Map<String, Object> param = FieldUtil.fieldMethod(phaseTimingSendVO); Map<String, Object> param = FieldUtil.fieldMethod(phaseTimingSendVO);
Map<String, String> path = PathUtil.getPathMapByApiCode("setPhaseRlatLanes"); Map<String, String> path = PathUtil.getPathMapByApiCode("setPhaseRlatLanes");
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, JSON.toJSONString(param), null, null, "application/json", null);
path,
JSON.toJSONString(param), null, null, "application/json", null);
JSONObject obj = JSON.parseObject(strResult); JSONObject obj = JSON.parseObject(strResult);
if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) { if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) {
return jsonViewObject.success(); return jsonViewObject.success();
...@@ -448,23 +435,19 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -448,23 +435,19 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
// throw new ControlException("当前控制模式是定周期控制,请勿下发恢复命令"); // throw new ControlException("当前控制模式是定周期控制,请勿下发恢复命令");
// } // }
} }
Map<String, Object> param = new HashMap<String, Object>() { Map<String, Object> param = new HashMap<>();
{ param.put("crossCode", code);
put("crossCode", code); param.put("controlType", runningMode);
put("controlType", runningMode); param.put("controlNo", 0);
put("controlNo", 0); //控制时长,单位 s,0 则持续控制
//控制时长,单位 s,0 则持续控制 param.put("duration", 0);
put("duration", 0);
} String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, PathUtil.getPathMapByApiCode("setSignalControl"), JSON.toJSONString(param), null, null, "application/json", null);
}; HKResponse hkResponse = JSONObject.parseObject(strResult, HKResponse.class);
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, if (Objects.nonNull(hkResponse) && Objects.equals(HK_SUCCESS_STRING_CODE, hkResponse.getCode())) {
PathUtil.getPathMapByApiCode("setSignalControl"), return jsonViewObject.success("海康下发信号机控制成功");
JSON.toJSONString(param), null, null, "application/json", null);
JSONObject obj = JSON.parseObject(strResult);
if (HK_SUCCESS_STRING_CODE.equals(obj.get(HK_CODE_KEY))) {
return jsonViewObject.success();
} }
return jsonViewObject.fail(obj.getString("msg")); return jsonViewObject.fail("海康下发信号机控制失败,".concat(hkResponse.getMsg()));
} }
/** /**
......
...@@ -50,8 +50,7 @@ public class HkCrossSchedulesServiceImpl implements HkCrossSchedulesService { ...@@ -50,8 +50,7 @@ public class HkCrossSchedulesServiceImpl implements HkCrossSchedulesService {
if (Objects.nonNull(hkResponse) && Objects.equals(Constants.HK_SUCCESS_CODE, hkResponse.getCode())) { if (Objects.nonNull(hkResponse) && Objects.equals(Constants.HK_SUCCESS_CODE, hkResponse.getCode())) {
String dataStr = String.valueOf(hkResponse.getData()); String dataStr = String.valueOf(hkResponse.getData());
if (StringUtils.isNotBlank(dataStr)) { if (StringUtils.isNotBlank(dataStr)) {
List<ScheduleResponseListPO> scheduleResponseListPOS = JSONObject.parseObject(dataStr, new TypeReference<List<ScheduleResponseListPO>>() { List<ScheduleResponseListPO> scheduleResponseListPOS = JSONObject.parseObject(dataStr, new TypeReference<List<ScheduleResponseListPO>>() {});
});
for (ScheduleResponseListPO scheduleResponseListPO : scheduleResponseListPOS) { for (ScheduleResponseListPO scheduleResponseListPO : scheduleResponseListPOS) {
String crossCode = scheduleResponseListPO.getCrossCode(); String crossCode = scheduleResponseListPO.getCrossCode();
List<ScheduleResponsePO> schedules = scheduleResponseListPO.getSchedules(); List<ScheduleResponsePO> schedules = scheduleResponseListPO.getSchedules();
......
package net.wanji.utc.service.staticinfo.impl; package net.wanji.utc.service.staticinfo.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.hikvision.artemis.sdk.ArtemisHttpUtil; import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig; import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -14,12 +13,20 @@ import net.wanji.utc.mapper.CrossSectionMapper; ...@@ -14,12 +13,20 @@ import net.wanji.utc.mapper.CrossSectionMapper;
import net.wanji.utc.po.CrossPlanPO; import net.wanji.utc.po.CrossPlanPO;
import net.wanji.utc.po.CrossSchemePO; import net.wanji.utc.po.CrossSchemePO;
import net.wanji.utc.po.CrossSectionPO; import net.wanji.utc.po.CrossSectionPO;
import net.wanji.utc.po.hk.request.PlanSectionInfoQueryPO;
import net.wanji.utc.po.hk.response.HKResponse;
import net.wanji.utc.po.hk.response.PlanPO;
import net.wanji.utc.po.hk.response.PlanSectionResponseListPO;
import net.wanji.utc.po.hk.response.SectionPO;
import net.wanji.utc.service.staticinfo.HkPlanSectionService; import net.wanji.utc.service.staticinfo.HkPlanSectionService;
import net.wanji.utc.util.PathUtil; import net.wanji.utc.util.PathUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.Arrays;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author Kent HAN * @author Kent HAN
...@@ -37,63 +44,76 @@ public class HkPlanSectionServiceImpl implements HkPlanSectionService { ...@@ -37,63 +44,76 @@ public class HkPlanSectionServiceImpl implements HkPlanSectionService {
public void planSection(String crossCode, Integer planNo, String crossId) throws Exception { public void planSection(String crossCode, Integer planNo, String crossId) throws Exception {
// 请求3.1.6接口,获取信号机计划 // 请求3.1.6接口,获取信号机计划
Map<String, String> path = PathUtil.getPathMapByApiCode("uploadPlan"); Map<String, String> path = PathUtil.getPathMapByApiCode("uploadPlan");
JSONObject dataEle = new JSONObject(); PlanSectionInfoQueryPO planSectionInfoQueryPO = new PlanSectionInfoQueryPO();
dataEle.put("crossCode", crossCode); PlanSectionInfoQueryPO.PlanSectionQueryPO planSectionQueryPO = new PlanSectionInfoQueryPO.PlanSectionQueryPO();
dataEle.put("planNo", planNo); planSectionQueryPO.setCrossCode(crossCode);
ArrayList<JSONObject> data = new ArrayList<>(); planSectionQueryPO.setPlanNo(planNo);
data.add(dataEle); planSectionInfoQueryPO.setData(Arrays.asList(planSectionQueryPO));
JSONObject requestContent = new JSONObject(); String requestBody = JSONObject.toJSONString(planSectionInfoQueryPO);
requestContent.put("data", data); // 调用海康平台获取结果
String body = requestContent.toJSONString(); String responseStr = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, requestBody, null,
String responseStr = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, body, null,
null, "application/json", null); null, "application/json", null);
JSONObject responseObj = JSON.parseObject(responseStr); HKResponse hkResponse = JSONObject.parseObject(responseStr, HKResponse.class);
if(Constants.HK_SUCCESS_CODE.equals(responseObj.getInteger(Constants.HK_CODE_KEY))) { // 数据处理
JSONArray responsedata = responseObj.getJSONArray("data"); insertPlanSection(crossId, hkResponse);
for (int n = 0; n < responsedata.size(); n++) { }
JSONObject responseDataEle = responsedata.getJSONObject(n);
JSONArray planList = responseDataEle.getJSONArray("planList"); /**
for (int i = 0; i < planList.size(); i++) { * 解析数据,将数据保存到本地数据库
*
* @param crossId
* @param hkResponse
*/
private void insertPlanSection(String crossId, HKResponse hkResponse) {
if (Objects.nonNull(hkResponse) && Objects.equals(hkResponse.getCode(), Constants.HK_SUCCESS_CODE)) {
String dataStr = String.valueOf(hkResponse.getData());
List<PlanSectionResponseListPO> planSectionResponseListPOS = JSONObject.parseObject(dataStr, new TypeReference<List<PlanSectionResponseListPO>>() {});
for (PlanSectionResponseListPO planSectionResponseListPO : planSectionResponseListPOS) {
String crossCodeRes = planSectionResponseListPO.getCrossCode();
List<PlanPO> planList = planSectionResponseListPO.getPlanList();
for (PlanPO planPO : planList) {
CrossPlanPO crossPlanPO = new CrossPlanPO(); CrossPlanPO crossPlanPO = new CrossPlanPO();
JSONObject plan = planList.getJSONObject(i); crossPlanPO.setPlanNo(String.valueOf(planPO.getPlanNo()));
String responsePlanNo = plan.getString("planNo"); crossPlanPO.setName(planPO.getPlanName());
crossPlanPO.setPlanNo(responsePlanNo);
String name = plan.getString("planName");
crossPlanPO.setName(name);
crossPlanPO.setCrossId(crossId); crossPlanPO.setCrossId(crossId);
// 插入之前的计划id,时段删除时使用
List<CrossPlanPO> crossPlanPOS = crossPlanMapper.selectByCrossIdAndPlanNo(crossId, planPO.getPlanNo());
Integer planId = null;
if (!CollectionUtils.isEmpty(crossPlanPOS)) {
planId = crossPlanPOS.get(0).getId();
}
// 写入数据库 // 写入数据库
crossPlanMapper.deleteOne(crossId, Integer.parseInt(responsePlanNo)); crossPlanMapper.deleteOne(crossId, planPO.getPlanNo());
crossPlanMapper.insertOne(crossPlanPO); crossPlanMapper.insertOne(crossPlanPO);
Integer crossPlanPOId = crossPlanPO.getId(); Integer crossPlanPOId = crossPlanPO.getId();
// 构造时段数据 // 构造时段数据
JSONArray sectionList = plan.getJSONArray("sectionList"); List<SectionPO> sectionList = planPO.getSectionList();
for (int j = 0; j < sectionList.size(); j++) { for (int i = 0; i < sectionList.size(); i++) {
JSONObject section = sectionList.getJSONObject(j); SectionPO sectionPO = sectionList.get(i);
CrossSectionPO crossSectionPO = new CrossSectionPO(); CrossSectionPO crossSectionPO = new CrossSectionPO();
String timeSecNo = section.getString("timeSecNo"); crossSectionPO.setSectionNo(String.valueOf(sectionPO.getTimeSecNo()));
crossSectionPO.setSectionNo(timeSecNo); String beginTime = sectionPO.getBeginTime();
String beginTime = section.getString("beginTime");
crossSectionPO.setStartTime(beginTime); crossSectionPO.setStartTime(beginTime);
// 计算结束时间 // 计算结束时间
if (j < sectionList.size() - 1) { if (i < sectionList.size() - 1) {
JSONObject nextSection = sectionList.getJSONObject(j + 1); SectionPO nextSection = sectionList.get(i + 1);
String endTime = nextSection.getString("beginTime"); String endTime = nextSection.getBeginTime();
crossSectionPO.setEndTime(endTime); crossSectionPO.setEndTime(endTime);
} else { } else {
crossSectionPO.setEndTime("24:00"); crossSectionPO.setEndTime("24:00");
} }
crossSectionPO.setCrossId(crossId); crossSectionPO.setCrossId(crossId);
crossSectionPO.setPlanId(crossPlanPOId); crossSectionPO.setPlanId(crossPlanPOId);
Integer controlType = section.getInteger("controlType"); Integer controlType = sectionPO.getControlType();
controlType = HkPlanSectionControlTypeEnum.getCodeByHkCode(controlType); controlType = HkPlanSectionControlTypeEnum.getCodeByHkCode(controlType);
crossSectionPO.setControlMode(controlType); crossSectionPO.setControlMode(controlType);
// 获取方案ID // 获取方案ID
Integer schemeNo = section.getInteger("patternNo"); Integer schemeNo = sectionPO.getPatternNo();
CrossSchemePO crossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, schemeNo); CrossSchemePO crossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, schemeNo);
Integer schemePOId = crossSchemePO.getId(); Integer schemePOId = crossSchemePO.getId();
crossSectionPO.setScemeId(schemePOId); crossSectionPO.setScemeId(schemePOId);
// 写入数据库 // 写入数据库
crossSectionMapper.deleteOne(crossId, Integer.parseInt(timeSecNo)); crossSectionMapper.deleteOne(crossId, sectionPO.getTimeSecNo(), planId);
crossSectionMapper.insertOne(crossSectionPO); crossSectionMapper.insertOne(crossSectionPO);
} }
} }
......
...@@ -48,6 +48,7 @@ public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsServic ...@@ -48,6 +48,7 @@ public class HkSchemePhaseLightsServiceImpl implements HkSchemePhaseLightsServic
JSONObject object = JSON.parseObject(Result); JSONObject object = JSON.parseObject(Result);
if(Constants.HK_SUCCESS_CODE.equals(object.getInteger(Constants.HK_CODE_KEY))) { if(Constants.HK_SUCCESS_CODE.equals(object.getInteger(Constants.HK_CODE_KEY))) {
JSONArray data = object.getJSONArray("data"); JSONArray data = object.getJSONArray("data");
// 轮询获取方案详细信息
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
JSONObject obj = data.getJSONObject(i); JSONObject obj = data.getJSONObject(i);
Integer patternNo = obj.getInteger("patternNo"); Integer patternNo = obj.getInteger("patternNo");
......
...@@ -90,7 +90,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -90,7 +90,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
List<CrossSectionPO> crossSectionPOList = content.getCrossSectionPOList(); List<CrossSectionPO> crossSectionPOList = content.getCrossSectionPOList();
crossSectionPOList.forEach(crossSectionPO -> { crossSectionPOList.forEach(crossSectionPO -> {
crossSectionMapper.deleteOne(crossId, Integer.parseInt(crossSectionPO.getSectionNo())); crossSectionMapper.deleteOne(crossId, Integer.parseInt(crossSectionPO.getSectionNo()), null);
crossSectionMapper.insertOne(crossSectionPO); crossSectionMapper.insertOne(crossSectionPO);
}); });
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<select id="selectByCrossIds" resultMap="BaseResultMap"> <select id="selectByCrossIds" resultMap="BaseResultMap">
select select
id,scheduleNo,name,cross_id,plan_id,week,special_date,gmt_create,gmt_modified id,schedule_no,name,cross_id,plan_id,week,special_date,gmt_create,gmt_modified
from t_cross_schedules from t_cross_schedules
where cross_id in where cross_id in
<foreach collection="crossIds" item="crossId" separator="," open="(" close=")"> <foreach collection="crossIds" item="crossId" separator="," open="(" close=")">
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
</resultMap> </resultMap>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true"> <insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_cross_section(section_no,start_time,end_time,cross_id,plan_id,control_mode,sceme_id) insert into t_cross_section(section_no, start_time, end_time, cross_id, plan_id, control_mode, sceme_id)
values (#{sectionNo},#{startTime},#{endTime},#{crossId},#{planId},#{controlMode},#{scemeId}) values (#{sectionNo}, #{startTime}, #{endTime}, #{crossId}, #{planId}, #{controlMode}, #{scemeId})
</insert> </insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
...@@ -29,21 +29,48 @@ ...@@ -29,21 +29,48 @@
<delete id="deleteOne"> <delete id="deleteOne">
delete from t_cross_section delete from t_cross_section
where cross_id = #{crossId} and section_no = #{timeSecNo} <where>
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
<if test="timeSecNo != null and timeSecNo != ''">
and section_no = #{timeSecNo}
</if>
<if test="planId != null and planId != ''">
and plan_id = #{planId}
</if>
</where>
</delete> </delete>
<select id="selectByCrossId" resultMap="BaseResultMap"> <select id="selectByCrossId" resultMap="BaseResultMap">
select select id,
id,section_no,start_time,end_time,cross_id,plan_id,control_mode,sceme_id,gmt_create,gmt_modified section_no,
start_time,
end_time,
cross_id,
plan_id,
control_mode,
sceme_id,
gmt_create,
gmt_modified
from t_cross_section from t_cross_section
where cross_id = #{crossId} where cross_id = #{crossId}
</select> </select>
<select id="selectByCrossIdAndPlanId" resultMap="BaseResultMap"> <select id="selectByCrossIdAndPlanId" resultMap="BaseResultMap">
select select id,
id,section_no,start_time,end_time,cross_id,plan_id,control_mode,sceme_id,gmt_create,gmt_modified section_no,
start_time,
end_time,
cross_id,
plan_id,
control_mode,
sceme_id,
gmt_create,
gmt_modified
from t_cross_section from t_cross_section
where cross_id = #{crossId} and plan_id = #{planId} where cross_id = #{crossId}
and plan_id = #{planId}
</select> </select>
......
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