拍照时间表管理修改查询

master
liuguijing 2 years ago
parent 3667796f27
commit 14f61aaabb

@ -1,9 +1,9 @@
package com.shxy.xymanager_admin;
import com.shxy.xymanager_common.entity.TerminalSchedulesTemp;
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_common.model.TerminalScheduleRuleTimeListModel;
import com.shxy.xymanager_common.util.SaltUtil;
import com.shxy.xymanager_dao.dao.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,6 +32,9 @@ class XymanagerAdminApplicationTests {
@Autowired
private TerminalSchedulesTempDao terminalSchedulesTempDao;
@Autowired
private TerminalScheduleDao terminalScheduleDao;
@Test
void contextLoads() {
@ -121,16 +124,39 @@ class XymanagerAdminApplicationTests {
// user.setPassword(MD5.toHex());
// userDao.save(user);
ArrayList<Integer> requestidlist = new ArrayList<>();
requestidlist.add(1);
requestidlist.add(2);
requestidlist.add(3);
List<TerminalSchedulesTemp> terminalSchedulesTemps = terminalSchedulesTempDao.updateStatusByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value(), new Date());
System.out.println(terminalSchedulesTemps.toArray());
// ArrayList<Integer> requestidlist = new ArrayList<>();
// requestidlist.add(1);
// requestidlist.add(2);
// requestidlist.add(3);
//
//
// List<TerminalSchedulesTemp> terminalSchedulesTemps = terminalSchedulesTempDao.updateStatusByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value(), new Date());
// System.out.println(terminalSchedulesTemps.toArray());
// ArrayList<TerminalSchedule> record = new ArrayList<>();
// TerminalSchedule e = new TerminalSchedule();
// e.setTermId(1);
// e.setChannelId(1);
// e.setScheduleId(4);
// record.add(e);
// TerminalSchedule e1 = new TerminalSchedule();
// e1.setTermId(1);
// e1.setChannelId(2);
// e1.setScheduleId(3);
// record.add(e1);
// int i = terminalScheduleDao.insertOrUpdate(record, new Date(), new Date());
// System.out.println(i);
// 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;
}
}

@ -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,12 +1,16 @@
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 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);

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

@ -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
@ -126,4 +127,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>

@ -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;
@ -225,80 +222,80 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
public ServiceBody<GetModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
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();
// ProcessExecUtils.exec(cmd);
// }
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();
ProcessExecUtils.exec(cmd);
}
model.setRequestId(Integer.parseInt(Constants.REQUEST_ID.toString()));
Constants.REQUEST_ID.addAndGet(1);
// if (i != 0) {
if (i != 0) {
return Asserts.success(model);
// } else {
// return Asserts.error("关联失败");
// }
} else {
return Asserts.error("关联失败");
}
}
@ -311,46 +308,68 @@ 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
/*
*
* */
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);
// if (i != 0) {
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
//end
if (i != 0) {
return Asserts.success("下发成功");
// } else {
// return Asserts.error("关联失败");
// }
} else {
return Asserts.error("关联失败");
}
}
@ -397,7 +416,7 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
////end
// if (i != 0) {
return Asserts.success(null);
return Asserts.success(null);
// } else {
// return Asserts.error("关联失败");
// }
@ -412,7 +431,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 {

Loading…
Cancel
Save