|
@@ -1,111 +0,0 @@
|
|
|
-package cn.fastfun.controller.api;
|
|
|
-
|
|
|
-import cn.fastfun.controller.param.LibraryOutFormParam;
|
|
|
-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;
|
|
|
-import cn.fastfun.service.entity.Product;
|
|
|
-import com.bridge.dto.ApiDTO;
|
|
|
-import com.bridge.dto.ApiPageDTO;
|
|
|
-import com.bridge.dto.IdParam;
|
|
|
-import com.bridge.service.JpaService;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-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
|
|
|
- */
|
|
|
-@Api(tags = {"设备出入库记录"})
|
|
|
-@RestController
|
|
|
-@RequestMapping("/api/v1/applibrarylog")
|
|
|
-public class ApiAppLibraryLogController {
|
|
|
- //业务类
|
|
|
- @Resource(name = "appLibraryLogService")
|
|
|
- AppLibraryLogService appLibraryLogService;
|
|
|
-
|
|
|
- @ApiOperation(value = "设备入库")
|
|
|
- @RequestMapping(value = "in", method = RequestMethod.POST)
|
|
|
- public ApiDTO in(@RequestBody @ApiParam(name = "设备出入库记录对象", value = "传入json格式", required = true) AppLibraryLog entity) {
|
|
|
- return ApiDTO.ok("保存成功", appLibraryLogService.save(entity));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "设备出库")
|
|
|
- @RequestMapping(value = "out", method = RequestMethod.POST)
|
|
|
- public ApiDTO out(@RequestBody @ApiParam(name = "设备出库记录", value = "传入json格式", required = true) LibraryOutFormParam param) {
|
|
|
- appLibraryLogService.outAppDevice(param);
|
|
|
- return ApiDTO.ok("保存成功");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 数据保存
|
|
|
- */
|
|
|
- @ApiOperation(value = "保存信息")
|
|
|
- @RequestMapping(value = "save", method = RequestMethod.POST)
|
|
|
- public ApiDTO save(@RequestBody @ApiParam(name = "设备出入库记录对象", value = "传入json格式", required = true) AppLibraryLog entity) {
|
|
|
- return ApiDTO.ok("保存成功", appLibraryLogService.save(entity));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询信息")
|
|
|
- @RequestMapping(value = "get", method = RequestMethod.POST)
|
|
|
- public ApiDTO get(@RequestBody @ApiParam(name = "设备出入库记录id", required = true) IdParam param) {
|
|
|
- return ApiDTO.ok("查询成功!", appLibraryLogService.get(param.getId()));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "删除信息")
|
|
|
- @RequestMapping(value = "delete", method = RequestMethod.POST)
|
|
|
- public ApiDTO delete(@RequestBody @ApiParam(name = "设备出入库记录id", required = true) IdParam param) {
|
|
|
- appLibraryLogService.delete(Arrays.asList(param.getId().split(",")));
|
|
|
- return ApiDTO.ok("删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "分页搜索")
|
|
|
- @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
|
|
|
- public ApiPageDTO pageQuery(@RequestBody LibraryQueryParam param) {
|
|
|
- return new ApiPageDTO(null, appLibraryLogService.findByParam(param));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "显示批次待入库的电池")
|
|
|
- @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();
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "入库批次待入库的电池")
|
|
|
- @RequestMapping(value = "importAppDevice", method = RequestMethod.POST)
|
|
|
- public ApiDTO importRestDevice(@RequestBody LibraryQueryParam param) {
|
|
|
- int snSize = appLibraryLogService.importAppDevices(param.getSnArray());
|
|
|
- return ApiDTO.ok("入库成功", snSize);
|
|
|
- }
|
|
|
-
|
|
|
-}
|