diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/CameraScheduleController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/CameraScheduleController.java new file mode 100644 index 0000000..a18b626 --- /dev/null +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/CameraScheduleController.java @@ -0,0 +1,42 @@ +package com.shxy.xymanager_admin.controller; + +import com.shxy.xymanager_common.annotation.Log; +import com.shxy.xymanager_common.base.BaseController; +import com.shxy.xymanager_common.base.ResponseReult; +import com.shxy.xymanager_common.entity.CameraSchedule; +import com.shxy.xymanager_service.service.CameraScheduleService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = {"活动相关接口"}) +@RequestMapping("activity") +@Slf4j +public class CameraScheduleController extends BaseController { + + @Resource + CameraScheduleService service; + + @GetMapping("list") + @ApiOperation("查询") + @Log(title = "查询", type = "查询") + public ResponseReult> list(@RequestParam(value = "termId", required = false) Integer termId) { + List result = service.list(termId); + return ResponseReult.success(result); + } + + @GetMapping("getOne") + @ApiOperation("查询") + @Log(title = "查询", type = "查询") + public ResponseReult getOne(@RequestParam(value = "termId", required = true) Integer termId, + @RequestParam(value = "channel", required = true) Integer channel) { + CameraSchedule result = service.getOne(termId, channel); + return ResponseReult.success(result); + } + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java index 2f61833..fda741a 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; /** @@ -213,4 +214,7 @@ public class Constants { public static final Integer NetType_M2M10086 = 3; public static final Integer NetType_LWWLKJ = 4; + public static HashMap scheduleRequestMap = new HashMap<>(); + public static HashMap scheduleRequestDoneMap = new HashMap<>(); + } \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraSchedule.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraSchedule.java new file mode 100644 index 0000000..214c6de --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraSchedule.java @@ -0,0 +1,135 @@ +package com.shxy.xymanager_common.entity; + +public class CameraSchedule { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column camera_schedule.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column camera_schedule.term_id + * + * @mbg.generated + */ + private Integer termId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column camera_schedule.channel_id + * + * @mbg.generated + */ + private Integer channelId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column camera_schedule.data + * + * @mbg.generated + */ + private String data; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column camera_schedule.id + * + * @return the value of camera_schedule.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column camera_schedule.id + * + * @param id the value for camera_schedule.id + * + * @mbg.generated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column camera_schedule.term_id + * + * @return the value of camera_schedule.term_id + * + * @mbg.generated + */ + public Integer getTermId() { + return termId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column camera_schedule.term_id + * + * @param termId the value for camera_schedule.term_id + * + * @mbg.generated + */ + public void setTermId(Integer termId) { + this.termId = termId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column camera_schedule.channel_id + * + * @return the value of camera_schedule.channel_id + * + * @mbg.generated + */ + public Integer getChannelId() { + return channelId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column camera_schedule.channel_id + * + * @param channelId the value for camera_schedule.channel_id + * + * @mbg.generated + */ + public void setChannelId(Integer channelId) { + this.channelId = channelId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column camera_schedule.data + * + * @return the value of camera_schedule.data + * + * @mbg.generated + */ + public String getData() { + return data; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column camera_schedule.data + * + * @param data the value for camera_schedule.data + * + * @mbg.generated + */ + public void setData(String data) { + this.data = data; + } +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraScheduleExample.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraScheduleExample.java new file mode 100644 index 0000000..cc50de7 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/CameraScheduleExample.java @@ -0,0 +1,481 @@ +package com.shxy.xymanager_common.entity; + +import java.util.ArrayList; +import java.util.List; + +public class CameraScheduleExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table camera_schedule + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table camera_schedule + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table camera_schedule + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public CameraScheduleExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table camera_schedule + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andTermIdIsNull() { + addCriterion("term_id is null"); + return (Criteria) this; + } + + public Criteria andTermIdIsNotNull() { + addCriterion("term_id is not null"); + return (Criteria) this; + } + + public Criteria andTermIdEqualTo(Integer value) { + addCriterion("term_id =", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdNotEqualTo(Integer value) { + addCriterion("term_id <>", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdGreaterThan(Integer value) { + addCriterion("term_id >", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdGreaterThanOrEqualTo(Integer value) { + addCriterion("term_id >=", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdLessThan(Integer value) { + addCriterion("term_id <", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdLessThanOrEqualTo(Integer value) { + addCriterion("term_id <=", value, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdIn(List values) { + addCriterion("term_id in", values, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdNotIn(List values) { + addCriterion("term_id not in", values, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdBetween(Integer value1, Integer value2) { + addCriterion("term_id between", value1, value2, "termId"); + return (Criteria) this; + } + + public Criteria andTermIdNotBetween(Integer value1, Integer value2) { + addCriterion("term_id not between", value1, value2, "termId"); + return (Criteria) this; + } + + public Criteria andChannelIdIsNull() { + addCriterion("channel_id is null"); + return (Criteria) this; + } + + public Criteria andChannelIdIsNotNull() { + addCriterion("channel_id is not null"); + return (Criteria) this; + } + + public Criteria andChannelIdEqualTo(Integer value) { + addCriterion("channel_id =", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotEqualTo(Integer value) { + addCriterion("channel_id <>", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdGreaterThan(Integer value) { + addCriterion("channel_id >", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdGreaterThanOrEqualTo(Integer value) { + addCriterion("channel_id >=", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdLessThan(Integer value) { + addCriterion("channel_id <", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdLessThanOrEqualTo(Integer value) { + addCriterion("channel_id <=", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdIn(List values) { + addCriterion("channel_id in", values, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotIn(List values) { + addCriterion("channel_id not in", values, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdBetween(Integer value1, Integer value2) { + addCriterion("channel_id between", value1, value2, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotBetween(Integer value1, Integer value2) { + addCriterion("channel_id not between", value1, value2, "channelId"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table camera_schedule + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table camera_schedule + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/CameraScheduleMapper.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/CameraScheduleMapper.java new file mode 100644 index 0000000..6c22aa5 --- /dev/null +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/CameraScheduleMapper.java @@ -0,0 +1,121 @@ +package com.shxy.xymanager_dao.dao; + +import com.shxy.xymanager_common.entity.CameraSchedule; +import com.shxy.xymanager_common.entity.CameraScheduleExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface CameraScheduleMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + long countByExample(CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int deleteByExample(CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int insert(CameraSchedule row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int insertSelective(CameraSchedule row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + List selectByExampleWithBLOBs(CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + List selectByExample(CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + CameraSchedule selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") CameraSchedule row, @Param("example") CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByExampleWithBLOBs(@Param("row") CameraSchedule row, @Param("example") CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByExample(@Param("row") CameraSchedule row, @Param("example") CameraScheduleExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(CameraSchedule row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByPrimaryKeyWithBLOBs(CameraSchedule row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table camera_schedule + * + * @mbg.generated + */ + int updateByPrimaryKey(CameraSchedule row); +} \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/CameraScheduleMapper.xml b/xymanager_dao/src/main/resources/mappers/CameraScheduleMapper.xml new file mode 100644 index 0000000..aec22a3 --- /dev/null +++ b/xymanager_dao/src/main/resources/mappers/CameraScheduleMapper.xml @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, term_id, channel_id + + + + `data` + + + + + + + delete from camera_schedule + where id = #{id,jdbcType=INTEGER} + + + + delete from camera_schedule + + + + + + + + SELECT LAST_INSERT_ID() + + insert into camera_schedule (term_id, channel_id, `data` + ) + values (#{termId,jdbcType=INTEGER}, #{channelId,jdbcType=INTEGER}, #{data,jdbcType=LONGVARCHAR} + ) + + + + + SELECT LAST_INSERT_ID() + + insert into camera_schedule + + + term_id, + + + channel_id, + + + `data`, + + + + + #{termId,jdbcType=INTEGER}, + + + #{channelId,jdbcType=INTEGER}, + + + #{data,jdbcType=LONGVARCHAR}, + + + + + + + update camera_schedule + + + id = #{row.id,jdbcType=INTEGER}, + + + term_id = #{row.termId,jdbcType=INTEGER}, + + + channel_id = #{row.channelId,jdbcType=INTEGER}, + + + `data` = #{row.data,jdbcType=LONGVARCHAR}, + + + + + + + + + update camera_schedule + set id = #{row.id,jdbcType=INTEGER}, + term_id = #{row.termId,jdbcType=INTEGER}, + channel_id = #{row.channelId,jdbcType=INTEGER}, + `data` = #{row.data,jdbcType=LONGVARCHAR} + + + + + + + update camera_schedule + set id = #{row.id,jdbcType=INTEGER}, + term_id = #{row.termId,jdbcType=INTEGER}, + channel_id = #{row.channelId,jdbcType=INTEGER} + + + + + + + update camera_schedule + + + term_id = #{termId,jdbcType=INTEGER}, + + + channel_id = #{channelId,jdbcType=INTEGER}, + + + `data` = #{data,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update camera_schedule + set term_id = #{termId,jdbcType=INTEGER}, + channel_id = #{channelId,jdbcType=INTEGER}, + `data` = #{data,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + update camera_schedule + set term_id = #{termId,jdbcType=INTEGER}, + channel_id = #{channelId,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/StoreCameraScheduleTask.java b/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/StoreCameraScheduleTask.java new file mode 100644 index 0000000..a59db10 --- /dev/null +++ b/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/StoreCameraScheduleTask.java @@ -0,0 +1,68 @@ +package com.shxy.xymanager_framework.timeTask; + +import com.shxy.xymanager_common.constant.Constants; +import com.shxy.xymanager_common.entity.CameraSchedule; +import com.shxy.xymanager_common.entity.CameraScheduleExample; +import com.shxy.xymanager_common.entity.RequestResults; +import com.shxy.xymanager_dao.dao.CameraScheduleMapper; +import com.shxy.xymanager_dao.dao.RequestResultsDao; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Iterator; +import java.util.List; + +@Service +@Slf4j +public class StoreCameraScheduleTask { + + @Resource + RequestResultsDao requestResultsDao; + @Resource + CameraScheduleMapper cameraScheduleMapper; + + @Scheduled(initialDelay = 60000, fixedDelay = 60000) + private void store() { + Iterator it = Constants.scheduleRequestMap.keySet().iterator(); + while (it.hasNext()) { + Integer requestid = it.next(); + RequestResults results = requestResultsDao.selectByRequestId(requestid); + if (results != null) { + Integer channel = Constants.scheduleRequestMap.get(requestid); + Constants.scheduleRequestMap.remove(requestid); + + CameraScheduleExample example = new CameraScheduleExample(); + CameraScheduleExample.Criteria criteria = example.createCriteria(); + criteria.andTermIdEqualTo(results.getTermId()); + criteria.andChannelIdEqualTo(channel); + List list = cameraScheduleMapper.selectByExample(example); + if (CollectionUtils.isEmpty(list)) { + CameraSchedule record = new CameraSchedule(); + record.setTermId(results.getTermId()); + record.setChannelId(channel); + record.setData(results.getData()); + cameraScheduleMapper.insert(record); + } else { + CameraSchedule record = list.get(0); + record.setData(results.getData()); + cameraScheduleMapper.updateByPrimaryKeyWithBLOBs(record); + } + } else { + if (Constants.scheduleRequestDoneMap.containsKey(requestid)) { + Constants.scheduleRequestDoneMap.remove(requestid); + Constants.scheduleRequestMap.remove(requestid); + } else { + Constants.scheduleRequestDoneMap.put(requestid, ""); + } + } + } + } + + @Scheduled(cron = "0 1 3 * * ?") + private void search() { + + } +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CameraScheduleServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CameraScheduleServiceImpl.java new file mode 100644 index 0000000..4d90718 --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CameraScheduleServiceImpl.java @@ -0,0 +1,49 @@ +package com.shxy.xymanager_service.impl; + + +import com.shxy.xymanager_common.entity.CameraSchedule; +import com.shxy.xymanager_common.entity.CameraScheduleExample; +import com.shxy.xymanager_dao.dao.CameraScheduleMapper; +import com.shxy.xymanager_service.service.CameraScheduleService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; + + +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class CameraScheduleServiceImpl implements CameraScheduleService { + + @Resource + CameraScheduleMapper mapper; + + @Override + public CameraSchedule getOne(Integer termId, Integer channel) { + CameraSchedule result = null; + CameraScheduleExample example = new CameraScheduleExample(); + CameraScheduleExample.Criteria criteria = example.createCriteria(); + criteria.andTermIdEqualTo(termId); + criteria.andChannelIdEqualTo(channel); + List list = mapper.selectByExample(example); + if (!CollectionUtils.isEmpty(list)) { + result = list.get(0); + } + return result; + } + + @Override + public List list(Integer termId) { + CameraScheduleExample example = new CameraScheduleExample(); + CameraScheduleExample.Criteria criteria = example.createCriteria(); + if (termId != null) { + criteria.andTermIdEqualTo(termId); + } + List list = mapper.selectByExample(example); + return list; + } +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TermSetServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TermSetServiceImpl.java index 6c99158..caf6958 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TermSetServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TermSetServiceImpl.java @@ -175,6 +175,14 @@ public class TermSetServiceImpl implements TermSetService { model.setRequestId(requestId); DateTime now = DateTime.now(); model.setDate(now); + String act = ctrlBeanMap.get("act"); + if ("schedule".equals(act)) { + String flag = ctrlBeanMap.get("flag"); + if ("0".equals(flag)) { + Integer channel = Integer.parseInt(ctrlBeanMap.get("channel")); + Constants.scheduleRequestMap.put(requestId, channel); + } + } return Asserts.success(model); } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/CameraScheduleService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/CameraScheduleService.java new file mode 100644 index 0000000..0f11f66 --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/CameraScheduleService.java @@ -0,0 +1,13 @@ +package com.shxy.xymanager_service.service; + +import com.shxy.xymanager_common.entity.CameraSchedule; + +import java.util.List; + +public interface CameraScheduleService { + + CameraSchedule getOne(Integer termId, Integer channel); + + List list(Integer termId); + +}