Merge remote-tracking branch 'origin/master'

# Conflicts:
#	xymanager_admin/src/test/java/com/shxy/xymanager_admin/XymanagerAdminApplicationTests.java
master
18616268358 2 years ago
commit 91b62b03d4

@ -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 {

@ -1,5 +1,9 @@
package com.shxy.xymanager_admin;
import cn.hutool.core.collection.CollectionUtil;
import com.shxy.xymanager_common.entity.TerminalSchedule;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_dao.dao.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,6 +30,9 @@ class XymanagerAdminApplicationTests {
@Autowired
private TerminalSchedulesTempDao terminalSchedulesTempDao;
@Autowired
private TerminalScheduleDao terminalScheduleDao;
@Test
void contextLoads() {
@ -121,8 +128,17 @@ class XymanagerAdminApplicationTests {
requestidlist.add(3);
// TerminalSchedule terminalSchedule = terminalScheduleDao.selectByPrimaryKey(1);
// System.out.println(terminalSchedule.toString());
ArrayList<Integer> list = new ArrayList<>();
list.add(1);
list.add(1);
list.add(2);
list.add(3);
System.out.println(list.toArray());
ArrayList<Integer> distinct = CollectionUtil.distinct(list);
System.out.println(distinct.toArray());
}
}

@ -6,7 +6,7 @@ import java.io.Serializable;
import java.util.Date;
@Data
public class TerminalSchedules implements Serializable {
public class TerminalSchedule implements Serializable {
private Integer id;
private Integer termId;

@ -1,12 +1,17 @@
package com.shxy.xymanager_common.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class TerminalScheduleDetails implements Serializable {
private Integer id;
private Integer scheduleId;
private Integer termId;
private Integer channelId;
private Date startTime;
@ -20,59 +25,4 @@ public class TerminalScheduleDetails implements Serializable {
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getScheduleId() {
return scheduleId;
}
public void setScheduleId(Integer scheduleId) {
this.scheduleId = scheduleId;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Integer getSpan() {
return span;
}
public void setSpan(Integer span) {
this.span = span;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

@ -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);
}

@ -1,8 +1,10 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.ScheduleDetails;
import com.shxy.xymanager_common.entity.TerminalSchedule;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -16,11 +18,14 @@ public interface ScheduleDetailsDao {
List<ScheduleDetails> selectAll(@Param("status") Integer status);
List<ScheduleDetails> selectAllByList(@Param("list") List<TerminalSchedule> list);
int deleteById(@Param("scheduleid") Integer id);
int updateByPrimaryKeySelective(@Param("data") ScheduleDetails record, @Param("updateat") Date update);
int updateByPrimaryKey(ScheduleDetails record);
List<ScheduleDetails> selectAllBySceduleidList(@Param("list") List<Integer> distinct);
}

@ -0,0 +1,30 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.TerminalSchedule;
import com.shxy.xymanager_common.vo.RelateTerminalListRuleIdVo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface TerminalScheduleDao {
int deleteByChannelId(@Param("list") List<TerminalSchedule> list);
int insert(TerminalSchedule record);
int insertSelective(TerminalSchedule record);
int insertList(@Param("list") List<TerminalSchedule> record, @Param("createat") Date create, @Param("updateat") Date update);
TerminalSchedule selectByPrimaryKey(Integer id);
TerminalSchedule selectByChannelId(@Param("channelid") Integer list, @Param("termid") Integer termid);
List<TerminalSchedule> selectByTerminalBean(@Param("list") List<RelateTerminalListRuleIdVo.Items> list);
int insertOrUpdate(@Param("list") List<TerminalSchedule> record, @Param("createat") Date create, @Param("updateat") Date update);
int updateByPrimaryKeySelective(TerminalSchedule record);
int updateByPrimaryKey(TerminalSchedule record);
}

@ -1,16 +1,22 @@
package com.shxy.xymanager_dao.dao;
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 {
int deleteByPrimaryKey(Integer id);
int deleteByTermiAndChannel(Integer id);
int deleteByTermidAndChannelIdList(@Param("list") List<TerminalSchedule> lsit);
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);

@ -1,30 +0,0 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.TerminalSchedules;
import com.shxy.xymanager_common.vo.RelateTerminalListRuleIdVo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface TerminalSchedulesDao {
int deleteByChannelId(@Param("list") List<TerminalSchedules> list);
int insert(TerminalSchedules record);
int insertSelective(TerminalSchedules record);
int insertList(@Param("list") List<TerminalSchedules> record, @Param("createat") Date create, @Param("updateat") Date update);
TerminalSchedules selectByPrimaryKey(Integer id);
TerminalSchedules selectByChannelId(@Param("channelid") Integer list, @Param("termid") Integer termid);
List<TerminalSchedules> selectByTerminalBean(@Param("list") List<RelateTerminalListRuleIdVo.Items> list);
int updateList(List<TerminalSchedules> record);
int updateByPrimaryKeySelective(TerminalSchedules record);
int updateByPrimaryKey(TerminalSchedules 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},

@ -13,6 +13,13 @@
<sql id="Base_Column_List">
id, schedule_id, start_time, end_time, span, create_time, update_time
</sql>
<select id="selectByScheduleId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from schedule_details
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
@ -26,6 +33,20 @@
from schedule_details
where status = #{status}
</select>
<select id="selectAllBySceduleidList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from schedule_details
<if test="list != null and list.size > 0">
where schedule_id in
<foreach collection="list" item="id" index="index" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</select>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.ScheduleDetails">
insert into schedule_details (id, name, start_time,
end_time, span, remark,

@ -1,7 +1,7 @@
<?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.TerminalSchedulesDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalSchedules">
<mapper namespace="com.shxy.xymanager_dao.dao.TerminalScheduleDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalSchedule">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="TINYINT" property="channelId"/>
@ -58,7 +58,7 @@
</insert>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalSchedules">
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalSchedule">
insert into terminal_schedule (id, term_id, channel_id,
schedule_id, create_time, update_time
)
@ -66,7 +66,7 @@
#{scheduleId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalSchedules">
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalSchedule">
insert into terminal_schedule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -109,7 +109,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalSchedules">
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalSchedule">
update terminal_schedule
<set>
<if test="termId != null">
@ -130,17 +130,30 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateList" >
update terminal_schedule
set term_id = #{termId,jdbcType=INTEGER},
channel_id = #{channelId,jdbcType=TINYINT},
schedule_id = #{scheduleId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateList">
<foreach collection="list" index="index" item="item" separator=";">
update terminal_schedule
set term_id = #{item.termId},
channel_id = #{item.channelId},
schedule_id = #{item.scheduleId},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where term_id = #{id,jdbcType=INTEGER}
</foreach>
</update>
<insert id="insertOrUpdate">
insert into terminal_schedule (id,term_id,channel_id,schedule_id,create_time,update_time)
values
<foreach collection="list" index="index" item="item" separator="," >
(#{item.id} ,#{item.termId}, #{item.channelId},#{item.scheduleId},#{createat},#{updateat})
</foreach>
ON DUPLICATE KEY UPDATE
term_id = values(term_id),
channel_id = values(channel_id),
schedule_id = values(schedule_id)
</insert>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalSchedules">
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalSchedule">
update terminal_schedule
set term_id = #{termId,jdbcType=INTEGER},
channel_id = #{channelId,jdbcType=TINYINT},

@ -3,7 +3,8 @@
<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="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="INTEGER" property="channelId"/>
<result column="start_time" jdbcType="TIME" property="startTime"/>
<result column="end_time" jdbcType="TIME" property="endTime"/>
<result column="span" jdbcType="INTEGER" property="span"/>
@ -11,7 +12,7 @@
<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
id,term_id, channel_id, start_time, end_time, span, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -36,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">
@ -126,4 +125,11 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByTermidAndChannelIdList">
delete from terminal_schedule_details
where
<foreach collection="list" item="item" index="index" separator="or" open="(" close=")">
term_id = #{item.termId} and channel_id = #{item.channelId}
</foreach>
</delete>
</mapper>

@ -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>

@ -82,7 +82,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,
@ -96,7 +96,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

@ -301,15 +301,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);
}
@ -471,7 +476,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";

@ -28,13 +28,10 @@ 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;
@ -54,7 +51,7 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
ScheduleDetailsDao scheduleDetailsDao;
@Autowired
TerminalSchedulesDao terminalSchedulesDao;
TerminalScheduleDao terminalScheduleDao;
@Autowired
TerminalSchedulesTempDao terminalSchedulesTempDao;
@ -222,83 +219,73 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
*/
@Override
@Transactional
public ServiceBody<GetModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
public ServiceBody<GetListModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
GetListModel model = new GetListModel();
List<TerminalSchedulesTemp> list = terminalSchedulesTempDao.selectByTermAndChannel(vo.getList(), CommonStatus.DELETE.value());
if (CollectionUtil.isNotEmpty(list)) {
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();
//
// 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)) {
// return Asserts.error("没有该装置");
// }
// ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
// 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) {
// 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();
return Asserts.error("有装置时间尚未下发成功");
}
List<RelateTerminalListRuleIdVo.Items> termlist = vo.getList();
Integer scheduleid = vo.getScheduleid();
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++) {
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) {
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);
}
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("关联失败");
// }
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);
}
@ -311,49 +298,65 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
@Override
@Transactional
public ServiceBody<String> checkScheldule(RequestIdListVo vo) {
// /*
// * 当定时任务或者用户主动查询下发状态时
// * */
// List<Integer> requestidlist = vo.getList();
// List<RequestResults> resultsList = requestResultsDao.selectByRequestIdList(requestidlist);
// /*
// * 如果下发成功
// * 1,将临时表中的数据状态改成1下发成功状态
// * 2将装置关联拍照时间正式表改为临时表的对应状态
// * 3将装置自身detial表插入新数据
// * */
// if (CollectionUtil.isEmpty(resultsList)) {
// return Asserts.success("尚未查询到下发数据");
// }
// terminalSchedulesTempDao.updateStatusByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value(), new Date());
//
// List<TerminalSchedulesTemp> terminalSchedulesTemps = terminalSchedulesTempDao.selectByRequestId(requestidlist, CommonStatus.EFFECTIVE.value());
//
// ArrayList<TerminalSchedules> terminalSchedules = new ArrayList<>();
// for (TerminalSchedulesTemp item : terminalSchedulesTemps) {
// TerminalSchedules record = new TerminalSchedules();
// record.setChannelId(item.getChannelId());
// record.setScheduleId(item.getScheduleId());
// record.setTermId(item.getTermId());
// }
// terminalSchedulesDao.updateList(terminalSchedules);//将实际的拍照时间表规则从临时表更新到正式表中
//
//// terminalScheduleDetailsDao.deleteByPrimaryKey();//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
//
// ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
// terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
//
// int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
////end
// if (i != 0) {
/*
*
* */
List<Integer> requestidlist = vo.getList();
List<RequestResults> resultsList = requestResultsDao.selectByRequestIdList(requestidlist);
/*
*
* 1,1
* 2
* 3detial
* */
if (CollectionUtil.isEmpty(resultsList)) {
return Asserts.success("尚未查询到下发数据");
}
terminalSchedulesTempDao.updateStatusByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value(), new Date());
List<TerminalSchedulesTemp> terminalSchedulesTemps = terminalSchedulesTempDao.selectByRequestId(requestidlist, CommonStatus.EFFECTIVE.value());
ArrayList<TerminalSchedule> terminalSchedules = new ArrayList<>();
ArrayList<Integer> scheduleidlist = new ArrayList<>();
for (TerminalSchedulesTemp item : terminalSchedulesTemps) {
TerminalSchedule record = new TerminalSchedule();
record.setChannelId(item.getChannelId());
record.setScheduleId(item.getScheduleId());
record.setTermId(item.getTermId());
scheduleidlist.add(item.getScheduleId());
terminalSchedules.add(record);
}
Date date = new Date();
terminalScheduleDao.insertOrUpdate(terminalSchedules, date, date);//将实际的拍照时间表规则从临时表更新到正式表中
ArrayList<Integer> distinct = CollectionUtil.distinct(scheduleidlist);
List<ScheduleDetails> scheduleDetails = scheduleDetailsDao.selectAllBySceduleidList(distinct);
ArrayList<TerminalScheduleDetails> terminalScheduleDetails = new ArrayList<>();
for (int i = 0; i < terminalSchedules.size(); i++) {
for (int j = 0; j < scheduleDetails.size(); j++) {
TerminalSchedule terminalSchedule = terminalSchedules.get(i);
ScheduleDetails scheduleDetailsbean = scheduleDetails.get(j);
if (scheduleDetailsbean.getScheduleId().intValue() == terminalSchedule.getScheduleId().intValue()) {
TerminalScheduleDetails bean = new TerminalScheduleDetails();
bean.setTermId(terminalSchedule.getTermId());
bean.setChannelId(terminalSchedule.getChannelId());
bean.setStartTime(scheduleDetailsbean.getStartTime());
bean.setEndTime(scheduleDetailsbean.getEndTime());
bean.setSpan(scheduleDetailsbean.getSpan());
terminalScheduleDetails.add(bean);
}
}
}
terminalScheduleDetailsDao.deleteByTermidAndChannelIdList(terminalSchedules);
terminalScheduleDetailsDao.insertList(terminalScheduleDetails, date, date);
int i = requestResultsDao.updateByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value());//根据requestid将结果表中的状态修改为已下发
if (i != 0) {
return Asserts.success("下发成功");
// } else {
// return Asserts.error("关联失败");
// }
} else {
return Asserts.error("关联失败");
}
}
/**
*
*
@ -362,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下发成功状态
@ -397,7 +400,7 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
////end
// if (i != 0) {
return Asserts.success(null);
return Asserts.success(null);
// } else {
// return Asserts.error("关联失败");
// }
@ -412,7 +415,7 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
@Override
public ServiceBody<TerminalScheduleRuleTimeListModel> getChannelSchelduleRule(TerminalAndChannelIdVo vo) {
TerminalScheduleRuleTimeListModel model = new TerminalScheduleRuleTimeListModel();
TerminalSchedules mapper = terminalSchedulesDao.selectByChannelId(vo.getChannelid(), vo.getTerminalid());
TerminalSchedule mapper = terminalScheduleDao.selectByChannelId(vo.getChannelid(), vo.getTerminalid());
if (mapper == null) {
model.setList(new ArrayList<>());
} else {

@ -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