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. 66
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  10. 94
      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.RequestParam;
import javax.annotation.Resource;
/**
* @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 = "通知用户")
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.message.MessageConstants;
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.fegin.IMessageClient;
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.mapper.OperMaintenancePlanMapper;
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.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
@ -64,6 +66,9 @@ public class MaintenanceTaskCreateTask {
private final IMessageClient messageClient;
private final BladeLogger logger;
private final List<TemplateService> templateService;
@Value("${hzims.operation.task.templateCode.maintenance.taskDispose}")
private String maintenanceTaskKey;
@ -195,24 +200,41 @@ public class MaintenanceTaskCreateTask {
* @return void
**/
private void pushTaskMessage(OperMaintenanceTaskEntity taskEntity) {
XxlJobLogger.log("开始保存{}的日常维护消息推送记录",taskEntity.getDisposer());
R<MessageTemplateEntity> templateR = messageClient.getMsgTemplateById(taskEntity.getMessageTemplateId());
if(templateR.isSuccess() && ObjectUtil.isNotEmpty(templateR.getData())) {
Func.toLongList("",taskEntity.getDisposer()).forEach(userId -> {
MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class);
recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),",")));
recordDto.setDeptId(taskEntity.getCreateDept());
recordDto.setCreateUser(taskEntity.getCreateUser());
recordDto.setCreateDept(taskEntity.getCreateDept());
// MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class);
// recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),",")));
// recordDto.setDeptId(taskEntity.getCreateDept());
// recordDto.setCreateUser(taskEntity.getCreateUser());
// 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();
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("距离任务执行时间已不满一小时,请及时处理");
PlanMsgRecordDto planMsgRecordDto = new PlanMsgRecordDto();
planMsgRecordDto.setTemplateId(taskEntity.getMessageTemplateId());
planMsgRecordDto.setCreateUser(taskEntity.getCreateUser());
planMsgRecordDto.setPlanTime(LocalDateTime.ofInstant(taskEntity.getDisposeTime().toInstant(),zoneId));
planMsgRecordDto.setTaskId(taskEntity.getId());
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()));
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.metadata.IPage;
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.service.IImsDutyClassService;
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.MaintenanceTaskCreateTask;
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.wrapper.OperMaintenancePlanWrapper;
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient;
@ -52,6 +54,9 @@ public class OperMaintenancePlanServiceImpl extends BaseServiceImpl<OperMaintena
private final IDangerSourceClient dangerSourceClient;
private final List<TemplateService> templateService;
@Override
public R<OperMaintenancePlanVO> detail(Long 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())
.eq(OperMaintenancePlanEntity::getId,planEntity.getId()));
}
catch(Exception e) {
BladeLogger logger = SpringUtil.getBean(BladeLogger.class);
logger.error("maintenance:generateTask",e.getMessage());
}
});
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(areaMonthlyVo.getYearMonth() != null, "date_format(create_time,'%Y-%m')", areaMonthlyVo.getYearMonth());
//queryWrapper.lambda().eq(OperMaintenanceTaskEntity::getStatus,5);
Page<OperMaintenanceTaskEntity> operMaintenanceTaskEntityPage = baseMapper.selectPage(pageParam, queryWrapper);
//数据转换
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);
}
}

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

@ -73,30 +73,29 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override
public void buildStation(StationEntity req) {
// 新建站点的所属机构
Assert.isTrue(this.buildDept(req),() -> {
Assert.isTrue(this.buildDept(req), () -> {
throw new ServiceException("创建/修改机构失败!");
});
LambdaQueryWrapper lwq;
if(Func.isEmpty(req.getId())) {
if (Func.isEmpty(req.getId())) {
lwq = Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName());
}
else {
lwq = Wrappers.<StationEntity>lambdaQuery().ne(StationEntity::getId,req.getId())
.and(wrapper -> wrapper.eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName()));
.eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName());
} else {
lwq = Wrappers.<StationEntity>lambdaQuery().ne(StationEntity::getId, req.getId())
.and(wrapper -> wrapper.eq(StationEntity::getCode, req.getCode()).or().eq(StationEntity::getName, req.getName()));
}
List<StationEntity> list = super.list(lwq);
Assert.isTrue(CollectionUtil.isEmpty(list),() -> {
Assert.isTrue(CollectionUtil.isEmpty(list), () -> {
throw new ServiceException("该站点名/编码已有对应记录,请找到相应记录做修改处理");
});
Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder());
req.setSort(sort.isPresent() ? sort.get()+1 : 1);
Assert.isTrue(this.saveOrUpdate(req),() -> {
req.setSort(sort.isPresent() ? sort.get() + 1 : 1);
Assert.isTrue(this.saveOrUpdate(req), () -> {
throw new ServiceException("创建/修改站点信息失败!");
});
// 如果设备数据来源未选定其他 则进行站点初始化操作
if(!StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
if (!StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
// 智能诊断站点推送
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> questionClient.submitStationInfo(req.getCode(), ""));
@ -107,10 +106,10 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override
public boolean instanceProject(StationEntity req) {
if(Func.isEmpty(req.getSecretKey()) || Func.isEmpty(req.getDataSource())) {
if (Func.isEmpty(req.getSecretKey()) || Func.isEmpty(req.getDataSource())) {
return true;
}
if(super.updateById(req)) {
if (super.updateById(req)) {
ProjectDTO projectDTO = new ProjectDTO();
projectDTO.setName(req.getName());
projectDTO.setSource(1);
@ -118,7 +117,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
projectDTO.setListenKind(req.getDataSource());
projectDTO.setId(req.getCode());
Result result = projectClient.saveOrUpdate(projectDTO);
logger.info("operational:station:buildStation:"+req.getCode(), JSON.toJSONString(result));
logger.info("operational:station:buildStation:" + req.getCode(), JSON.toJSONString(result));
return result.getCode() == ResultCode.SUCCESS.getCode() && result.isSuccess();
}
return false;
@ -129,22 +128,20 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
public boolean removeStation(String id) {
StationEntity stationEntity = this.getById(id);
boolean saveFlag = this.removeById(Long.valueOf(id));
if(saveFlag) {
if (saveFlag) {
// 删除数据平台项目
Result dataDelete = projectClient.delete(stationEntity.getCode());
Assert.isTrue(dataDelete.isSuccess(),() -> {
logger.error("hzims-operational:station:removeStation",stationEntity.getCode()+"删除失败,报错信息为:"+dataDelete.getMsg());
Assert.isTrue(dataDelete.isSuccess(), () -> {
logger.error("hzims-operational:station:removeStation", stationEntity.getCode() + "删除失败,报错信息为:" + dataDelete.getMsg());
throw new ServiceException("数据平台删除项目失败!");
});
// 删除所属机构
R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept());
if(deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) {
if (deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) {
deptClient.deleteDeptById(stationEntity.getRefDept());
}
// 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode());
//删除所属机构信息
deptClient.deleteDeptById(stationEntity.getRefDept());
}
return saveFlag;
}
@ -597,15 +594,16 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/**
* 通过站点编辑所属机构
*
* @param stationEntity 站点信息
* @return
*/
private boolean buildDept(StationEntity stationEntity) {
//若所属机构不为空 则说明机构已建 获取所属机构
Dept request = new Dept();
if(Func.isNotEmpty(stationEntity.getRefDept())) {
if (Func.isNotEmpty(stationEntity.getRefDept())) {
R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept());
if(deptResult.isSuccess() && Func.isNotEmpty(deptResult.getData())) {
if (deptResult.isSuccess() && Func.isNotEmpty(deptResult.getData())) {
request = deptResult.getData();
}
}
@ -617,7 +615,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
request.setDeptCategory(StationConstants.DeptCategoryEnum.STATION.getValue());
request.setSort(1);
R<Void> buildResult = deptClient.createOrUpdateDept(request);
if(buildResult.isSuccess()) {
if (buildResult.isSuccess()) {
// 所属机构回传
R<Dept> deptByStation = sysClient.getDeptByStation(request.getStationId(), AuthUtil.getTenantId());
stationEntity.setRefDept(Optional.ofNullable(deptByStation).map(R::getData).map(Dept::getId).orElse(null));
@ -627,6 +625,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/**
* 查询下拉列表站点
*
* @param type
* @param serveType
* @return
@ -634,33 +633,33 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override
public List<StationEntity> select(Integer type, Integer serveType) {
List<Integer> types;
if(ObjectUtil.isEmpty(type)){
if (ObjectUtil.isEmpty(type)) {
types = HomePageConstant.types;
}else if(HomePageConstant.WATER_CONSERVANCY.equals(type)){
} else if (HomePageConstant.WATER_CONSERVANCY.equals(type)) {
types = HomePageConstant.waterList;
}else{
} else {
types = Collections.singletonList(type);
}
List<Integer> serveTypes;
if(ObjectUtil.isEmpty(serveType)){
serveTypes = Arrays.asList(HomePageConstant.HYDROPOWER_SERVETYPE,HomePageConstant.CLOUD_SERVETYPE);
}else{
if (ObjectUtil.isEmpty(serveType)) {
serveTypes = Arrays.asList(HomePageConstant.HYDROPOWER_SERVETYPE, HomePageConstant.CLOUD_SERVETYPE);
} else {
serveTypes = Collections.singletonList(serveType);
}
return this.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getType, types)
.in(StationEntity::getServeType,serveTypes)
.in(StationEntity::getServeType, serveTypes)
);
}
@Override
public StationEntity getOne(StationEntity request) {
LambdaQueryWrapper<StationEntity> queryWrapper = Condition.getQueryWrapper(new StationEntity(), request);
if(Func.isNotEmpty(request.getStatus())) {
queryWrapper.eq(StationEntity::getStatus,request.getStatus());
if (Func.isNotEmpty(request.getStatus())) {
queryWrapper.eq(StationEntity::getStatus, request.getStatus());
}
List<StationEntity> list = this.list(queryWrapper);
if(CollectionUtil.isNotEmpty(list) && list.size() > 1) {
if (CollectionUtil.isNotEmpty(list) && list.size() > 1) {
throw new ServiceException("获取站点数量超过一条");
}
return list.size() > 0 ? list.get(0) : null;
@ -668,6 +667,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/**
* 删除新建站点时绑定的数据项目智能诊断站点
*
* @param idList id集合
*/
private void deleteStation(List<Long> idList) {

94
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.toolkit.Wrappers;
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.SafetyToolDTO;
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.SafetyToolTypeMapper;
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.HtmlModule;
import com.hnac.hzims.safeproduct.utils.HtmltoPdf;
@ -53,10 +55,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -79,6 +78,8 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
private final RedisTemplate redisTemplate;
private final IUserClient userClient;
private final List<TemplateService> templateService;
@Value("${hzims.safeProduct.safeTool.sadeToolKey}")
private String sadeToolKey;
@Value("${hzims.tenantId}")
@ -95,7 +96,7 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
String toolCode = req.getToolCode();
List<SafetyToolEntity> list = this.list(new LambdaQueryWrapper<SafetyToolEntity>().eq(SafetyToolEntity::getToolCode, toolCode));
if (CollectionUtil.isNotEmpty(list)) {
return R.fail(400,String.format("编号[%s]已经被使用!", toolCode));
return R.fail(400, String.format("编号[%s]已经被使用!", toolCode));
}
return R.status(super.save(req));
}
@ -105,7 +106,7 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
String toolCode = req.getToolCode();
SafetyToolEntity entity = safetyToolMapper.selectOne(new LambdaQueryWrapper<SafetyToolEntity>().eq(SafetyToolEntity::getToolCode, toolCode));
if (entity != null && !entity.getId().equals(req.getId())) {
return R.fail(400,String.format("编号[%s]已经被使用!", toolCode));
return R.fail(400, String.format("编号[%s]已经被使用!", toolCode));
}
return R.status(super.updateById(req));
}
@ -133,6 +134,27 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
for (SafetyToolEntity item : safetyTools) {
item.setLastCheckTime(currentTime);
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)) {
throw new RuntimeException("数据库update操作失败!");
@ -152,6 +174,8 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) {
throw new RuntimeException("数据库insert操作失败!");
}
}
@Override
@ -163,7 +187,7 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(MultipartFile file,Long createDept) {
public void importExcel(MultipartFile file, Long createDept) {
String filename = file.getOriginalFilename();
ExcelToolListener excelToolListener = new ExcelToolListener();
if (StringUtils.isEmpty(filename)) {
@ -173,25 +197,25 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
} else {
try {
InputStream inputStream = new BufferedInputStream(file.getInputStream());
com.hnac.hzims.safeproduct.utils.ExcelUtil.asyncReadModel(inputStream, excelToolListener,SafetyToolSaveExcel.class,0,1);
com.hnac.hzims.safeproduct.utils.ExcelUtil.asyncReadModel(inputStream, excelToolListener, SafetyToolSaveExcel.class, 0, 1);
} catch (IOException e) {
e.printStackTrace();
}
}
List dataList = excelToolListener.getDataList();
if(CollectionUtil.isNotEmpty(dataList)){
if (CollectionUtil.isNotEmpty(dataList)) {
List<SafetyToolEntity> entityList = new ArrayList<>();
Map<String,List<SafetyToolEntity>> map = JSONArray.parseArray(JSON.toJSONString(dataList),SafetyToolEntity.class).stream()
Map<String, List<SafetyToolEntity>> map = JSONArray.parseArray(JSON.toJSONString(dataList), SafetyToolEntity.class).stream()
.filter(entity -> Func.isNotEmpty(entity.getToolCode())).collect(Collectors.groupingBy(SafetyToolEntity::getToolCode));
Assert.isTrue(CollectionUtil.isNotEmpty(map),()->{
Assert.isTrue(CollectionUtil.isNotEmpty(map), () -> {
throw new ServiceException("填入工器具编码不能为空");
});
IntStream.iterate(0,index->index+1).limit(dataList.size()).forEachOrdered(index->{
SafetyToolEntity entity = BeanUtil.copy(dataList.get(index),SafetyToolEntity.class);
SafetyToolSaveExcel safetyToolSaveExcel = JSONObject.parseObject(JSON.toJSONString(dataList.get(index)),SafetyToolSaveExcel.class);
IntStream.iterate(0, index -> index + 1).limit(dataList.size()).forEachOrdered(index -> {
SafetyToolEntity entity = BeanUtil.copy(dataList.get(index), SafetyToolEntity.class);
SafetyToolSaveExcel safetyToolSaveExcel = JSONObject.parseObject(JSON.toJSONString(dataList.get(index)), SafetyToolSaveExcel.class);
Assert.isTrue(Func.isNotEmpty(entity.getToolCode()) && Func.isNotEmpty(entity.getToolName())
&& Func.isNotEmpty(entity.getSafeTime()) && Func.isNotEmpty(safetyToolSaveExcel.getTypeName()),()->{
throw new ServiceException("第"+ index+"填入数据部分缺失,请修改后重新导入");
&& Func.isNotEmpty(entity.getSafeTime()) && Func.isNotEmpty(safetyToolSaveExcel.getTypeName()), () -> {
throw new ServiceException("第" + index + "填入数据部分缺失,请修改后重新导入");
});
List<SafetyToolEntity> list = this.list(new LambdaQueryWrapper<SafetyToolEntity>().eq(SafetyToolEntity::getToolCode, entity.getToolCode()));
if (CollectionUtil.isNotEmpty(list) || (CollectionUtil.isNotEmpty(map.get(entity.getToolCode())) && map.get(entity.getToolCode()).size() > 1)) {
@ -199,8 +223,8 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
}
List<SafetyToolTypeEntity> safetyToolTypeEntityList = safetyToolTypeService.list(Wrappers.<SafetyToolTypeEntity>lambdaQuery()
.eq(SafetyToolTypeEntity::getTypeName, safetyToolSaveExcel.getTypeName()));
Assert.isTrue(safetyToolTypeEntityList.size() > 0,()->{
throw new ServiceException("第"+ index+"行填入类型未找到相关记录,请修改后重新导入");
Assert.isTrue(safetyToolTypeEntityList.size() > 0, () -> {
throw new ServiceException("第" + index + "行填入类型未找到相关记录,请修改后重新导入");
});
//验证账户
String userIds = Arrays.stream(safetyToolSaveExcel.getAccounts().split(",")).map(account -> {
@ -222,24 +246,24 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
/**
* 安全工器具二维码导出
*
* @param idList
* @return 文件路径
*/
@Override
public String safetyToolRQExport(List idList){
public String safetyToolRQExport(List idList) {
List<SafetyToolEntity> entityList = null;
if(CollectionUtil.isNotEmpty(idList)){
entityList = list(new LambdaQueryWrapper<SafetyToolEntity>(){{
in(SafetyToolEntity::getId,idList);
if (CollectionUtil.isNotEmpty(idList)) {
entityList = list(new LambdaQueryWrapper<SafetyToolEntity>() {{
in(SafetyToolEntity::getId, idList);
orderByDesc(SafetyToolEntity::getCreateTime);
}});
} else {
entityList = page(Condition.getPage(new Query()), new LambdaQueryWrapper<SafetyToolEntity>()).getRecords();
}
else{
entityList = page(Condition.getPage(new Query()),new LambdaQueryWrapper<SafetyToolEntity>()).getRecords();
}
if(CollectionUtil.isNotEmpty(entityList)){
if (CollectionUtil.isNotEmpty(entityList)) {
List<SafeProductPdf> pdfList = new ArrayList<>(entityList.size());
entityList.forEach(entity->{
entityList.forEach(entity -> {
String imgPath = uploadPath + "/" + entity.getTenantId() + entity.getToolCode() + UPLOAD_IMG_SUFFIX;
File file = new File(imgPath);
if (!file.exists()) {
@ -249,32 +273,30 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
SafeProductPdf safeProductPdf = new SafeProductPdf();
safeProductPdf.setData_1(entity.getToolName());
safeProductPdf.setData_2(DateUtil.format(entity.getCreateTime(),"yyyy年MM月dd日"));
safeProductPdf.setData_2(DateUtil.format(entity.getCreateTime(), "yyyy年MM月dd日"));
safeProductPdf.setData_3(imgPath);
pdfList.add(safeProductPdf);
});
/**二维码写入html文件中成功后生成pdf文件地址**/
String pdfPath = uploadPath + "/" + UUID.randomUUID().toString() + ".pdf";
try{
try {
/**将生成二维码写入html文件内**/
String html = HtmlModule.buildHtml(pdfList, modulePath);
HtmltoPdf.htmlToPdf(html, pdfPath);
return pdfPath;
} catch (Exception e) {
throw new ServiceException("导出pdf发生异常:" + e.getMessage());
}
catch (Exception e){
throw new ServiceException("导出pdf发生异常:"+e.getMessage());
}
}
else{
} else {
return null;
}
}
@Override
public R remove(List<Long> idList) {
List<SafetyToolEntity> toolEntityList = list(new LambdaQueryWrapper<SafetyToolEntity>(){{
in(SafetyToolEntity::getId,idList);
List<SafetyToolEntity> toolEntityList = list(new LambdaQueryWrapper<SafetyToolEntity>() {{
in(SafetyToolEntity::getId, idList);
isNotNull(SafetyToolEntity::getNextCheckTime);
orderByDesc(SafetyToolEntity::getNextCheckTime);
}});

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(areaVo.getYearMonth() != null,
"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);
//数据转换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')",
areaVo.getYearMonth());
//如果为1为合格
queryWrapper.eq("tie.status",1);
// queryWrapper.eq("tie.status",1);
Page<WorkTicketInfoEntity> workTicketInfoEntityPage = baseMapper.selectPages(pageEntity, queryWrapper);
//数据转换
List<StandardWorkVo> standardWorkList = new ArrayList<>();

Loading…
Cancel
Save