Commit 5fad6605 authored by zhangsen's avatar zhangsen

bug修改

parent e349c346
......@@ -42,6 +42,8 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static org.typroject.tyboot.core.foundation.utils.DateTimeUtil.ISO8601_DATE_HOUR_MIN_SEC;
/**
* <p>
* 前端控制器
......@@ -795,10 +797,12 @@ public class TopographyController extends AbstractBaseController {
try {
//Date date = DateUtils.dateParse(String.valueOf(timeList.get(j-1).getValue()), DateUtils.DATE_TIME_T_PATTERN);
SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.DATE_TIME_T_PATTERN);
String value = String.valueOf(timeList.get(j-1).getValue());
String strDate = value.substring(0, 19);
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date1=sdf.parse(String.valueOf(timeList.get(j-1).getValue()));
Date date1=sdf.parse(strDate);
String time= DateTimeUtil.format(date1, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
iotVo.setTime(sdf1.parse(time));
......@@ -874,11 +878,13 @@ public class TopographyController extends AbstractBaseController {
List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
List<Date> dates = new ArrayList<>();
for (IotDataVO vo : timeList) {
SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.DATE_TIME_T_PATTERN);
String value = String.valueOf(vo.getValue());
String strDate = value.substring(0, 19);
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
logger.info("返回时间===================================(" + vo.getValue() + ") =======================================");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date=sdf.parse(String.valueOf(vo.getValue()));
Date date=sdf.parse(strDate);
// String time= sdf.format(date);
String time= DateTimeUtil.format(date, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
......
......@@ -370,6 +370,13 @@ public class LatentDangerController extends BaseController {
return ResponseHelper.buildResponse((iLatentDangerService.getAllDangerLevel()));
}
@ApiOperation(value = "获取所有隐患等级名称", notes = "获取所有隐患等级名称")
@GetMapping(value = "/all/dangerLevelName")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel getAllDangerLevelName() {
return ResponseHelper.buildResponse((iLatentDangerService.getAllDangerLevelName()));
}
@ApiOperation(value = "获取所有隐患整改方式", notes = "获取所有隐患整改方式")
@GetMapping(value = "/all/dangerGovernance")
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.latentdanger.business.service.impl;
import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo;
import static com.yeejoin.amos.latentdanger.common.enums.LatentDangerLevelEnum.patrolDangerLevelEnumMap;
import static com.yeejoin.amos.latentdanger.common.enums.LatentDangerLevelEnum.supervisionDangerLevelEnumMap;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -1893,7 +1885,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
});
}
if (bizTypeSet.contains("patrol")) {
LatentDangerLevelEnum.patrolDangerLevelEnumMap.forEach((code, e) -> {
patrolDangerLevelEnumMap.forEach((code, e) -> {
Map<String, String> l = Maps.newHashMap();
l.put("code", code);
l.put("name", e.getName());
......@@ -1904,6 +1896,23 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
}
@Override
public Set<String> getAllDangerLevelName() {
Set<String> levelList = new HashSet<>();
Set<String> bizTypeSet = getBizTypeSet();
if (bizTypeSet.contains("supervision")) {
LatentDangerLevelEnum.supervisionDangerLevelEnumMap.forEach((code, e) -> {
levelList.add(e.getName());
});
}
if (bizTypeSet.contains("patrol")) {
patrolDangerLevelEnumMap.forEach((code, e) -> {
levelList.add(e.getName());
});
}
return levelList;
}
@Override
public List<Map<String, String>> getAllDangerGovernance() {
List<Map<String, String>> governanceList = Lists.newArrayList();
Set<String> bizTypeSet = getBizTypeSet();
......@@ -2049,6 +2058,22 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
@Override
public IPage<LatentDanger> pageListDanger(PageParam pageParam, String userId) throws Exception {
if (pageParam.containsKey("dangerLevelName")) {
List<String> dangerLevelList = new ArrayList<>();
Collection<LatentDangerLevelEnum> values1 = patrolDangerLevelEnumMap.values();
values1.stream().forEach(item -> {
if (item.getName().equals(pageParam.get("dangerLevelName"))) {
dangerLevelList.add(item.getCode());
}
});
Collection<LatentDangerLevelEnum> values = supervisionDangerLevelEnumMap.values();
values.stream().forEach(item -> {
if (item.getName().equals(pageParam.get("dangerLevelName"))) {
dangerLevelList.add(item.getCode());
}
});
pageParam.put("dangerLevelList", dangerLevelList);
}
List allTaskList;
String idsStr = (String) pageParam.get("dangerIds");
List<String> dangerIdList = Lists.newArrayList();
......
......@@ -157,6 +157,13 @@ public interface ILatentDangerService {
List<Map<String, String>> getAllDangerLevel();
/**
* 获取多个业务的隐患等级名称
*
* @return
*/
Set<String> getAllDangerLevelName();
/**
* 获取多个业务的隐患治理方式
*
* @return
......
......@@ -182,6 +182,24 @@ public class PlanTaskController extends AbstractBaseController {
}
/**
* 模拟发送维保待办任务消息定时任务
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟发送维保待办任务消息定时任务", notes = "模拟发送维保待办任务消息定时任务")
@RequestMapping(value = "/taskMessage", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public CommonResponse taskMessage(@ApiParam(value = "跑批日期格式yyyyMMdd", required = false) @RequestParam(required = false) String runDate) {
try {
planTaskService.taskMessage(runDate);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure();
}
}
/**
* 查询任务列表
*
* @param
......
package com.yeejoin.amos.maintenance.business.dao.mapper;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.maintenance.dao.entity.Plan;
import org.apache.ibatis.annotations.Param;
import com.yeejoin.amos.maintenance.business.entity.mybatis.CheckChkExListBo;
......@@ -186,4 +188,7 @@ public interface PlanTaskMapper extends BaseMapper {
List<Map<String, Object>> statisticsTaskWithAuth(Map<String, Object> param);
List<Plan> getPlanIdsByDate(Date date);
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.maintenance.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Joiner;
import com.yeejoin.amos.boot.biz.common.enums.RuleTypeEnum;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
......@@ -32,6 +33,7 @@ import com.yeejoin.amos.maintenance.exception.YeeException;
import com.yeejoin.amos.maintenance.feign.RemoteSecurityService;
import com.yeejoin.amos.maintenance.quartz.IJobService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.tomcat.jni.Time;
import org.assertj.core.util.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -86,6 +88,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
JCSFeignClient jcsFeignClient;
@Autowired
RedisUtils redisUtils;
private final String MAINTENANCE_PLAN_TASK_KEY = "MAINTENANCE_PLAN_ID:";
@Override
public Page<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params) {
long total = planTaskMapper.countPlanTask(params);
......@@ -254,6 +261,32 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return bigDecimal.compareTo(bigDecimal1) <= 0 && bigDecimal.compareTo(new BigDecimal(0)) >= 0;
}
//bug 5980 待办任务消息应只触发执行中的任务,漏检的任务和未开始的任务不需要触发待办任务消息.
@Override
@Transactional
public void taskMessage(String runDate) {
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
//1.扫描plan表查询,需要生成执行数据的任务信息,无则return
Date now = new Date();//今天
String format = df.format(now);
if (runDate != null) {//上送则已上送的为准
runDate = runDate + " " + format;
now = DateUtil.str2Date(runDate, "yyyyMMdd HH:mm:ss");
}
List<Plan> planIdsByDate = planTaskMapper.getPlanIdsByDate(now);
for (Plan plan : planIdsByDate) {
if (!redisUtils.hasKey(MAINTENANCE_PLAN_TASK_KEY + plan.getId())) {
try {
sendMessage(plan);
} catch (Exception e) {
e.printStackTrace();
}
redisUtils.set(MAINTENANCE_PLAN_TASK_KEY + plan.getId(), 1, (long) plan.getDuration() * 60);
}
}
}
/**
* 自动任务执行
*/
......@@ -273,23 +306,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
log.info(strDate + " " + " 暂无待生成执行数据的计划");
return;
}
// //bug 5980 待办任务消息应只触发执行中的任务,漏检的任务和未开始的任务不需要触发待办任务消息.
// List<Plan> planListTwo = new ArrayList<>();
// //将日期格式化
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
// LocalTime nowTime = LocalTime.parse(simpleDateFormat.format(new Date()));
// for (Plan plan : planList) {
// LocalTime dayTime = LocalTime.parse(plan.getDayTime());
//// LocalTime plusHoursTime = dayTime.plusHours(1);
// if (getTimeDifference(nowTime, dayTime)) {
// planListTwo.add(plan);
// }
// }
// if (planListTwo == null || planListTwo.size() <= 0) {
// log.info(strDate + " " + " 暂无待生成执行数据的计划 (更改后,只执行进行中的数据)");
// return;
// }
// planList = planListTwo;
//2.循环遍历执行
HashMap<String, Object> paramMap = new HashMap<String, Object>();
for (Plan plan : planList) {
......@@ -478,7 +494,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
// 2.保存执行数据明细表
planTaskDetail.saveAndFlush(planTaskDetailInstance);
}
sendMessage(plan);
//bug 5980 待办任务消息应只触发执行中的任务,漏检的任务和未开始的任务不需要触发待办任务消息.
//(重写定时任务去发送消息)
// sendMessage(plan);
// 定时任务监控
jobService.planTaskAddJob(planTask);
}
......
......@@ -37,6 +37,13 @@ public interface IPlanTaskService {
List<PlanTaskVo> planTaskReport(String toke, String product, String appKey, PlanTaskPageParam params);
/**
* 定时任务发送消息执行中的消息
*
* @param runDate
*/
void taskMessage(String runDate);
/**
* 自动任务执行
*
* @param runDate
......
......@@ -24,4 +24,12 @@ public class PlanTaskJob {
public void scheduleJob() {
planTaskService.taskExecution(null);
}
/**
* 定时任务推送维保待办任务消息
*/
@Scheduled(cron = "${jobs.cron}")
public void taskMessage() {
planTaskService.taskMessage(null);
}
}
......@@ -1002,6 +1002,12 @@
<if test="key == 'dangerLevel' and value != null and value != ''">
and a.danger_level = #{value}
</if>
<if test="key == 'dangerLevelList' and value != null and value.size() > 0">
and a.danger_level in
<foreach collection="value" item="dangerLevel" open="(" separator="," close=")">
#{dangerLevel}
</foreach>
</if>
<if test="key == 'startTime' and value != null and value != ''">
and a.create_date <![CDATA[ >= ]]> #{value}
</if>
......
......@@ -879,4 +879,19 @@
</choose>
GROUP BY td.is_finish
</select>
<select id="getPlanIdsByDate" resultType="com.yeejoin.amos.maintenance.dao.entity.Plan">
select *
from p_plan
where id in (
select plan_id
from p_plan_task
where
begin_time &lt;= #{date,jdbcType=TIMESTAMP}
and end_time &gt; #{date,jdbcType=TIMESTAMP}
and finish_status in (0, 1)
and status = 0
group by plan_id
)
</select>
</mapper>
\ No newline at end of file
......@@ -212,7 +212,7 @@
INNER JOIN p_route r on r.id = pt.route_id
<if test="outsideType != null and outsideType == 1 ">
where
p.checkLevel != 3
p.check_level != 3
</if>
) a
<include refid="mobile-plan-task-where"/>
......@@ -279,7 +279,7 @@
INNER JOIN p_route r on r.id = pt.route_id
<if test="outsideType != null and outsideType == 1 ">
where
p.checkLevel != 3
p.check_level != 3
</if>
) a
<include refid="mobile-plan-task-where"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment