Commit 54d411dc authored by zhangsen's avatar zhangsen

改bug

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