Blame view

src/main/java/com/huaheng/pc/config/warehouse/controller/WarehouseU8Controller.java 4.59 KB
易文鹏 authored
1
2
package com.huaheng.pc.config.warehouse.controller;
tongzhonghao authored
3
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
易文鹏 authored
4
import com.huaheng.common.redis.service.IRedisService;
tongzhonghao authored
5
6
7
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
易文鹏 authored
8
9
10
11
12
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
xumiao authored
13
14
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.pc.config.company.domain.Company;
tongzhonghao authored
15
import com.huaheng.pc.config.material.domain.Material;
tongzhonghao authored
16
import com.huaheng.pc.config.warehouse.domain.WarehouseU8;
17
import com.huaheng.pc.config.warehouse.service.WarehouseU8Service;
易文鹏 authored
18
19
20
import com.huaheng.pc.config.warehouse.domain.WorkOrderComponent;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
xumiao authored
21
import org.springframework.transaction.annotation.Transactional;
易文鹏 authored
22
import org.springframework.web.bind.annotation.GetMapping;
tongzhonghao authored
23
import org.springframework.web.bind.annotation.PostMapping;
易文鹏 authored
24
25
26
27
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
tongzhonghao authored
28
29
import java.util.ArrayList;
import java.util.HashMap;
tongzhonghao authored
30
import java.util.List;
tongzhonghao authored
31
import java.util.Map;
易文鹏 authored
32
33
34

@Controller
@RequestMapping("/config/warehouseWu")
tongzhonghao authored
35
public class WarehouseU8Controller extends BaseController {
易文鹏 authored
36
37

    @Resource
38
    private WarehouseU8Service warehouseWuService;
易文鹏 authored
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
    @Resource
    private IRedisService iRedisService;

    @ApiOperation("获取U8工单子件")
    @Log(title = "获取U8工单子件", action = BusinessType.OTHER)
    @GetMapping("/queryWorkOrders")
    @ResponseBody
    @ApiLogger(apiName = "获取U8工单子件", from = "U8")
    public AjaxResult queryWorkOrders(WorkOrderComponent data,String type){
        AjaxResult ajax;
        try {
            ajax = warehouseWuService.GetCurrentStock(data, type);
        }catch (Exception e){
            if (iRedisService.isKeyExists("CS_work_order_list")){
                iRedisService.remove("CS_work_order_list");
            }
            return AjaxResult.error(e.getMessage());
        }
        return ajax;
    }

    @GetMapping("/getCompanyCodeList")
    @ResponseBody
    public AjaxResult getCompanyCodeList(String companyCode){
        try {
tongzhonghao authored
64
65
66
            List<WarehouseU8> list = warehouseWuService.list(new LambdaQueryWrapper<WarehouseU8>()
                    .eq(WarehouseU8::getCompanyCode, companyCode));
            return AjaxResult.success(list);
易文鹏 authored
67
68
69
70
71
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
tongzhonghao authored
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    @PostMapping("/getData")
    @ResponseBody // 这个是物料编码list要增加表单提交获取的
    public Map<String, Object> getData (String uWarehouseName, String uWarehouseCode) { // 新增表单是没有物料名和物料编码
        LambdaQueryWrapper<WarehouseU8> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(StringUtils.isNotEmpty(uWarehouseName), WarehouseU8::getUWarehouseCode, uWarehouseName) //  WHERE material =
                .or() // sql语句拼接or
                .like(StringUtils.isNotEmpty(uWarehouseName), WarehouseU8::getUWarehouseName, uWarehouseName);
        queryWrapper.eq(WarehouseU8::getWarehouseCode, ShiroUtils.getWarehouseCode());
        List<WarehouseU8> materialList = warehouseWuService.list(queryWrapper);

        List<Map<String, Object>> list = new ArrayList<>();
        for (WarehouseU8 material : materialList) {
            Map<String, Object> resultMap = new HashMap<>();
            if(StringUtils.isNotEmpty(uWarehouseCode) && material.getUWarehouseCode().equals(uWarehouseCode)) {
                resultMap.put("selected", true);
            }
            resultMap.put("id", material.getUWarehouseCode());
89
            resultMap.put("companyCode", material.getCompanyCode());
tongzhonghao authored
90
91
92
93
94
95
96
97
            resultMap.put("text", material.getUWarehouseName());
            list.add(resultMap);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("results", list);
        return map; // 不返回页面只返回数据
    }
xumiao authored
98
99
100
101
102
103
104
105
    @PostMapping( "/findByWareAndCompany")
    @ResponseBody
    @Transactional
    public TableDataInfo findByWarehouseCode(String warehouseCode,String companyCode) {
        List<WarehouseU8> warehouseU8s = warehouseWuService.findByWareAndCompany(warehouseCode,companyCode);
        return getDataTable(warehouseU8s);
    }
易文鹏 authored
106
107

}