liwen
10 months ago
9 changed files with 312 additions and 2 deletions
@ -0,0 +1,68 @@
|
||||
package com.hnac.hzims.safeproduct.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import javax.validation.constraints.Size; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2024-01-12 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("hzims_device") |
||||
@ApiModel(value = "特种设备实体类") |
||||
public class DeviceEntity extends BaseEntity { |
||||
|
||||
@Size(max = 50, message = "设备名称长度不能超过50") |
||||
@ApiModelProperty("设备名称") |
||||
private String name; |
||||
|
||||
@Size(max = 50, message = "规格型号长度不能超过50") |
||||
@ApiModelProperty("规格型号") |
||||
private String type; |
||||
|
||||
@Size(max = 50, message = "设备编码长度不能超过50") |
||||
@ApiModelProperty("设备编码") |
||||
private String code; |
||||
|
||||
@Size(max = 255, message = "产品合格证号长度不能超过255") |
||||
@ApiModelProperty("产品合格证号") |
||||
private String qualityCertificateNo; |
||||
|
||||
@ApiModelProperty("生产日期") |
||||
private Date productionTime; |
||||
|
||||
@ApiModelProperty("使用时间") |
||||
private Date usedTime; |
||||
|
||||
@Size(max = 255, message = "使用地点长度不能超过255") |
||||
@ApiModelProperty("使用地点") |
||||
private String usedLocation; |
||||
|
||||
@ApiModelProperty("检验周期") |
||||
private Integer inspectionPeriod; |
||||
|
||||
@ApiModelProperty("本次检验日期") |
||||
private Date inspectionCurrentTime; |
||||
|
||||
@ApiModelProperty("下次检验日期") |
||||
private Date inspectionNextTime; |
||||
|
||||
@ApiModelProperty("上次检验日期") |
||||
private Date inspectionLastTime; |
||||
|
||||
@Size(max = 50, message = "设备管理人长度不能超过50") |
||||
@ApiModelProperty("设备管理人") |
||||
private String manager; |
||||
|
||||
@Size(max = 20, message = "设备状态长度不能超过20") |
||||
@ApiModelProperty("设备状态") |
||||
private String deviceStatus; |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.hnac.hzims.safeproduct.enums; |
||||
|
||||
/** |
||||
* 特种设备状态枚举类 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-16 |
||||
*/ |
||||
public enum DeviceStatusEnum { |
||||
|
||||
NORMAL("NORMAL", "正常"), |
||||
EXPIRED("EXPIRED", "待检修"); |
||||
|
||||
private final String value; |
||||
|
||||
private final String desc; |
||||
|
||||
DeviceStatusEnum(String value, String desc) { |
||||
this.value = value; |
||||
this.desc = desc; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public String getDesc() { |
||||
return desc; |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.hnac.hzims.safeproduct.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.common.utils.Condition; |
||||
import com.hnac.hzims.safeproduct.entity.DeviceEntity; |
||||
import com.hnac.hzims.safeproduct.service.IDeviceService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiImplicitParam; |
||||
import io.swagger.annotations.ApiImplicitParams; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 特种设备管理接口类 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-12 |
||||
*/ |
||||
@RequestMapping("/device") |
||||
@AllArgsConstructor |
||||
@RestController |
||||
@Api(value = "特种设备", tags = "特种设备接口") |
||||
public class DeviceController extends BladeController { |
||||
|
||||
private final IDeviceService deviceService; |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增") |
||||
@ApiOperationSupport(order = 1) |
||||
public R save(@Valid @RequestBody DeviceEntity deviceEntity) { |
||||
return R.status(deviceService.save(deviceEntity)); |
||||
} |
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改") |
||||
@ApiOperationSupport(order = 2) |
||||
public R update(DeviceEntity deviceEntity) { |
||||
return R.status(deviceService.updateById(deviceEntity)); |
||||
} |
||||
|
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "删除") |
||||
@ApiOperationSupport(order = 3) |
||||
public R remove(@RequestParam Long id) { |
||||
return R.status(deviceService.removeById(id)); |
||||
} |
||||
|
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情") |
||||
@ApiOperationSupport(order = 4) |
||||
public R<DeviceEntity> detail(@RequestParam Long id) { |
||||
return R.data(deviceService.getById(id)); |
||||
} |
||||
|
||||
@GetMapping("/page") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), |
||||
@ApiImplicitParam(name = "plateNumber", value = "车牌号", dataType = "query", paramType = "string") |
||||
}) |
||||
@ApiOperation(value = "分页") |
||||
@ApiOperationSupport(order = 5) |
||||
public R<IPage<DeviceEntity>> page(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { |
||||
IPage<DeviceEntity> page = deviceService.page(Condition.getPage(query), Condition.getQueryWrapper(param, DeviceEntity.class) |
||||
.lambda().orderByDesc(DeviceEntity::getCreateTime)); |
||||
return R.data(page); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.hnac.hzims.safeproduct.jobs; |
||||
|
||||
import com.hnac.hzims.safeproduct.entity.DeviceEntity; |
||||
import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; |
||||
import com.hnac.hzims.safeproduct.service.IDeviceService; |
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.annotation.XxlJob; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 特种设备模块定时任务 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-16 |
||||
*/ |
||||
@Component |
||||
public class DeviceJob { |
||||
|
||||
@Autowired |
||||
IDeviceService deviceService; |
||||
|
||||
@XxlJob("autoChangeDeviceStatus") |
||||
public ReturnT<String> autoChangeDeviceStatus(String param) { |
||||
// 获取时间范围
|
||||
Date current = DateUtil.now(); |
||||
Date before = DateUtil.minusDays(current, 1); |
||||
String today = DateUtil.format(current, "yyyy-mm-dd"); |
||||
String yesterday = DateUtil.format(before, "yyyy-mm-dd"); |
||||
// 查询昨天的过期设备
|
||||
List<DeviceEntity> list = deviceService.getExpiredDeviceByTime(yesterday, today); |
||||
list.forEach(e -> e.setDeviceStatus(DeviceStatusEnum.EXPIRED.getValue())); |
||||
// 更新状态
|
||||
boolean update = deviceService.updateBatchById(list); |
||||
return update ? ReturnT.SUCCESS : ReturnT.FAIL; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.hnac.hzims.safeproduct.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.safeproduct.entity.DeviceEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 特种设备Mapper类 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-12 |
||||
*/ |
||||
@Mapper |
||||
public interface DeviceMapper extends BaseMapper<DeviceEntity> { |
||||
|
||||
} |
@ -0,0 +1,4 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.safeproduct.mapper.DeviceMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,22 @@
|
||||
package com.hnac.hzims.safeproduct.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.safeproduct.entity.DeviceEntity; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 特种设备服务类 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-12 |
||||
*/ |
||||
public interface IDeviceService extends IService<DeviceEntity> { |
||||
|
||||
/** |
||||
* 查找时间范围内的过期设备 |
||||
* @param startTime 开始时间 |
||||
* @param endTime 结束时间 |
||||
*/ |
||||
List<DeviceEntity> getExpiredDeviceByTime(String startTime, String endTime); |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.safeproduct.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.safeproduct.entity.DeviceEntity; |
||||
import com.hnac.hzims.safeproduct.enums.DeviceStatusEnum; |
||||
import com.hnac.hzims.safeproduct.mapper.DeviceMapper; |
||||
import com.hnac.hzims.safeproduct.service.IDeviceService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 特种设备服务实现类 |
||||
* |
||||
* @author liwen |
||||
* @date 2024-01-12 |
||||
*/ |
||||
@Service |
||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, DeviceEntity> implements IDeviceService { |
||||
|
||||
/** |
||||
* 查找时间范围内的过期设备 |
||||
*/ |
||||
@Override |
||||
public List<DeviceEntity> getExpiredDeviceByTime(String startTime, String endTime) { |
||||
QueryWrapper<DeviceEntity> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.lambda().eq(DeviceEntity::getDeviceStatus, DeviceStatusEnum.NORMAL.getValue()) |
||||
.ge(DeviceEntity::getInspectionNextTime, startTime) |
||||
.le(DeviceEntity::getInspectionNextTime, endTime); |
||||
return this.list(queryWrapper); |
||||
} |
||||
} |
Loading…
Reference in new issue