Browse Source

add: 特种设备模块

zhongwei
liwen 10 months ago
parent
commit
c348f2b764
  1. 68
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java
  2. 30
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/DeviceStatusEnum.java
  3. 76
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java
  4. 41
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java
  5. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java
  6. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml
  7. 22
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java
  8. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java
  9. 24
      hzims-service/safeproduct/src/main/resources/db/1.0.2.sql

68
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DeviceEntity.java

@ -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;
}

30
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/DeviceStatusEnum.java

@ -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;
}
}

76
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DeviceController.java

@ -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);
}
}

41
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/DeviceJob.java

@ -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;
}
}

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.java

@ -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> {
}

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/DeviceMapper.xml

@ -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>

22
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDeviceService.java

@ -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);
}

33
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DeviceServiceImpl.java

@ -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);
}
}

24
hzims-service/safeproduct/src/main/resources/db/1.0.2.sql

@ -339,7 +339,27 @@ CREATE TABLE `hzims_car_check_item` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='车检项表' ROW_FORMAT=Dynamic;
CREATE TABLE `hzims_equipment` (
CREATE TABLE `hzims_device` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`name`
`name` varchar(50) NOT NULL COMMENT '设备名称',
`type` varchar(50) NOT NULL DEFAULT '' COMMENT '规格型号',
`code` varchar(50) NOT NULL COMMENT '编码',
`quality_cerfiticate_no` varchar(255) NOT NULL DEFAULT '' COMMENT '产品合格证号',
`production_time` date DEFAULT NULL COMMENT '生产日期',
`used_time` date DEFAULT NULL COMMENT '使用日期',
`used_location` varchar(255) NOT NULL DEFAULT '' COMMENT '使用地点',
`inspection_period` int(10) DEFAULT NULL COMMENT '检验周期',
`inspection_current_time` date DEFAULT NULL COMMENT '本次检验日期',
`inspection_next_time` date DEFAULT NULL COMMENT '下次检验日期',
`inspection_last_time` date DEFAULT NULL COMMENT '上次检验日期',
`manager` varchar(50) NOT NULL DEFAULT '' COMMENT '设备管理人',
`device_status` varchar(20) NOT NULL DEFAULT 'NORMAL' COMMENT '设备状态',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_user` bigint(20) DEFAULT '-1' COMMENT '更新人',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`status` int(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='特种设备表' ROW_FORMAT=Dynamic;
Loading…
Cancel
Save