拍照时间表管理修改

master
liuguijing 2 years ago
parent 719aac9d22
commit 189f22bdee

@ -122,4 +122,30 @@ public class TerminalScheduleRuleController extends BaseController {
}
}
@ApiOperation(value = "通过Cma获取装置的实际拍照时间调用", notes = "通过Cma获取装置的实际拍照时间调用", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/cmaSchelduleDetials")
@Log(title = "通过Cma获取装置的实际拍照时间调用", type = "查询")
public ResponseReult<GetModel> cmaSchelduleDetials(@RequestBody @Validated TerminalAndChannelIdVo vo) {
ServiceBody<GetModel> serviceBody = terminalScheduleRuleService.cmaSchelduleDetials(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
@ApiOperation(value = "获取Cma调用实际拍照时间的结果", notes = "获取Cma调用实际拍照时间的结果", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getCmaSchelduleDetials")
@Log(title = "获取Cma调用实际拍照时间的结果", type = "查询")
public ResponseReult<TerminalScheduleRuleTimeListModel> getCmaSchelduleDetials(@RequestBody @Validated RequestIdVo vo) {
ServiceBody<TerminalScheduleRuleTimeListModel> serviceBody = terminalScheduleRuleService.getCmaSchelduleDetials(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
}

@ -0,0 +1,17 @@
package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "查询Cma结果requestid的Vo", description = "查询Cma结果requestid的Vo")
public class RequestIdVo {
@NotNull(message = "查询编号不能缺少")
@ApiModelProperty(value = "查询编号", example = "123455")
private Integer requestid;
}

@ -1,12 +1,17 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.TerminalScheduleDetails;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TerminalScheduleDetailsDao {
int deleteByPrimaryKey(Integer id);
int insert(TerminalScheduleDetails record);
int insertList(@Param("list") List<TerminalScheduleDetails> record);
int insertSelective(TerminalScheduleDetails record);
TerminalScheduleDetails selectByPrimaryKey(Integer id);

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shxy.xymanager_dao.dao.TerminalScheduleDetailsDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="schedule_id" jdbcType="INTEGER" property="scheduleId" />
<result column="start_time" jdbcType="TIME" property="startTime" />
<result column="end_time" jdbcType="TIME" property="endTime" />
<result column="span" jdbcType="INTEGER" property="span" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="schedule_id" jdbcType="INTEGER" property="scheduleId"/>
<result column="start_time" jdbcType="TIME" property="startTime"/>
<result column="end_time" jdbcType="TIME" property="endTime"/>
<result column="span" jdbcType="INTEGER" property="span"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
id, schedule_id, start_time, end_time, span, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from terminal_schedule_details
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_schedule_details
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from terminal_schedule_details
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
insert into terminal_schedule_details (id, schedule_id, start_time,
end_time, span, create_time,
update_time)
@ -31,80 +31,92 @@
#{endTime,jdbcType=TIME}, #{span,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
insert into terminal_schedule_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="scheduleId != null">
schedule_id,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="span != null">
span,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="scheduleId != null">
#{scheduleId,jdbcType=INTEGER},
</if>
<if test="startTime != null">
#{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIME},
</if>
<if test="span != null">
#{span,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
update terminal_schedule_details
<set>
<if test="scheduleId != null">
schedule_id = #{scheduleId,jdbcType=INTEGER},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIME},
</if>
<if test="span != null">
span = #{span,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
<insert id="insertList">
insert into terminal_schedule_details
(term_id, channel_id,start_time, end_time, span, create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{scheduleId,jdbcType=INTEGER}, #{startTime,jdbcType=TIME},
#{endTime,jdbcType=TIME}, #{span,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
<foreach collection="list" item="item" separator=",">
(#{item.termId},#{item.channelId},#{item.startTime},#{item.endTime},#{span},#{createat},#{updateat})
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
insert into terminal_schedule_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="scheduleId != null">
schedule_id,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="span != null">
span,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="scheduleId != null">
#{scheduleId,jdbcType=INTEGER},
</if>
<if test="startTime != null">
#{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIME},
</if>
<if test="span != null">
#{span,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
update terminal_schedule_details
<set>
<if test="scheduleId != null">
schedule_id = #{scheduleId,jdbcType=INTEGER},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIME},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIME},
</if>
<if test="span != null">
span = #{span,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">
update terminal_schedule_details
set schedule_id = #{scheduleId,jdbcType=INTEGER},
start_time = #{startTime,jdbcType=TIME},

@ -6,10 +6,14 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.dto.ChannelAndTermDto;
import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
import com.shxy.xymanager_common.dto.ScheduleAndRuleDto;
import com.shxy.xymanager_common.dto.ScheduleRuleDto;
import com.shxy.xymanager_common.entity.*;
@ -19,14 +23,18 @@ import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
import lombok.extern.slf4j.Slf4j;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Date;
@ -57,6 +65,9 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
@Autowired
RequestResultsDao requestResultsDao;
@Autowired
TerminalScheduleDetailsDao terminalScheduleDetailsDao;
/**
*
*
@ -291,7 +302,6 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
}
/**
*
*
@ -299,85 +309,90 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
* @return
*/
@Transactional
public ServiceBody<GetModel> checkScheldule(RelateTerminalListRuleIdVo vo) {
public ServiceBody<String> checkScheldule(RelateTerminalListRuleIdVo vo) {
Integer requestid = 0;
ArrayList<Integer> intlist = new ArrayList<>();
RequestResults results = requestResultsDao.selectByRequestId(1);
String data = results.getData();
Integer result = results.getResult();
if (result == 255) {
// terminalSchedulesTempDao.selectByRequestId(intlist);
/*
*
* 1,1
* 2
* 3detial
* */
if (results != null) {
TerminalSchedulesTemp record = new TerminalSchedulesTemp();
record.setStatus(CommonStatus.EFFECTIVE.value());
record.setRequestId(requestid);
terminalSchedulesTempDao.updateByPrimaryKeySelective(record);
}
ArrayList<Integer> id = new ArrayList<>();
TerminalSchedulesTemp temp1 = terminalSchedulesTempDao.selectByRequestId(id, CommonStatus.EFFECTIVE.value());
GetModel model = new GetModel();
List<TerminalSchedulesTemp> list = terminalSchedulesTempDao.selectByTermAndChannel(vo.getList(), CommonStatus.DELETE.value());
if (CollectionUtil.isNotEmpty(list)) {
return Asserts.error("有装置时间尚未下发成功");
}
List<RelateTerminalListRuleIdVo.Items> termlist = vo.getList();
TerminalSchedules record = new TerminalSchedules();
record.setChannelId(temp1.getChannelId());
record.setScheduleId(temp1.getScheduleId());
record.setTermId(temp1.getTermId());
terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
Integer scheduleid = vo.getScheduleid();
List<TerminalSchedulesTemp> temps = new ArrayList<>();
List<Integer> termidlist = new ArrayList<>();
for (RelateTerminalListRuleIdVo.Items item : termlist) {
termidlist.add(item.getTermid());
List<Integer> channelidlist = item.getChannelidlist();
for (Integer it : channelidlist) {
TerminalSchedulesTemp temp = new TerminalSchedulesTemp();
temp.setTermId(item.getTermid());
temp.setScheduleId(scheduleid);
temp.setChannelId(it);
temps.add(temp);
}
}
Date date = new Date();
int i = terminalSchedulesTempDao.insertList(temps, CommonStatus.EFFECTIVE.value(), date, date);
// terminalScheduleDetailsDao.deleteByPrimaryKey();//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(vo.getList(), CommonStatus.EFFECTIVE.value());
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
if (CollectionUtil.isEmpty(termidlist)) {
return Asserts.error("没有该装置");
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
//end
if (i != 0) {
return Asserts.success("下发成功");
} else {
return Asserts.error("关联失败");
}
ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
List<ScheduleRuleDto> dtoList = dto.getList();
if (CollectionUtil.isEmpty(dtoList)) {
return Asserts.error("没有该拍照时间规则");
}
/**
*
*
* @param vo
* @return
*/
@Transactional
public ServiceBody<GetModel> getSchedule(RelateTerminalListRuleIdVo vo) {
GetModel model = new GetModel();
Integer requestid = 0;
ArrayList<Integer> intlist = new ArrayList<>();
RequestResults results = requestResultsDao.selectByRequestId(1);
/*
*
* 1,1
* 2
* 3detial
* */
if (results != null) {
TerminalSchedulesTemp record = new TerminalSchedulesTemp();
record.setStatus(CommonStatus.EFFECTIVE.value());
record.setRequestId(requestid);
terminalSchedulesTempDao.updateByPrimaryKeySelective(record);
}
StringBuffer timestr = new StringBuffer();
for (int j = 0; j < dtoList.size(); j++) {
TerminalPhotosTimeModel.PhotosTimeBean bean = new TerminalPhotosTimeModel.PhotosTimeBean();
Integer span = dtoList.get(j).getSpan();
Date startTime = dtoList.get(j).getStartTime();
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
ArrayList<Integer> id = new ArrayList<>();
TerminalSchedulesTemp temp1 = terminalSchedulesTempDao.selectByRequestId(id, CommonStatus.EFFECTIVE.value());
TerminalSchedules record = new TerminalSchedules();
record.setChannelId(temp1.getChannelId());
record.setScheduleId(temp1.getScheduleId());
record.setTermId(temp1.getTermId());
terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
Date endTime = dtoList.get(j).getEndTime();
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
terminalScheduleDetailsDao.deleteByPrimaryKey(0);//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
//end
Integer span1 = -1;
Integer span2 = -1;
if (span / 60 > 0) {
span1 = (span / 60);
span2 = (span % 60);
} else if (span < 60) {
span1 = 0;
span2 = span;
}
String string = "--hour1=" + startHour + "\t" + "--min1=" + startMin + "\t" + "--preset1=255 --hour2=" + endTimeHour + "\t" + "--min2=" + endTimeMin + "\t"
+ "--preset2=255 --hour3=" + span1 + "\t" + "--min3=" + span2 + "\t" + "--preset3=255";
timestr.append(string);
}
for (int x = 0; x < terminalsList.size(); x++) {
ChannelAndTermDto channelAndTermDto = terminalsList.get(x);
String cmd = Constants.CMD + "schedule --flag=1 --cmdid=" + channelAndTermDto.getCmdid() + "\t" + "--channel=" + channelAndTermDto.getChannelid() + "\t" +
timestr.toString();
ProcessExecUtils.exec(cmd);
}
model.setRequestId(Integer.parseInt(Constants.REQUEST_ID.toString()));
Constants.REQUEST_ID.addAndGet(1);
if (i != 0) {
return Asserts.success(model);
} else {
@ -417,4 +432,56 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
return Asserts.success(model);
}
//调用CMA获取装置的拍照时间表详情
@Override
public ServiceBody<GetModel> cmaSchelduleDetials(TerminalAndChannelIdVo vo) {
GetModel model = new GetModel();
Integer terminalid = vo.getTerminalid();
Integer channelid = vo.getChannelid();
String cmdIdByTermId = terminalsDao.getCmdIdByTermId(terminalid);
String cmd = Constants.CMD + "schedule --cmdid=" + cmdIdByTermId + "\t" + "--reqid=" + Constants.REQUEST_ID + "\t" + "--clientid=10 --flag=0 --rf=7 --channel=" + channelid;
ProcessExecUtils.exec(cmd);
Integer requestId = Integer.parseInt(Constants.REQUEST_ID.toString());
model.setRequestId(requestId);
Constants.REQUEST_ID.addAndGet(1);
model.setRequestId(requestId);
return Asserts.success(model);
}
/*获取Cma调用获取装置拍照时间表结果*/
@Override
public ServiceBody<TerminalScheduleRuleTimeListModel> getCmaSchelduleDetials(RequestIdVo vo) {
TerminalScheduleRuleTimeListModel model = new TerminalScheduleRuleTimeListModel();
RequestResults results = requestResultsDao.selectByRequestId(vo.getRequestid());
String resultsData = results.getData();
if (StringUtils.isNotBlank(resultsData)) {
JSONObject resultObj = JSONObject.parseObject(resultsData);
if (null != resultObj.get("groupData")) {
List<PhotoTimeResultDto> resultDtoList = JSONArray.parseArray(resultObj.get("groupData").toString(), PhotoTimeResultDto.class);
if (CollectionUtil.isNotEmpty(resultDtoList)) {
List<String> resultList = Lists.newArrayList();
String startTimeStr = resultDtoList.get(0).getHour() + ":" + resultDtoList.get(0).getMinute() + ":00";
String endTimeStr = resultDtoList.get(1).getHour() + ":" + resultDtoList.get(1).getMinute() + ":00";
Date startTime = DateUtil.parseTime(startTimeStr);
Date endTime = DateUtil.parseTime(endTimeStr);
Integer span = resultDtoList.get(2).getHour() * 60 + resultDtoList.get(2).getMinute();
List<DateTime> dateTimes = MyDateUtils.rangeToList(startTime, endTime, DateField.MINUTE, span);
for (DateTime data : dateTimes) {
String dateTime = DateUtil.formatTime(data);
resultList.add(dateTime);
}
model.setList(resultList);
model.setIsNew(true);
}
}
return Asserts.success(model);
} else {
return Asserts.error("查询失败");
}
}
}

@ -65,4 +65,18 @@ public interface TerminalScheduleRuleService {
* @return
*/
ServiceBody<TerminalScheduleRuleTimeListModel> getChannelSchelduleRule(TerminalAndChannelIdVo vo);
/**
* CMA
* @param vo
* @return
*/
ServiceBody<GetModel> cmaSchelduleDetials(TerminalAndChannelIdVo vo);
/**
* Cma
* @param vo
* @return
*/
ServiceBody<TerminalScheduleRuleTimeListModel> getCmaSchelduleDetials(RequestIdVo vo);
}

Loading…
Cancel
Save