WarehouseU8Controller.java
6.87 KB
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
package com.huaheng.pc.config.warehouse.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.redis.service.IRedisService;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
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;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.config.company.domain.Company;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.warehouse.domain.WarehouseU8;
import com.huaheng.pc.config.warehouse.service.WarehouseU8Service;
import com.huaheng.pc.config.warehouse.domain.WorkOrderComponent;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/config/warehouseWu")
public class WarehouseU8Controller extends BaseController {
@Resource
private WarehouseU8Service warehouseWuService;
@Resource
private IRedisService iRedisService;
private String prefix = "config/warehouse";
@RequiresPermissions("config:warehouse:view")
@GetMapping()
public String warehouse() {
return prefix + "/warehouseU8";
}
/**
* 查询仓库列表
*/
@RequiresPermissions("config:warehouse:list")
@Log(title = "配置-库存资料-仓库管理", operating = "查看仓库列表", action = BusinessType.GRANT)
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(WarehouseU8 warehouse) {
LambdaQueryWrapper<WarehouseU8> lambdaQueryWrapper = Wrappers.lambdaQuery();
PageDomain pageDomain = TableSupport.buildPageRequest();// 分页
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
lambdaQueryWrapper
.eq(StringUtils.isNotEmpty(warehouse.getCompanyCode()), WarehouseU8::getCompanyCode, warehouse.getCompanyCode())
.eq(StringUtils.isNotEmpty(warehouse.getUCompanyCode()), WarehouseU8::getUCompanyCode,warehouse.getUCompanyCode())
.eq(StringUtils.isNotEmpty(warehouse.getUWarehouseCode()), WarehouseU8::getUWarehouseCode,warehouse.getUWarehouseCode())
.like(StringUtils.isNotEmpty(warehouse.getUWarehouseName()), WarehouseU8::getUWarehouseName,warehouse.getUWarehouseName())
.like(StringUtils.isNotEmpty(warehouse.getErpCode()), WarehouseU8::getErpCode,warehouse.getErpCode())
;
/**
* 使用分页查询
*/
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
Page<WarehouseU8> page = new Page<>(pageNum, pageSize);
IPage<WarehouseU8> iPage = warehouseWuService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
} else {
List<WarehouseU8> list = warehouseWuService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
@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 {
List<WarehouseU8> list = warehouseWuService.list(new LambdaQueryWrapper<WarehouseU8>()
.eq(WarehouseU8::getCompanyCode, companyCode));
return AjaxResult.success(list);
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@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());
resultMap.put("companyCode", material.getCompanyCode());
resultMap.put("text", material.getUWarehouseName());
list.add(resultMap);
}
Map<String, Object> map = new HashMap<>();
map.put("results", list);
return map; // 不返回页面只返回数据
}
@PostMapping( "/findByWareAndCompany")
@ResponseBody
@Transactional
public TableDataInfo findByWarehouseCode(String warehouseCode,String companyCode) {
List<WarehouseU8> warehouseU8s = warehouseWuService.findByWareAndCompany(warehouseCode,companyCode);
return getDataTable(warehouseU8s);
}
}