Commit 54d411dc authored by zhangsen's avatar zhangsen

改bug

parent 1e38ae49
......@@ -15,7 +15,7 @@ public enum RuleTypeEnum {
计划审核任务("计划审核", "planAudit", "auditPage", RuleConstant.APP_WEB, RuleConstant.TASK),
计划审核完成("计划审核完成", "planAuditAll", "formulatePage", RuleConstant.APP_WEB, RuleConstant.TASK),
消息型计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.NOTIFY),
任务型计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.TASK),
任务型计划生成("计划生成", "addPlanTask", "TaskDetail", RuleConstant.APP, RuleConstant.TASK),
计划完成("计划完成", "planCompleted", null, RuleConstant.APP_WEB, RuleConstant.NOTIFY),
// 隐患
......
......@@ -447,15 +447,18 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
map.put("pageNum", (pageBean.getCurrent() - 1) * pageBean.getSize());
map.put("pageSize", pageBean.getSize());
List<Map<String, Object>> list = this.baseMapper.selectPersonList(map);
//处理循环中的远程调用(原有逻辑不变)
List<String> amosIds = new ArrayList<>();
list.stream().forEach(t -> {
// BUG2886 因为前期沟通 人员code 可能会发生改变 所以 现在接口code 不再保存,查询数据时通过接口重新赋值 by kongfm
// 2021-09-16
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString())) {
FeignClientResult<AgencyUserModel> result1 = Privilege.agencyUserClient
.queryByUserId(t.get("amosOrgId").toString());
if (null != result1.getResult()) {
t.put("amosOrgCode", result1.getResult().getRealName());
}
amosIds.add(t.get("amosOrgId").toString());
// FeignClientResult<AgencyUserModel> result1 = Privilege.agencyUserClient
// .queryByUserId(t.get("amosOrgId").toString());
// if (null != result1.getResult()) {
// t.put("amosOrgCode", result1.getResult().getRealName());
// }
String chargePersonId = iOrgUsrService.getIdNumberByAmosId(t.get("amosOrgId").toString());
t.put("chargePersonId", chargePersonId);
} else {
......@@ -463,6 +466,16 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
}
});
if (CollectionUtils.isNotEmpty(amosIds)) {
String join = String.join(",", amosIds);
List<AgencyUserModel> amosUser = Privilege.agencyUserClient.queryByIds(join, false).getResult();
Map<String, AgencyUserModel> collect = amosUser.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, t -> t));
list.stream().forEach(t -> {
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString()) && collect.containsKey(t.get("amosOrgId").toString())) {
t.put("amosOrgCode", collect.get(t.get("amosOrgId").toString()).getRealName());
}
});
}
/* Bug2652 根据名字和工号模糊查询失效 已添加模糊匹配 2021-09-01 陈召 结束 */
pageBean.setRecords(list);
return pageBean;
......
......@@ -261,6 +261,15 @@ public class PlanTaskController extends AbstractBaseController {
return ResponseHelper.buildResponse(planTaskService.getPlanTaskPoints(param));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据任务详情ID查信息(首页维保待办任务跳转试用)-mobile", notes = "根据任务详情ID查信息(首页维保待办任务跳转试用)-mobile")
@RequestMapping(value = "/point/{planTaskDetailId}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel getByTaskDetailId(@ApiParam(value = "任务详情ID", required = true) @PathVariable Long planTaskDetailId) {
return ResponseHelper.buildResponse(planTaskService.getByTaskDetailId(planTaskDetailId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询维保设施,检查内容详情")
@GetMapping(value = "/task-point-detail")
......
......@@ -191,4 +191,6 @@ public interface PlanTaskMapper extends BaseMapper {
List<Plan> getPlanIdsByDate(Date date);
List<PlanTask> getPlanTaskList(Date now);
}
......@@ -35,4 +35,7 @@ public interface IPlanTaskDetailDao extends BaseDao<PlanTaskDetail, Long> {
List<PlanTaskDetail> findALLByPointId(Long pointId);
List<PlanTaskDetail> findByPointId(long pointId);
@Query(value = "select id FROM p_plan_task_detail WHERE task_no = ?1 limit 1", nativeQuery = true)
Long findIdByTaskNo(Long taskNo);
}
\ No newline at end of file
......@@ -27,6 +27,9 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "SELECT DISTINCT point_id FROM `p_route_point` where route_id = ?1", nativeQuery = true)
List<Long> queryRoutePointIds(Long routeId);
@Query(value = "SELECT DISTINCT id FROM `p_route_point` where route_id = ?1 limit 1", nativeQuery = true)
Long queryIdByRouteId(Long routeId);
@Modifying
@Transactional
@Query(value = "select * from p_route_point WHERE route_id = ?1 and point_id in (?2)", nativeQuery = true)
......
......@@ -279,14 +279,17 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
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())) {
List<PlanTask> planTaskList = planTaskMapper.getPlanTaskList(now);
Map<Long, Plan> collect = planIdsByDate.stream().collect(Collectors.toMap(Plan::getId, t -> t));
for (PlanTask planTask : planTaskList) {
if (!redisUtils.hasKey(MAINTENANCE_PLAN_TASK_KEY + planTask.getId())) {
try {
sendMessage(plan);
sendMessage(collect.get(planTask.getPlanId()), planTask);
} catch (Exception e) {
e.printStackTrace();
}
redisUtils.set(MAINTENANCE_PLAN_TASK_KEY + plan.getId(), 1, (long) plan.getDuration() * 60);
redisUtils.set(MAINTENANCE_PLAN_TASK_KEY + planTask.getId(), 1, (long) collect.get(planTask.getPlanId()).getDuration() * 60);
}
}
}
......@@ -535,7 +538,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
public void sendMessage(Plan plan) throws Exception {
public void sendMessage(Plan plan, PlanTask planTask) throws Exception {
// 查询检查对象对应防火监督负责人id
List<String> extraUserIds = com.google.common.collect.Lists.newArrayList();
//
......@@ -543,7 +546,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
/* // 规则推送消息
rulePlanService.addPlanRule(plan, null, RuleTypeEnum.消息型计划生成, extraUserIds);*/
// NOTIFY
String userIdString = plan.getUserId();
String userIdString = planTask.getUserId();
if (org.apache.commons.lang3.StringUtils.isNotBlank(userIdString)) {
String[] userIdArr = userIdString.split(",");
List<String> userIdList = Arrays.asList(userIdArr);
......@@ -559,9 +562,10 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
if (CollectionUtils.isNotEmpty(extraUserIds)) {
log.info("接收人ID:{}", extraUserIds);
rulePlanService.addPlanRule(plan, null, RuleTypeEnum.任务型计划生成, extraUserIds);
rulePlanService.addPlanRule(plan, planTask, RuleTypeEnum.任务型计划生成, extraUserIds);
}
}
}
......@@ -791,6 +795,15 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return result;
}
@Override
public Boolean getByTaskDetailId(Long planTaskDetailId) {
HashMap<String, Object> resultMap = new HashMap<>();
PlanTaskDetail planTaskDetail = iPlanTaskDetailDao.findById(planTaskDetailId).orElseThrow(() -> new RuntimeException("任务不存在"));
resultMap.put("isFinish", planTaskDetail.getIsFinish());
PlanTask planTask = iplanTaskDao.findById(planTaskDetail.getTaskNo()).orElseThrow(() -> new RuntimeException("任务不存在"));
return 0 == planTaskDetail.getIsFinish() && 1 == planTask.getFinishStatus();
}
private List<Map<String, Object>> buildCheckInputItem(String routePointId) {
return inputItemMapper.queryInputItemInRountPoint(routePointId);
}
......
......@@ -3,10 +3,13 @@ package com.yeejoin.amos.maintenance.business.service.impl;
import com.yeejoin.amos.boot.biz.common.constants.RuleConstant;
import com.yeejoin.amos.boot.biz.common.enums.RuleTypeEnum;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.maintenance.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.maintenance.business.dao.repository.IRoutePointDao;
import com.yeejoin.amos.maintenance.business.dto.PlanRo;
import com.yeejoin.amos.maintenance.business.feign.JCSFeignClient;
import com.yeejoin.amos.maintenance.business.util.DateUtil;
import com.yeejoin.amos.maintenance.dao.entity.Plan;
import com.yeejoin.amos.maintenance.dao.entity.PlanTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -30,15 +33,21 @@ public class RulePlanService {
@Autowired
private JCSFeignClient jcsFeignClient;
public Boolean addPlanRule(Plan plan, List<String> userIds, RuleTypeEnum ruleType, List<String> extraUserIds) throws Exception {
PlanRo planRo = buildPlanRo(plan, userIds, ruleType, extraUserIds);
@Autowired
IPlanTaskDetailDao iPlanTaskDetailDao;
@Autowired
IRoutePointDao iRoutePointDao;
public Boolean addPlanRule(Plan plan, PlanTask planTask, RuleTypeEnum ruleType, List<String> extraUserIds) throws Exception {
PlanRo planRo = buildPlanRo(plan, planTask, ruleType, extraUserIds);
//触发规则
log.info("消防维保推规则触发消息入参:{}, packageId:{} ", planRo, packageId);
ruleTrigger.publish(planRo, packageId, new String[0]);
return true;
}
private PlanRo buildPlanRo(Plan plan, List<String> userIds, RuleTypeEnum ruleType, List<String> extraUserIds) {
private PlanRo buildPlanRo(Plan plan, PlanTask planTask, RuleTypeEnum ruleType, List<String> extraUserIds) {
PlanRo planRo = new PlanRo();
BeanUtils.copyProperties(plan, planRo);
......@@ -54,6 +63,11 @@ public class RulePlanService {
map.put("url", ruleType.getUrl());
}
Long routePointId = iRoutePointDao.queryIdByRouteId(planTask.getRouteId());
Long idByTaskNo = iPlanTaskDetailDao.findIdByTaskNo(planTask.getId());
map.put("planTaskDetailId", String.valueOf(idByTaskNo));
map.put("routePointId", String.valueOf(routePointId));
if (RuleConstant.WEB.equals(ruleType.getTerminal())){
planRo.setIsSendWeb(true);
} else if (RuleConstant.APP.equals(ruleType.getTerminal())){
......
......@@ -122,4 +122,11 @@ public interface IPlanTaskService {
* @return Map<String, Object>
*/
Map<String, Object> planTaskPointDetail(String planTaskDetailId, String routePointId);
/**
* 根据任务详情ID查信息
* @param planTaskDetailId
* @return
*/
Boolean getByTaskDetailId(Long planTaskDetailId);
}
......@@ -894,4 +894,14 @@
group by plan_id
)
</select>
<select id="getPlanTaskList" resultType="com.yeejoin.amos.maintenance.dao.entity.PlanTask">
select *
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
</select>
</mapper>
\ No newline at end of file
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