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. 1224
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  10. 474
      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);
}
}

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

File diff suppressed because it is too large Load Diff

474
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;
@ -70,243 +69,266 @@ import java.util.stream.IntStream;
@Slf4j
@RequiredArgsConstructor
public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, SafetyToolEntity> implements ISafetyToolService {
private final HttpServletResponse httpServletResponse;
private final ISysClient sysClient;
private final SafetyToolTypeServiceImpl safetyToolTypeService;
private final SafetyToolMapper safetyToolMapper;
private final SafetyToolTypeMapper safetyToolTypeMapper;
private final SafetyToolRecheckMapper safetyToolRecheckMapper;
private final RedisTemplate redisTemplate;
private final IUserClient userClient;
private final HttpServletResponse httpServletResponse;
private final ISysClient sysClient;
private final SafetyToolTypeServiceImpl safetyToolTypeService;
private final SafetyToolMapper safetyToolMapper;
private final SafetyToolTypeMapper safetyToolTypeMapper;
private final SafetyToolRecheckMapper safetyToolRecheckMapper;
private final RedisTemplate redisTemplate;
private final IUserClient userClient;
@Value("${hzims.safeProduct.safeTool.sadeToolKey}")
private String sadeToolKey;
@Value("${hzims.tenantId}")
private String tenantId;
@Value("${hzims.safeProduct.safeTool.filePath}")
private String uploadPath;
@Value("${hzims.safeProduct.safeTool.modulePath}")
private String modulePath;
private final List<TemplateService> templateService;
private static final String UPLOAD_IMG_SUFFIX = ".jpg";
@Value("${hzims.safeProduct.safeTool.sadeToolKey}")
private String sadeToolKey;
@Value("${hzims.tenantId}")
private String tenantId;
@Value("${hzims.safeProduct.safeTool.filePath}")
private String uploadPath;
@Value("${hzims.safeProduct.safeTool.modulePath}")
private String modulePath;
@Override
public R doSave(SafetyToolEntity req) {
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.status(super.save(req));
}
private static final String UPLOAD_IMG_SUFFIX = ".jpg";
@Override
public R doUpdate(SafetyToolEntity req) {
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.status(super.updateById(req));
}
@Override
public R doSave(SafetyToolEntity req) {
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.status(super.save(req));
}
@Override
public R<IPage<SafetyToolVO>> pageCondition(SafetyToolDTO req, Query query) {
IPage page = super.page(Condition.getPage(query), this.getListCondition(req));
page.setRecords(SafetyToolWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@Override
public R doUpdate(SafetyToolEntity req) {
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.status(super.updateById(req));
}
@Override
public R<List<SafetyToolVO>> queryByCondition(SafetyToolDTO req) {
List<SafetyToolEntity> list = safetyToolMapper.selectList(this.getListCondition(req));
return R.data(SafetyToolWrapper.build().listVO(list));
}
@Override
public R<IPage<SafetyToolVO>> pageCondition(SafetyToolDTO req, Query query) {
IPage page = super.page(Condition.getPage(query), this.getListCondition(req));
page.setRecords(SafetyToolWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@Override
public void doBatchRecheck(SafetyToolBatchRecheckDTO req) {
//更新工器具记录数据
Date currentTime = new Date();
Long userId = AuthUtil.getUserId();
String userName = AuthUtil.getUserName();
List<SafetyToolEntity> safetyTools = safetyToolMapper.selectBatchIds(req.getToolIds());
for (SafetyToolEntity item : safetyTools) {
item.setLastCheckTime(currentTime);
item.setNextCheckTime(DateUtil.plusDays(currentTime, Long.valueOf(item.getSafeTime().toString())));
}
if (!super.updateBatchById(safetyTools)) {
throw new RuntimeException("数据库update操作失败!");
}
@Override
public R<List<SafetyToolVO>> queryByCondition(SafetyToolDTO req) {
List<SafetyToolEntity> list = safetyToolMapper.selectList(this.getListCondition(req));
return R.data(SafetyToolWrapper.build().listVO(list));
}
//插入复核记录
List<SafetyToolRecheckEntity> safetyToolRechecks = new ArrayList<>(safetyTools.size());
for (SafetyToolEntity item : safetyTools) {
SafetyToolRecheckEntity entity = new SafetyToolRecheckEntity();
entity.setCheckUserName(userName);
entity.setCheckUserId(userId);
entity.setToolId(item.getId());
entity.setCheckTime(currentTime);
entity.setRemark(req.getRemark());
safetyToolRechecks.add(entity);
}
if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) {
throw new RuntimeException("数据库insert操作失败!");
}
}
@Override
public void doBatchRecheck(SafetyToolBatchRecheckDTO req) {
//更新工器具记录数据
Date currentTime = new Date();
Long userId = AuthUtil.getUserId();
String userName = AuthUtil.getUserName();
List<SafetyToolEntity> safetyTools = safetyToolMapper.selectBatchIds(req.getToolIds());
for (SafetyToolEntity item : safetyTools) {
item.setLastCheckTime(currentTime);
item.setNextCheckTime(DateUtil.plusDays(currentTime, Long.valueOf(item.getSafeTime().toString())));
@Override
public void exportExcel(SafetyToolDTO req) {
List<SafetyToolEntity> list = safetyToolMapper.selectList(this.getListCondition(req));
List<SafetyToolExcel> data = SafetyToolWrapper.build().entityExcelList(list, sysClient, safetyToolTypeMapper);
ExcelUtil.export(httpServletResponse, "安全工器具" + System.currentTimeMillis(), "安全工器具", data, SafetyToolExcel.class);
}
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);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(MultipartFile file,Long createDept) {
String filename = file.getOriginalFilename();
ExcelToolListener excelToolListener = new ExcelToolListener();
if (StringUtils.isEmpty(filename)) {
throw new ExcelException("请上传文件!");
} else if (!StringUtils.endsWithIgnoreCase(filename, ".xls") && !StringUtils.endsWithIgnoreCase(filename, ".xlsx")) {
throw new ExcelException("请上传正确的excel文件!");
} else {
try {
InputStream inputStream = new BufferedInputStream(file.getInputStream());
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)){
List<SafetyToolEntity> entityList = new ArrayList<>();
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),()->{
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);
Assert.isTrue(Func.isNotEmpty(entity.getToolCode()) && Func.isNotEmpty(entity.getToolName())
&& 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)) {
throw new ServiceException(String.format("编号[%s]已经被使用!", entity.getToolCode()));
}
List<SafetyToolTypeEntity> safetyToolTypeEntityList = safetyToolTypeService.list(Wrappers.<SafetyToolTypeEntity>lambdaQuery()
.eq(SafetyToolTypeEntity::getTypeName, safetyToolSaveExcel.getTypeName()));
Assert.isTrue(safetyToolTypeEntityList.size() > 0,()->{
throw new ServiceException("第"+ index+"行填入类型未找到相关记录,请修改后重新导入");
});
//验证账户
String userIds = Arrays.stream(safetyToolSaveExcel.getAccounts().split(",")).map(account -> {
R<User> userR = userClient.userByAccount(AuthUtil.getTenantId(), account);
Assert.isTrue(userR.isSuccess() && ObjectUtil.isNotEmpty(userR.getData()), () -> {
throw new ServiceException("第" + index + "行填入用户账号未找到相关记录,请修改后重新导入");
});
return userR.getData();
}).map(User::getId).map(id -> Func.isNotEmpty(id) ? id.toString() : "").collect(Collectors.joining(","));
entity.setNoticeUsers(userIds);
entity.setTypeId(safetyToolTypeEntityList.get(0).getId());
entity.setSendType(safetyToolTypeEntityList.get(0).getSendType());
entity.setCurSts(createDept);
entityList.add(entity);
});
this.saveBatch(entityList);
}
}
}
/**
* 安全工器具二维码导出
* @param idList
* @return 文件路径
*/
@Override
public String safetyToolRQExport(List idList){
List<SafetyToolEntity> entityList = null;
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();
}
if(CollectionUtil.isNotEmpty(entityList)){
List<SafeProductPdf> pdfList = new ArrayList<>(entityList.size());
entityList.forEach(entity->{
String imgPath = uploadPath + "/" + entity.getTenantId() + entity.getToolCode() + UPLOAD_IMG_SUFFIX;
File file = new File(imgPath);
if (!file.exists()) {
/**生成二维码**/
ZXingGenCode.encode("AQQJ=" + entity.getId(), 200, 200, imgPath, BarcodeFormat.QR_CODE);
}
}
if (!super.updateBatchById(safetyTools)) {
throw new RuntimeException("数据库update操作失败!");
}
SafeProductPdf safeProductPdf = new SafeProductPdf();
safeProductPdf.setData_1(entity.getToolName());
safeProductPdf.setData_2(DateUtil.format(entity.getCreateTime(),"yyyy年MM月dd日"));
safeProductPdf.setData_3(imgPath);
pdfList.add(safeProductPdf);
});
//插入复核记录
List<SafetyToolRecheckEntity> safetyToolRechecks = new ArrayList<>(safetyTools.size());
for (SafetyToolEntity item : safetyTools) {
SafetyToolRecheckEntity entity = new SafetyToolRecheckEntity();
entity.setCheckUserName(userName);
entity.setCheckUserId(userId);
entity.setToolId(item.getId());
entity.setCheckTime(currentTime);
entity.setRemark(req.getRemark());
safetyToolRechecks.add(entity);
}
if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) {
throw new RuntimeException("数据库insert操作失败!");
}
/**二维码写入html文件中成功后生成pdf文件地址**/
String pdfPath = uploadPath + "/" + UUID.randomUUID().toString() + ".pdf";
try{
/**将生成二维码写入html文件内**/
String html = HtmlModule.buildHtml(pdfList, modulePath);
HtmltoPdf.htmlToPdf(html, pdfPath);
return pdfPath;
}
catch (Exception e){
throw new ServiceException("导出pdf发生异常:"+e.getMessage());
}
}
else{
return null;
}
}
@Override
public R remove(List<Long> idList) {
List<SafetyToolEntity> toolEntityList = list(new LambdaQueryWrapper<SafetyToolEntity>(){{
in(SafetyToolEntity::getId,idList);
isNotNull(SafetyToolEntity::getNextCheckTime);
orderByDesc(SafetyToolEntity::getNextCheckTime);
}});
return R.status(deleteLogic(idList));
}
}
@Override
public void exportExcel(SafetyToolDTO req) {
List<SafetyToolEntity> list = safetyToolMapper.selectList(this.getListCondition(req));
List<SafetyToolExcel> data = SafetyToolWrapper.build().entityExcelList(list, sysClient, safetyToolTypeMapper);
ExcelUtil.export(httpServletResponse, "安全工器具" + System.currentTimeMillis(), "安全工器具", data, SafetyToolExcel.class);
}
/**
* 工器具Code唯一性校验
*/
private void toolCodeUniquenessCheck(Long id, String toolCode) {
SafetyToolEntity entity = safetyToolMapper.selectOne(new LambdaQueryWrapper<SafetyToolEntity>().eq(SafetyToolEntity::getToolCode, toolCode));
if (entity != null && !entity.getId().equals(id)) {
throw new RuntimeException(String.format("编号[%s]已经被使用!", toolCode));
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(MultipartFile file, Long createDept) {
String filename = file.getOriginalFilename();
ExcelToolListener excelToolListener = new ExcelToolListener();
if (StringUtils.isEmpty(filename)) {
throw new ExcelException("请上传文件!");
} else if (!StringUtils.endsWithIgnoreCase(filename, ".xls") && !StringUtils.endsWithIgnoreCase(filename, ".xlsx")) {
throw new ExcelException("请上传正确的excel文件!");
} else {
try {
InputStream inputStream = new BufferedInputStream(file.getInputStream());
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)) {
List<SafetyToolEntity> entityList = new ArrayList<>();
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), () -> {
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);
Assert.isTrue(Func.isNotEmpty(entity.getToolCode()) && Func.isNotEmpty(entity.getToolName())
&& 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)) {
throw new ServiceException(String.format("编号[%s]已经被使用!", entity.getToolCode()));
}
List<SafetyToolTypeEntity> safetyToolTypeEntityList = safetyToolTypeService.list(Wrappers.<SafetyToolTypeEntity>lambdaQuery()
.eq(SafetyToolTypeEntity::getTypeName, safetyToolSaveExcel.getTypeName()));
Assert.isTrue(safetyToolTypeEntityList.size() > 0, () -> {
throw new ServiceException("第" + index + "行填入类型未找到相关记录,请修改后重新导入");
});
//验证账户
String userIds = Arrays.stream(safetyToolSaveExcel.getAccounts().split(",")).map(account -> {
R<User> userR = userClient.userByAccount(AuthUtil.getTenantId(), account);
Assert.isTrue(userR.isSuccess() && ObjectUtil.isNotEmpty(userR.getData()), () -> {
throw new ServiceException("第" + index + "行填入用户账号未找到相关记录,请修改后重新导入");
});
return userR.getData();
}).map(User::getId).map(id -> Func.isNotEmpty(id) ? id.toString() : "").collect(Collectors.joining(","));
entity.setNoticeUsers(userIds);
entity.setTypeId(safetyToolTypeEntityList.get(0).getId());
entity.setSendType(safetyToolTypeEntityList.get(0).getSendType());
entity.setCurSts(createDept);
entityList.add(entity);
});
this.saveBatch(entityList);
}
}
/**
* 获取列表查询条件
*/
private Wrapper<SafetyToolEntity> getListCondition(SafetyToolDTO req) {
return new LambdaQueryWrapper<SafetyToolEntity>() {{
orderByDesc(SafetyToolEntity::getCreateTime);
if (null != req.getTypeId()) {
eq(SafetyToolEntity::getTypeId, req.getTypeId());
}
if (StringUtil.isNotBlank(req.getToolCode())) {
like(SafetyToolEntity::getToolCode, "%".concat(req.getToolCode()).concat("%"));
}
if (StringUtil.isNotBlank(req.getToolName())) {
like(SafetyToolEntity::getToolName, req.getToolName());
}
}};
}
/**
* 安全工器具二维码导出
*
* @param idList
* @return 文件路径
*/
@Override
public String safetyToolRQExport(List idList) {
List<SafetyToolEntity> entityList = null;
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();
}
if (CollectionUtil.isNotEmpty(entityList)) {
List<SafeProductPdf> pdfList = new ArrayList<>(entityList.size());
entityList.forEach(entity -> {
String imgPath = uploadPath + "/" + entity.getTenantId() + entity.getToolCode() + UPLOAD_IMG_SUFFIX;
File file = new File(imgPath);
if (!file.exists()) {
/**生成二维码**/
ZXingGenCode.encode("AQQJ=" + entity.getId(), 200, 200, imgPath, BarcodeFormat.QR_CODE);
}
SafeProductPdf safeProductPdf = new SafeProductPdf();
safeProductPdf.setData_1(entity.getToolName());
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 {
/**将生成二维码写入html文件内**/
String html = HtmlModule.buildHtml(pdfList, modulePath);
HtmltoPdf.htmlToPdf(html, pdfPath);
return pdfPath;
} catch (Exception e) {
throw new ServiceException("导出pdf发生异常:" + e.getMessage());
}
} else {
return null;
}
}
@Override
public R remove(List<Long> idList) {
List<SafetyToolEntity> toolEntityList = list(new LambdaQueryWrapper<SafetyToolEntity>() {{
in(SafetyToolEntity::getId, idList);
isNotNull(SafetyToolEntity::getNextCheckTime);
orderByDesc(SafetyToolEntity::getNextCheckTime);
}});
return R.status(deleteLogic(idList));
}
/**
* 工器具Code唯一性校验
*/
private void toolCodeUniquenessCheck(Long id, String toolCode) {
SafetyToolEntity entity = safetyToolMapper.selectOne(new LambdaQueryWrapper<SafetyToolEntity>().eq(SafetyToolEntity::getToolCode, toolCode));
if (entity != null && !entity.getId().equals(id)) {
throw new RuntimeException(String.format("编号[%s]已经被使用!", toolCode));
}
}
/**
* 获取列表查询条件
*/
private Wrapper<SafetyToolEntity> getListCondition(SafetyToolDTO req) {
return new LambdaQueryWrapper<SafetyToolEntity>() {{
orderByDesc(SafetyToolEntity::getCreateTime);
if (null != req.getTypeId()) {
eq(SafetyToolEntity::getTypeId, req.getTypeId());
}
if (StringUtil.isNotBlank(req.getToolCode())) {
like(SafetyToolEntity::getToolCode, "%".concat(req.getToolCode()).concat("%"));
}
if (StringUtil.isNotBlank(req.getToolName())) {
like(SafetyToolEntity::getToolName, req.getToolName());
}
}};
}
}

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