KuaidiHeaderController.java
8.88 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
package com.huaheng.pc.shipment.kuaidiHeader.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.utils.poi.ExcelUtil;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.shipment.kuaidiHeader.domain.KuaidiHeader;
import com.huaheng.pc.shipment.kuaidiHeader.service.KuaidiHeaderService;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.dict.service.IDictDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
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.common.support.Convert;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 【请填写功能名称】 信息操作处理
*
* @author huaheng
* @date 2022-09-07
*/
@Controller
@RequestMapping("/shipment/kuaidiHeader")
public class KuaidiHeaderController extends BaseController {
private String prefix = "shipment/kuaidiHeader";
@Resource
private KuaidiHeaderService kuaidiHeaderService;
@Resource
private IDictDataService dictDataService;
@RequiresPermissions("shipment:kuaidiHeader:view")
@GetMapping()
public String kuaidiHeader() {
return prefix + "/list";
}
/**
* 查询【请填写功能名称】列表
*/
@RequiresPermissions("shipment:kuaidiHeader:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(KuaidiHeader kuaidiHeader) {
LambdaQueryWrapper<KuaidiHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(KuaidiHeader::getDeleted,false);
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
/*使用分页查询*/
Page<KuaidiHeader> page = new Page<>(pageNum, pageSize);
IPage<KuaidiHeader> iPage = kuaidiHeaderService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
} else {
List<KuaidiHeader> list = kuaidiHeaderService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
/**
* 新增【请填写功能名称】
*/
@GetMapping("/add")
public String add() {
return prefix + "/add";
}
/**
* 新增保存【请填写功能名称】
*/
@RequiresPermissions("shipment:kuaidiHeader:add")
@Log(title = "【请填写功能名称】", action = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(KuaidiHeader kuaidiHeader) {
return kuaidiHeaderService.saveHeader(kuaidiHeader);
}
/**
* 修改【请填写功能名称】
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
KuaidiHeader kuaidiHeader = kuaidiHeaderService.getById(id);
mmap.put("kuaidiHeader", kuaidiHeader);
return prefix + "/edit";
}
/**
* 修改保存【请填写功能名称】
*/
@RequiresPermissions("shipment:kuaidiHeader:edit")
@Log(title = "【请填写功能名称】", action = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(KuaidiHeader kuaidiHeader) {
return toAjax(kuaidiHeaderService.updateById(kuaidiHeader));
}
/**
* 删除【请填写功能名称】
*/
@RequiresPermissions("shipment:kuaidiHeader:remove")
@Log(title = "【请填写功能名称】", action = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids) {
if (StringUtils.isEmpty(ids)){
return AjaxResult.error("id不能为空");
}
for (Integer id : Convert.toIntArray(ids)) {
KuaidiHeader kuaidiHeader = kuaidiHeaderService.getById(id);
if(kuaidiHeader == null){
return AjaxResult.error("没有此快递单");
}
kuaidiHeader.setDeleted(true);
boolean tag= kuaidiHeaderService.updateById(kuaidiHeader);
if (!tag) {
return AjaxResult.error("删除失败");
}
}
return AjaxResult.success("删除成功");
}
/**
* U8导入快递信息
*/
@GetMapping("/U8Save")
public String U8Save()
{
return prefix + "/save";
}
@RequiresPermissions("shipment:kuaidiHeader:add")
@Log(title = "出库-快递单", operating="新增快递单主单", action = BusinessType.INSERT)
@PostMapping("/save")
@ResponseBody
public AjaxResult save(KuaidiHeader kuaidiHeader)
{
AjaxResult ajaxResult =kuaidiHeaderService.saveU8Kuaidi(kuaidiHeader);
return ajaxResult;
}
@PostMapping("/getKuaidiHeader")
@ResponseBody
public AjaxResult<KuaidiHeader> getKuaidiHeader(int id){
return AjaxResult.success(kuaidiHeaderService.getById(id));
}
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file) throws Exception {
ExcelUtil<KuaidiHeader> util = new ExcelUtil<>(KuaidiHeader.class);
List<KuaidiHeader> list = util.importExcel(file.getInputStream());
String operName = ShiroUtils.getLoginName();
Boolean flag = true;
flag = kuaidiHeaderService.importData(list,false);
if (flag == true) {
return AjaxResult.success("导入成功");
} else {
return AjaxResult.success("导入失败,数据格式不对");
}
}
/**
* 导出模板
* @return
* @throws Exception
*/
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate() {
ExcelUtil<KuaidiHeader> util = new ExcelUtil<>(KuaidiHeader.class);
return util.importTemplateExcel("快递导入");
}
// @RequiresPermissions("shipment:kuaidi:edit")
@Log(title = "出库-快递单", operating = "快递导入", action = BusinessType.OTHER)
@PostMapping("/importKD")
@ResponseBody
public AjaxResult importKD(KuaidiHeader kuaidiHeader){
AjaxResult ajaxResult =kuaidiHeaderService.sendKD(kuaidiHeader);
return ajaxResult;
}
@Log(title = "出库-快递单", operating = "快递批量导入", action = BusinessType.OTHER)
@PostMapping("/importKDS")
@ResponseBody
public AjaxResult importKDS(KuaidiHeader kuaidiHeader){
AjaxResult ajaxResult =kuaidiHeaderService.sendKDS(kuaidiHeader);
return ajaxResult;
}
// @RequiresPermissions("shipment:kuaidi:edit")
@Log(title = "出库-快递单", operating = "快递打印", action = BusinessType.OTHER)
@PostMapping("/printKD")
@ResponseBody
public AjaxResult printKD(Integer id){
KuaidiHeader kuaidiHeader =new KuaidiHeader();
kuaidiHeader =kuaidiHeaderService.getById(id);
if(kuaidiHeader == null){
return AjaxResult.error("要打印的单据不存在");
}
AjaxResult ajaxResult =kuaidiHeaderService.printKD(kuaidiHeader.getKuaidiNum());
return ajaxResult;
}
// @RequiresPermissions("shipment:kuaidi:edit")
@Log(title = "出库-快递单", operating = "快递批量打印", action = BusinessType.OTHER)
@PostMapping("/printKDS")
@ResponseBody
public AjaxResult printKDS(String ids){
AjaxResult ajaxResult =kuaidiHeaderService.printKDS(ids);
return ajaxResult;
}
/**
* 选择快递公司
*/
@GetMapping("/importt/{id}")
public String editt(@PathVariable("id") Integer id, ModelMap mmap)
{
DictData dictData =new DictData();
dictData.setDictType("kuaidi");
dictData =dictDataService.selectModel(dictData);
KuaidiHeader kuaidiHeader =new KuaidiHeader();
kuaidiHeader.setId(id);
if(dictData !=null) {
kuaidiHeader.setKuaidiCom(dictData.getDictValue());
}
mmap.put("kuaidiHeader", kuaidiHeader);
return prefix + "/import";
}
/**
* 批量选择快递公司
*/
@GetMapping("/importKDS/{ids}")
public String importKDS(@PathVariable("ids") String ids, ModelMap mmap)
{
DictData dictData =new DictData();
dictData.setDictType("kuaidi");
dictData =dictDataService.selectModel(dictData);
KuaidiHeader kuaidiHeader =new KuaidiHeader();
kuaidiHeader.setOrderBill(ids);
if(dictData !=null) {
kuaidiHeader.setKuaidiCom(dictData.getDictValue());
}
mmap.put("kuaidiHeader", kuaidiHeader);
return prefix + "/imports";
}
}