Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package com.gk.firework.Controller;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gk.firework.Controller.Base.BaseController;
import com.gk.firework.Domain.EntryOrderInfo;
import com.gk.firework.Domain.Enum.ErrorCode;
import com.gk.firework.Domain.Log.JsonParams;
import com.gk.firework.Domain.SoldNoStockInfo;
import com.gk.firework.Domain.StockInfo;
import com.gk.firework.Domain.UserInfo;
import com.gk.firework.Domain.Utils.FilterObject;
import com.gk.firework.Domain.Utils.Msg;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Domain.Vo.DirectionDetail;
import com.gk.firework.Domain.Vo.FireworkDeal;
import com.gk.firework.Domain.Vo.ProductVo;
import com.gk.firework.Service.EntryDetailService;
import com.gk.firework.Service.EntryService;
import com.gk.firework.Service.ProductService;
import com.gk.firework.Service.StockService;
import com.gk.firework.Service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * @author : jingjy
 * @date : 2021/4/9 16:17
 */
@Api(tags = "入库接口")
@RestController
@RequestMapping("/entry")
public class EntryController extends BaseController {
    @Autowired
    private ProductService productService;
    @Autowired
    private EntryService entryService;
    @Autowired
    private EntryDetailService entryDetailService;
    @Autowired
    private StockService stockService;
    @Autowired
    private SoldNoStockService soldNoStockService;
    @Autowired
    private UserService userService;
 
    @GetMapping(value = "/getEntryDetail/directionCode/{directionCode}")
    public Msg getEntryDetail(@PathVariable String directionCode){
        Msg msg = new Msg(true);
        if (FireworkDeal.isNotDirectionCode(directionCode)){
            msg.setCode(ErrorCode.ERROR_999.getCode());
            msg.setMessage("流向码不符合规则,请重新输入!");
            return msg;
        }
 
        List<ProductVo>productVoList = new ArrayList<>();
        if (FireworkDeal.is22Characters(directionCode)){
            DirectionDetail detail = FireworkDeal.dealDirectionCode(directionCode);
            ProductVo productVo = productService.selectVoByDirection(directionCode);
            if (productVo == null){
                msg.setCode(ErrorCode.ERROR_999.getCode());
                msg.setMessage("产品不存在,请重新输入!");
                return msg;
            }
            FireworkDeal.getProductVos(directionCode,detail,detail,productVoList,productVo);
        }else {
            ProductVo productVo = productService.selectVoByDirection(directionCode);
            if (productVo == null){
                msg.setCode(ErrorCode.ERROR_999.getCode());
                msg.setMessage("产品不存在,请重新输入!");
                return msg;
            }
            productVoList.add(productVo);
        }
 
 
        if (productVoList.size() == 0){
            msg.setCode(ErrorCode.ERROR_999.getCode());
            msg.setMessage("流向码:"+directionCode+"未找到相应入库信息!");
            return msg;
        }
 
        StringBuilder content = new StringBuilder();
 
        List<ProductVo>productVos = new ArrayList<>();
        for (ProductVo productVo1 : productVoList){
            StockInfo stockInfo = stockService.selectStockByDireAndUser(getUser().getCompanyid(),productVo1.getDirectionCode());
            if (stockInfo == null || stockInfo.getStatus().equals(StockInfo.STOCK_SOLD)){
                msg.setCode(ErrorCode.ERROR_999.getCode());
                content.append(productVo1.getDirectionCode()).append("  未入库或者已经销售了!");
            }else {
                productVos.add(productVo1);
            }
        }
 
        msg.setMessage(content.toString());
        msg.setResult(productVos);
 
        return msg;
    }
 
    @PostMapping("entryPatch")
    @JsonParams
    public Msg entryPatch(@RequestBody JSONArray jsonArray){
        Msg msg = new Msg(true);
        if (jsonArray.size() == 0){
            msg.setCode(ErrorCode.ERROR_999.getCode());
            msg.setMessage(ErrorCode.ERROR_999.getMsg());
            return msg;
        }
        UserInfo userInfo = userService.getById(getUser().getId());
        String auth = getAuth();
        auth = StringUtils.isBlank(auth) ? "NOAUTH" : auth;
        List<SoldNoStockInfo>soldNoStockInfos = new ArrayList<>();
        for (int i = 0; i < jsonArray.size(); i++){
            JSONObject object = jsonArray.getJSONObject(i);
            String directionCode = object.getString("directioncode");
            SoldNoStockInfo soldNoStockInfo = soldNoStockService.selectSoldNoStockByDire(directionCode);
            if (soldNoStockInfo == null){
                msg.setCode(ErrorCode.ERROR_999.getCode());
                msg.setMessage(ErrorCode.ERROR_999.getMsg());
                return msg;
            }
            soldNoStockInfos.add(soldNoStockInfo);
        }
        entryService.entryPatch(soldNoStockInfos,userInfo,auth);
 
        return msg;
    }
 
 
 
    /**
     * @Description: 入库查询
     * @date 2021/4/14 16:35
     */
    @PostMapping("/inbound-query")
    @ApiOperation(value = "入库查询", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", required = true),
            @ApiImplicitParam(name = "filter.province", value = "省"),
            @ApiImplicitParam(name = "filter.city", value = "市"),
            @ApiImplicitParam(name = "filter.district", value = "区"),
            @ApiImplicitParam(name = "filter.street", value = "街道"),
            @ApiImplicitParam(name = "filter.committee", value = "委员会"),
            @ApiImplicitParam(name = "filter.starttime", value = "开始时间"),
            @ApiImplicitParam(name = "filter.endtime", value = "结束时间"),
            @ApiImplicitParam(name = "filter.transportcert", value = "运输证号码"),
            @ApiImplicitParam(name = "filter.enterprisename", value = "入库企业名称"),
            @ApiImplicitParam(name = "filter.safetysupervision", value = "安全监管分类"),
            @ApiImplicitParam(name = "filter.type", value = "入库类型"),
            @ApiImplicitParam(name = "filter.code", value = "单号"),
    })
    Object getInboundInfo(@RequestBody FilterObject jsonFilter) {
        Integer pageIndex = jsonFilter.getPageIndex();
        Integer pageSize = jsonFilter.getPageSize();
        IPage page = entryService.selectPage(new Page<>(pageIndex, pageSize), jsonFilter.getFilter(), getUser());
        return success(page);
    }
 
    @PostMapping("/stock/inbound-query")
    @ApiOperation(value = "入库查询", httpMethod = "POST")
    Object getStockInboundInfo(@RequestBody FilterObject jsonFilter) {
        Integer pageIndex = jsonFilter.getPageIndex();
        Integer pageSize = jsonFilter.getPageSize();
        IPage page = entryService.selectStockPage(new Page<>(pageIndex, pageSize), jsonFilter.getFilter(), getUser());
        return success(page);
    }
 
    /**
    * @Description: 入库导出
    * @date 2021/4/19 17:11
    */
 
    @PostMapping("/export/inbound")
    @ApiOperation(value = "入库查询导出", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "filter.province", value = "省"),
            @ApiImplicitParam(name = "filter.city", value = "市"),
            @ApiImplicitParam(name = "filter.district", value = "区"),
            @ApiImplicitParam(name = "filter.street", value = "街道"),
            @ApiImplicitParam(name = "filter.committee", value = "委员会"),
            @ApiImplicitParam(name = "filter.starttime", value = "开始时间"),
            @ApiImplicitParam(name = "filter.endtime", value = "结束时间"),
            @ApiImplicitParam(name = "filter.transportcert", value = "运输证号码"),
            @ApiImplicitParam(name = "filter.enterprisename", value = "入库企业名称"),
    })
    Object exportInbound(@RequestBody FilterObject jsonFilter) {
        List<EntryOrderInfo> list = entryService.selectExportInBound(jsonFilter.getFilter(), getUser());
        return success(list);
    }
 
    /**
    * @Description: 根据{入库单code}查询入库明细
    * @date 2021/4/15 11:09
    */
    @PostMapping("/inbound-detail")
    @ApiOperation(value = "入库单明细", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", required = true),
            @ApiImplicitParam(name = "filter.code", value = "入库单号code"),
    })
    Object getInboundDetail(@RequestBody FilterObject jsonFilter) {
        Integer pageIndex = jsonFilter.getPageIndex();
        Integer pageSize = jsonFilter.getPageSize();
        IPage page = entryService.selectDetailPage(new Page<>(pageIndex,pageSize),jsonFilter.getFilter());
        return success(page);
    }
 
 
    /**
     * @Description: 根据{入库单code}查询入库明细并导出
     * @date 2021/4/15 11:09
     */
    @GetMapping("/export/inbound-detail")
    @ApiOperation(value = "入库单明细导出", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "入库单号code"),
    })
    Object getInboundDetail(@RequestParam String code) {
         List<Map> detailExport = entryDetailService.selectDetailExport(code);
        return success(detailExport);
    }
 
}