luqingyang
2023-11-02 5e6c61b8753870ef2f8cde60eef47e3eeefe89e6
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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.LWhFormOutputVo;
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;
    @Autowired
    private LWhFormTransferCoreService lWhFormTransferCoreService;
 
    /**
     * @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<LWhFormTransferExtend> 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);
                LWhFormTransferExtend formTransferExtend = new LWhFormTransferExtend();
                BeanUtils.copyProperties(item, formTransferExtend);
                formTransferExtend.setModels(models);
                newDatas.add(formTransferExtend);
            });
        }
        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) {
        if (id == null) {
            return ResponseValue.error("调拨单id为空");
        }
        LWhFormTransferVo vo = this.lWhFormTransferService.getById(id);
        return ResponseValue.success(vo);
    }
 
    /**
     * 撤销
     * @author 卢庆阳
     * @date 2023/10/31
     */
    @PostMapping("/updStatus")
    public ResponseValue updateStatus(Long id) {
        if (id == null) {
            return ResponseValue.error("参数错误");
        }
 
        int num = this.lWhFormTransferService.updateStatus(id);
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("修改失败!");
    }
 
    /**
     * @Description  调拨入库
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @PostMapping("/income")
    public ResponseValue income(Long id) {
        lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser());
        return ResponseValue.success();
    }
 
    /**
     * @Description  调拨出库
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @PostMapping("/output")
    public ResponseValue output(Long id) {
        lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser());
        return ResponseValue.success();
    }
 
    /**
     * @Description  导出调拨出库单
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @GetMapping("/export")
    public ResponseValue export(Long id) {
        if (id == null) {
            return ResponseValue.error("调拨单id为空");
        }
        LWhFormOutputVo vo = this.lWhFormTransferService.export(id,this.getCurrentUser());
        return ResponseValue.success(vo);
    }
 
 
}