定时任务下发

master
liuguijing 2 years ago
parent 3a6390c09c
commit c63894bf4d

@ -2,7 +2,7 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:13306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://127.0.0.1:3306/xymp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
@ -135,7 +135,7 @@ server:
logging:
config: classpath:log4j2.xml
level:
com.fc: trace
com.shxy: trace
org.springframework: warn
@ -166,8 +166,10 @@ swagger2:
# urlPatterns: /system/*,/monitor/*,/tool/*
cma:
server: 47.96.238.157
server: 127.0.0.1
port: 6891
clientid: 10
scheduletype: 202
upload:
# path: file:/usr/local/home/manager/download/
path: http://47.96.238.157/usr/local/home/manager/download/

@ -20,6 +20,8 @@ public class RequestResults implements Serializable {
private Integer result;
private Integer scheduleStatus;
private Long requestTime;
private Long createTime;

@ -46,6 +46,9 @@ public class TerminalPhotoListForOpenModel implements Serializable {
@ApiModelProperty(value = "图片类型", example = "0--图片 1--视频")
private Integer mediaType;
@ApiModelProperty(value = "图片名称", example = "图片名称")
private String name;
@ApiModelProperty(value = "拍照时间", example = "123456")
private Date photoTime;

@ -18,17 +18,17 @@ public class TerminalAndTimeForOpenVo {
@ApiModelProperty(value = "装置编号", example = "123455")
private String cmdId;
@ApiModelProperty(value = "查询开始时间", example = "123455")
private Date startTime;
@ApiModelProperty(value = "查询开始时间", example = "yyyy-")
private String startTime;
@ApiModelProperty(value = "查询结束时间", example = "123455")
private Date endTime;
private String endTime;
// @Min(value = 1, message = "分页位置最小从1开始")
// @Min(value = 1, message = "分页位置最小从1开始")
@ApiModelProperty(value = "分页位置从1开始", required = false, example = "1")
private Integer pageIndex;
// @Min(value = 1, message = "分页大小最小为1")
// @Min(value = 1, message = "分页大小最小为1")
@ApiModelProperty(value = "分页大小", required = false, example = "1")
private Integer pageSize;
}

@ -13,6 +13,8 @@ public interface RequestResultsDao {
List<RequestResults> selectByRequestIdList(@Param("list") List<Integer> id);
List<RequestResults> selectByTypeAndStatus(@Param("requesttype") Integer requesttype, @Param("clientid") Integer clientid, @Param("schedulestatus") Integer status);
int updateByPrimaryKeySelective(RequestResults record);

@ -9,6 +9,7 @@
<result column="client_id" jdbcType="TINYINT" property="clientId"/>
<result column="request_id" jdbcType="INTEGER" property="requestId"/>
<result column="result" jdbcType="TINYINT" property="result"/>
<result column="request_schedule_status" jdbcType="INT" property="scheduleStatus"/>
<result column="request_time" jdbcType="BIGINT" property="requestTime"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="data" jdbcType="LONGVARCHAR" property="data"/>
@ -31,6 +32,15 @@
where request_id = #{requestId}
</select>
<select id="selectByTypeAndStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from request_results
where request_type = #{requesttype}
and client_id = #{clientid}
and request_schedule_status = #{schedulestatus}
</select>
<select id="selectByRequestIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>

@ -17,7 +17,7 @@
<select id="selectByTermAndChannel" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_schedules_temp
from terminal_schedule_temp
where status = #{status}
<if test="list != null and list.size>0">
and

@ -21,6 +21,7 @@ public class CustomSecurityConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this.jwtInterceptor)
.excludePathPatterns("/swagger-ui.html")
.excludePathPatterns("/getPhotoListForOpen")
.excludePathPatterns("/api/login")
.excludePathPatterns("/login")
.excludePathPatterns("/doc.html")

@ -240,12 +240,12 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
pagesize = 10;
}
PageUtils.SetPage(pageindex, pagesize);
Date starttime = vo.getStartTime();
Date starttime = MyDateUtils.myparseDate(vo.getStartTime());
BigInteger start = null;
if (starttime != null) {
start = MyDateUtils.TimeMillSecond2Second(DateTime.of(starttime));
}
Date endtime = vo.getEndTime();
Date endtime = MyDateUtils.myparseDate(vo.getEndTime());
BigInteger end = null;
if (endtime != null) {
end = MyDateUtils.TimeMillSecond2Second(DateTime.of(endtime));
@ -262,11 +262,20 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
photoBean.setMediaType(item.getMediaType());
photoBean.setOrginalId(item.getOrginalId());
// photoBean.setPath(photoaddress + item.getPath());
String path = item.getPath();
if (item.getMediaType() == 0) {
photoBean.setPath(photoaddress + item.getPath());
photoBean.setPath(photoaddress + path);
} else {
photoBean.setPath(videoaddress + item.getPath());
}
if (path != null) {
photoBean.setPath(photoaddress + path);
String[] split = path.split("/");
int length = split.length;
String s = split[length - 1];
photoBean.setName(s);
}
photoBean.setPresetId(item.getPresetId());
BigInteger phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photoBean.setPhotoTime(MyDateUtils.date(phototime.longValue()));
@ -311,7 +320,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
hasNew = false;
}
}
}else {
} else {
hasNew = false;
}

@ -29,6 +29,7 @@ import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -65,6 +66,13 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
@Autowired
TerminalScheduleDetailsDao terminalScheduleDetailsDao;
@Value("${cma.clientid}")
public int clientid;
@Value("${cma.scheduletype}")
public int scheduletype;
/**
*
*
@ -357,6 +365,71 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
}
}
/*定时任务查询下发*/
public ServiceBody<String> TimerscheckScheldule() {
/*
*
* */
List<Integer> requestidlist = new ArrayList<>();
List<RequestResults> resultsList = requestResultsDao.selectByTypeAndStatus(scheduletype, clientid, null);
for (RequestResults item : resultsList) {
requestidlist.add(item.getRequestId());
}
/*
*
* 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("关联失败");
}
}
/**
*
*

Loading…
Cancel
Save