src/main/java/com/ruoyi/approve/service/impl/ApproveProcessServiceImpl.java
@@ -440,6 +440,8 @@ return "危险作业审批"; case 9: return "入库审批"; case 10: return "通知"; } return null; } src/main/java/com/ruoyi/production/controller/ProductInspectionRecordController.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.domain.AjaxResult; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Objects; /** * <p> @@ -34,6 +36,11 @@ @Log(title = "巡检记录 分页查询", businessType = BusinessType.OTHER) public AjaxResult page(ProductInspectionRecordDto productInspectionRecord, Page<ProductInspectionRecord> page) { LambdaQueryWrapper<ProductInspectionRecord> ew = Wrappers.<ProductInspectionRecord>lambdaQuery(); ew.eq(StringUtils.isNotEmpty(productInspectionRecord.getProcess()), ProductInspectionRecord::getProcess, productInspectionRecord.getProcess()) .eq(StringUtils.isNotEmpty(productInspectionRecord.getProcessId()), ProductInspectionRecord::getProcessId, productInspectionRecord.getProcessId()) .between(Objects.nonNull(productInspectionRecord.getStartTime()) && Objects.nonNull(productInspectionRecord.getEndTime()), ProductInspectionRecord::getInspectionTime, productInspectionRecord.getStartTime(), productInspectionRecord.getEndTime()); return AjaxResult.success(productInspectionRecordService.page(page, ew)); } @@ -61,4 +68,12 @@ productInspectionRecordService.removeBatchByIds(ids); return AjaxResult.success(); } @ApiOperation("巡检记录 通知") @PostMapping("/notify") @Log(title = "巡检记录 通知", businessType = BusinessType.OTHER) public AjaxResult notify(@RequestBody List<Long> ids) { productInspectionRecordService.notify(ids); return AjaxResult.success("发送通知成功"); } } src/main/java/com/ruoyi/production/dto/ProductInspectionRecordDto.java
@@ -1,7 +1,10 @@ package com.ruoyi.production.dto; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.production.pojo.ProductInspectionRecord; import lombok.Data; import java.time.LocalDateTime; /** * @author yuan @@ -10,4 +13,8 @@ */ @Data public class ProductInspectionRecordDto extends ProductInspectionRecord { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime startTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime endTime; } src/main/java/com/ruoyi/production/pojo/ProductInspectionRecord.java
@@ -35,6 +35,9 @@ @TableId(value = "id", type = IdType.AUTO) private Long id; @ApiModelProperty("工序id") private String processId; @ApiModelProperty("工序") private String process; @@ -50,7 +53,12 @@ @ApiModelProperty("判定(yes合格 / no不合格)") private String judgement; @ApiModelProperty("不合格订单") private String unqualifiedOrder; @ApiModelProperty("巡检时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime inspectionTime; @ApiModelProperty("巡检员") src/main/java/com/ruoyi/production/service/ProductInspectionRecordService.java
@@ -2,6 +2,7 @@ import com.ruoyi.production.pojo.ProductInspectionRecord; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * <p> @@ -13,4 +14,10 @@ */ public interface ProductInspectionRecordService extends IService<ProductInspectionRecord> { /** * 发送巡检记录通知 * * @param ids 巡检记录ID列表 */ void notify(List<Long> ids); } src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java
@@ -1,10 +1,21 @@ package com.ruoyi.production.service.impl; import com.ruoyi.production.pojo.ProductInspectionRecord; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.production.mapper.ProductInspectionRecordMapper; import com.ruoyi.production.pojo.ProductInspectionRecord; import com.ruoyi.production.service.ProductInspectionRecordService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.project.system.domain.SysNotice; import com.ruoyi.project.system.domain.SysUser; import com.ruoyi.project.system.mapper.SysUserMapper; import com.ruoyi.project.system.service.ISysNoticeService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; /** * <p> @@ -14,7 +25,90 @@ * @author 芯导软件(江苏)有限公司 * @since 2026-03-16 04:16:32 */ @Slf4j @Service public class ProductInspectionRecordServiceImpl extends ServiceImpl<ProductInspectionRecordMapper, ProductInspectionRecord> implements ProductInspectionRecordService { public class ProductInspectionRecordServiceImpl extends ServiceImpl<ProductInspectionRecordMapper, ProductInspectionRecord> implements ProductInspectionRecordService { private static final String OP_POST_CODE = "op"; @Autowired private SysUserMapper userMapper; @Autowired private ISysNoticeService noticeService; @Override @Transactional(rollbackFor = Exception.class) public void notify(List<Long> ids) { if (ids == null || ids.isEmpty()) { return; } // 1. 查询巡检记录 List<ProductInspectionRecord> records = listByIds(ids); if (records == null || records.isEmpty()) { log.warn("未找到对应的巡检记录, ids={}", ids); return; } // 2. 查询岗位为op的用户 List<SysUser> opUsers = userMapper.selectUserListByPostCode(OP_POST_CODE); if (opUsers == null || opUsers.isEmpty()) { log.warn("未找到岗位编码为[{}]的用户", OP_POST_CODE); return; } // 3. 获取当前用户信息 Long currentUserId = SecurityUtils.getLoginUser().getUserId(); Long tenantId = SecurityUtils.getLoginUser().getTenantId(); // 4. 为每条巡检记录发送通知 List<SysNotice> notices = new ArrayList<>(); for (ProductInspectionRecord record : records) { // 过滤出不合格的记录 if (!"no".equalsIgnoreCase(record.getJudgement())) { continue; } // 构建消息内容:xxx生产订单,xx工序,xx检验项不合格,请及时对工艺及参数做调整! String productionOrder = record.getUnqualifiedOrder(); String process = record.getProcess(); String inspectionItem = record.getInspectionItem(); StringBuilder messageBuilder = new StringBuilder(); if (productionOrder != null && !productionOrder.isEmpty()) { messageBuilder.append(productionOrder).append("生产订单,"); } if (process != null && !process.isEmpty()) { messageBuilder.append(process).append("工序,"); } if (inspectionItem != null && !inspectionItem.isEmpty()) { messageBuilder.append(inspectionItem).append("检验项不合格,"); } messageBuilder.append("请及时对工艺及参数做调整!"); String title = "巡检不合格通知"; String message = messageBuilder.toString(); // 为每个op岗位用户创建通知 for (SysUser opUser : opUsers) { SysNotice notice = new SysNotice(); notice.setNoticeType("1"); notice.setNoticeTitle(title); notice.setNoticeContent(message); notice.setStatus("0"); notice.setConsigneeId(opUser.getUserId()); notice.setSenderId(currentUserId); notice.setTenantId(tenantId); notices.add(notice); } } // 5. 批量保存通知 if (!notices.isEmpty()) { noticeService.saveBatch(notices); log.info("已发送{}条巡检不合格通知给{}个op岗位用户", notices.size(), opUsers.size()); } } } src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
@@ -156,4 +156,12 @@ List<Long> getUserByRole(@Param("role") String role); List<Long> getUserByPerms(@Param("perms") List<String> perms); /** * 根据岗位编码查询用户ID列表 * * @param postCode 岗位编码 * @return 用户ID列表 */ List<SysUser> selectUserListByPostCode(@Param("postCode") String postCode); } src/main/java/com/ruoyi/quality/mapper/QualityTestStandardParamMapper.java
@@ -1,5 +1,6 @@ package com.ruoyi.quality.mapper; import com.ruoyi.quality.pojo.QualityTestStandard; import com.ruoyi.quality.pojo.QualityTestStandardParam; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -20,4 +21,6 @@ public interface QualityTestStandardParamMapper extends BaseMapper<QualityTestStandardParam> { List<QualityTestStandardParam> selectListByProductId(@Param("productId") Long productId); List<QualityTestStandardParam> selectParameterItemByProcessOrCategory(@Param("id") Long id, @Param("inspectType") Integer inspectType); } src/main/java/com/ruoyi/quality/service/IQualityTestStandardService.java
@@ -26,5 +26,5 @@ int delQualityTestStandard(List<Integer> ids); List<QualityTestStandard> getParameterItemByProcessOrCategory(Long id, Integer inspectType); List<QualityTestStandardParam> getParameterItemByProcessOrCategory(Long id, Integer inspectType); } src/main/java/com/ruoyi/quality/service/impl/QualityTestStandardServiceImpl.java
@@ -90,10 +90,8 @@ } @Override public List<QualityTestStandard> getParameterItemByProcessOrCategory(Long id, Integer inspectType) { return baseMapper.selectList(Wrappers.<QualityTestStandard>lambdaQuery() .eq(Objects.nonNull(id),QualityTestStandard::getProcessId, id) .eq(QualityTestStandard::getInspectType, inspectType)); public List<QualityTestStandardParam> getParameterItemByProcessOrCategory(Long id, Integer inspectType) { return qualityTestStandardParamMapper.selectParameterItemByProcessOrCategory(id, inspectType); } src/main/resources/mapper/quality/QualityTestStandardParamMapper.xml
@@ -23,5 +23,13 @@ left join quality_test_standard_binding t3 on t2.id = t3.test_standard_id where t3.product_id = #{productId} </select> <select id="selectParameterItemByProcessOrCategory" resultType="com.ruoyi.quality.pojo.QualityTestStandardParam"> select * from quality_test_standard qts left join quality_test_standard_param qtsp on qts.id = qtsp.test_standard_id where qts.process_id = #{id} and qts.inspect_type = #{inspectType} </select> </mapper> src/main/resources/mapper/system/SysUserMapper.xml
@@ -298,4 +298,16 @@ </if> </select> <!-- 根据岗位编码查询用户列表 --> <select id="selectUserListByPostCode" resultType="com.ruoyi.project.system.domain.SysUser"> SELECT DISTINCT u.user_id, u.user_name, u.nick_name, u.phonenumber, u.status, u.tenant_id FROM sys_user u LEFT JOIN sys_user_post up ON u.user_id = up.user_id LEFT JOIN sys_post p ON up.post_id = p.post_id WHERE u.del_flag = '0' AND u.status = '0' AND p.post_code = #{postCode} AND p.status = '0' </select> </mapper>