From 250e77fd3faf2e503870cc21f6a6c97f003e5dd7 Mon Sep 17 00:00:00 2001 From: “linengliang” <vanSuperEnergy@163.com> Date: 星期三, 25 十月 2023 18:39:22 +0800 Subject: [PATCH] 数据权限 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/RepairOrder.java | 2 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/RepairOrderMapper.xml | 3 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/RepairOrderMapper.java | 3 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/RepairOrderWarning.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/RepairOrderServiceImpl.java | 13 ++++++ 5 files changed, 115 insertions(+), 2 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/RepairOrder.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/RepairOrder.java index c0fa349..1b82779 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/RepairOrder.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/RepairOrder.java @@ -284,6 +284,8 @@ private String factoryModelId; @TableField(exist = false) private String equipmentCategoryId; + @TableField(exist = false) + private String userId; } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/RepairOrderWarning.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/RepairOrderWarning.java new file mode 100644 index 0000000..c4ddca3 --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/RepairOrderWarning.java @@ -0,0 +1,96 @@ +package org.jeecg.modules.eam.job; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import org.jeecg.common.api.dto.message.MessageDTO; +import org.jeecg.common.system.api.ISysBaseAPI; +import org.jeecg.modules.eam.entity.Equipment; +import org.jeecg.modules.eam.entity.EquipmentReportRepair; +import org.jeecg.modules.eam.service.IEamEquipmentService; +import org.jeecg.modules.eam.service.IEquipmentReportRepairService; +import org.jeecg.modules.eam.service.IPredictiveWorkPlanWarnService; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysUserService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; +import java.util.List; + +/** + * @author 鏉庤兘闈� + */ +public class RepairOrderWarning implements Job { + @Resource + private IEquipmentReportRepairService equipmentReportRepairService; + + @Resource + private IEamEquipmentService equipmentService; + + @Resource + private ISysBaseAPI sysBaseAPI; + + @Resource + private ISysUserService sysUserService; + + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + LocalDateTime currentDateTime = LocalDateTime.now(); + LocalDateTime dateBefore3Days = currentDateTime.minusDays(3); + LocalDateTime dateBefore1Days = currentDateTime.minusDays(1); + Date result3 = Date.from(dateBefore3Days.atZone(ZoneId.systemDefault()).toInstant()); + Date result1= Date.from(dateBefore1Days.atZone(ZoneId.systemDefault()).toInstant()); + List<EquipmentReportRepair> equipmentReportRepairs1 = equipmentReportRepairService.list(new QueryWrapper<EquipmentReportRepair>().lt("fault_time",result1).eq("status","1")); + List<EquipmentReportRepair> equipmentReportRepairs3 = equipmentReportRepairService.list(new QueryWrapper<EquipmentReportRepair>().lt("fault_time",result3).eq("status","1")); + for(EquipmentReportRepair equipmentReportRepair1:equipmentReportRepairs1){ + Equipment equipment1 = equipmentService.getById(equipmentReportRepair1.getEquipmentId()); + if(StringUtils.isNotBlank(equipment1.getSpecificEquipment())){ + String teamId = equipment1.getTeamId(); + if(StringUtils.isNotBlank(teamId)){ + List<SysUser> sysUsers = sysUserService.list(new QueryWrapper<SysUser>() + .eq("team_id",teamId) + .eq("del_flag",0)); + for(SysUser user:sysUsers){ + String msg = "缁熶竴缂栧彿涓恒��"+equipment1.getNum()+"銆戠殑璁惧宸茬粡瓒呰繃涓�澶╂湭缁翠慨锛岃绉绘鑷虫晠闅滄姤淇煡鐪�"; + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setTitle("鏁呴殰鎶ヤ慨鎻愰啋"); + messageDTO.setContent(msg); + messageDTO.setCategory("鏁呴殰鎶ヤ慨鎻愰啋"); + messageDTO.setFromUser("鏁呴殰鎶ヤ慨鎻愰啋灏忓姪鎵�"); + messageDTO.setToUser(user.getUsername()); + sysBaseAPI.sendSysAnnouncement(messageDTO); + } + } + } + + } + + for(EquipmentReportRepair equipmentReportRepair3:equipmentReportRepairs3){ + Equipment equipment3 = equipmentService.getById(equipmentReportRepair3.getEquipmentId()); + if(StringUtils.isNotBlank(equipment3.getSpecificEquipment())){ + String teamId = equipment3.getTeamId(); + if(StringUtils.isNotBlank(teamId)){ + List<SysUser> sysUsers = sysUserService.list(new QueryWrapper<SysUser>() + .eq("team_id",teamId) + .eq("del_flag",0)); + for(SysUser user:sysUsers){ + String msg = "缁熶竴缂栧彿涓恒��"+equipment3.getNum()+"銆戠殑璁惧宸茬粡瓒呰繃涓夊ぉ鏈淮淇紝璇风Щ姝ヨ嚦鏁呴殰鎶ヤ慨鏌ョ湅"; + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setTitle("鏁呴殰鎶ヤ慨鎻愰啋"); + messageDTO.setContent(msg); + messageDTO.setCategory("鏁呴殰鎶ヤ慨鎻愰啋"); + messageDTO.setFromUser("鏁呴殰鎶ヤ慨鎻愰啋灏忓姪鎵�"); + messageDTO.setToUser(user.getUsername()); + sysBaseAPI.sendSysAnnouncement(messageDTO); + } + } + } + } + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/RepairOrderMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/RepairOrderMapper.java index c568a66..6e65ac6 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/RepairOrderMapper.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/RepairOrderMapper.java @@ -33,7 +33,8 @@ @Param("repairOrderType") Integer repairOrderType, @Param("equipmentCategoryId") String equipmentCategoryId, @Param("factoryModelId") String factoryModelId, - @Param("specificEquipment") String specificEquipment + @Param("specificEquipment") String specificEquipment, + @Param("teamId") String teamId ); IPage<Map<String, Object>> getUserTeam(IPage<Map> pageData, @Param("realname") String realname); diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/RepairOrderMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/RepairOrderMapper.xml index 87f5160..aa3a807 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/RepairOrderMapper.xml +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/RepairOrderMapper.xml @@ -71,6 +71,9 @@ <if test="specificEquipment != null and specificEquipment != ''"> and t2.specific_equipment = #{specificEquipment} </if> + <if test="teamId != null and teamId != ''"> + and t1.team_id = #{teamId} + </if> and t1.repair_order_type = #{repairOrderType} order by t1.create_time desc </select> diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/RepairOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/RepairOrderServiceImpl.java index 07867b0..e56b625 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/RepairOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/RepairOrderServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.eam.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.eam.entity.RepairOrder; @@ -8,6 +9,8 @@ import org.jeecg.modules.eam.mapper.*; import org.jeecg.modules.eam.service.IRepairOrderDetailService; import org.jeecg.modules.eam.service.IRepairOrderService; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +45,8 @@ private RepairOrderActualWorkHoursMapper repairOrderActualWorkHoursMapper; @Autowired private EquipmentDocumentMapper equipmentDocumentMapper; + @Autowired + private SysUserMapper sysUserMapper; @@ -75,8 +80,14 @@ @Override public Page<RepairOrder> getRepairOrderList(Page<RepairOrder> page, RepairOrder repairOrder) { + if(StringUtils.isNotBlank(repairOrder.getUserId())){ + SysUser sysUser = sysUserMapper.selectById(repairOrder.getUserId()); + repairOrder.setTeamId(sysUser.getTeamId()); + }else{ + repairOrder.setTeamId(""); + } - return page.setRecords(baseMapper.getRepairOrderList(page,repairOrder.getNum(),repairOrder.getEquipmentNum(),repairOrder.getEquipmentName(),repairOrder.getStatus(),repairOrder.getRepairOrderType(),repairOrder.getEquipmentCategoryId(),repairOrder.getFactoryModelId(),repairOrder.getSpecificEquipment())); + return page.setRecords(baseMapper.getRepairOrderList(page,repairOrder.getNum(),repairOrder.getEquipmentNum(),repairOrder.getEquipmentName(),repairOrder.getStatus(),repairOrder.getRepairOrderType(),repairOrder.getEquipmentCategoryId(),repairOrder.getFactoryModelId(),repairOrder.getSpecificEquipment(),repairOrder.getTeamId())); } @Override -- Gitblit v1.9.3