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