Browse Source

批次入库设备入库

LeeXin 3 years ago
parent
commit
d39f1ad27e

+ 10 - 2
src/main/java/cn/fastfun/controller/api/ApiAppLibraryLogController.java

@@ -1,6 +1,7 @@
 package cn.fastfun.controller.api;
 
 import cn.fastfun.controller.param.LibraryQueryParam;
+import cn.fastfun.service.AppDeviceService;
 import cn.fastfun.service.AppLibraryLogService;
 import cn.fastfun.service.entity.AppDevice;
 import cn.fastfun.service.entity.AppLibraryLog;
@@ -63,8 +64,8 @@ public class ApiAppLibraryLogController {
 
 
     @ApiOperation(value = "显示批次待入库的电池")
-    @RequestMapping(value = "appDevice", method = RequestMethod.POST)
-    public ApiDTO importRestDevice(@RequestBody LibraryQueryParam param) {
+    @RequestMapping(value = "showAppDevice", method = RequestMethod.POST)
+    public ApiDTO showRestDevice(@RequestBody LibraryQueryParam param) {
         List<AppDevice> appDevices = appLibraryLogService.showAppDevice(param.getBatchName());
         appDevices.sort(Comparator.comparing(AppDevice::getAddTime).reversed());
         int resultSize = appDevices.size();
@@ -86,4 +87,11 @@ public class ApiAppLibraryLogController {
         return result;
     }
 
+    @ApiOperation(value = "入库批次待入库的电池")
+    @RequestMapping(value = "importAppDevice", method = RequestMethod.POST)
+    public ApiDTO importRestDevice(@RequestBody LibraryQueryParam param) {
+        int snSize = appLibraryLogService.importAppDevices(param.getSnArray());
+        return ApiDTO.ok("入库成功",snSize);
+    }
+
 }

+ 4 - 0
src/main/java/cn/fastfun/controller/param/LibraryQueryParam.java

@@ -7,6 +7,7 @@ import org.springframework.util.StringUtils;
 public class LibraryQueryParam extends QueryParam {
 
     private String batchName;
+    private String[] snArray;
 
     public void setSn(String sn) {
         if (!StringUtils.isEmpty(sn))
@@ -22,4 +23,7 @@ public class LibraryQueryParam extends QueryParam {
         return batchName;
     }
 
+    public String[] getSnArray() {
+        return snArray;
+    }
 }

+ 8 - 1
src/main/java/cn/fastfun/service/AppLibraryLogService.java

@@ -10,9 +10,16 @@ import java.util.List;
 public interface AppLibraryLogService extends JpaService<AppLibraryLog, String> {
 
     /**
-     * 指定批次号入库的设备
+     * 获得指定批次号的设备
      @param batchNum
      @return
      */
     List<AppDevice> showAppDevice(String batchNum);
+
+    /**
+     * 完成多个设备的入库
+     @param sns
+     @return
+     */
+    int importAppDevices(String[] sns);
 }

+ 14 - 1
src/main/java/cn/fastfun/service/impl/AppLibraryLogServiceImp.java

@@ -29,7 +29,20 @@ public class AppLibraryLogServiceImp extends JpaServiceImp<AppLibraryLog, String
     @Override
     public List<AppDevice> showAppDevice(String batchNum) {
         List<AppDevice> restAppDevice = appDeviceService.findAll(
-                Arrays.asList(QueryParamExp.eq("batchNum",batchNum),QueryParamExp.eq("status",0)));
+                QueryParamExp.eq("batchNum",batchNum));
         return restAppDevice;
     }
+
+    @Override
+    public int importAppDevices(String[] sns) {
+        int snSize = 0;
+        for(String sn: sns){
+            List<AppDevice> appDevice = appDeviceService.findAll(
+                    QueryParamExp.eq("imei",sn));
+            appDevice.get(0).setStatus(1);
+            appDeviceService.save(appDevice.get(0));
+            snSize += 1;
+        }
+        return snSize;
+    }
 }