|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|