TvController.java
9.97 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
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
package com.huaheng.api.tv.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.AdjustDomain;
import com.huaheng.api.tv.domain.ErrInfo;
import com.huaheng.api.tv.domain.OrderDetail;
import com.huaheng.api.tv.domain.TvBean;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.api.wcs.domain.WmsTask;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
import com.huaheng.pc.monitor.apilog.service.IApiLogService;
import com.huaheng.pc.system.config.service.IConfigService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.lang.ref.WeakReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping("/API/WMS/v2")
public class TvController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private ContainerService containerService;
@Resource
private LocationService locationService;
@Resource
private InventoryTransactionService inventoryTransactionService;
@Resource
private ZoneService zoneService;
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private InventoryMaterialSummaryService inventoryMaterialSummaryService;
@Resource
private IApiLogService apiLogService;
@Resource
private IConfigService iConfigService;
@Resource
private AddressService addressService;
@PostMapping("/getTvView")
@ApiOperation("获取电视信息")
@ResponseBody
public AjaxResult getTvView(@RequestBody WcsTask wcsTask) {
String area = wcsTask.getArea();
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper
.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)
.orderByDesc(TaskHeader::getId);
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
LambdaQueryWrapper<Container> containerEmptyLambdaQueryWrapper = Wrappers.lambdaQuery();
containerEmptyLambdaQueryWrapper
.ne(Container::getLocationCode, "")
.eq(Container::getEmptyPallet,"1");
List<Container> containerEmptyList = containerService.list(containerEmptyLambdaQueryWrapper);
int containerEmptySize = containerEmptyList.size();
LambdaQueryWrapper<Container> containerSomeLambdaQueryWrapper = Wrappers.lambdaQuery();
containerSomeLambdaQueryWrapper
.eq(Container::getEmptyPallet,"0")
.ne(Container::getLocationCode, "");
List<Container> containerSomeList = containerService.list(containerSomeLambdaQueryWrapper);
int containerSomeSize = containerSomeList.size();
LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
locationLambdaQueryWrapper.eq(Location::getArea, "1");
List<Location> locationList = locationService.list(locationLambdaQueryWrapper);
int totalLocationSize = locationList.size();
LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
zoneLambdaQueryWrapper.eq(Zone::getArea, "1");
Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zone.getCode());
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list();
int inventorySize =0; //inventoryDetailList.size();
LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(InventoryMaterialSummary::getZoneCode, zone.getCode());
List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
if (list == null) {
list = Collections.emptyList();
}
//筛选库存汇总数据的专用方法
List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);
TvBean tvBean = new TvBean();
tvBean.setDetails(details);
tvBean.setContainerEmptySize(containerEmptySize);
tvBean.setContainerSomeSize(containerSomeSize);
tvBean.setTotalLocationSize(totalLocationSize);
tvBean.setTaskHeaderList(taskHeaderList);
tvBean.setInventorySize(inventorySize);
if(area.equals("3")){//1,2区域为站台电视机区域,3为里面分拣台电视机
List<ErrInfo> errList=apiLogService.getErrorList();
tvBean.setErrinfo(errList);
inventorySize=taskHeaderService.getPickNum();
}else{
String containerCode="";
String port="";
List<OrderDetail> ordernfo =new ArrayList<>();
if (area.equals("1")){
port="P1031";
}else{
port="P1030";
}
containerCode=taskHeaderService.getContinerCode(port);
if(containerCode==null){
tvBean.setMessage(port+":当前无托盘出库信息显示......");
}else{
JSONObject jsonObject=JSONObject.parseObject(getOrderByWms(containerCode));
String palletContent =jsonObject.getString("list");
ordernfo = JSONObject.parseArray(palletContent, OrderDetail.class);
tvBean.setMessage(jsonObject.getString("message"));
}
tvBean.setOrderDetails(ordernfo);
inventorySize=containerEmptySize+containerSomeSize;
}
tvBean.setInventorySize(inventorySize);
return AjaxResult.success(tvBean);
}
//获取托盘订单内容
public String getOrderByWms(String containercode){
String code="";
String message="";
List<OrderDetail> list=new ArrayList<>();
WmsTask wmsTask=new WmsTask();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
wmsTask.setReqID(iConfigService.getRegId());
wmsTask.setContainerCode(containercode);
wmsTask.setRequestTime(df.format(new Date()));
String JsonParam = JSON.toJSONString(wmsTask);
System.out.println(JsonParam);
String url = addressService.selectAddress(QuantityConstant.ADDRESS_ORDER_WMS_INFO, "ZH0001", "1");
String result = HttpUtils.bodypost(url, JsonParam);
JSONObject json=new JSONObject();
json=JSONObject.parseObject(result);
code=json.getString("code");
if(code.equals("1")){
JSONObject data=JSONObject.parseObject(json.getString("data"));
message=data.getString("message");
String palletContent=data.getString("palletContent");
list = JSON.parseArray(palletContent,OrderDetail.class);
}
JSONObject json2=new JSONObject();
json2.put("code",code);
json2.put("message",message);
json2.put("list",list);
System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println(list);
System.out.println("code:"+code);
return json2.toJSONString();
}
public String getOrderByWms3(String containercode){
String code="2";
String message="3";
List<OrderDetail> list=new ArrayList<>();
WmsTask wmsTask=new WmsTask();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
wmsTask.setReqID(iConfigService.getRegId());
wmsTask.setContainerCode(containercode);
wmsTask.setRequestTime(df.format(new Date()));
OrderDetail p=new OrderDetail();
OrderDetail p2=new OrderDetail();
p.setOrderNo("ZH0120211123000009");
p.setStation("000000-0010-WMSGX");
p.setMaterialCode("materialCode");
p.setMaterialName("丝座SMHW40.1.1-8");
p.setQty("3.0");
p2.setOrderNo("2342");
p2.setStation("000000-432-WMSGX");
p2.setMaterialCode("materialCode");
p2.setMaterialName("bbbbbb.1.1-8");
p2.setQty("3.0");
list.add(p);
list.add(p2);
JSONObject json=new JSONObject();
json.put("code",code);
json.put("message",message);
json.put("list",list);
System.out.println("code:"+code);
return json.toJSONString();
}
}