| | |
| | | List<Map<String, Object>> treeDevice(@Param("deviceName") String deviceName); |
| | | |
| | | DeviceDto selectDeviceByCode(Integer id); |
| | | |
| | | /** |
| | | * 查询到达校准有效期的设备-提前5天 |
| | | * @return |
| | | */ |
| | | List<Device> selectOverdueDevice(); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.utils.WxCpUtils; |
| | | import com.ruoyi.device.dto.DeviceRecordDto; |
| | | import com.ruoyi.device.mapper.DeviceMapper; |
| | | import com.ruoyi.device.mapper.DeviceRecordMapper; |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.pojo.DeviceRecord; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | */ |
| | | @Component |
| | | public class DeviceRecordSchedule { |
| | | |
| | | @Resource |
| | | private DeviceMapper deviceMapper; |
| | | @Resource |
| | | private DeviceRecordMapper deviceRecordMapper; |
| | | @Resource |
| | |
| | | |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 每天9点执行一次 除了星期天 |
| | | * 判断是否有设备到达校准有效期 |
| | | */ |
| | | // @Scheduled(cron = "0/5 * * * * *") |
| | | @Scheduled(cron = "0 0 9 * * 1-6") // 每天9点执行一次 除了星期天 |
| | | public void task2() { |
| | | // 查询到达校准有效期的设备-提前5天 |
| | | List<Device> deviceList = deviceMapper.selectOverdueDevice(); |
| | | Map<Integer, List<Device>> userPersonIdMap = deviceList.stream().collect(Collectors.groupingBy(Device::getEquipmentManager)); |
| | | userPersonIdMap.forEach((userId, recordList) -> { |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // 企业微信通知填写设备使用记录 |
| | | User user = userMapper.selectById(userId); |
| | | String message = ""; |
| | | message += "设备使用记录未填写提醒通知"; |
| | | for (Device deviceRecord : recordList) { |
| | | message += "\n设备名称编号: " + deviceRecord.getDeviceName() + "-" + deviceRecord.getManagementNumber(); |
| | | message += "\n委托编号: " + deviceRecord.getSampleCode(); |
| | | message += "\n"; |
| | | } |
| | | message += "\n请去填写设备使用记录"; |
| | | |
| | | //发送企业微信消息通知 |
| | | try { |
| | | WxCpUtils.inform(user.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | <resultMap id="deviceNameMap" type="map"> |
| | | <result property="value" column="id"/> |
| | | <result property="label" column="device_name"/> |
| | | <result property="activationDate" column="activation_date"/> |
| | | <result property="managementNumber" column="management_number"/> |
| | | </resultMap> |
| | | |
| | |
| | | case when d.storage_point is null || d.storage_point ='' then '其他' else d.storage_point end as storage_point, |
| | | d.device_name, |
| | | d.management_number, |
| | | null as value |
| | | null as value, |
| | | d.activation_date |
| | | from device d |
| | | LEFT JOIN laboratory l ON l.id = d.subordinate_departments_id |
| | | <where> |
| | |
| | | and device_name like concat('%',#{deviceName},'%') |
| | | </if> |
| | | </where> |
| | | order by l.laboratory_name desc, d.storage_point desc |
| | | </select> |
| | | |
| | | <select id="selectDeviceByCode" resultType="com.ruoyi.device.dto.DeviceDto"> |
| | |
| | | u1.name, |
| | | u2.name |
| | | </select> |
| | | |
| | | <!-- 查询到达校准有效期的设备-提前5天 --> |
| | | <select id="selectOverdueDevice" resultType="com.ruoyi.device.pojo.Device"> |
| | | SELECT * |
| | | FROM device |
| | | WHERE |
| | | -- 筛选出 activation_date 在当前日期前五天内的数据 |
| | | activation_date BETWEEN now() AND now() + INTERVAL 5 DAY |
| | | -- 筛选出 activation_date 已经超过当前日期的数据 |
| | | OR activation_date < now() |
| | | </select> |
| | | </mapper> |
| | |
| | | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| | | |
| | | /** |
| | | * 提醒填写设备使用记录 |
| | | * 提醒填写人员培训记录 |
| | | */ |
| | | // @Scheduled(cron = "0/5 * * * * *") |
| | | @Scheduled(cron = "0 0 9 1 * *") // 每月一号执行 |
| | | @Scheduled(cron = "0 0 9 1,15 * *") // 每月一号执行 |
| | | public void task1() { |
| | | // 查询当月培训计划 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.M"); |
| | |
| | | public void exportSuperviseDetailRecord(Integer superviseDetailsId, HttpServletResponse response) { |
| | | QualitySuperviseDetailsRecord recordDto = qualitySuperviseDetailsRecordMapper.selectSuperviseDetailRecord(superviseDetailsId); |
| | | |
| | | //获取技术负责人的签名地址 |
| | | String ratifyUrl = null; |
| | | if (recordDto.getRatifyUserId() != null) { |
| | | ratifyUrl = userMapper.selectById(recordDto.getRatifyUserId()).getSignatureUrl(); |
| | | if (StringUtils.isBlank(ratifyUrl)) { |
| | | throw new ErrorException("找不到技术负责人的签名"); |
| | | } |
| | | // 查询检测人员 |
| | | User tserUser = new User(); |
| | | if (StringUtils.isNotBlank(recordDto.getTestMember())) { |
| | | tserUser = userMapper.selectOne(Wrappers.<User>lambdaQuery() |
| | | .eq(User::getName, recordDto.getTestMember()) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | // 获取路径 |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/supervision-detail-record.docx"); |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | String finalRatifyUrl = ratifyUrl; |
| | | User finalTserUser = tserUser; |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("supervision", recordDto); |
| | | put("testMemberUrl", UserUtils.getFinalUserSignatureUrl(finalTserUser.getId())); |
| | | put("supervisoruUrl", UserUtils.getFinalUserSignatureUrl(recordDto.getSupervisor())); |
| | | put("technicalDirectorUrl", StringUtils.isNotBlank(finalRatifyUrl) ? Pictures.ofLocal(imgUrl + "/" + finalRatifyUrl).create() : null); |
| | | put("technicalDirectorUrl", UserUtils.getFinalUserSignatureUrl(recordDto.getRatifyUserId())); |
| | | put("technicalDirectorDateUrl", recordDto.getRatifyTime() != null ? |
| | | Pictures.ofStream(DateImageUtil.createDateImage(recordDto.getRatifyTime())).create() : null); |
| | | }}); |
| | |
| | | |
| | | // 修改检验项 |
| | | for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) { |
| | | insSampleService.update(Wrappers.<InsSample>lambdaUpdate() |
| | | .eq(InsSample::getId, sampleProductDto.getId()) |
| | | .set(InsSample::getSpecialStandardMethod, sampleProductDto.getSpecialStandardMethod())); |
| | | |
| | | insProductService.updateBatchById(sampleProductDto.getInsProduct()); |
| | | } |
| | | |