Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 2 years ago
parent
commit
f0f699e3b5
  1. 2
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java
  2. 5
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java
  3. 46
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java
  4. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenancePlanServiceImpl.java
  5. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java
  6. 54
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/abstracts/TemplateAbstractService.java
  7. 24
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/service/TemplateService.java
  8. 42
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/serviceimpl/MaintenanceTempleServiceImpl.java
  9. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  10. 42
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java
  11. 54
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/abstracts/TemplateAbstractService.java
  12. 24
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/service/TemplateService.java
  13. 55
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java
  14. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  15. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

2
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java

@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
/** /**
* @author hx * @author hx
*/ */

5
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolEntity.java

@ -68,4 +68,9 @@ public class SafetyToolEntity extends TenantEntity {
@ApiModelProperty(value = "通知用户") @ApiModelProperty(value = "通知用户")
private String noticeUsers; private String noticeUsers;
@ApiModelProperty(value = "模板Id")
private Long messageTemplateId;
} }

46
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java

@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.message.req.PushExtrasReq;
@ -18,6 +19,7 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
@ -64,6 +66,9 @@ public class MaintenanceTaskCreateTask {
private final IMessageClient messageClient; private final IMessageClient messageClient;
private final BladeLogger logger; private final BladeLogger logger;
private final List<TemplateService> templateService;
@Value("${hzims.operation.task.templateCode.maintenance.taskDispose}") @Value("${hzims.operation.task.templateCode.maintenance.taskDispose}")
private String maintenanceTaskKey; private String maintenanceTaskKey;
@ -195,24 +200,41 @@ public class MaintenanceTaskCreateTask {
* @return void * @return void
**/ **/
private void pushTaskMessage(OperMaintenanceTaskEntity taskEntity) { private void pushTaskMessage(OperMaintenanceTaskEntity taskEntity) {
XxlJobLogger.log("开始保存{}的日常维护消息推送记录",taskEntity.getDisposer()); XxlJobLogger.log("开始保存{}的日常维护消息推送记录",taskEntity.getDisposer());
R<MessageTemplateEntity> templateR = messageClient.getMsgTemplateById(taskEntity.getMessageTemplateId()); R<MessageTemplateEntity> templateR = messageClient.getMsgTemplateById(taskEntity.getMessageTemplateId());
if(templateR.isSuccess() && ObjectUtil.isNotEmpty(templateR.getData())) { if(templateR.isSuccess() && ObjectUtil.isNotEmpty(templateR.getData())) {
Func.toLongList("",taskEntity.getDisposer()).forEach(userId -> { Func.toLongList("",taskEntity.getDisposer()).forEach(userId -> {
MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class); // MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class);
recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),","))); // recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),",")));
recordDto.setDeptId(taskEntity.getCreateDept()); // recordDto.setDeptId(taskEntity.getCreateDept());
recordDto.setCreateUser(taskEntity.getCreateUser()); // recordDto.setCreateUser(taskEntity.getCreateUser());
recordDto.setCreateDept(taskEntity.getCreateDept()); // recordDto.setCreateDept(taskEntity.getCreateDept());
// ZoneId zoneId = ZoneId.systemDefault();
// recordDto.setPlanTime(LocalDateTime.ofInstant(taskEntity.getDisposeTime().toInstant(),zoneId));
// recordDto.setPushType(MessageConstants.PLAN);
// recordDto.setPusher(userId.toString());
// recordDto.setPusherName(UserCache.getUser(userId).getName());
// recordDto.setAccount(recordDto.getPusher());
// recordDto.setContent("距离任务执行时间已不满一小时,请及时处理");
//推送消息
ZoneId zoneId = ZoneId.systemDefault(); ZoneId zoneId = ZoneId.systemDefault();
recordDto.setPlanTime(LocalDateTime.ofInstant(taskEntity.getDisposeTime().toInstant(),zoneId)); PlanMsgRecordDto planMsgRecordDto = new PlanMsgRecordDto();
recordDto.setPushType(MessageConstants.PLAN); planMsgRecordDto.setTemplateId(taskEntity.getMessageTemplateId());
recordDto.setPusher(userId.toString()); planMsgRecordDto.setCreateUser(taskEntity.getCreateUser());
recordDto.setPusherName(UserCache.getUser(userId).getName()); planMsgRecordDto.setPlanTime(LocalDateTime.ofInstant(taskEntity.getDisposeTime().toInstant(),zoneId));
recordDto.setAccount(recordDto.getPusher()); planMsgRecordDto.setTaskId(taskEntity.getId());
recordDto.setContent("距离任务执行时间已不满一小时,请及时处理"); planMsgRecordDto.setDeptId(taskEntity.getCreateDept());
planMsgRecordDto.setReceiver(userId);
TemplateService templateService1 = templateService.stream().filter(item -> item.isTemplateStatus(1)).findFirst().orElse(null);
templateService1.execute(planMsgRecordDto);
XxlJobLogger.log("推送内容体为:{}", JSON.toJSONString(taskEntity.getDisposer())); XxlJobLogger.log("推送内容体为:{}", JSON.toJSONString(taskEntity.getDisposer()));
messageClient.sendMessage(recordDto); //messageClient.sendMessage(recordDto);
}); });
} }
} }

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenancePlanServiceImpl.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity;
import com.hnac.hzims.operational.duty.service.IImsDutyClassService; import com.hnac.hzims.operational.duty.service.IImsDutyClassService;
import com.hnac.hzims.operational.maintenance.dto.OperMaintenancePlanDTO; import com.hnac.hzims.operational.maintenance.dto.OperMaintenancePlanDTO;
@ -14,6 +15,7 @@ import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper;
import com.hnac.hzims.operational.maintenance.scheduled.MaintenancePlanCreateTask; import com.hnac.hzims.operational.maintenance.scheduled.MaintenancePlanCreateTask;
import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskCreateTask; import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskCreateTask;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService;
import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenancePlanVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenancePlanVO;
import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenancePlanWrapper; import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenancePlanWrapper;
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient;
@ -52,6 +54,9 @@ public class OperMaintenancePlanServiceImpl extends BaseServiceImpl<OperMaintena
private final IDangerSourceClient dangerSourceClient; private final IDangerSourceClient dangerSourceClient;
private final List<TemplateService> templateService;
@Override @Override
public R<OperMaintenancePlanVO> detail(Long id) { public R<OperMaintenancePlanVO> detail(Long id) {
OperMaintenancePlanVO detail = OperMaintenancePlanWrapper.build().entityVO(super.getById(id)); OperMaintenancePlanVO detail = OperMaintenancePlanWrapper.build().entityVO(super.getById(id));
@ -107,12 +112,17 @@ public class OperMaintenancePlanServiceImpl extends BaseServiceImpl<OperMaintena
//更新任务派发时间 //更新任务派发时间
this.update(new LambdaUpdateWrapper<OperMaintenancePlanEntity>().set(OperMaintenancePlanEntity::getCreateTaskTime,new Date()) this.update(new LambdaUpdateWrapper<OperMaintenancePlanEntity>().set(OperMaintenancePlanEntity::getCreateTaskTime,new Date())
.eq(OperMaintenancePlanEntity::getId,planEntity.getId())); .eq(OperMaintenancePlanEntity::getId,planEntity.getId()));
} }
catch(Exception e) { catch(Exception e) {
BladeLogger logger = SpringUtil.getBean(BladeLogger.class); BladeLogger logger = SpringUtil.getBean(BladeLogger.class);
logger.error("maintenance:generateTask",e.getMessage()); logger.error("maintenance:generateTask",e.getMessage());
} }
}); });
return R.success("操作成功"); return R.success("操作成功");
} }

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

@ -360,6 +360,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
//区域编号必传 //区域编号必传
queryWrapper.eq("CREATE_DEPT", areaMonthlyVo.getAreaId()); queryWrapper.eq("CREATE_DEPT", areaMonthlyVo.getAreaId());
queryWrapper.eq(areaMonthlyVo.getYearMonth() != null, "date_format(create_time,'%Y-%m')", areaMonthlyVo.getYearMonth()); queryWrapper.eq(areaMonthlyVo.getYearMonth() != null, "date_format(create_time,'%Y-%m')", areaMonthlyVo.getYearMonth());
//queryWrapper.lambda().eq(OperMaintenanceTaskEntity::getStatus,5);
Page<OperMaintenanceTaskEntity> operMaintenanceTaskEntityPage = baseMapper.selectPage(pageParam, queryWrapper); Page<OperMaintenanceTaskEntity> operMaintenanceTaskEntityPage = baseMapper.selectPage(pageParam, queryWrapper);
//数据转换 //数据转换
if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntityPage.getRecords())) { if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntityPage.getRecords())) {

54
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/abstracts/TemplateAbstractService.java

@ -0,0 +1,54 @@
package com.hnac.hzims.operational.maintenance.template.abstracts;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:27
*/
@Slf4j
public abstract class TemplateAbstractService implements TemplateService {
@Resource
private IMessageClient messageClient;
/**
* 具体业务
*
* @param planMsgRecord
*/
@Override
public void execute(PlanMsgRecordDto planMsgRecord) {
//1.具体的业务逻辑
PlanMsgRecordDto list = executeTemplateMessage(planMsgRecord);
//2.保存数据
saveData(list);
}
/**
* 推送的数据
*
* @param list
*/
private void saveData(PlanMsgRecordDto list) {
log.info("正在保存推送的数据");
messageClient.planSendMessage(list);
}
/**
* 执行具体的业务场景,推送消息
*
* @return
*/
public abstract PlanMsgRecordDto executeTemplateMessage(PlanMsgRecordDto planMsgRecord);
}

24
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/service/TemplateService.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.maintenance.template.service;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:25
*/
public interface TemplateService {
/**
* 模板状态
*/
Boolean isTemplateStatus(int status);
/**
* 具体业务
*/
void execute(PlanMsgRecordDto planMsgRecord);
}

42
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/template/serviceimpl/MaintenanceTempleServiceImpl.java

@ -0,0 +1,42 @@
package com.hnac.hzims.operational.maintenance.template.serviceimpl;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.maintenance.template.abstracts.TemplateAbstractService;
import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* 日常维护计划
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:48
*/
@Service
public class MaintenanceTempleServiceImpl extends TemplateAbstractService {
/**
* 执行具体的业务场景,推送消息
*
* @return
*/
@Override
public PlanMsgRecordDto executeTemplateMessage(PlanMsgRecordDto planMsgRecord) {
planMsgRecord.setContent("距离任务执行时间已不满一小时,请及时处理");
return planMsgRecord;
}
/**
* 模板状态
* @param status
*/
@Override
public Boolean isTemplateStatus(int status) {
return Objects.equals(status,1);
}
}

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -80,8 +80,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (Func.isEmpty(req.getId())) { if (Func.isEmpty(req.getId())) {
lwq = Wrappers.<StationEntity>lambdaQuery() lwq = Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName()); .eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName());
} } else {
else {
lwq = Wrappers.<StationEntity>lambdaQuery().ne(StationEntity::getId, req.getId()) lwq = Wrappers.<StationEntity>lambdaQuery().ne(StationEntity::getId, req.getId())
.and(wrapper -> wrapper.eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName())); .and(wrapper -> wrapper.eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName()));
} }
@ -143,8 +142,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
} }
// 删除智能诊断站点 // 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode()); questionClient.deleteStationInfo(stationEntity.getCode());
//删除所属机构信息
deptClient.deleteDeptById(stationEntity.getRefDept());
} }
return saveFlag; return saveFlag;
} }
@ -597,6 +594,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/** /**
* 通过站点编辑所属机构 * 通过站点编辑所属机构
*
* @param stationEntity 站点信息 * @param stationEntity 站点信息
* @return * @return
*/ */
@ -627,6 +625,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/** /**
* 查询下拉列表站点 * 查询下拉列表站点
*
* @param type * @param type
* @param serveType * @param serveType
* @return * @return
@ -668,6 +667,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/** /**
* 删除新建站点时绑定的数据项目智能诊断站点 * 删除新建站点时绑定的数据项目智能诊断站点
*
* @param idList id集合 * @param idList id集合
*/ */
private void deleteStation(List<Long> idList) { private void deleteStation(List<Long> idList) {

42
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.safeproduct.dto.SafetyToolBatchRecheckDTO; import com.hnac.hzims.safeproduct.dto.SafetyToolBatchRecheckDTO;
import com.hnac.hzims.safeproduct.dto.SafetyToolDTO; import com.hnac.hzims.safeproduct.dto.SafetyToolDTO;
import com.hnac.hzims.safeproduct.entity.SafeProductPdf; import com.hnac.hzims.safeproduct.entity.SafeProductPdf;
@ -20,6 +21,7 @@ import com.hnac.hzims.safeproduct.mapper.SafetyToolMapper;
import com.hnac.hzims.safeproduct.mapper.SafetyToolRecheckMapper; import com.hnac.hzims.safeproduct.mapper.SafetyToolRecheckMapper;
import com.hnac.hzims.safeproduct.mapper.SafetyToolTypeMapper; import com.hnac.hzims.safeproduct.mapper.SafetyToolTypeMapper;
import com.hnac.hzims.safeproduct.service.ISafetyToolService; import com.hnac.hzims.safeproduct.service.ISafetyToolService;
import com.hnac.hzims.safeproduct.template.service.TemplateService;
import com.hnac.hzims.safeproduct.utils.ExcelToolListener; import com.hnac.hzims.safeproduct.utils.ExcelToolListener;
import com.hnac.hzims.safeproduct.utils.HtmlModule; import com.hnac.hzims.safeproduct.utils.HtmlModule;
import com.hnac.hzims.safeproduct.utils.HtmltoPdf; import com.hnac.hzims.safeproduct.utils.HtmltoPdf;
@ -53,10 +55,7 @@ import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.time.Instant; import java.time.*;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -79,6 +78,8 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IUserClient userClient; private final IUserClient userClient;
private final List<TemplateService> templateService;
@Value("${hzims.safeProduct.safeTool.sadeToolKey}") @Value("${hzims.safeProduct.safeTool.sadeToolKey}")
private String sadeToolKey; private String sadeToolKey;
@Value("${hzims.tenantId}") @Value("${hzims.tenantId}")
@ -133,6 +134,27 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
for (SafetyToolEntity item : safetyTools) { for (SafetyToolEntity item : safetyTools) {
item.setLastCheckTime(currentTime); item.setLastCheckTime(currentTime);
item.setNextCheckTime(DateUtil.plusDays(currentTime, Long.valueOf(item.getSafeTime().toString()))); item.setNextCheckTime(DateUtil.plusDays(currentTime, Long.valueOf(item.getSafeTime().toString())));
String noticeUsers = item.getNoticeUsers();
if (!StringUtils.isEmpty(noticeUsers)) {
String[] split = noticeUsers.split(",");
for (String s : split) {
PlanMsgRecordDto planMsgRecordDtoDto = new PlanMsgRecordDto();
planMsgRecordDtoDto.setTemplateId(item.getMessageTemplateId());
planMsgRecordDtoDto.setTaskId(item.getId());
planMsgRecordDtoDto.setDeptId(item.getCurSts());
planMsgRecordDtoDto.setCreateUser(item.getCreateUser());
planMsgRecordDtoDto.setReceiver(Long.valueOf(s));
ZoneId zoneId = ZoneId.systemDefault();
Date nextCheckTime = item.getNextCheckTime();
planMsgRecordDtoDto.setPlanTime(nextCheckTime.toInstant().atZone(zoneId).toLocalDateTime());
TemplateService templateService1 =
templateService.stream().filter(item1 -> item1.isTemplateStatus(1)).findFirst().orElse(null);
templateService1.execute(planMsgRecordDtoDto);
}
}
} }
if (!super.updateBatchById(safetyTools)) { if (!super.updateBatchById(safetyTools)) {
throw new RuntimeException("数据库update操作失败!"); throw new RuntimeException("数据库update操作失败!");
@ -152,6 +174,8 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) { if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) {
throw new RuntimeException("数据库insert操作失败!"); throw new RuntimeException("数据库insert操作失败!");
} }
} }
@Override @Override
@ -222,6 +246,7 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
/** /**
* 安全工器具二维码导出 * 安全工器具二维码导出
*
* @param idList * @param idList
* @return 文件路径 * @return 文件路径
*/ */
@ -233,8 +258,7 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
in(SafetyToolEntity::getId, idList); in(SafetyToolEntity::getId, idList);
orderByDesc(SafetyToolEntity::getCreateTime); orderByDesc(SafetyToolEntity::getCreateTime);
}}); }});
} } else {
else{
entityList = page(Condition.getPage(new Query()), new LambdaQueryWrapper<SafetyToolEntity>()).getRecords(); entityList = page(Condition.getPage(new Query()), new LambdaQueryWrapper<SafetyToolEntity>()).getRecords();
} }
if (CollectionUtil.isNotEmpty(entityList)) { if (CollectionUtil.isNotEmpty(entityList)) {
@ -261,12 +285,10 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
String html = HtmlModule.buildHtml(pdfList, modulePath); String html = HtmlModule.buildHtml(pdfList, modulePath);
HtmltoPdf.htmlToPdf(html, pdfPath); HtmltoPdf.htmlToPdf(html, pdfPath);
return pdfPath; return pdfPath;
} } catch (Exception e) {
catch (Exception e){
throw new ServiceException("导出pdf发生异常:" + e.getMessage()); throw new ServiceException("导出pdf发生异常:" + e.getMessage());
} }
} } else {
else{
return null; return null;
} }
} }

54
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/abstracts/TemplateAbstractService.java

@ -0,0 +1,54 @@
package com.hnac.hzims.safeproduct.template.abstracts;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.safeproduct.template.service.TemplateService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:27
*/
@Slf4j
public abstract class TemplateAbstractService implements TemplateService {
@Resource
private IMessageClient messageClient;
/**
* 具体业务
*
* @param planMsgRecord
*/
@Override
public void execute(PlanMsgRecordDto planMsgRecord) {
//1.具体的业务逻辑
PlanMsgRecordDto list = executeTemplateMessage(planMsgRecord);
//2.保存数据
saveData(list);
}
/**
* 推送的数据
*
* @param list
*/
private void saveData(PlanMsgRecordDto list) {
log.info("正在保存推送的数据");
messageClient.planSendMessage(list);
}
/**
* 执行具体的业务场景,推送消息
*
* @return
*/
public abstract PlanMsgRecordDto executeTemplateMessage(PlanMsgRecordDto planMsgRecord);
}

24
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/service/TemplateService.java

@ -0,0 +1,24 @@
package com.hnac.hzims.safeproduct.template.service;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:25
*/
public interface TemplateService {
/**
* 模板状态
*/
Boolean isTemplateStatus(int status);
/**
* 具体业务
*/
void execute(PlanMsgRecordDto planMsgRecord);
}

55
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java

@ -0,0 +1,55 @@
package com.hnac.hzims.safeproduct.template.serviceimpl;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.safeproduct.template.abstracts.TemplateAbstractService;
import com.qiniu.util.Json;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
/**
* 日常维护计划
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/14 14:48
*/
@Service
public class MaintenanceTempleServiceImpl extends TemplateAbstractService {
/**
* 执行具体的业务场景,推送消息
*
* @return
*/
@Override
public PlanMsgRecordDto executeTemplateMessage(PlanMsgRecordDto planMsgRecord) {
Map<String,Object> map = new HashMap<>();
map.put("one",
Optional.ofNullable(UserCache.getUser(planMsgRecord.getReceiver())).map(User::getName).orElse(""));
map.put("two", planMsgRecord.getPlanTime());
planMsgRecord.setContent(JSON.toJSONString(map));
return planMsgRecord;
}
/**
* 模板状态
* @param status
*/
@Override
public Boolean isTemplateStatus(int status) {
return Objects.equals(status,1);
}
}

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java

@ -348,7 +348,7 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
queryWrapper.eq("sti.CREATE_DEPT", areaVo.getAreaId()); queryWrapper.eq("sti.CREATE_DEPT", areaVo.getAreaId());
queryWrapper.eq(areaVo.getYearMonth() != null, queryWrapper.eq(areaVo.getYearMonth() != null,
"date_format(sti.create_time,'%Y-%m')", areaVo.getYearMonth()); "date_format(sti.create_time,'%Y-%m')", areaVo.getYearMonth());
queryWrapper.eq("tie.status",1); // queryWrapper.eq("tie.status",1);
Page<StandardTicketInfoEntity> standardTicketInfoEntityPage = baseMapper.selectPages(searchPage, queryWrapper); Page<StandardTicketInfoEntity> standardTicketInfoEntityPage = baseMapper.selectPages(searchPage, queryWrapper);
//数据转换StandardTicketInfoEntity ==> StandardTicketVo //数据转换StandardTicketInfoEntity ==> StandardTicketVo

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

@ -902,7 +902,7 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
queryWrapper.eq(areaVo.getYearMonth() != null, "date_format(sti.create_time,'%Y-%m')", queryWrapper.eq(areaVo.getYearMonth() != null, "date_format(sti.create_time,'%Y-%m')",
areaVo.getYearMonth()); areaVo.getYearMonth());
//如果为1为合格 //如果为1为合格
queryWrapper.eq("tie.status",1); // queryWrapper.eq("tie.status",1);
Page<WorkTicketInfoEntity> workTicketInfoEntityPage = baseMapper.selectPages(pageEntity, queryWrapper); Page<WorkTicketInfoEntity> workTicketInfoEntityPage = baseMapper.selectPages(pageEntity, queryWrapper);
//数据转换 //数据转换
List<StandardWorkVo> standardWorkList = new ArrayList<>(); List<StandardWorkVo> standardWorkList = new ArrayList<>();

Loading…
Cancel
Save