无关风月
2024-12-20 6dd0a9a11ca7ff6f71c195d8187d138e28115f2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.jilongda.manage.controller;
 
 
import com.jilongda.common.basic.ApiResult;
import com.jilongda.common.basic.PageInfo;
import com.jilongda.manage.dto.FrameInventoryDTO;
import com.jilongda.manage.model.TInventory;
import com.jilongda.manage.model.TInventoryFrameDetail;
import com.jilongda.manage.query.TFrameGoodsQuery;
import com.jilongda.manage.query.TInventoryQuery;
import com.jilongda.manage.service.TInventoryFrameDetailService;
import com.jilongda.manage.service.TInventoryLensDetailService;
import com.jilongda.manage.service.TInventoryService;
import com.jilongda.manage.utils.LoginInfoUtil;
import com.jilongda.manage.vo.TFrameGoodsVO;
import com.jilongda.manage.vo.TInventoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
 
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
 
/**
 * <p>
 * 盘点表 前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-12-09
 */
@RestController
@Api(tags = "盘点管理")
@RequestMapping("/t-inventory")
public class TInventoryController {
 
    @Resource
    private TInventoryService inventoryService;
    @Resource
    private TInventoryFrameDetailService inventoryFrameDetailService;
    @Resource
    private TInventoryLensDetailService inventoryLensDetailService;
    @Resource
    private LoginInfoUtil loginInfoUtil;
    @ApiOperation(value = "盘点分页列表")
    @PostMapping(value = "/pageList")
    public ApiResult<PageInfo<TInventoryVO>> pageList(@RequestBody TInventoryQuery query) {
        if (StringUtils.hasLength(query.getStartTime())){
            query.setStartTime(query.getStartTime()+" 00:00:00");
            query.setEndTime(query.getEndTime()+" 23:59:59");
        }
        return ApiResult.success(inventoryService.pageList(query));
    }
    @ApiOperation(value = "镜架添加盘点")
    @PostMapping(value = "/addFrameInventory")
    public ApiResult<PageInfo<TInventoryVO>> addFrameInventory(@RequestBody TInventoryQuery query) {
        if (StringUtils.hasLength(query.getStartTime())){
            query.setStartTime(query.getStartTime()+" 00:00:00");
            query.setEndTime(query.getEndTime()+" 23:59:59");
        }
        return ApiResult.success(inventoryService.pageList(query));
    }
    @ApiOperation(value = "镜片添加盘点")
    @PostMapping(value = "/addLensInventory")
    public ApiResult addLensInventory(@RequestBody FrameInventoryDTO query) {
        TInventory tInventory = new TInventory();
        BeanUtils.copyProperties(query, tInventory);
        inventoryService.save(tInventory);
        for (TInventoryFrameDetail tInventoryFrameDetail : query.getList()) {
            tInventoryFrameDetail.setInventoryId(tInventory.getId());
        }
        inventoryFrameDetailService.saveBatch(query.getList());
        return ApiResult.success();
    }
}