Browse Source

批次入库设备显示

LeeXin 3 years ago
parent
commit
21f19c9feb

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

@@ -1,7 +1,10 @@
 package cn.fastfun.controller.api;
 
 import cn.fastfun.controller.param.LibraryQueryParam;
+import cn.fastfun.service.AppLibraryLogService;
+import cn.fastfun.service.entity.AppDevice;
 import cn.fastfun.service.entity.AppLibraryLog;
+import cn.fastfun.service.entity.Product;
 import com.bridge.dto.ApiDTO;
 import com.bridge.dto.ApiPageDTO;
 import com.bridge.dto.IdParam;
@@ -16,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
 
 /**
  * @author Bridge AutoGen
@@ -26,8 +31,7 @@ import java.util.Arrays;
 public class ApiAppLibraryLogController {
     //业务类
     @Resource(name = "appLibraryLogService")
-    JpaService<AppLibraryLog, String> appLibraryLogService;
-
+    AppLibraryLogService appLibraryLogService;
 
     /**
      * 数据保存
@@ -57,4 +61,29 @@ public class ApiAppLibraryLogController {
         return new ApiPageDTO(null, appLibraryLogService.findByParam(param));
     }
 
+
+    @ApiOperation(value = "显示批次待入库的电池")
+    @RequestMapping(value = "appDevice", method = RequestMethod.POST)
+    public ApiDTO importRestDevice(@RequestBody LibraryQueryParam param) {
+        List<AppDevice> appDevices = appLibraryLogService.showAppDevice(param.getBatchName());
+        appDevices.sort(Comparator.comparing(AppDevice::getAddTime).reversed());
+        int resultSize = appDevices.size();
+        int startIndex = (param.getIndex() - 1) * param.getLength();
+        int endIndex = startIndex +  param.getLength();
+        List<AppDevice> appDevicesByPage;
+        try {
+            if(endIndex > resultSize){
+                endIndex = resultSize;
+                appDevicesByPage = appDevices.subList(startIndex,endIndex);
+            }else{
+                appDevicesByPage = appDevices.subList(startIndex,endIndex);
+            }
+        }catch(IllegalArgumentException e){
+            return ApiDTO.error("分页索引越界!");
+        }
+        ApiPageDTO result = new ApiPageDTO("搜索成功!",appDevicesByPage);
+        result.setTotal(appDevicesByPage.size());
+        return result;
+    }
+
 }

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

@@ -6,6 +6,8 @@ import org.springframework.util.StringUtils;
 
 public class LibraryQueryParam extends QueryParam {
 
+    private String batchName;
+
     public void setSn(String sn) {
         if (!StringUtils.isEmpty(sn))
             addParam(QueryParamExp.like("sn", "%".concat(sn).concat("%")));
@@ -15,4 +17,9 @@ public class LibraryQueryParam extends QueryParam {
         if (!StringUtils.isEmpty(status))
             addParam(QueryParamExp.eq("status", status));
     }
+
+    public String getBatchName() {
+        return batchName;
+    }
+
 }

+ 18 - 0
src/main/java/cn/fastfun/service/AppLibraryLogService.java

@@ -0,0 +1,18 @@
+package cn.fastfun.service;
+
+
+import cn.fastfun.service.entity.AppDevice;
+import cn.fastfun.service.entity.AppLibraryLog;
+import com.bridge.service.JpaService;
+
+import java.util.List;
+
+public interface AppLibraryLogService extends JpaService<AppLibraryLog, String> {
+
+    /**
+     * 指定批次号入库的设备
+     @param batchNum
+     @return
+     */
+    List<AppDevice> showAppDevice(String batchNum);
+}

+ 1 - 0
src/main/java/cn/fastfun/service/impl/AppDeviceServiceImp.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 

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

@@ -1,15 +1,35 @@
 package cn.fastfun.service.impl;
 
+import cn.fastfun.service.AppDeviceService;
+import cn.fastfun.service.AppLibraryLogService;
+import cn.fastfun.service.entity.AppDevice;
 import cn.fastfun.service.entity.AppLibraryLog;
+import cn.fastfun.service.repository.AppDeviceRepository;
+import com.bridge.dto.QueryParamExp;
 import com.bridge.service.JpaService;
 import com.bridge.service.impl.JpaServiceImp;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
 /**
 * 服务实现类
 * Created by Bridge.
 */
 @Service("appLibraryLogService")
-public class AppLibraryLogServiceImp extends JpaServiceImp<AppLibraryLog, String> implements JpaService<AppLibraryLog, String> {
+public class AppLibraryLogServiceImp extends JpaServiceImp<AppLibraryLog, String> implements AppLibraryLogService {
+
+
+    @Resource
+    AppDeviceService appDeviceService;
 
+    @Override
+    public List<AppDevice> showAppDevice(String batchNum) {
+        List<AppDevice> restAppDevice = appDeviceService.findAll(
+                Arrays.asList(QueryParamExp.eq("batchNum",batchNum),QueryParamExp.eq("status",0)));
+        return restAppDevice;
+    }
 }