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());
......
...@@ -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