luqingyang
2023-10-30 b82ed8cbcc9e262f2bce2a662f8ce0d8c59b5d70
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package com.consum.base.controller;
 
import com.consum.base.BaseController;
import com.consum.base.core.CodeGeneratorEnum;
import com.consum.base.core.CodeGeneratorService;
import com.consum.base.core.WhBusinessEnum;
import com.consum.base.pojo.*;
import com.consum.base.service.*;
import com.consum.model.po.*;
import com.consum.model.vo.LWhFormTransferVo;
import com.iplatform.model.po.S_user_core;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.CollectionUtils;
import com.walker.infrastructure.utils.DateUtils;
import com.walker.infrastructure.utils.NumberGenerator;
import com.walker.web.ResponseValue;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * @Description  调拨管理
 * @Author 卢庆阳
 * @Date 2023/10/30
 */
@RestController
@RequestMapping("/pc/l/wh/form/transfer")
public class LWhFormTransferController extends BaseController {
 
    @Autowired
    private LWhFormTransferServiceImpl lWhFormTransferService;
    @Autowired
    private BaseWarehouseServiceImpl baseWarehouseService;
    @Autowired
    private LWhProcureModelService lWhProcureModelService;
 
    /**
     * @Description 新增
     */
    @PostMapping("/add")
    public ResponseValue add(@RequestBody LWhFormTransferParam param) {
        S_user_core currentUser = this.getCurrentUser();
        if (currentUser == null) {
            return ResponseValue.error("登录用户信息不存在");
        }
        List<LWhProcureModelParams> transferGoods = param.getModels();
        if (CollectionUtils.isEmpty(transferGoods)) {
            return ResponseValue.error("调拨单不能为空");
        }
        int result = this.lWhFormTransferService.add(param, currentUser,this.getSysInfo());
        if (result > 0) return ResponseValue.success(1);
        return ResponseValue.error("新增失败!");
    }
 
    /**
     * @Description  列表查询
     * @Author 卢庆阳
     * @Date 2023/10/30
     */
//    1.查询调拨单
//    2.查询物品型号
    @GetMapping("/list")
    public ResponseValue queryFormTransferList(LWhFormTransferParam param) {
        S_user_core currentUser = this.getCurrentUser();
        if (currentUser == null) {
            return ResponseValue.error("登录用户信息不存在");
        }
        FinSysTenantUser sysInfo = getSysInfo();
 
        //只能查询本级 及以下机构的进货单
        //??????
 
        GenericPager genericPager = lWhFormTransferService.queryFormTransferList(param);
        List<LWhFormTransfer> datas = genericPager.getDatas();
        ArrayList<LWhFormProcureExtend> newDatas = new ArrayList<>();
        if (!CollectionUtils.isEmpty(datas)) {
            datas.forEach(item -> {
                // 查询型号数量
                LWhProcureModel lWhProcureModel = new LWhProcureModel();
                lWhProcureModel.setBusinessType(2);
                lWhProcureModel.setBusinessId(item.getId());
                List<LWhProcureModel> models = lWhProcureModelService.select(lWhProcureModel);
                LWhFormProcureExtend formProcureExtend = new LWhFormProcureExtend();
                BeanUtils.copyProperties(item, formProcureExtend);
                formProcureExtend.setModels(models);
                newDatas.add(formProcureExtend);
            });
        }
        try {
            Field fieldDatas = GenericPager.class.getDeclaredField("datas");
            fieldDatas.setAccessible(true);
            fieldDatas.set(genericPager, newDatas);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        genericPager.setDatas(newDatas);
        return ResponseValue.success(genericPager);
    }
 
    /**
     * @Description  根据id查询详情
     * @Author 卢庆阳
     * @Date 2023/10/30
     */
    @GetMapping("/detail")
    public ResponseValue getById(Long id) throws IllegalAccessException {
        if (id == null) {
            return ResponseValue.error("调拨单id为空");
        }
        LWhFormTransferVo vo = this.lWhFormTransferService.getById(id);
        return ResponseValue.success(vo);
    }
 
 
}