Jelajahi Sumber

Merge remote-tracking branch 'origin/dev_v1.0.0' into dev_v1.0.0

wangliang 1 tahun lalu
induk
melakukan
02ea69a5d0

+ 1 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceInOutSubmitParam.java

@@ -27,6 +27,7 @@ public class DeviceInOutSubmitParam {
     private String sopNo;
 
     @ApiModelProperty("出入库时间")
+    @NotNull(message = "缺少出入库时间")
     @Range(min = 1L,message = "缺少出入库时间")
     private Long inOutTime;
 

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/DeviceInOutResult.java

@@ -31,6 +31,8 @@ public class DeviceInOutResult {
     private String deviceNo;
     @ApiModelProperty("设备品牌")
     private String deviceBrand;
+    @ApiModelProperty("设备型号")
+    private String deviceModel;
     @ApiModelProperty("扫描量")
     private Integer scanCount;
 
@@ -122,6 +124,14 @@ public class DeviceInOutResult {
         this.deviceBrand = deviceBrand;
     }
 
+    public String getDeviceModel() {
+        return deviceModel;
+    }
+
+    public void setDeviceModel(String deviceModel) {
+        this.deviceModel = deviceModel;
+    }
+
     public Integer getScanCount() {
         return scanCount;
     }

+ 10 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceInOutServiceImpl.java

@@ -85,9 +85,15 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
         List<DeviceInOutForm> deviceInOutFormList = deviceInOutSubmitParam.getDeviceInOutFormList();
         List<TBDeviceInOut> tbDeviceInOutList = deviceInOutFormList.stream().flatMap(e -> {
             TBDeviceInOut tbDeviceInOut = new TBDeviceInOut();
-            tbDeviceInOut.setServiceId(serviceUnitId);
-            tbDeviceInOut.setCrmNo(crmNo);
-            tbDeviceInOut.setSopNo(sopNo);
+            if (serviceUnitId != null && serviceUnitId > 0) {
+                tbDeviceInOut.setServiceId(serviceUnitId);
+            }
+            if (crmNo != null && crmNo.length() > 0) {
+                tbDeviceInOut.setCrmNo(crmNo);
+            }
+            if (sopNo != null && sopNo.length() > 0) {
+                tbDeviceInOut.setSopNo(sopNo);
+            }
             tbDeviceInOut.setUserId(requestUser.getId());
             tbDeviceInOut.setType(inOutType);
             tbDeviceInOut.setDeviceNo(e.getDeviceNo());
@@ -104,6 +110,7 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
                     .set(SysDevice::getLocation, e.getAddress())
                     .set(SysDevice::getScanCount, e.getScanCount())
                     .set(SysDevice::getStatus, e.getDeviceStatus())
+                    .set(SysDevice::getBound, inOutType)
                     .eq(SysDevice::getSerialNo, e.getDeviceNo());
             sysDeviceService.update(updateWrapper);
 

+ 19 - 2
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -169,8 +169,25 @@ CREATE TABLE `t_b_ding_submit` (
                                    `update_id` bigint DEFAULT NULL COMMENT '更新人id',
                                    `update_time` bigint DEFAULT NULL COMMENT '更新时间',
                                    PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='考勤提交审核表'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='考勤提交审核表';
 
 ALTER TABLE t_b_ding
     ADD COLUMN user_archives_id BIGINT NOT NULL COMMENT '人员档案id' AFTER user_id,
-    ADD COLUMN role_type VARCHAR(20) NOT NULL COMMENT '项目角色' AFTER user_archives_id;
+    ADD COLUMN role_type VARCHAR(20) NOT NULL COMMENT '项目角色' AFTER user_archives_id;
+
+-- 2023/08/28
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2032', 'sop管理 - 设备出入库登记查询', '/api/admin/device/in/out/sop_page', 'URL', '43', '1', 'AUTH', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2033', '查询可出库的设备信息', '/api/admin/device/in/out/can_out_info', 'URL', '43', '2', 'AUTH', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2034', '查询可入库的设备信息', '/api/admin/device/in/out/can_in_info', 'URL', '43', '3', 'AUTH', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2035', '设备出入库提交', '/api/admin/device/in/out/submit', 'URL', '43', '4', 'AUTH', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2036', '资源保障-设备保障-出入库登记查询', '/api/admin/device/in/out/source_page', 'URL', '37', '1', 'AUTH', '1', '1', '0');
+UPDATE sys_privilege SET related = '2032' WHERE (id = '188');
+UPDATE sys_privilege SET related = '2032' WHERE (id = '189');
+UPDATE sys_privilege SET related = '2032' WHERE (id = '192');
+UPDATE sys_privilege SET related = '2033,2034,2035' WHERE (id = '190');
+UPDATE sys_privilege SET related = '2036' WHERE (id = '167');
+UPDATE sys_privilege SET related = '2036' WHERE (id = '168');
+UPDATE sys_privilege SET related = '2036' WHERE (id = '169');
+
+ALTER TABLE t_b_device_in_out
+    CHANGE COLUMN service_id service_id BIGINT NULL COMMENT '服务单元id' ;

+ 7 - 17
sop-business/src/main/resources/mapper/TBDeviceInOutMapper.xml

@@ -11,6 +11,7 @@
             tbdio.device_no AS deviceNo,
             sd.id AS deviceId,
             sd.brand AS deviceBrand,
+            sd.model AS deviceModel,
             tbdio.status AS deviceStatus,
             tbdio.in_out_time AS inOutTime,
             su.id AS userId,
@@ -70,6 +71,7 @@
             tbdio.device_no AS deviceNo,
             sd.id AS deviceId,
             sd.brand AS deviceBrand,
+            sd.model AS deviceModel,
             tbdio.status AS deviceStatus,
             tbdio.in_out_time AS inOutTime,
             su.id AS userId,
@@ -119,6 +121,7 @@
         SELECT
             sd.serial_no AS serialNo,
             sd.brand AS deviceBrand,
+            sd.model AS deviceModel,
             ss.name AS supplierName,
             sd.status AS deviceStatus,
             sd.scan_count AS scanCount,
@@ -127,13 +130,6 @@
             sys_device sd
                 LEFT JOIN
             sys_supplier ss ON sd.supplier_id = ss.id
-                LEFT JOIN
-            (SELECT
-                 device_no, type
-             FROM
-                 t_b_device_in_out
-             ORDER BY in_out_time DESC
-             LIMIT 1) lt ON sd.serial_no = lt.device_no
         <where>
             AND sd.enable
             <if test="supplierId != null">
@@ -143,7 +139,7 @@
                 AND sd.status = #{status}
             </if>
             <if test="inOutType != null">
-                AND (lt.type is null OR lt.type = #{inOutType})
+                AND sd.bound = #{inOutType}
             </if>
         </where>
         ORDER BY ss.id,sd.brand,sd.serial_no
@@ -152,6 +148,7 @@
         SELECT
             sd.serial_no AS serialNo,
             sd.brand AS deviceBrand,
+            sd.model AS deviceModel,
             ss.name AS supplierName,
             sd.status AS deviceStatus,
             sd.scan_count AS scanCount,
@@ -161,23 +158,16 @@
             sys_device sd
         LEFT JOIN
             sys_supplier ss ON sd.supplier_id = ss.id
-        LEFT JOIN
-        (SELECT
-            device_no, type, crm_no
-        FROM
-            t_b_device_in_out
-        ORDER BY in_out_time DESC
-        LIMIT 1) lt ON sd.serial_no = lt.device_no
         <where>
             AND sd.enable
             <if test="supplierId != null">
                 AND ss.id = #{supplierId}
             </if>
             <if test="inOutType != null">
-                AND lt.type = #{inOutType}
+                AND sd.bound = #{inOutType}
             </if>
             <if test="crmNo != null and crmNo != ''">
-                AND lt.crm_no = #{crmNo}
+                AND EXISTS(SELECT 1 FROM t_b_device_in_out tbdio WHERE tbdio.device_no = sd.serial_no AND tbdio.crm_no = #{crmNo})
             </if>
         </where>
         ORDER BY ss.id,sd.brand,sd.serial_no

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -169,6 +169,7 @@ public class SystemConstant {
     public static final String PREFIX_URL_PRODUCT = "/admin/tb/product";
     public static final String PREFIX_URL_MY_WORK_BENCH = "/admin/my/work_bench";
     public static final String PREFIX_URL_PROJECT_EXCHANGE = "/admin/project/exchange";
+    public static final String PREFIX_URL_DEVICE_IN_OUT = "/admin/device/in/out";
 
     /**
      * 缓存配置

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/EnumList.java

@@ -39,6 +39,8 @@ public enum EnumList {
 
     DEVICE_USAGE_TYPE_ENUM(DeviceUsageTypeEnum.class),
 
+    DEVICE_STATUS_ENUM(DeviceStatusEnum.class),
+
     WARN_TYPE_ENUM(WarnTypeEnum.class),
 
     DELAY_WARN_TYPE_ENUM(DelayWarnTypeEnum.class),

+ 6 - 0
sop-server/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -478,6 +478,12 @@ public class SysController {
                     map.put(deviceUsageTypeEnum, deviceUsageTypeEnum.getTitle());
                 }
                 break;
+            case DEVICE_STATUS_ENUM://设备状态类型
+                DeviceStatusEnum[] deviceStatusEnums = DeviceStatusEnum.values();
+                for (DeviceStatusEnum deviceStatusEnum : deviceStatusEnums) {
+                    map.put(deviceStatusEnum, deviceStatusEnum.getTitle());
+                }
+                break;
             case WARN_TYPE_ENUM://预警类型
                 WarnTypeEnum[] warnTypeEnums = WarnTypeEnum.values();
                 for (WarnTypeEnum warnTypeEnum : warnTypeEnums) {

+ 92 - 4
sop-server/src/main/java/com/qmth/sop/server/api/TBDeviceInOutController.java

@@ -1,9 +1,25 @@
 package com.qmth.sop.server.api;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.annotation.OperationLog;
+import com.qmth.sop.business.bean.params.DeviceInOutSubmitParam;
+import com.qmth.sop.business.bean.result.DeviceInOutResult;
+import com.qmth.sop.business.service.TBDeviceInOutService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.DeviceStatusEnum;
+import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
+import com.qmth.sop.common.enums.InOutTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 
 /**
  * <p>
@@ -13,8 +29,80 @@ import org.springframework.web.bind.annotation.RestController;
  * @author wangliang
  * @since 2023-08-01
  */
+@Api(tags = "设备出入库管理前端控制器")
 @RestController
-@RequestMapping("/t-bdevice-in-out")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DEVICE_IN_OUT)
 public class TBDeviceInOutController {
+    @Resource
+    private TBDeviceInOutService tbDeviceInOutService;
 
-}
+    @ApiOperation(value = "sop管理 - 设备出入库登记查询")
+    @RequestMapping(value = "/sop_page", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DeviceInOutResult.class)})
+    @OperationLog
+    public Result findDeviceInOutPageBySop(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
+                                           @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
+                                           @ApiParam(value = "登记人") @RequestParam(required = false) String userId,
+                                           @ApiParam(value = "运行状态") @RequestParam(required = false) DeviceStatusEnum deviceStatus,
+                                           @ApiParam(value = "出入库时间 - 开始") @RequestParam(required = false) Long inOutTimeStart,
+                                           @ApiParam(value = "出入库时间 - 结束") @RequestParam(required = false) Long inOutTimeEnd,
+                                           @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo,
+                                           @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
+                                           @ApiParam(value = "当前地") @RequestParam(required = false) String location,
+                                           @ApiParam(value = "发往地") @RequestParam(required = false) String address,
+                                           @ApiParam(value = "分页页数", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                                           @ApiParam(value = "分页容量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+
+        return ResultUtil.ok(tbDeviceInOutService.findDeviceInOutPageBySop(SystemConstant.convertIdToLong(serviceUnitId),
+                usageType, SystemConstant.convertIdToLong(userId), deviceStatus, inOutTimeStart, inOutTimeEnd, deviceNo, customName, location, address,
+                pageNumber, pageSize));
+    }
+
+    @ApiOperation(value = "查询可出库的设备信息")
+    @RequestMapping(value = "/can_out_info", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DeviceInOutResult.class)})
+    @OperationLog
+    public Result findDeviceCanOutInfo(@ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId) {
+        return ResultUtil.ok(tbDeviceInOutService.findDeviceCanOutInfo(SystemConstant.convertIdToLong(supplierId)));
+    }
+
+    @ApiOperation(value = "查询可入库的设备信息")
+    @RequestMapping(value = "/can_in_info", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DeviceInOutResult.class)})
+    @OperationLog
+    public Result findDeviceCanInInfo(@ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId,
+                                      @ApiParam(value = "派单号") @RequestParam(required = false) String crmNo) {
+        return ResultUtil.ok(tbDeviceInOutService.findDeviceCanInInfo(SystemConstant.convertIdToLong(supplierId), crmNo));
+    }
+
+    @ApiOperation(value = "设备出入库提交")
+    @RequestMapping(value = "/submit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
+    @OperationLog
+    public Result deviceInOutSubmit(@Valid @RequestBody DeviceInOutSubmitParam deviceInOutSubmitParam, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        tbDeviceInOutService.deviceInOutSubmit(deviceInOutSubmitParam);
+        return ResultUtil.ok();
+    }
+
+    @ApiOperation(value = "资源保障-设备保障-出入库登记查询")
+    @RequestMapping(value = "/source_page", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DeviceInOutResult.class)})
+    @OperationLog
+    public Result findDeviceInOutPageBySource(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
+                                              @ApiParam(value = "出入库类型") @RequestParam(required = false) InOutTypeEnum inOutType,
+                                              @ApiParam(value = "设备编号") @RequestParam(required = false) String deviceNo,
+                                              @ApiParam(value = "出入库时间 - 开始") @RequestParam(required = false) Long inOutTimeStart,
+                                              @ApiParam(value = "出入库时间 - 结束") @RequestParam(required = false) Long inOutTimeEnd,
+                                              @ApiParam(value = "供应商id") @RequestParam(required = false) String supplierId,
+                                              @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
+                                              @ApiParam(value = "分页页数", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                                              @ApiParam(value = "分页容量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+
+        return ResultUtil.ok(tbDeviceInOutService.findDeviceInOutPageBySource(SystemConstant.convertIdToLong(serviceUnitId),
+                inOutType, deviceNo, inOutTimeStart, inOutTimeEnd, SystemConstant.convertIdToLong(supplierId), customName,
+                pageNumber, pageSize));
+    }
+}