Merge remote-tracking branch 'origin/dev_New' into dev_New
已添加10个文件
已修改56个文件
已删除3个文件
| | |
| | | alter table staff_join_leave_record |
| | | add dimission_reason varchar(255) null, |
| | | add dimission_remark text null; |
| | | add dimission_reason varchar(255) null comment '离èåå ', |
| | | add dimission_remark text null comment '离è夿³¨'; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | alter table staff_join_leave_record |
| | | add sys_post_id bigint not null default 0 comment 'å²ä½id'; |
| | | alter table staff_join_leave_record |
| | | drop column post_job; |
| | | alter table staff_on_job |
| | | add sys_post_id bigint not null default 0 comment 'å²ä½id'; |
| | | alter table staff_on_job |
| | | drop column post_job; |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceDefectRecordDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceDefectRecord; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.DeviceDefectRecordService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceLedgerDto; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Anonymous; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.ehcache.spi.service.MaintainableService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "设å¤å°è´¦ç®¡ç") |
| | |
| | | public void export(HttpServletResponse response, Long[] ids) { |
| | | deviceLedgerService.export(response, ids); |
| | | } |
| | | /** |
| | | * |
| | | */ |
| | | @GetMapping("/report/forms") |
| | | @ApiOperation("æ¥è¯¢è®¾å¤å°è´¦å¾è¡¨æ°æ®") |
| | | public AjaxResult report() { |
| | | return AjaxResult.success(deviceLedgerService.report()); |
| | | } |
| | | |
| | | @PostMapping("import") |
| | | @ApiModelProperty("导å
¥è®¾å¤å°è´¦") |
| | | public AjaxResult importData(MultipartFile file) throws IOException { |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.device.service.IDeviceRepairService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | |
| | | @Api(tags = "设å¤ä¿å
»") |
| | |
| | | package com.ruoyi.device.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.approve.service.IApproveProcessService; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "è®¾å¤æ¥ä¿®ç®¡ç") |
| | | @RequestMapping("/device/repair") |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceLedgerService deviceLedgerService; |
| | | @Autowired |
| | | private IApproveProcessService approveProcessService; |
| | | |
| | | @ApiModelProperty("è®¾å¤æ¥ä¿®å表") |
| | | @GetMapping("/page") |
| | |
| | | } |
| | | |
| | | @PostMapping() |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @ApiModelProperty("æ·»å è®¾å¤æ¥ä¿®") |
| | | public AjaxResult add( @RequestBody DeviceRepair deviceRepair) throws Exception { |
| | | deviceRepairService.saveDeviceRepair(deviceRepair); |
| | | // todo å端代ç ä¸å¹é
ï¼å¾
å¤ç |
| | | // ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | // LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // // è·åå½åç»å½å
¬å¸ |
| | | // Long tenantId = loginUser.getTenantId(); |
| | | // if(null != tenantId){ |
| | | // //è·åå½åç»å½é¨é¨id |
| | | // approveProcessVO.setApproveDeptId(tenantId); |
| | | // //è·åå½åç»å½ç¨æ·id |
| | | // approveProcessVO.setApproveUser(loginUser.getUserId()); |
| | | // //è·åå½åæ¶é´ |
| | | // approveProcessVO.setApproveTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | // approveProcessVO.setApproveType(4); |
| | | // approveProcessVO.setApproveUserIds(deviceRepair.getApproverId().toString()); |
| | | // approveProcessVO.setApproveReason(deviceRepair.getRemark()); |
| | | // approveProcessVO.setDeviceRepairId(deviceRepair.getId()); |
| | | // approveProcessVO.setMaintenancePrice(deviceRepair.getMaintenancePrice()); |
| | | // approveProcessService.addApprove(approveProcessVO); |
| | | // } |
| | | return AjaxResult.success(); |
| | | public AjaxResult add( @RequestBody DeviceRepair deviceRepair) { |
| | | return deviceRepairService.saveDeviceRepair(deviceRepair); |
| | | } |
| | | |
| | | @ApiModelProperty("æ ¹æ®idæ¥è¯¢è®¾å¤æ¥ä¿®") |
| | |
| | | @DeleteMapping("/{ids}") |
| | | @ApiModelProperty("å é¤è®¾å¤æ¥ä¿®") |
| | | public AjaxResult delete(@PathVariable("ids") Long[] ids) { |
| | | LambdaQueryWrapper<ApproveProcess> QueryWrapper = new LambdaQueryWrapper<>(); |
| | | QueryWrapper.in(ApproveProcess::getDeviceRepairId,ids); |
| | | List<ApproveProcess> approveProcessList = approveProcessService.list(QueryWrapper); |
| | | if(!approveProcessList.isEmpty()){ |
| | | approveProcessList.forEach(approveProcess -> { |
| | | if (approveProcess.getApproveStatus() != 0){ |
| | | //æåºå¼å¸¸ |
| | | throw new RuntimeException("ææ£å¨å¤çä¸çå®¡æ¹æµç¨ï¼ä¸è½å é¤"); |
| | | } |
| | | }); |
| | | } |
| | | boolean b = deviceRepairService.removeBatchByIds(Arrays.asList(ids)); |
| | | if (!b) { |
| | | return AjaxResult.error("å é¤å¤±è´¥"); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | import com.ruoyi.device.service.MaintenanceTaskService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/12/22 14:58 |
| | | */ |
| | | @Api(tags = "设å¤ä¿å
»å®æ¶ä»»å¡ç®¡ç") |
| | | @RestController |
| | | @RequestMapping("/deviceMaintenanceTask") |
| | | public class MaintenanceTaskController extends BaseController { |
| | | |
| | | |
| | | @Autowired |
| | | private MaintenanceTaskService maintenanceTaskService; |
| | | |
| | | |
| | | @GetMapping("/listPage") |
| | | @ApiOperation(value = "设å¤ä¿å
»å®æ¶ä»»å¡å表") |
| | | public AjaxResult listPage(Page page, MaintenanceTask maintenanceTask) { |
| | | return maintenanceTaskService.listPage(page,maintenanceTask); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "æ·»å 设å¤ä¿å
»å®æ¶ä»»å¡") |
| | | @Log(title = "设å¤ä¿å
»å®æ¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody MaintenanceTask maintenanceTask) { |
| | | return maintenanceTaskService.add(maintenanceTask); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation(value = "ä¿®æ¹è®¾å¤ä¿å
»å®æ¶ä»»å¡") |
| | | @Log(title = "设å¤ä¿å
»å®æ¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | public AjaxResult update(@RequestBody MaintenanceTask maintenanceTask) { |
| | | return maintenanceTaskService.updateByMaintenanceTaskId(maintenanceTask); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation(value = "å é¤è®¾å¤ä¿å
»å®æ¶ä»»å¡") |
| | | @Log(title = "设å¤ä¿å
»å®æ¶ä»»å¡", businessType = BusinessType.DELETE) |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | return maintenanceTaskService.delete(ids); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class DeviceMaintenanceDto { |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | |
| | | @ApiModelProperty("ç§æ·id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | @ApiModelProperty("ç»´ä¿®ä»·æ ¼") |
| | | private String maintenancePrice; |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.device.execl; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class DeviceLedgerExeclDto { |
| | |
| | | package com.ruoyi.device.execl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/12/22 14:56 |
| | | */ |
| | | public interface MaintenanceTaskMapper extends BaseMapper<MaintenanceTask> { |
| | | } |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 设å¤å°è´¦å®ä½ç±» |
| | |
| | | package com.ruoyi.device.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("device_maintenance") |
| | |
| | | @ApiModelProperty("设å¤å°è´¦id") |
| | | private Long deviceLedgerId; |
| | | |
| | | @ApiModelProperty("ä¿å
»ä»»å¡id") |
| | | private Long maintenanceTaskId; |
| | | |
| | | @ApiModelProperty(value = "颿¬¡") |
| | | private String frequencyType; |
| | | |
| | | @ApiModelProperty(value = "颿¬¡è¯¦æ
") |
| | | private String frequencyDetail; |
| | | |
| | | @ApiModelProperty(value = "䏿¬¡æ§è¡æ¶é´") |
| | | private LocalDateTime nextExecutionTime; |
| | | |
| | | @ApiModelProperty(value = "æåæ§è¡æ¶é´") |
| | | private LocalDateTime lastExecutionTime; |
| | | |
| | | |
| | | private String deviceName; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | |
| | | |
| | | @ApiModelProperty("设å¤å°è´¦id") |
| | | private Long deviceLedgerId; |
| | | @ApiModelProperty("设å¤åç§°") |
| | | |
| | | private String deviceName; |
| | | @ApiModelProperty("设å¤åå·") |
| | | |
| | | private String deviceModel; |
| | | |
| | | @ApiModelProperty("æ¥ä¿®æ¶é´") |
| | |
| | | @ApiModelProperty("ç»´ä¿®ç»æ") |
| | | private String maintenanceResult; |
| | | |
| | | @ApiModelProperty("ç¶æ:0å®¡æ ¸ä¸,1å®¡æ ¸éè¿,2å®¡æ ¸å¤±è´¥,3ç»´ä¿®ä¸,4ç»´ä¿®éè¿,5维修失败") |
| | | @ApiModelProperty("ç¶æ 0 å¾
ç»´ä¿® 1å®ç» 2 失败") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | |
| | | @ApiModelProperty("ç§æ·id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | @ApiModelProperty("ç»´ä¿®ä»·æ ¼") |
| | | private BigDecimal maintenancePrice; |
| | | @ApiModelProperty("审æ¹äººid") |
| | | private Integer approverId; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/9/19 10:27 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | @TableName("maintenance_task") |
| | | public class MaintenanceTask { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "è§æ ¼åå·") |
| | | private String deviceModel; |
| | | |
| | | /** |
| | | * 主é®ID |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "设å¤åç§°") |
| | | @Excel(name = "ä¿å
»ä»»å¡åç§°") |
| | | private String taskName; |
| | | |
| | | @ApiModelProperty(value = "设å¤id") |
| | | private Long taskId; |
| | | |
| | | @ApiModelProperty(value = "颿¬¡") |
| | | @Excel(name = "颿¬¡") |
| | | private String frequencyType; |
| | | |
| | | @ApiModelProperty(value = "颿¬¡è¯¦æ
") |
| | | @Excel(name = "å¼å§æ¥æä¸æ¶é´") |
| | | private String frequencyDetail; |
| | | |
| | | @ApiModelProperty(value = "䏿¬¡æ§è¡æ¶é´") |
| | | private LocalDateTime nextExecutionTime; |
| | | |
| | | @ApiModelProperty(value = "æåæ§è¡æ¶é´") |
| | | private LocalDateTime lastExecutionTime; |
| | | |
| | | @ApiModelProperty(value = "æ¯å¦æ¿æ´»") |
| | | private boolean isActive; |
| | | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remarks; |
| | | |
| | | @ApiModelProperty(value = "å½å
¥äººid") |
| | | private Long registrantId; |
| | | |
| | | @ApiModelProperty(value = "å½å
¥äºº") |
| | | @Excel(name = "å½å
¥äºº") |
| | | private String registrant; |
| | | |
| | | @ApiModelProperty(value = "å½å
¥æ¥æ") |
| | | @Excel(name = "å½å
¥æ¥æ", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate registrationDate; |
| | | |
| | | @ApiModelProperty(value = "ç¶æ") |
| | | private String status; |
| | | |
| | | @ApiModelProperty(value = "软å 餿 å¿ï¼0=æªå é¤ï¼1=å·²å é¤") |
| | | private Integer deleted; |
| | | |
| | | @TableField(exist = false) |
| | | private String dateStr; |
| | | |
| | | @ApiModelProperty(value = "å建该记å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½å建æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | // @JsonFormat(pattern = "yyyy-MM-dd") |
| | | // @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æåä¿®æ¹è¯¥è®°å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½æåæ´æ°æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.device.dto.DeviceAssetInfoDto; |
| | | import com.ruoyi.device.dto.DeviceLedgerDto; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | |
| | | public interface IDeviceLedgerService extends IService<DeviceLedger> { |
| | | IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger); |
| | |
| | | void export(HttpServletResponse response, Long[] ids); |
| | | |
| | | Boolean importData(MultipartFile file) throws IOException; |
| | | DeviceAssetInfoDto report(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/12/22 14:56 |
| | | */ |
| | | public interface MaintenanceTaskService extends IService<MaintenanceTask> { |
| | | AjaxResult listPage(Page page, MaintenanceTask maintenanceTask); |
| | | |
| | | AjaxResult add(MaintenanceTask maintenanceTask); |
| | | |
| | | AjaxResult updateByMaintenanceTaskId(MaintenanceTask maintenanceTask); |
| | | |
| | | AjaxResult delete(List<Long> ids); |
| | | } |
| | |
| | | import com.ruoyi.device.pojo.DeviceDefectRecord; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.DeviceDefectRecordService; |
| | | import com.ruoyi.device.service.IDeviceRepairService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.dto.DeviceAssetInfoDto; |
| | | import com.ruoyi.device.dto.DeviceLedgerDto; |
| | | import com.ruoyi.device.execl.DeviceLedgerExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.ZoneOffset; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | }); |
| | | |
| | | return true; |
| | | } |
| | | @Override |
| | | public DeviceAssetInfoDto report() { |
| | | List<DeviceLedger> list = deviceLedgerMapper.selectList(null); |
| | | DeviceAssetInfoDto deviceAssetInfoDto = new DeviceAssetInfoDto(); |
| | | deviceAssetInfoDto.setTotalEquipment(list.stream().map(DeviceLedger::getNumber).reduce(BigDecimal.ZERO, BigDecimal::add).intValue()); |
| | | deviceAssetInfoDto.setTotalOriginalValue(list.stream().map(DeviceLedger::getTaxIncludingPriceTotal).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | deviceAssetInfoDto.setTotalNetValue(list.stream().map(DeviceLedger::getUnTaxIncludingPriceTotal).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | deviceAssetInfoDto.setTotalDepreciation(deviceAssetInfoDto.getTotalOriginalValue().subtract(deviceAssetInfoDto.getTotalNetValue())); |
| | | return deviceAssetInfoDto; |
| | | } |
| | | } |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | import com.ruoyi.device.dto.DeviceDefectRecordDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.execl.DeviceRepairExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceDefectRecordMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceDefectRecord; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.device.service.DeviceDefectRecordService; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service.impl; |
| | | |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | import org.quartz.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.DayOfWeek; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.YearMonth; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | @DisallowConcurrentExecution // ç¦æ¢å¹¶åæ§è¡åä¸ä¸ªJob |
| | | public class MaintenanceTaskJob implements Job, Serializable { |
| | | private static final long serialVersionUID = 1L; // å¿
é¡»å®ä¹åºååID |
| | | |
| | | @Autowired |
| | | private DeviceMaintenanceServiceImpl deviceMaintenanceService; |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); |
| | | // ä¿®å¤ç±»å转æ¢éè¯¯ï¼æ£ç¡®è·åtaskId |
| | | Long taskId = jobDataMap.getLong("maintenanceTaskId"); |
| | | |
| | | try { |
| | | // 3. å°è¯æ¥è¯¢ä½ çä¸å¡æ°æ® |
| | | // éè¿JDBCæ¨¡æ¿æ¥è¯¢å®æ¶ä»»å¡ä¿¡æ¯ï¼ä½¿ç¨åæ°åæ¥è¯¢é²æ¢SQL注å
¥ |
| | | String yourSql = "SELECT * FROM maintenance_task where id = ?"; |
| | | List<MaintenanceTask> tasks = jdbcTemplate.query( |
| | | yourSql, |
| | | new BeanPropertyRowMapper<>(MaintenanceTask.class), |
| | | taskId |
| | | ); |
| | | MaintenanceTask timingTask = tasks.isEmpty() ? null : tasks.get(0); |
| | | if (timingTask == null) { |
| | | throw new JobExecutionException("MaintenanceTaskJobæ¾ä¸å°å®æ¶ä»»å¡: " + taskId); |
| | | } |
| | | |
| | | // 2. å建并ä¿åå·¡æ£ä»»å¡è®°å½ - è¿å°±æ¯æ¨æä¾ç代ç åºè¯¥æ¾çä½ç½® |
| | | DeviceMaintenance deviceMaintenance = createInspectionTask(timingTask); |
| | | deviceMaintenanceService.save(deviceMaintenance); |
| | | |
| | | // 3. æ´æ°å®æ¶ä»»å¡çæ§è¡æ¶é´ |
| | | if (!tasks.isEmpty()) { |
| | | MaintenanceTask task = tasks.get(0); |
| | | |
| | | // æ´æ°æåæ§è¡æ¶é´ä¸ºå½åæ¶é´ |
| | | LocalDateTime lastExecutionTime = LocalDateTime.now(); |
| | | |
| | | // 计ç®ä¸æ¬¡æ§è¡æ¶é´ |
| | | LocalDateTime nextExecutionTime = calculateNextExecutionTime( |
| | | task.getFrequencyType(), |
| | | task.getFrequencyDetail(), |
| | | lastExecutionTime |
| | | ); |
| | | |
| | | // æ§è¡æ´æ°æä½ |
| | | String updateSql = "UPDATE maintenance_task " + |
| | | "SET last_execution_time = ?, next_execution_time = ? " + |
| | | "WHERE id = ?"; |
| | | |
| | | jdbcTemplate.update( |
| | | updateSql, |
| | | lastExecutionTime, |
| | | nextExecutionTime, |
| | | taskId |
| | | ); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new JobExecutionException(e); |
| | | } |
| | | } |
| | | |
| | | // è¿å°±æ¯æ¨æä¾ç代ç å°è£
æçæ¹æ³ |
| | | private DeviceMaintenance createInspectionTask(MaintenanceTask timingTask) { |
| | | DeviceMaintenance inspectionTask = new DeviceMaintenance(); |
| | | |
| | | // å¤å¶åºæ¬å±æ§ |
| | | inspectionTask.setDeviceName(timingTask.getTaskName()); |
| | | inspectionTask.setMaintenanceTaskId(timingTask.getId()); |
| | | inspectionTask.setDeviceLedgerId(timingTask.getTaskId()); |
| | | inspectionTask.setMaintenancePlanTime(LocalDateTime.now()); |
| | | inspectionTask.setFrequencyType(timingTask.getFrequencyType()); |
| | | inspectionTask.setFrequencyDetail(timingTask.getFrequencyDetail()); |
| | | inspectionTask.setTenantId(timingTask.getTenantId()); |
| | | inspectionTask.setStatus(0); |
| | | inspectionTask.setDeviceModel(timingTask.getDeviceModel()); |
| | | inspectionTask.setCreateUser(Integer.parseInt(timingTask.getRegistrantId().toString())); |
| | | inspectionTask.setUpdateTime(LocalDateTime.now()); |
| | | inspectionTask.setCreateTime(LocalDateTime.now()); |
| | | inspectionTask.setUpdateUser(Integer.parseInt(timingTask.getRegistrantId().toString())); |
| | | return inspectionTask; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 计ç®ä¸æ¬¡æ§è¡æ¶é´ |
| | | */ |
| | | private LocalDateTime calculateNextExecutionTime(String frequencyType, |
| | | String frequencyDetail, |
| | | LocalDateTime currentTime) { |
| | | try { |
| | | switch (frequencyType) { |
| | | case "DAILY": |
| | | return calculateDailyNextTime(frequencyDetail, currentTime); |
| | | case "WEEKLY": |
| | | return calculateWeeklyNextTime(frequencyDetail, currentTime); |
| | | case "MONTHLY": |
| | | return calculateMonthlyNextTime(frequencyDetail, currentTime); |
| | | case "QUARTERLY": |
| | | return calculateQuarterlyNextTime(frequencyDetail, currentTime); |
| | | default: |
| | | throw new IllegalArgumentException("䏿¯æçé¢çç±»å: " + frequencyType); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("计ç®ä¸æ¬¡æ§è¡æ¶é´å¤±è´¥: " + e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ¯æ¥ä»»å¡ç䏿¬¡æ§è¡æ¶é´ |
| | | */ |
| | | private LocalDateTime calculateDailyNextTime(String timeStr, LocalDateTime current) { |
| | | LocalTime executionTime = LocalTime.parse(timeStr); // è§£ææ ¼å¼ "HH:mm" |
| | | LocalDateTime nextTime = LocalDateTime.of(current.toLocalDate(), executionTime); |
| | | |
| | | // 妿ä»å¤©çæ¶é´å·²è¿ï¼å宿æå¤© |
| | | return current.isBefore(nextTime) ? nextTime : nextTime.plusDays(1); |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ¯å¨ä»»å¡ç䏿¬¡æ§è¡æ¶é´ |
| | | */ |
| | | private LocalDateTime calculateWeeklyNextTime(String detail, LocalDateTime current) { |
| | | String[] parts = detail.split(","); |
| | | String dayOfWeekStr = parts[0]; // å¦ "MON" æ "MON|WED|FRI" |
| | | LocalTime time = LocalTime.parse(parts[1]); // æ¶é´é¨å |
| | | |
| | | // è§£æææå (æ¯æå¤ä¸ªææ) |
| | | Set<DayOfWeek> targetDays = parseDayOfWeeks(dayOfWeekStr); |
| | | |
| | | // ä»å½åæ¶é´å¼å§æ¾ä¸ä¸ä¸ªç¬¦åæ¡ä»¶çææå |
| | | LocalDateTime nextTime = current; |
| | | while (true) { |
| | | nextTime = nextTime.plusDays(1); |
| | | if (targetDays.contains(nextTime.getDayOfWeek())) { |
| | | return LocalDateTime.of(nextTime.toLocalDate(), time); |
| | | } |
| | | |
| | | // 鲿¢æ é循ç¯(ç论ä¸ä¸ä¼åç) |
| | | if (nextTime.isAfter(current.plusYears(1))) { |
| | | throw new RuntimeException("æ æ³æ¾å°ä¸æ¬¡æ§è¡æ¶é´"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ¯æä»»å¡ç䏿¬¡æ§è¡æ¶é´ |
| | | */ |
| | | private LocalDateTime calculateMonthlyNextTime(String detail, LocalDateTime current) { |
| | | String[] parts = detail.split(","); |
| | | int dayOfMonth = Integer.parseInt(parts[0]); |
| | | LocalTime time = LocalTime.parse(parts[1]); |
| | | |
| | | // ä»ä¸ä¸ªæå¼å§è®¡ç® |
| | | LocalDateTime nextTime = current.plusMonths(1) |
| | | .withDayOfMonth(Math.min(dayOfMonth, current.plusMonths(1).toLocalDate().lengthOfMonth())) |
| | | .with(time); |
| | | |
| | | return nextTime; |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ¯å£åº¦ä»»å¡ç䏿¬¡æ§è¡æ¶é´ |
| | | */ |
| | | private LocalDateTime calculateQuarterlyNextTime(String detail, LocalDateTime current) { |
| | | String[] parts = detail.split(","); |
| | | int quarterMonth = Integer.parseInt(parts[0]); // 1=第1个æï¼2=第2个æï¼3=第3个æ |
| | | int dayOfMonth = Integer.parseInt(parts[1]); |
| | | LocalTime time = LocalTime.parse(parts[2]); |
| | | |
| | | // 计ç®å½åå£åº¦ |
| | | int currentQuarter = (current.getMonthValue() - 1) / 3 + 1; |
| | | int currentMonthInQuarter = (current.getMonthValue() - 1) % 3 + 1; |
| | | |
| | | YearMonth targetYearMonth; |
| | | if (currentMonthInQuarter < quarterMonth) { |
| | | // æ¬å£åº¦å
è¿ææ§è¡æºä¼ |
| | | targetYearMonth = YearMonth.from(current) |
| | | .plusMonths(quarterMonth - currentMonthInQuarter); |
| | | } else { |
| | | // éè¦å°ä¸ä¸ªå£åº¦ |
| | | targetYearMonth = YearMonth.from(current) |
| | | .plusMonths(3 - currentMonthInQuarter + quarterMonth); |
| | | } |
| | | |
| | | // å¤çææ«æ¥æ |
| | | int adjustedDay = Math.min(dayOfMonth, targetYearMonth.lengthOfMonth()); |
| | | |
| | | return LocalDateTime.of( |
| | | targetYearMonth.getYear(), |
| | | targetYearMonth.getMonthValue(), |
| | | adjustedDay, |
| | | time.getHour(), |
| | | time.getMinute() |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * è§£æææå å符串 |
| | | */ |
| | | private Set<DayOfWeek> parseDayOfWeeks(String dayOfWeekStr) { |
| | | Set<DayOfWeek> days = new HashSet<>(); |
| | | String[] dayStrs = dayOfWeekStr.split("\\|"); |
| | | |
| | | for (String dayStr : dayStrs) { |
| | | switch (dayStr) { |
| | | case "MON": days.add(DayOfWeek.MONDAY); break; |
| | | case "TUE": days.add(DayOfWeek.TUESDAY); break; |
| | | case "WED": days.add(DayOfWeek.WEDNESDAY); break; |
| | | case "THU": days.add(DayOfWeek.THURSDAY); break; |
| | | case "FRI": days.add(DayOfWeek.FRIDAY); break; |
| | | case "SAT": days.add(DayOfWeek.SATURDAY); break; |
| | | case "SUN": days.add(DayOfWeek.SUNDAY); break; |
| | | default: throw new IllegalArgumentException("æ æçææå : " + dayStr); |
| | | } |
| | | } |
| | | |
| | | return days; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service.impl; |
| | | |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.quartz.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/12/22 15:16 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class MaintenanceTaskScheduler { |
| | | |
| | | @Autowired |
| | | private Scheduler scheduler; |
| | | |
| | | /** |
| | | * æ·»å æ°ä»»å¡å°è°åº¦å¨ |
| | | */ |
| | | public void scheduleMaintenanceTask(MaintenanceTask task){ |
| | | try { |
| | | JobDetail jobDetail = buildJobDetail(task); |
| | | Trigger trigger = buildJobTrigger(task, jobDetail); |
| | | scheduler.scheduleJob(jobDetail, trigger); |
| | | }catch (SchedulerException e){ |
| | | log.error("SchedulerException scheduleMaintenanceTask ERROR",e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°å·²æä»»å¡ |
| | | */ |
| | | public void rescheduleMaintenanceTask(MaintenanceTask task){ |
| | | try{ |
| | | TriggerKey triggerKey = new TriggerKey("triggerMaintenanceTask_" + task.getId()); |
| | | |
| | | // è·åç°æè§¦åå¨å¹¶è½¬æ¢ä¸º CronTrigger |
| | | Trigger oldTrigger = scheduler.getTrigger(triggerKey); |
| | | if (!(oldTrigger instanceof CronTrigger)) { |
| | | throw new SchedulerException("Existing trigger is not a CronTrigger"); |
| | | } |
| | | |
| | | // 3. æå»ºCronTriggerï¼ç¡®ä¿æä¹
åé
ç½® |
| | | CronTrigger newTrigger = TriggerBuilder.newTrigger() |
| | | .withIdentity(triggerKey) // å¯ä¸æ è¯ï¼ç¨äºæä¹
ååå¨ |
| | | .withDescription(task.getTaskName() + "_TRIGGER") // 触åå¨æè¿° |
| | | .forJob(oldTrigger.getJobKey()) // å
³è对åºçJob |
| | | .withSchedule(CronScheduleBuilder |
| | | .cronSchedule(convertToCronExpression(task)) // éè¿æ§è¡æ¶ççç¥ï¼æ ¹æ®ä¸å¡è°æ´ï¼ |
| | | ) |
| | | // 4. 设置å¼å§æ¶é´ï¼è¥ä¸ºnullåç«å³çæï¼ |
| | | .startAt(task.getNextExecutionTime() != null |
| | | ? Date.from(task.getNextExecutionTime().atZone(ZoneId.systemDefault()).toInstant()) |
| | | : new Date()) |
| | | .build(); |
| | | scheduler.rescheduleJob(triggerKey, newTrigger); |
| | | }catch (SchedulerException e){ |
| | | log.error("SchedulerException rescheduleMaintenanceTask ERROR",e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æåä»»å¡ |
| | | */ |
| | | public void pauseMaintenanceTask(Long taskId) throws SchedulerException { |
| | | JobKey jobKey = new JobKey("MaintenanceTask_" + taskId); |
| | | scheduler.pauseJob(jobKey); |
| | | } |
| | | |
| | | /** |
| | | * æ¢å¤ä»»å¡ |
| | | */ |
| | | public void resumeMaintenanceTask(Long taskId) throws SchedulerException { |
| | | JobKey jobKey = new JobKey("MaintenanceTask_" + taskId); |
| | | scheduler.resumeJob(jobKey); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä»»å¡ |
| | | */ |
| | | public void unscheduleMaintenanceTask(Long taskId){ |
| | | try { |
| | | JobKey jobKey = new JobKey("MaintenanceTask_" + taskId); |
| | | scheduler.deleteJob(jobKey); |
| | | }catch (SchedulerException e){ |
| | | log.error("SchedulerException unscheduleMaintenanceTask ERROR",e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | private JobDetail buildJobDetail(MaintenanceTask task) { |
| | | // 1. æå»ºå¯ä¸JobKeyï¼åºäºä»»å¡IDï¼ç¡®ä¿éå¯åè½è¯å«ï¼ |
| | | JobKey jobKey = new JobKey("MaintenanceTask_" + task.getId()); |
| | | |
| | | // 2. å°è£
任塿°æ®ï¼ä»
使ç¨åºæ¬ç±»åï¼ç¡®ä¿å¯åºååï¼ |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("maintenanceTaskId", task.getId()); // ä»»å¡IDï¼Longï¼å¯åºååï¼ |
| | | jobDataMap.put("taskName", task.getTaskName()); // ä»»å¡åç§°ï¼Stringï¼å¯åºååï¼ |
| | | jobDataMap.put("taskType", task.getFrequencyType()); // ä»»å¡ç±»åï¼Stringï¼ |
| | | // æéæ·»å å
¶ä»å¿
è¦çåºæ¬ç±»ååæ° |
| | | |
| | | // 3. æå»ºJobDetailï¼è®¾ç½®æä¹
åç¸å
³å±æ§ |
| | | return JobBuilder.newJob(MaintenanceTaskJob.class) |
| | | .withIdentity(jobKey) // å¯ä¸æ è¯ï¼ç¨äºæä¹
ååå¨ |
| | | .withDescription(task.getTaskName()) // ä»»å¡æè¿°ï¼åå
¥æ°æ®åº |
| | | .usingJobData(jobDataMap) // ç»å®ä»»å¡æ°æ® |
| | | .storeDurably(true) // å³ä½¿æ²¡æè§¦åå¨å
³è乿ä¹
åä¿å |
| | | .requestRecovery(true) // å½è°åº¦å¨å´©æºåæ¢å¤æ¶ï¼éæ°æ§è¡æªå®æçä»»å¡ |
| | | .build(); |
| | | } |
| | | |
| | | private Trigger buildJobTrigger(MaintenanceTask task, JobDetail jobDetail) { |
| | | // 1. æå»ºå¯ä¸TriggerKeyï¼åºäºä»»å¡IDï¼ |
| | | TriggerKey triggerKey = new TriggerKey("triggerMaintenanceTask_" + task.getId()); |
| | | |
| | | // 2. çæCron表达å¼ï¼åé»è¾ä¸åï¼ |
| | | String cronExpression = convertToCronExpression(task); |
| | | |
| | | // 3. æå»ºCronTriggerï¼ç¡®ä¿æä¹
åé
ç½® |
| | | return TriggerBuilder.newTrigger() |
| | | .withIdentity(triggerKey) // å¯ä¸æ è¯ï¼ç¨äºæä¹
ååå¨ |
| | | .withDescription(task.getTaskName() + "_TRIGGER") // 触åå¨æè¿° |
| | | .forJob(jobDetail) // å
³è对åºçJob |
| | | .withSchedule(CronScheduleBuilder |
| | | .cronSchedule(cronExpression) |
| | | .withMisfireHandlingInstructionDoNothing() // éè¿æ§è¡æ¶ççç¥ï¼æ ¹æ®ä¸å¡è°æ´ï¼ |
| | | ) |
| | | // 4. 设置å¼å§æ¶é´ï¼è¥ä¸ºnullåç«å³çæï¼ |
| | | .startAt(task.getNextExecutionTime() != null |
| | | ? Date.from(task.getNextExecutionTime().atZone(ZoneId.systemDefault()).toInstant()) |
| | | : new Date()) |
| | | .build(); |
| | | } |
| | | private String convertToCronExpression(MaintenanceTask task) { |
| | | // åæ°æ ¡éª |
| | | if (task == null || task.getFrequencyType() == null || task.getFrequencyDetail() == null) { |
| | | throw new IllegalArgumentException("ä»»å¡åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // 使ç¨switchç¡®ä¿æ¡ä»¶äºæ¥ |
| | | String frequencyType = task.getFrequencyType().toUpperCase(); // ç»ä¸è½¬ä¸ºå¤§åæ¯è¾ |
| | | switch (frequencyType) { |
| | | case "DAILY": |
| | | return convertDailyToCron(task.getFrequencyDetail()); |
| | | case "WEEKLY": |
| | | return convertWeeklyToCron(task.getFrequencyDetail()); |
| | | case "MONTHLY": |
| | | return convertMonthlyToCron(task.getFrequencyDetail()); |
| | | case "QUARTERLY": |
| | | return convertQuarterlyToCron(task.getFrequencyDetail()); |
| | | default: |
| | | throw new IllegalArgumentException("䏿¯æçé¢çç±»å: " + task.getFrequencyType()); |
| | | } |
| | | } |
| | | |
| | | // æ¯æ¥ä»»å¡è½¬æ¢ |
| | | private String convertDailyToCron(String frequencyDetail) { |
| | | LocalTime time = parseTime(frequencyDetail); |
| | | return String.format("0 %d %d * * ?", time.getMinute(), time.getHour()); |
| | | } |
| | | |
| | | // æ¯å¨ä»»å¡è½¬æ¢ |
| | | private String convertWeeklyToCron(String frequencyDetail) { |
| | | String[] parts = validateAndSplit(frequencyDetail, ",", 2); |
| | | String daysOfWeek = convertDayNamesToCron(parts[0]); |
| | | LocalTime time = parseTime(parts[1]); |
| | | return String.format("0 %d %d ? * %s", time.getMinute(), time.getHour(), daysOfWeek); |
| | | } |
| | | |
| | | // æ¯æä»»å¡è½¬æ¢ |
| | | private String convertMonthlyToCron(String frequencyDetail) { |
| | | String[] parts = validateAndSplit(frequencyDetail, ",", 2); |
| | | int day = validateDayOfMonth(parts[0]); |
| | | LocalTime time = parseTime(parts[1]); |
| | | return String.format("0 %d %d %d * ?", time.getMinute(), time.getHour(), day); |
| | | } |
| | | |
| | | // æ¯å£åº¦ä»»å¡è½¬æ¢ |
| | | private String convertQuarterlyToCron(String frequencyDetail) { |
| | | String[] parts = validateAndSplit(frequencyDetail, ",", 3); |
| | | int month = validateMonth(parts[0]); // éªè¯æä»½(1-12) |
| | | int day = validateDayOfMonth(parts[1]); // éªè¯æ¥æ |
| | | LocalTime time = parseTime(parts[2]); // è§£ææ¶é´ |
| | | |
| | | // 计ç®å£åº¦èµ·å§æä»½(1æ=1, 4æ=4, 7æ=7, 10æ=10) |
| | | int quarterStartMonth = ((month - 1) / 3) * 3 + 1; |
| | | |
| | | return String.format("0 %d %d %d %d/3 ?", |
| | | time.getMinute(), |
| | | time.getHour(), |
| | | day, |
| | | quarterStartMonth); |
| | | } |
| | | |
| | | // æ°å¢éªè¯æä»½çæ¹æ³(1-12) |
| | | private int validateMonth(String monthStr) { |
| | | try { |
| | | int month = Integer.parseInt(monthStr); |
| | | if (month < 1 || month > 12) { |
| | | throw new IllegalArgumentException("æä»½å¿
é¡»å¨1-12ä¹é´"); |
| | | } |
| | | return month; |
| | | } catch (NumberFormatException e) { |
| | | throw new IllegalArgumentException("æ æçæä»½æ ¼å¼"); |
| | | } |
| | | } |
| | | |
| | | // è¾
婿¹æ³ï¼è§£ææ¶é´ |
| | | private LocalTime parseTime(String timeStr) { |
| | | try { |
| | | return LocalTime.parse(timeStr); |
| | | } catch (DateTimeParseException e) { |
| | | throw new IllegalArgumentException("æ¶é´æ ¼å¼å¿
须为HH:mm", e); |
| | | } |
| | | } |
| | | |
| | | // è¾
婿¹æ³ï¼éªè¯å¹¶åå²å符串 |
| | | private String[] validateAndSplit(String input, String delimiter, int expectedParts) { |
| | | String[] parts = input.split(delimiter); |
| | | if (parts.length != expectedParts) { |
| | | throw new IllegalArgumentException( |
| | | String.format("æ ¼å¼é误ï¼åºä¸º%dé¨åç¨'%s'åé", expectedParts, delimiter)); |
| | | } |
| | | return parts; |
| | | } |
| | | |
| | | // è¾
婿¹æ³ï¼éªè¯æä»½ä¸çæ¥ |
| | | private int validateDayOfMonth(String dayStr) { |
| | | int day = Integer.parseInt(dayStr); |
| | | if (day < 1 || day > 31) { |
| | | throw new IllegalArgumentException("æ¥æå¿
é¡»å¨1-31ä¹é´"); |
| | | } |
| | | return day; |
| | | } |
| | | |
| | | // è¾
婿¹æ³ï¼éªè¯å£åº¦ä¸çæ |
| | | private int validateMonthInQuarter(String monthStr) { |
| | | int month = Integer.parseInt(monthStr); |
| | | if (month < 1 || month > 3) { |
| | | throw new IllegalArgumentException("å£åº¦æä»½å¿
é¡»æ¯1ã2æ3"); |
| | | } |
| | | return month; |
| | | } |
| | | |
| | | // è½¬æ¢ææå åç§° |
| | | private String convertDayNamesToCron(String dayNames) { |
| | | return Arrays.stream(dayNames.split("\\|")) |
| | | .map(this::convertSingleDayName) |
| | | .collect(Collectors.joining(",")); |
| | | } |
| | | |
| | | // 转æ¢å个ææå åç§° |
| | | private String convertSingleDayName(String dayName) { |
| | | switch (dayName.toUpperCase()) { |
| | | case "MON": return "MON"; |
| | | case "TUE": return "TUE"; |
| | | case "WED": return "WED"; |
| | | case "THU": return "THU"; |
| | | case "FRI": return "FRI"; |
| | | case "SAT": return "SAT"; |
| | | case "SUN": return "SUN"; |
| | | default: throw new IllegalArgumentException("æ æçææå : " + dayName); |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.device.mapper.MaintenanceTaskMapper; |
| | | import com.ruoyi.device.pojo.MaintenanceTask; |
| | | import com.ruoyi.device.service.MaintenanceTaskService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.inspectiontask.pojo.TimingTask; |
| | | import com.ruoyi.inspectiontask.service.impl.TimingTaskServiceImpl; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/12/22 14:57 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class MaintenanceTaskServiceImpl extends ServiceImpl<MaintenanceTaskMapper, MaintenanceTask> implements MaintenanceTaskService { |
| | | |
| | | @Autowired |
| | | private MaintenanceTaskMapper maintenanceTaskMapper; |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Autowired |
| | | private TimingTaskServiceImpl timingTaskService; |
| | | |
| | | @Autowired |
| | | private MaintenanceTaskScheduler maintenanceTaskScheduler; |
| | | |
| | | @Override |
| | | public AjaxResult listPage(Page page, MaintenanceTask maintenanceTask) { |
| | | Page<MaintenanceTask> taskPage = maintenanceTaskMapper.selectPage(page, null); |
| | | // 2. å¦ææ²¡ææ°æ®ï¼ç´æ¥è¿å空å页 |
| | | if (taskPage.getRecords().isEmpty()) { |
| | | return AjaxResult.success(taskPage); |
| | | } |
| | | |
| | | // 3. æ¶éææéè¦æ¥è¯¢çç¨æ·ID |
| | | Set<Long> userIds = new HashSet<>(); |
| | | |
| | | // æ¶éç»è®°äººID |
| | | taskPage.getRecords().forEach(task -> { |
| | | if (task.getRegistrantId() != null) { |
| | | userIds.add(task.getRegistrantId()); |
| | | } |
| | | }); |
| | | |
| | | // 4. æ¹éæ¥è¯¢ç¨æ·ä¿¡æ¯ |
| | | Map<Long, String> userNickNameMap = new HashMap<>(); |
| | | if (!userIds.isEmpty()) { |
| | | List<SysUser> users = sysUserMapper.selectUserByIds((new ArrayList<>(userIds))); |
| | | users.forEach(user -> userNickNameMap.put(user.getUserId(), user.getNickName())); |
| | | } |
| | | taskPage.getRecords().forEach(task -> { |
| | | // 设置ç»è®°äººæµç§° |
| | | if (task.getRegistrantId() != null) { |
| | | task.setRegistrant(userNickNameMap.getOrDefault(task.getRegistrantId(), "æªç¥ç¨æ·")); |
| | | } |
| | | }); |
| | | return AjaxResult.success(taskPage); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult add(MaintenanceTask maintenanceTask) { |
| | | maintenanceTask.setActive(true); |
| | | // 计ç®é¦æ¬¡æ§è¡æ¶é´ |
| | | TimingTask task = new TimingTask(); |
| | | task.setFrequencyType(maintenanceTask.getFrequencyType()); |
| | | task.setFrequencyDetail(maintenanceTask.getFrequencyDetail()); |
| | | LocalDateTime firstExecutionTime = timingTaskService.calculateFirstExecutionTime(task); |
| | | maintenanceTask.setNextExecutionTime(firstExecutionTime); |
| | | int insert = maintenanceTaskMapper.insert(maintenanceTask); |
| | | if (insert > 0) { |
| | | maintenanceTaskScheduler.scheduleMaintenanceTask(maintenanceTask); |
| | | } |
| | | return AjaxResult.success("æ·»å æå"); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateByMaintenanceTaskId(MaintenanceTask maintenanceTask) { |
| | | MaintenanceTask maintenanceTask1 = maintenanceTaskMapper.selectById(maintenanceTask.getId()); |
| | | if (maintenanceTask1 == null) { |
| | | return AjaxResult.warn("æ²¡ææ¤æ°æ®"); |
| | | } |
| | | BeanUtils.copyProperties(maintenanceTask, maintenanceTask1); |
| | | int update = maintenanceTaskMapper.updateById(maintenanceTask1); |
| | | if (update > 0) { |
| | | maintenanceTaskScheduler.rescheduleMaintenanceTask(maintenanceTask1); |
| | | } |
| | | return AjaxResult.success("æ´æ°æå"); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult delete(List<Long> ids) { |
| | | int delete = maintenanceTaskMapper.deleteBatchIds(ids); |
| | | if (delete > 0) { |
| | | ids.forEach(id -> { |
| | | maintenanceTaskScheduler.unscheduleMaintenanceTask(id); |
| | | }); |
| | | } |
| | | return AjaxResult.success("å 餿å"); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.inspectiontask.dto.InspectionTaskDto; |
| | | import com.ruoyi.inspectiontask.dto.TimingTaskDto; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | | import com.ruoyi.inspectiontask.service.InspectionTaskService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import com.ruoyi.inspectiontask.service.QrCodeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | import com.ruoyi.inspectiontask.service.QrCodeScanRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.inspectiontask.dto.TimingTaskDto; |
| | |
| | | import com.ruoyi.inspectiontask.service.TimingTaskService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @PostMapping("/addOrEditTimingTask") |
| | | @ApiOperation(value = "æ°å¢ä¿®æ¹å®æ¶ä»»å¡") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | public R addOrEditTimingTask(@RequestBody TimingTaskDto timingTaskDto) throws SchedulerException { |
| | | return R.ok(timingTaskService.addOrEditTimingTask(timingTaskDto)); |
| | | } |
| | |
| | | */ |
| | | @DeleteMapping("/delTimingTask") |
| | | @ApiOperation(value = "å é¤å®æ¶ä»»å¡") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE) |
| | | public R remove(@RequestBody Long[] ids) { |
| | | return R.ok(timingTaskService.delByIds(ids)); |
| | | } |
| | |
| | | private Integer deleted; |
| | | |
| | | @ApiModelProperty(value = "å建该记å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½å建æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "ç»è®°æ¥æ", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æåä¿®æ¹è¯¥è®°å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½æåæ´æ°æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·") |
| | |
| | | private Integer deleted; |
| | | |
| | | @ApiModelProperty(value = "å建该记å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½å建æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æåä¿®æ¹è¯¥è®°å½çç¨æ·") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty(value = "è®°å½æåæ´æ°æ¶é´") |
| | | @TableField(fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | |
| | | // æ¹éæ¥è¯¢ç»è®°äºº |
| | | Map<Long, SysUser> sysUserMap; |
| | | if (!registrantIds.isEmpty()) { |
| | | List<SysUser> sysUsers = sysUserMapper.selectRegistrantIds(registrantIds); |
| | | List<SysUser> sysUsers = sysUserMapper.selectList(registrantIds); |
| | | sysUserMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity())); |
| | | } else { |
| | | sysUserMap = new HashMap<>(); |
| | |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.pojo.StorageBlob; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.common.constant.StorageAttachmentConstants; |
| | | import com.ruoyi.common.utils.MinioUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.inspectiontask.dto.QrCodeScanRecordDto; |
| | |
| | | import com.ruoyi.inspectiontask.service.QrCodeScanRecordService; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | package com.ruoyi.inspectiontask.service.impl; |
| | | |
| | | import org.quartz.*; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.spi.TriggerFiredBundle; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.config.AutowireCapableBeanFactory; |
| | |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.scheduling.quartz.JobDetailFactoryBean; |
| | | import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
| | | import org.springframework.scheduling.quartz.SpringBeanJobFactory; |
| | | |
| | |
| | | package com.ruoyi.inspectiontask.service.impl; |
| | | |
| | | import org.quartz.JobExecutionContext; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.sql.DataSource; |
| | | import java.io.Serializable; |
| | | import java.time.DayOfWeek; |
| | | import java.time.LocalDateTime; |
| | |
| | | /** |
| | | * å é¤ä»»å¡ |
| | | */ |
| | | public void unscheduleTimingTask(Long taskId) throws SchedulerException { |
| | | JobKey jobKey = new JobKey("timingTask_" + taskId); |
| | | scheduler.deleteJob(jobKey); |
| | | public void unscheduleTimingTask(Long taskId){ |
| | | try { |
| | | JobKey jobKey = new JobKey("timingTask_" + taskId); |
| | | scheduler.deleteJob(jobKey); |
| | | }catch (SchedulerException e){ |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | private JobDetail buildJobDetail(TimingTask task) { |
| | |
| | | } |
| | | } |
| | | |
| | | private LocalDateTime calculateFirstExecutionTime(TimingTask task) { |
| | | public LocalDateTime calculateFirstExecutionTime(TimingTask task) { |
| | | // æ ¹æ®é¢çç±»åå详æ
计ç®é¦æ¬¡æ§è¡æ¶é´ |
| | | String frequencyType = task.getFrequencyType(); |
| | | if ("DAILY".equals(frequencyType)) { |
| | |
| | | |
| | | @Override |
| | | public int delByIds(Long[] ids) { |
| | | return timingTaskMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | int i = timingTaskMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | if(i > 0){ |
| | | for (Long id : ids) { |
| | | timingTaskScheduler.unscheduleTimingTask(id); |
| | | } |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerRecordDTO; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerDto; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord; |
| | |
| | | @ApiOperation("计éå¨å
·å°è´¦-æ£å®") |
| | | @Log(title = "计éå¨å
·å°è´¦-æ£å®", businessType = BusinessType.UPDATE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult verifying(@RequestBody MeasuringInstrumentLedgerRecordDTO measuringInstrumentLedgerRecordDTO) throws IOException { |
| | | boolean update = measuringInstrumentLedgerService.verifying(measuringInstrumentLedgerRecordDTO); |
| | | public AjaxResult verifying(@RequestBody MeasuringInstrumentLedgerDto measuringInstrumentLedger) throws IOException { |
| | | boolean update = measuringInstrumentLedgerService.verifying(measuringInstrumentLedger); |
| | | return update ? AjaxResult.success("æ£å®æå") : AjaxResult.error("æ£å®å¤±è´¥"); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord; |
| | | import com.ruoyi.measuringinstrumentledger.service.MeasuringInstrumentLedgerRecordService; |
| | | import io.jsonwebtoken.lang.Collections; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("计éå¨å
·å°è´¦è®°å½-å é¤") |
| | | @Log(title = "计éå¨å
·å°è´¦è®°å½-å é¤", businessType = BusinessType.DELETE) |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | if(Collections.isEmpty(ids)) return AjaxResult.error("è¯·éæ©è¦å é¤çæ°æ®"); |
| | | return AjaxResult.success(measuringInstrumentLedgerRecordService.removeBatchByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 导åºè®¡éå¨å
·å°è´¦ |
| | | */ |
| | |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response) { |
| | | measuringInstrumentLedgerRecordService.export( response); |
| | | } |
| | | |
| | | @GetMapping("/detail/{id}") |
| | | public AjaxResult getById(@PathVariable("id") Long id) { |
| | | return AjaxResult.success(measuringInstrumentLedgerRecordService.getById(id)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.measuringinstrumentledger.dto.SparePartsDto; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | | import com.ruoyi.measuringinstrumentledger.service.SparePartsService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | package com.ruoyi.measuringinstrumentledger.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | * ç¶æï¼1-ææ 2-é¾æï¼ |
| | | */ |
| | | @ApiModelProperty("ç¶æï¼1-ææ 2-龿ï¼") |
| | | @Excel(name = "ç¶æ", readConverterExp = "1=ææ,2=龿,3=å³å°å°æ") |
| | | @Excel(name = "ç¶æ", readConverterExp = "1=ææ,2=龿") |
| | | private Integer status; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty("å®è£
ä½ç½®") |
| | | private String installationLocation; |
| | | |
| | | @ApiModelProperty("æ£å®åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("æ£å®å¨æ(天)") |
| | | private Long cycle; |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | |
| | | */ |
| | | private String sparePartsNo; |
| | | /** |
| | | * å¤ä»¶ä»·æ ¼ |
| | | */ |
| | | private BigDecimal price; |
| | | |
| | | /** |
| | | * 设å¤idéåï¼å符串,éå¼ï¼ |
| | | */ |
| | | private String deviceIds; |
| | | |
| | | /** |
| | | * 设å¤åç§°éåï¼å符串,éå¼ï¼ |
| | | */ |
| | | @TableField(exist = false) |
| | | private String deviceNameStr; |
| | | /** |
| | | * å¤ä»¶ç¶id |
| | | */ |
| | | private Long parentId; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerRecordDTO; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | void export(HttpServletResponse response); |
| | | |
| | | boolean updateMeasuringInstrumentLedgerRecord(MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord) throws IOException; |
| | | |
| | | MeasuringInstrumentLedgerRecordDTO getById(Long id); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerRecordDTO; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerDto; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | * @param measuringInstrumentLedger |
| | | * @return |
| | | */ |
| | | boolean verifying(MeasuringInstrumentLedgerRecordDTO measuringInstrumentLedger) throws IOException; |
| | | |
| | | boolean verifying(MeasuringInstrumentLedgerDto measuringInstrumentLedger) throws IOException; |
| | | |
| | | void export(HttpServletResponse response); |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StorageAttachmentRecordType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerRecordDTO; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger; |
| | |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.common.constant.StorageAttachmentConstants.StorageAttachmentFile; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | |
| | | @Autowired |
| | | private TempFileMapper tempFileMapper; |
| | | |
| | | @Autowired |
| | | private StorageAttachmentService storageAttachmentService; |
| | | |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | |
| | | throw new IOException("æä»¶è¿ç§»å¼å¸¸", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MeasuringInstrumentLedgerRecordDTO getById(Long id) { |
| | | MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord = measuringInstrumentLedgerRecordMapper.selectById(id); |
| | | List<StorageAttachment> storageAttachments = storageAttachmentService.selectStorageAttachments(measuringInstrumentLedgerRecord.getId(), StorageAttachmentRecordType.MeasuringInstrumentLedgerRecord, StorageAttachmentFile); |
| | | List<StorageBlobDTO> storageBlobDTOList = |
| | | storageAttachments.stream() |
| | | .map(StorageAttachment::getStorageBlobDTO) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | MeasuringInstrumentLedgerRecordDTO measuringInstrumentLedgerRecordDTO = new MeasuringInstrumentLedgerRecordDTO(); |
| | | BeanUtils.copyProperties(measuringInstrumentLedgerRecord, measuringInstrumentLedgerRecordDTO); |
| | | measuringInstrumentLedgerRecordDTO.setBlobs(storageBlobDTOList); |
| | | return measuringInstrumentLedgerRecordDTO; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StorageAttachmentRecordType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerRecordDTO; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerDto; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.common.constant.StorageAttachmentConstants.StorageAttachmentFile; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Autowired |
| | | private StorageAttachmentService attachmentService; |
| | | |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | | @Override |
| | | public IPage<MeasuringInstrumentLedger> listPage(Page page, MeasuringInstrumentLedger measuringInstrumentLedger) { |
| | | IPage<MeasuringInstrumentLedger> iPage = measuringInstrumentLedgerMapper.listPage(page, measuringInstrumentLedger); |
| | | List<MeasuringInstrumentLedger> records = iPage.getRecords(); |
| | | List<Long> ids = records.stream().map(MeasuringInstrumentLedger::getId).collect(Collectors.toList()); |
| | | |
| | | List<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecords = measuringInstrumentLedgerRecordMapper.selectList(new LambdaQueryWrapper<MeasuringInstrumentLedgerRecord>() |
| | | .in(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId, ids) |
| | | .orderByDesc(MeasuringInstrumentLedgerRecord::getCreateTime)); |
| | | if (!CollectionUtils.isEmpty(measuringInstrumentLedgerRecords)) { |
| | | Map<Long, List<MeasuringInstrumentLedgerRecord>> collect = measuringInstrumentLedgerRecords.stream().collect(Collectors.groupingBy(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId)); |
| | | for (MeasuringInstrumentLedger ledger : records) { |
| | | if (collect.containsKey(ledger.getId())) { |
| | | ledger.setMostDate(collect.get(ledger.getId()).get(0).getRecordDate()); |
| | | } |
| | | IPage<MeasuringInstrumentLedger> measuringInstrumentLedgerIPage = measuringInstrumentLedgerMapper.listPage(page, measuringInstrumentLedger); |
| | | List<Integer> types = new ArrayList<>(); |
| | | types.add(FileNameType.MEASURING.getValue()); |
| | | types.add(FileNameType.MEASURINGRecord.getValue()); |
| | | measuringInstrumentLedgerIPage.getRecords().forEach(item -> { |
| | | LambdaQueryWrapper<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | measuringInstrumentLedgerRecordLambdaQueryWrapper.eq(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId, item.getId()); |
| | | List<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecords = measuringInstrumentLedgerRecordMapper.selectList(measuringInstrumentLedgerRecordLambdaQueryWrapper); |
| | | List<Long> collect = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(measuringInstrumentLedgerRecords)){ |
| | | collect = measuringInstrumentLedgerRecords.stream().map(MeasuringInstrumentLedgerRecord::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | return iPage; |
| | | collect.add(item.getId()); |
| | | LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerFileWrapper.in(CommonFile::getCommonId, collect) |
| | | .in(CommonFile::getType,types); |
| | | List<CommonFile> commonFiles = commonFileMapper.selectList(salesLedgerFileWrapper); |
| | | item.setCommonFiles(commonFiles); |
| | | |
| | | }); |
| | | return measuringInstrumentLedgerIPage; |
| | | } |
| | | |
| | | @Override |
| | | public boolean verifying(MeasuringInstrumentLedgerRecordDTO req) throws IOException { |
| | | MeasuringInstrumentLedger measuringInstrumentLedger = measuringInstrumentLedgerMapper.selectById(req.getMeasuringInstrumentLedgerId()); |
| | | if (measuringInstrumentLedger == null) { |
| | | throw new RuntimeException("计éå¨å
·å°è´¦ä¸åå¨"); |
| | | public boolean verifying(MeasuringInstrumentLedgerDto req) throws IOException { |
| | | MeasuringInstrumentLedger measuringInstrumentLedger = measuringInstrumentLedgerMapper.selectById(req.getId()); |
| | | if(measuringInstrumentLedger == null) { |
| | | return false; |
| | | } |
| | | measuringInstrumentLedgerRecordMapper.insert(req); |
| | | if (req.getBlobs() != null && !req.getBlobs().isEmpty()) { |
| | | List<StorageAttachment> attachments = new ArrayList<>(); |
| | | |
| | | for (StorageBlobDTO storageBlobDTO : req.getBlobs()) { |
| | | StorageAttachment storageAttachment = new StorageAttachment( |
| | | StorageAttachmentFile, |
| | | (long) StorageAttachmentRecordType.MeasuringInstrumentLedgerRecord.ordinal(), |
| | | req.getId() |
| | | ); |
| | | storageAttachment.setStorageBlobDTO(storageBlobDTO); |
| | | attachments.add(storageAttachment); |
| | | SysUser sysUser = sysUserMapper.selectUserById(measuringInstrumentLedger.getUserId()); |
| | | measuringInstrumentLedger.setValid(req.getValid()); |
| | | measuringInstrumentLedger.setMostDate(req.getRecordDate()); |
| | | measuringInstrumentLedger.setNextDate(new Date(req.getRecordDate().getTime() + 1000L * 60 * 60 * 24 * req.getValid())); |
| | | MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord = new MeasuringInstrumentLedgerRecord(); |
| | | if(measuringInstrumentLedgerMapper.updateById(measuringInstrumentLedger) > 0) { |
| | | measuringInstrumentLedgerRecord.setMeasuringInstrumentLedgerId(req.getId()); |
| | | measuringInstrumentLedgerRecord.setRecordDate(req.getRecordDate()); |
| | | measuringInstrumentLedgerRecord.setEntryDate(req.getEntryDate()); |
| | | measuringInstrumentLedgerRecord.setValid(req.getValid()); |
| | | measuringInstrumentLedgerRecord.setUserId(req.getUserId()); |
| | | measuringInstrumentLedgerRecord.setUserName(sysUser.getUserName()); |
| | | measuringInstrumentLedgerRecordMapper.insert(measuringInstrumentLedgerRecord); |
| | | // å°è´¦ç»å®ä¸æ¬¡ |
| | | // if(!CollectionUtils.isEmpty(req.getTempFileIds())){ |
| | | // migrateTempFilesToFormal(measuringInstrumentLedger.getId(), req.getTempFileIds(), FileNameType.MEASURING.getValue()); |
| | | // } |
| | | // å°è´¦è®°å½ç»å®ä¸æ¬¡ |
| | | if(!CollectionUtils.isEmpty(req.getTempFileIds())){ |
| | | migrateTempFilesToFormal(measuringInstrumentLedgerRecord.getId(), req.getTempFileIds(), FileNameType.MEASURINGRecord.getValue()); |
| | | } |
| | | attachmentService.saveStorageAttachment(attachments, req.getId(), StorageAttachmentRecordType.MeasuringInstrumentLedgerRecord, StorageAttachmentFile); |
| | | return true; |
| | | } |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.measuringinstrumentledger.dto.SparePartsDto; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class SparePartsServiceImpl extends ServiceImpl<SparePartsMapper, SpareParts> implements SparePartsService { |
| | | @Autowired |
| | | private SparePartsMapper sparePartsMapper; |
| | | |
| | | @Autowired |
| | | private DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | @Override |
| | | public IPage<SparePartsDto> listPage(Page page, SpareParts spareParts) { |
| | | return sparePartsMapper.listPage(page,spareParts); |
| | | IPage<SparePartsDto> sparePartsDtoIPage = sparePartsMapper.listPage(page, spareParts); |
| | | for (SparePartsDto record : sparePartsDtoIPage.getRecords()) { |
| | | if(StringUtils.isNotEmpty(record.getDeviceIds())){ |
| | | List<String> deviceIds = StringUtils.str2List(record.getDeviceIds(), ",", true, true); |
| | | List<DeviceLedger> deviceLedgers = deviceLedgerMapper.selectBatchIds(deviceIds); |
| | | if(CollectionUtils.isNotEmpty(deviceLedgers)){ |
| | | record.setDeviceNameStr(deviceLedgers.stream().map(DeviceLedger::getDeviceName).collect(Collectors.joining( ","))); |
| | | } |
| | | } |
| | | } |
| | | return sparePartsDtoIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.staff.dto.StaffJoinLeaveRecordDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.service.IStaffJoinLeaveRecordService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.staff.dto; |
| | | |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StaffJoinLeaveRecordDto extends StaffJoinLeaveRecord { |
| | | private String postName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.staff.dto; |
| | | |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StaffOnJobDto extends StaffOnJob { |
| | | private String postName; |
| | | } |
| | |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.excel.SupplierManageExcelDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.staff.dto.StaffJoinLeaveRecordDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | @Mapper |
| | | public interface StaffJoinLeaveRecordMapper extends BaseMapper<StaffJoinLeaveRecord> { |
| | | |
| | | IPage<StaffJoinLeaveRecord> staffJoinLeaveRecordListPage(Page page, @Param("staffJoinLeaveRecord") StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | IPage<StaffJoinLeaveRecordDto> staffJoinLeaveRecordListPage(Page page, @Param("staffJoinLeaveRecord") StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | |
| | | List<StaffJoinLeaveRecord> staffJoinLeaveRecordList(@Param("staffJoinLeaveRecord") StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | @Mapper |
| | | public interface StaffOnJobMapper extends BaseMapper<StaffOnJob> { |
| | | |
| | | IPage<StaffOnJob> staffOnJobListPage(Page page, @Param("staffOnJob") StaffOnJob staffOnJob); |
| | | IPage<StaffOnJobDto> staffOnJobListPage(Page page, @Param("staffOnJob") StaffOnJob staffOnJob); |
| | | |
| | | List<StaffOnJob> staffOnJobList(@Param("staffOnJob") StaffOnJob staffOnJob); |
| | | } |
| | |
| | | * å²ä½ |
| | | */ |
| | | @Excel(name = "å²ä½") |
| | | private String postJob; |
| | | private Integer sysPostId; |
| | | |
| | | /** |
| | | * å®¶åºä½å |
| | |
| | | * å²ä½ |
| | | */ |
| | | @Excel(name = "å²ä½") |
| | | private String postJob; |
| | | private Integer sysPostId; |
| | | |
| | | /** |
| | | * å®¶åºä½å |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.staff.dto.StaffJoinLeaveRecordDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | public interface IStaffJoinLeaveRecordService extends IService<StaffJoinLeaveRecord> { |
| | | |
| | | |
| | | IPage<StaffJoinLeaveRecord> staffJoinLeaveRecordListPage(Page page, StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | IPage<StaffJoinLeaveRecordDto> staffJoinLeaveRecordListPage(Page page, StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | |
| | | void staffJoinLeaveRecordExport(HttpServletResponse response, StaffJoinLeaveRecord staffJoinLeaveRecord); |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | public interface IStaffOnJobService extends IService<StaffOnJob> { |
| | | |
| | | |
| | | IPage<StaffOnJob> staffOnJobListPage(Page page, StaffOnJob staffOnJob); |
| | | IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJob staffOnJob); |
| | | |
| | | List<StaffJoinLeaveRecord> staffOnJobDetail(String staffNo); |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.staff.dto.StaffJoinLeaveRecordDto; |
| | | import com.ruoyi.staff.mapper.StaffJoinLeaveRecordMapper; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | |
| | | |
| | | //å页æ¥è¯¢ |
| | | @Override |
| | | public IPage<StaffJoinLeaveRecord> staffJoinLeaveRecordListPage(Page page, StaffJoinLeaveRecord staffJoinLeaveRecord) { |
| | | public IPage<StaffJoinLeaveRecordDto> staffJoinLeaveRecordListPage(Page page, StaffJoinLeaveRecord staffJoinLeaveRecord) { |
| | | return staffJoinLeaveRecordMapper.staffJoinLeaveRecordListPage(page,staffJoinLeaveRecord); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.dto.WordDateDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.mapper.StaffJoinLeaveRecordMapper; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | |
| | | |
| | | //å¨èåå·¥å°è´¦å页æ¥è¯¢ |
| | | @Override |
| | | public IPage<StaffOnJob> staffOnJobListPage(Page page, StaffOnJob staffOnJob) { |
| | | public IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJob staffOnJob) { |
| | | return staffOnJobMapper.staffOnJobListPage(page,staffOnJob); |
| | | } |
| | | |
| | |
| | | dr.maintenance_name, |
| | | dr.maintenance_time, |
| | | dr.maintenance_result, |
| | | dr.maintenance_price, |
| | | dr.status, |
| | | dr.create_time, |
| | | dr.update_time, |
| | |
| | | dr.maintenance_name, |
| | | dr.maintenance_time, |
| | | dr.maintenance_result, |
| | | dr.maintenance_price, |
| | | dr.status, |
| | | dr.create_time, |
| | | dr.update_time, |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper"> |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerPageDto"> |
| | | <select id="listPage" resultType="com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger"> |
| | | SELECT |
| | | mil.id, |
| | | mil.user_id, |
| | | mil.user_name, |
| | | mil.code, |
| | | sd.dept_name, |
| | | mil.installation_location, |
| | | mil.unit, |
| | | mil.cycle, |
| | | mil.name, |
| | | mil.model, |
| | | mil.most_date, |
| | | mil.valid, |
| | | mil.next_date, |
| | | mil.record_date, |
| | | mil.create_user, |
| | | mil.create_time, |
| | | mil.update_user, |
| | | mil.update_time, |
| | | mil.tenant_id |
| | | id, |
| | | user_id, |
| | | user_name, |
| | | code, |
| | | name, |
| | | model, |
| | | most_date, |
| | | valid, |
| | | next_date, |
| | | record_date, |
| | | CASE |
| | | WHEN next_date >= DATE_FORMAT(now(),'%Y-%m-%d') THEN 1 |
| | | ELSE 2 |
| | | END AS status, |
| | | create_user, |
| | | create_time, |
| | | update_user, |
| | | update_time, |
| | | tenant_id |
| | | FROM |
| | | measuring_instrument_ledger mil |
| | | left join sys_dept sd on sd.id = mil.dept_id |
| | | measuring_instrument_ledger |
| | | <where> |
| | | <!-- æ¥è¯¢æ¡ä»¶åä¸ --> |
| | | <if test="req.code != null and req.code != ''"> |
| | | AND mil.code LIKE CONCAT('%', #{req.code}, '%') |
| | | AND code LIKE CONCAT('%', #{req.code}, '%') |
| | | </if> |
| | | <if test="req.name != null and req.name != ''"> |
| | | AND mil.name LIKE CONCAT('%', #{req.name}, '%') |
| | | AND name LIKE CONCAT('%', #{req.name}, '%') |
| | | </if> |
| | | <if test="req.status != null"> |
| | | AND mil.status = #{req.status} |
| | | <choose> |
| | | <when test="req.status == 1"> |
| | | AND next_date >= DATE_FORMAT(now(),'%Y-%m-%d') |
| | | </when> |
| | | <when test="req.status == 2"> |
| | | AND next_date < DATE_FORMAT(now(),'%Y-%m-%d') |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | <if test="req.tenantId != null"> |
| | | AND mil.tenant_id = #{req.tenantId} |
| | | AND tenant_id = #{req.tenantId} |
| | | </if> |
| | | <if test="req.recordDate != null"> |
| | | AND mil.record_date = DATE_FORMAT(#{req.recordDate},'%Y-%m-%d') |
| | | AND record_date = DATE_FORMAT(#{req.recordDate},'%Y-%m-%d') |
| | | </if> |
| | | </where> |
| | | ORDER BY mil.update_time DESC |
| | | ORDER BY update_time DESC |
| | | </select> |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.ruoyi.staff.mapper.StaffJoinLeaveRecordMapper"> |
| | | <select id="staffJoinLeaveRecordListPage" resultType="com.ruoyi.staff.pojo.StaffJoinLeaveRecord"> |
| | | <select id="staffJoinLeaveRecordListPage" resultType="com.ruoyi.staff.dto.StaffJoinLeaveRecordDto"> |
| | | SELECT |
| | | * |
| | | staff_join_leave_record.*, |
| | | sp.post_name as postName |
| | | FROM staff_join_leave_record |
| | | LEFT JOIN |
| | | sys_post sp ON sp.post_id = staff_join_leave_record.sys_post_id |
| | | where |
| | | staff_state = #{staffJoinLeaveRecord.staffState} |
| | | <if test="staffJoinLeaveRecord.staffName != null and staffJoinLeaveRecord.staffName != '' "> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.ruoyi.staff.mapper.StaffOnJobMapper"> |
| | | <select id="staffOnJobListPage" resultType="com.ruoyi.staff.pojo.StaffOnJob"> |
| | | <select id="staffOnJobListPage" resultType="com.ruoyi.staff.dto.StaffOnJobDto"> |
| | | SELECT |
| | | * |
| | | staff_on_job.*, |
| | | sp.post_name as postName |
| | | FROM staff_on_job |
| | | LEFT JOIN |
| | | sys_post sp ON sp.post_id = staff_on_job.sys_post_id |
| | | where 1=1 |
| | | <if test="staffOnJob.staffState != null and staffOnJob.staffState != '' "> |
| | | <if test="staffOnJob.staffState != null"> |
| | | AND staff_state = #{staffOnJob.staffState} |
| | | </if> |
| | | <if test="staffOnJob.staffName != null and staffOnJob.staffName != '' "> |