lmstack преди 3 години
родител
ревизия
3ab4fbb1f4

+ 1 - 1
src/main/java/cn/fastfun/controller/api/ApiAppDeviceController.java

@@ -148,7 +148,7 @@ public class ApiAppDeviceController {
                 p.put("pack_title", device.getPackTitle());
                 p.put("deliver_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("deliver_time")), DateUtils.YMD));
                 p.put("add_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("add_time")), DateUtils.YMDHMS));
-                p.put("operator", "admin");
+                p.put("operator", device.getOperator());
             }
             page.setData(list);
         }

+ 17 - 7
src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java

@@ -49,6 +49,15 @@ public class ApiAppDeviceLogController {
         return ApiDTO.ok();
     }
 
+    @ApiOperation(value = "设备自检")
+    @RequestMapping(value = "selfcheck", method = RequestMethod.POST)
+    public ApiDTO selfCheck(@RequestBody @ApiParam(name = "入库参数", value = "指定sn", required = true) LibraryInFormParam param) {
+        AppDevice device = appDeviceService.getOne(QueryParamExp.eq("sn", param.getSn()));
+        device.setCheckStatus(1);
+        appDeviceService.save(device);
+        return ApiDTO.ok();
+    }
+
     @ApiOperation(value = "批次入库 搜索 & 重置")
     @RequestMapping(value = "instorage/batch/Query", method = RequestMethod.POST)
     public ApiPageDTO inStorageBatchQuery(@RequestBody DeviceBatchQueryParam param) {
@@ -109,15 +118,16 @@ public class ApiAppDeviceLogController {
     public ApiPageDTO inStoragePageQuery(@RequestBody LibraryInQueryParam param) {
 
         StringBuffer sql = new StringBuffer();
-        if (CollectionUtils.isEmpty(param.getCheckStatus())) {
+        if (StringUtils.isEmpty(param.getCheckStatus())) {
             sql.append("SELECT * FROM app_device_log WHERE type=1");
         } else {
             sql.append("SELECT * FROM app_device_log WHERE type=1 AND sn IN(SELECT sn FROM app_device WHERE check_status=" +
-                    param.getCheckStatus().get(0).toString() + ")");
+                    param.getCheckStatus().toString() + ")");
         }
 
         log.info("SQL: {}", sql.toString());
 
+        param.addParam(QueryParamExp.like("sn", "%".concat(param.getSn()).concat("%")));
         ApiPageDTO page = appDeviceService.getListBySQL(sql.toString(), new HashMap<>(), param);
         if (null != page.getData()) {
             // 组装数据
@@ -170,8 +180,7 @@ public class ApiAppDeviceLogController {
         Page<AppDeviceLog> deviceLogPage = deviceLogService.findByParam(param);
 
         deviceLogPage.getContent().forEach(p -> {
-            AppDevice device = new AppDevice();
-            device.setImei(p.getImei());
+            AppDevice device = appDeviceService.getOne(QueryParamExp.eq("sn", p.getSn()));
             appDeviceService.addImeiTitle(device);
             p.appendFormDevice(device);
             p.appendInTime(device);
@@ -250,7 +259,7 @@ public class ApiAppDeviceLogController {
             sql.append(" where t1.batch_num like '%").append(param.getBatchNum()).append("%'");
         }
 
-        sql.append(" group by t1.batch_num");
+        sql.append(" group by t1.operate_id");
         if (!StringUtils.isEmpty(param.getOrderBy())) {
             sql.append(param.getOrderBy());
         }
@@ -390,7 +399,7 @@ public class ApiAppDeviceLogController {
             sql.append(" where t1.batch_num like '%").append(param.getBatchNum()).append("%'");
         }
 
-        sql.append(" group by t1.batch_num");
+        sql.append(" group by t1.operate_id");
         if (!StringUtils.isEmpty(param.getOrderBy())) {
             sql.append(param.getOrderBy());
         }
@@ -401,7 +410,7 @@ public class ApiAppDeviceLogController {
             // 组装数据
             List<Map<String, Object>> list = (List<Map<String, Object>>) page.getData();
             for (Map<String, Object> p : list) {
-                AppDevice device = new AppDevice();
+                AppDevice device = appDeviceService.getOne(QueryParamExp.eq("sn",p.get("sn")));
                 device.setImei(ObjectUtil.obj2String(p.get("imei")));
                 appDeviceService.addImeiTitle(device);
 
@@ -410,6 +419,7 @@ public class ApiAppDeviceLogController {
                 p.put("deliver_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("deliver_time")), DateUtils.YMD));
                 p.put("add_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("add_time")), DateUtils.YMDHMS));
                 p.put("operator", "admin");
+                p.put("instorageTime", device.getInstorageTime());
             }
             page.setData(list);
         }

+ 18 - 0
src/main/java/cn/fastfun/controller/param/DeviceOperateQueryParam.java

@@ -17,6 +17,24 @@ public class DeviceOperateQueryParam extends QueryParam {
     @ApiModelProperty(value = "操作号", name = "operateID", required = true)
     public void setOperateID(Integer operateID) {
         addParam(QueryParamExp.eq("operateID", operateID));
+
+    }
+    @ApiModelProperty(value = "SN", name = "sn", required = true)
+    public void setSn(String sn) {
+        if (!StringUtils.isEmpty(sn))
+            addParam(QueryParamExp.eq("sn", sn));
     }
 
+    @ApiModelProperty(value = "IMEI", name = "imei", required = true)
+    public void setImei(String imei) {
+        if (!StringUtils.isEmpty(imei))
+            addParam(QueryParamExp.eq("imei", imei));
+    }
+
+    @ApiModelProperty(value = "设备状态", name = "status", example = "[], 0:未入库,1:已入库,2:已调拨,3:已出库,4:已处置")
+    public void setStatus(List<Integer> status) {
+        if (!CollectionUtils.isEmpty(status)) {
+            addParam(QueryParamExp.in("status", status.toArray(new Integer[]{})));
+        }
+    }
 }

+ 2 - 2
src/main/java/cn/fastfun/controller/param/LibraryInQueryParam.java

@@ -19,8 +19,8 @@ public class LibraryInQueryParam extends QueryParam{
     @ApiModelProperty(value = "设备编号", name = "sn", required = false)
     private String sn;
 
-    @ApiModelProperty(value = "自检状态", name = "checkStatus", example = "[], 0:未通过 ; 1:已通过;  空:全部")
-    private List<Integer> checkStatus;
+    @ApiModelProperty(value = "自检状态", name = "checkStatus", example = "0, 0:未通过 ; 1:已通过;  空:全部")
+    private Integer checkStatus;
 
 
 }

+ 1 - 1
src/main/java/cn/fastfun/controller/param/OutQueryParam.java

@@ -16,5 +16,5 @@ public class OutQueryParam extends QueryParam {
     private String sn;
 
     @ApiModelProperty(value = "出库类型", name = "outType")
-    private String outType;
+    private Integer outType;
 }