拍照时间表管理修改

master
liuguijing 2 years ago
parent 790066f8ab
commit 1401086e82

@ -5,10 +5,7 @@ import com.shxy.xymanager_common.base.BaseController;
import com.shxy.xymanager_common.base.ResponseReult;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.bean.ServiceStatus;
import com.shxy.xymanager_common.model.GetModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleListModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleTimeListModel;
import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
import io.swagger.annotations.Api;
@ -100,8 +97,8 @@ public class TerminalScheduleRuleController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/relateSchelduleRule")
@Log(title = "关联任务规则", type = "修改")
public ResponseReult<GetModel> relateSchelduleRule(@RequestBody @Validated RelateTerminalListRuleIdVo vo) {
ServiceBody<GetModel> serviceBody = terminalScheduleRuleService.relateSchelduleRule(vo);
public ResponseReult<GetListModel> relateSchelduleRule(@RequestBody @Validated RelateTerminalListRuleIdVo vo) {
ServiceBody<GetListModel> serviceBody = terminalScheduleRuleService.relateSchelduleRule(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {

@ -0,0 +1,21 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* ID
*/
@Data
@ApiModel(value = "触发查询信息列表", description = "触发查询信息列表")
public class GetListModel implements Serializable {
@ApiModelProperty(value = "请求ID", example = "123456")
private List<Integer> list;
}

@ -8,11 +8,11 @@ import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ApiModel(value = "查询Cma结果requestid的Vo", description = "查询Cma结果requestid的Vo")
@ApiModel(value = "查询Cma结果requestid的list", description = "查询Cma结果requestid的list")
public class RequestIdListVo {
@NotNull(message = "查询编号不能缺少")
@ApiModelProperty(value = "查询编号", example = "123455")
@NotNull(message = "查询编号列表不能缺少")
@ApiModelProperty(value = "查询编号列表", example = "123455")
private List<Integer> list;
}

@ -15,7 +15,8 @@ public interface RequestResultsDao {
int updateByPrimaryKeySelective(RequestResults record);
int updateByPrimaryKeyWithBLOBs(RequestResults record);
int updateByPrimaryKey(RequestResults record);
int updateByRequestIdList(@Param("list") List<Integer> requestidlist, @Param("status") Integer status);
}

@ -4,6 +4,8 @@ import com.shxy.xymanager_common.entity.TerminalSchedule;
import com.shxy.xymanager_common.entity.TerminalScheduleDetails;
import org.apache.ibatis.annotations.Param;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
public interface TerminalScheduleDetailsDao {
@ -14,7 +16,7 @@ public interface TerminalScheduleDetailsDao {
int insert(TerminalScheduleDetails record);
int insertList(@Param("list") List<TerminalScheduleDetails> record);
int insertList(@Param("list") List<TerminalScheduleDetails> record, @Param("createat") Date createat, @Param("updateat") Date updateat);
int insertSelective(TerminalScheduleDetails record);

@ -77,19 +77,14 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.shxy.xymanager_common.entity.RequestResults">
update request_results
set term_id = #{termId,jdbcType=INTEGER},
request_type = #{requestType,jdbcType=TINYINT},
frame_no = #{frameNo,jdbcType=TINYINT},
client_id = #{clientId,jdbcType=TINYINT},
request_id = #{requestId,jdbcType=INTEGER},
result = #{result,jdbcType=TINYINT},
request_time = #{requestTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
data = #{data,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByRequestIdList">
update request_results
set request_schedule_status = #{status}
where request_id in
<foreach collection="list" item="id" index="index" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.RequestResults">
update request_results
set term_id = #{termId,jdbcType=INTEGER},

@ -37,11 +37,9 @@
<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})
values
<foreach collection="list" item="item" separator=",">
(#{item.termId},#{item.channelId},#{item.startTime},#{item.endTime},#{span},#{createat},#{updateat})
(#{item.termId},#{item.channelId},#{item.startTime},#{item.endTime},#{item.span},#{createat},#{updateat})
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalScheduleDetails">

@ -21,7 +21,7 @@
where status = #{status}
<if test="list != null and list.size>0">
and
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
<foreach collection="list" item="item" index="index" open="(" close=")" separator="or">
term_id = #{item.termid}
<if test="item.channelidlist != null and item.channelidlist.size>0">
and channel_id in
@ -39,9 +39,9 @@
from terminal_schedules_temp
where status = #{status}
<if test="list != null and list.size>0">
and
and request_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
request_id = #{item}
#{item}
</foreach>
</if>
</select>
@ -78,9 +78,6 @@
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalSchedulesTemp">
insert into terminal_schedules_temp
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="termId != null">
term_id,
</if>
@ -90,6 +87,12 @@
<if test="scheduleId != null">
schedule_id,
</if>
<if test="requestId != null">
request_id,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
@ -98,9 +101,6 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="termId != null">
#{termId,jdbcType=INTEGER},
</if>
@ -110,6 +110,12 @@
<if test="scheduleId != null">
#{scheduleId,jdbcType=INTEGER},
</if>
<if test="requestId != null">
#{requestId},
</if>
<if test="status != null">
#{status},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>

@ -81,7 +81,7 @@
where status = #{status}
</select>
<select id="selectByIdList" resultMap="BaseResultMap">
<select id="selectByIdList" resultMap="ChannelAndTerm">
select
a.id as term_id,
a.line_id as line_id,
@ -95,7 +95,7 @@
where a.status = #{status}
<if test="list != null and list.size>0">
and
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
<foreach collection="list" item="item" index="index" open="(" close=")" separator="or">
a.id = #{item.termid}
<if test="item.channelidlist != null and item.channelidlist.size>0">
and c.id in

@ -296,15 +296,20 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
public ServiceBody<Boolean> getReturnedPhoto(ReturnedPhotoVo vo) {
Boolean hasNew = false;
TerminalPhoto photo = terminalPhotoDao.getLatestPhoto(vo.getTermId());
BigInteger localPhotoTime = MyDateUtils.TimeMillSecond2Second(vo.getPhotoTime());
log.info("请求时间:{}",localPhotoTime);
log.info("装置凯斯处理时间:{}",photo.getRecvTime());
hasNew = photo.getRecvTime().compareTo(localPhotoTime) < 0 ? false : true;
if(hasNew && photo.getMediaType() == 1){
if(!StringUtils.isNotBlank(photo.getThumb())){
hasNew=false;
if (photo != null) {
BigInteger localPhotoTime = MyDateUtils.TimeMillSecond2Second(vo.getPhotoTime());
log.info("请求时间:{}", localPhotoTime);
log.info("装置凯斯处理时间:{}", photo.getRecvTime());
hasNew = photo.getRecvTime().compareTo(localPhotoTime) < 0 ? false : true;
if (hasNew && photo.getMediaType() == 1) {
if (!StringUtils.isNotBlank(photo.getThumb())) {
hasNew = false;
}
}
}else {
hasNew = false;
}
return Asserts.success(hasNew);
}
@ -466,7 +471,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
JSONObject resultObj = JSONObject.parseObject(result);
if (null != resultObj.get("groupData")) {
List<PhotoTimeResultDto> resultDtoList = JSONArray.parseArray(resultObj.get("groupData").toString(), PhotoTimeResultDto.class);
if(CollectionUtil.isNotEmpty(resultDtoList)) {
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";

@ -219,57 +219,37 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
*/
@Override
@Transactional
public ServiceBody<GetModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
GetModel model = new GetModel();
public ServiceBody<GetListModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
GetListModel model = new GetListModel();
List<TerminalSchedulesTemp> list = terminalSchedulesTempDao.selectByTermAndChannel(vo.getList(), CommonStatus.DELETE.value());
if (CollectionUtil.isNotEmpty(list)) {
return Asserts.error("有装置时间尚未下发成功");
}
List<RelateTerminalListRuleIdVo.Items> termlist = vo.getList();
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);
List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(vo.getList(), CommonStatus.EFFECTIVE.value());
if (CollectionUtil.isEmpty(termidlist)) {
List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(termlist, CommonStatus.EFFECTIVE.value());
if (CollectionUtil.isEmpty(terminalsList)) {
return Asserts.error("没有该装置");
}
ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
if (BeanUtil.isEmpty(dto)) {
return Asserts.error("没有该拍照时间规则");
}
List<ScheduleRuleDto> dtoList = dto.getList();
if (CollectionUtil.isEmpty(dtoList)) {
return Asserts.error("没有该拍照时间规则");
}
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]);
Date endTime = dtoList.get(j).getEndTime();
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
Integer span1 = -1;
Integer span2 = -1;
if (span / 60 > 0) {
@ -283,19 +263,29 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
+ "--preset2=255 --hour3=" + span1 + "\t" + "--min3=" + span2 + "\t" + "--preset3=255";
timestr.append(string);
}
ArrayList<Integer> requestIdList = new ArrayList<>();
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 {
return Asserts.error("关联失败");
// ProcessExecUtils.exec(cmd);
int requestId = Integer.parseInt(Constants.REQUEST_ID.toString());
Constants.REQUEST_ID.addAndGet(1);
requestIdList.add(requestId);
Date date = new Date();
TerminalSchedulesTemp temp = new TerminalSchedulesTemp();
temp.setTermId(channelAndTermDto.getTermid());
temp.setChannelId(channelAndTermDto.getChannelid());
temp.setScheduleId(scheduleid);
temp.setRequestId(requestId);
temp.setStatus(CommonStatus.DELETE.value());
temp.setCreateTime(date);
temp.setUpdateTime(date);
terminalSchedulesTempDao.insertSelective(temp);
}
model.setList(requestIdList);
return Asserts.success(model);
}
@ -358,13 +348,8 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
}
}
terminalScheduleDetailsDao.deleteByTermidAndChannelIdList(terminalSchedules);
terminalScheduleDetailsDao.insertList(terminalScheduleDetails);
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
//end
terminalScheduleDetailsDao.insertList(terminalScheduleDetails, date, date);
int i = requestResultsDao.updateByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value());//根据requestid将结果表中的状态修改为已下发
if (i != 0) {
return Asserts.success("下发成功");
} else {
@ -372,7 +357,6 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
}
}
/**
*
*
@ -381,10 +365,10 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
*/
@Transactional
public ServiceBody<GetModel> getSchedule(RelateTerminalListRuleIdVo vo) {
// GetModel model = new GetModel();
// Integer requestid = 0;
// ArrayList<Integer> intlist = new ArrayList<>();
// RequestResults results = requestResultsDao.selectByRequestId(1);
GetModel model = new GetModel();
Integer requestid = 0;
ArrayList<Integer> intlist = new ArrayList<>();
RequestResults results = requestResultsDao.selectByRequestId(1);
// /*
// * 如果下发成功
// * 1,将临时表中的数据状态改成1下发成功状态

@ -1,10 +1,7 @@
package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.model.GetModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleListModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleTimeListModel;
import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.vo.*;
/**
@ -57,7 +54,7 @@ public interface TerminalScheduleRuleService {
* @param vo
* @return
*/
ServiceBody<GetModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo);
ServiceBody<GetListModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo);
/**
*

Loading…
Cancel
Save