Commit db24b152fdcd09878e37d6eb4e8cf73c2ebac894

Authored by 易文鹏
1 parent 8cdecfec

feat: 历史出库单打印

src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
... ... @@ -420,10 +420,16 @@ public class ShipmentHeaderController extends BaseController {
420 420 shipmentHeader = shipmentHeaderService.getById(id);
421 421 }
422 422 if (shipmentHeader == null) {
423   - AjaxResult.error("没有找到该出库单");
  423 + return AjaxResult.error("没有找到该出库单");
424 424 }
425 425 if (shipmentHeader.getShipmentType().equals("merge")) {
  426 + if (shipmentHeader.getRecordCode() == null) {
  427 + return AjaxResult.error("该出库单没有合并前单号:" + shipmentHeader.getCode());
  428 + }
426 429 String[] splitData = shipmentHeader.getRecordCode().split(",");
  430 + if (StringUtils.isEmpty(splitData)) {
  431 + return AjaxResult.error("该出库单没有合并前单号:" + shipmentHeader.getRecordCode());
  432 + }
427 433 List<String> recordCodes = new ArrayList<>(Arrays.asList(splitData));
428 434 if (!recordCodes.isEmpty()) {
429 435 for (String code : recordCodes) {
... ...
src/main/java/com/huaheng/pc/shipment/shipmentHeaderHistory/controller/ShipmentHeaderHistoryController.java
... ... @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6 6 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7 +import com.huaheng.common.exception.service.ServiceException;
7 8 import com.huaheng.common.support.Convert;
8 9 import com.huaheng.common.utils.DateUtils;
9 10 import com.huaheng.common.utils.StringUtils;
... ... @@ -19,15 +20,21 @@ import com.huaheng.pc.receipt.receiptHeaderHistory.domain.ReceiptHeaderHistory;
19 20 import com.huaheng.pc.shipment.shipmentDetailHistory.domain.ShipmentDetailHistory;
20 21 import com.huaheng.pc.shipment.shipmentDetailHistory.service.ShipmentDetailHistoryService;
21 22 import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
  23 +import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
22 24 import com.huaheng.pc.shipment.shipmentHeaderHistory.domain.ShipmentHeaderHistory;
23 25 import com.huaheng.pc.shipment.shipmentHeaderHistory.service.ShipmentHeaderHistoryService;
  26 +import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
  27 +import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
24 28 import org.apache.shiro.authz.annotation.RequiresPermissions;
  29 +import org.springframework.beans.BeanUtils;
25 30 import org.springframework.beans.factory.annotation.Autowired;
26 31 import org.springframework.stereotype.Controller;
27 32 import org.springframework.ui.ModelMap;
28 33 import org.springframework.web.bind.annotation.*;
29 34  
30 35 import java.text.SimpleDateFormat;
  36 +import java.util.ArrayList;
  37 +import java.util.Arrays;
31 38 import java.util.Date;
32 39 import java.util.List;
33 40  
... ... @@ -47,6 +54,10 @@ public class ShipmentHeaderHistoryController extends BaseController {
47 54 private ShipmentHeaderHistoryService shipmentHeaderHistoryService;
48 55 @Autowired
49 56 private ShipmentDetailHistoryService shipmentDetailHistoryService;
  57 + @Autowired
  58 + private ShipmentHeaderService shipmentHeaderService;
  59 + @Autowired
  60 + private TaskDetailService taskDetailService;
50 61  
51 62  
52 63 @RequiresPermissions("shipment:bill:view")
... ... @@ -217,4 +228,51 @@ public class ShipmentHeaderHistoryController extends BaseController {
217 228 }
218 229  
219 230  
  231 + @GetMapping("/autoreport/{id}")
  232 + @ResponseBody
  233 + public AjaxResult autoReport(@PathVariable("id") Integer id) {
  234 + ShipmentHeaderHistory shipmentHeaderHistory = shipmentHeaderHistoryService.getById(id);
  235 + if (shipmentHeaderHistory == null) {
  236 + return AjaxResult.error("没有找到该出库单");
  237 + }
  238 + ShipmentHeader newShipmentHeader = new ShipmentHeader();
  239 + if (shipmentHeaderHistory.getShipmentType().equals("merge")) {
  240 + if (shipmentHeaderHistory.getRecordCode() == null) {
  241 + return AjaxResult.error("该出库单没有合并前单号:" + shipmentHeaderHistory.getCode());
  242 + }
  243 + String[] splitData = shipmentHeaderHistory.getRecordCode().split(",");
  244 + if (StringUtils.isEmpty(splitData)) {
  245 + return AjaxResult.error("该出库单没有合并前单号:" + shipmentHeaderHistory.getCode());
  246 + }
  247 + List<String> recordCodes = new ArrayList<>(Arrays.asList(splitData));
  248 + if (!recordCodes.isEmpty()) {
  249 + for (String code : recordCodes) {
  250 + ShipmentHeaderHistory originalHeaderHistory = shipmentHeaderHistoryService.getOne(new LambdaQueryWrapper<ShipmentHeaderHistory>().eq(ShipmentHeaderHistory::getCode, code));
  251 +
  252 + List<TaskDetail> taskDetails = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getRecordCode, originalHeaderHistory.getCode()));
  253 + if (taskDetails.isEmpty()) {
  254 + throw new ServiceException("未组盘生成任务,无法打印!");
  255 + }
  256 + BeanUtils.copyProperties(originalHeaderHistory, newShipmentHeader);
  257 + AjaxResult result = shipmentHeaderService.autoReport(newShipmentHeader, taskDetails, shipmentHeaderHistory.getCode());
  258 + if (result.hasErr()) {
  259 + throw new ServiceException("打印平库出库单失败:" + result.getMsg());
  260 + }
  261 + }
  262 + }
  263 + } else {
  264 + List<TaskDetail> taskDetails = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getBillCode, shipmentHeaderHistory.getCode()));
  265 + if (taskDetails.isEmpty()) {
  266 + throw new ServiceException("未组盘生成任务,无法打印!");
  267 + }
  268 + BeanUtils.copyProperties(shipmentHeaderHistory, newShipmentHeader);
  269 + AjaxResult result = shipmentHeaderService.autoReport(newShipmentHeader, taskDetails, "");
  270 + if (result.hasErr()) {
  271 + throw new ServiceException("打印平库出库单失败:" + result.getMsg());
  272 + }
  273 + }
  274 + return AjaxResult.success();
  275 + }
  276 +
  277 +
220 278 }
... ...
src/main/java/com/huaheng/pc/shipment/shipmentHeaderHistory/domain/ShipmentHeaderHistory.java
... ... @@ -426,6 +426,12 @@ public class ShipmentHeaderHistory implements Serializable {
426 426 @TableField(value = "recordID")
427 427 @ApiModelProperty(value = "记录合并订单ID")
428 428 private String recordID;
  429 + /**
  430 + * 记录合并之前的单据号
  431 + */
  432 + @TableField(value = "recordCode")
  433 + @ApiModelProperty(value = "记录合并之前的单据号")
  434 + private String recordCode;
429 435  
430 436 /**
431 437 * 通知单号
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/ShipmentTaskService.java
... ... @@ -411,9 +411,21 @@ public class ShipmentTaskService {
411 411 task.setLastUpdatedBy(ShiroUtils.getName());
412 412 }
413 413 taskHeaderService.updateById(task);
414   - /* 更新库位和容器*/
415   - updateShipmentLocationContainer(task.getFromLocation(), task.getToLocation(),
416   - task.getContainerCode(), task.getTaskType(), warehouseCode);
  414 + //平库删除库位和容器
  415 + if (task.getFlat() != null && task.getFlat() == 1) {
  416 + if (!locationService.remove(new LambdaQueryWrapper<Location>().eq(Location::getCode, task.getFromLocation()))) {
  417 + throw new ServiceException("删除库位失败:" + task.getOriginLocation());
  418 + }
  419 + if (!containerService.remove(new LambdaQueryWrapper<Container>().eq(Container::getCode, task.getContainerCode()))) {
  420 + throw new ServiceException("删除容器失败:" + task.getContainerCode());
  421 + }
  422 +
  423 + } else {
  424 + /* 更新库位和容器*/
  425 + updateShipmentLocationContainer(task.getFromLocation(), task.getToLocation(),
  426 + task.getContainerCode(), task.getTaskType(), warehouseCode);
  427 + }
  428 +
417 429  
418 430 //设置出库货箱表头状态为拣货任务完成
419 431 LambdaUpdateWrapper<ShipmentContainerHeader> shipmentContainerHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate();
... ...
src/main/resources/templates/shipment/shipmentHeaderHistory/shipmentHeaderHistory.html
... ... @@ -324,30 +324,31 @@
324 324 {
325 325 checkbox: true
326 326 },
  327 +
  328 + {
  329 + title: '操作',
  330 + align: 'center',
  331 + formatter: function (value, row, index) {
  332 + var actions = [];
  333 + actions.push('<a id="table_edit" class="btn btn-success btn-xs ' + printFlag + '" href="#" onclick="receiptPrint(\'' + row.id + '\')"><i class="fa fa-print"></i>打印</a> ');
  334 + // actions.push('<a class="btn btn-info btn-xs " href="#" onclick="detail(\'' + row.id + '\',\'' + row.code + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
  335 + // if (row.lastStatus < 500) {
  336 + // actions.push('<a class="btn btn-info btn-xs ' + postFlag + '" href="#" onclick="posting(\'' + row.id + '\')"><i class="fa fa-edit"></i>结束</a> ');
  337 + // }
  338 + // if (row.firstStatus < 100) {
  339 + // // actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
  340 + // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash-o"></i>删除</a>');
  341 + // }
  342 + // if (row.firstStatus == 500 && row.lastStatus == 500) {
  343 + // actions.push('<a class="btn btn-info btn-xs ' + '" href="#" onclick="backERP(\''+row.id+'\')"><i class="fa fa-upload"></i>回传</a>');
  344 + // }
  345 + return actions.join('');
  346 + }
  347 + },
327 348 {
328 349 field: 'origin',
329 350 title: '删除来源',
330 351 },
331   - // {
332   - // title: '操作',
333   - // align: 'center',
334   - // formatter: function (value, row, index) {
335   - // var actions = [];
336   - // actions.push('<a id="table_edit" class="btn btn-success btn-xs ' + printFlag + '" href="#" onclick="receiptPrint(\'' + row.id + '\')"><i class="fa fa-print"></i>打印</a> ');
337   - // // actions.push('<a class="btn btn-info btn-xs " href="#" onclick="detail(\'' + row.id + '\',\'' + row.code + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
338   - // if (row.lastStatus < 500) {
339   - // actions.push('<a class="btn btn-info btn-xs ' + postFlag + '" href="#" onclick="posting(\'' + row.id + '\')"><i class="fa fa-edit"></i>结束</a> ');
340   - // }
341   - // if (row.firstStatus < 100) {
342   - // // actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
343   - // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash-o"></i>删除</a>');
344   - // }
345   - // // if (row.firstStatus == 500 && row.lastStatus == 500) {
346   - // // actions.push('<a class="btn btn-info btn-xs ' + '" href="#" onclick="backERP(\''+row.id+'\')"><i class="fa fa-upload"></i>回传</a>');
347   - // // }
348   - // return actions.join('');
349   - // }
350   - // },
351 352 {
352 353 field: 'id',
353 354 title: '出库单id',
... ... @@ -857,11 +858,21 @@
857 858 }
858 859 }
859 860  
860   - /* 打印 */
861   - function receiptPrint(id) {
862   - var url = prefix + "/report/" + id;
863   - $.modal.open("出库单打印", url);
864   - }
  861 + /* 打印 */
  862 + function receiptPrint(id) {
  863 + var url = prefix + "/autoreport/" + id;
  864 + $.ajax({
  865 + url: url,
  866 + type: "get",
  867 + success: function (response) {
  868 + if (response.code === 200) {
  869 + $.modal.alertSuccess('打印成功:' + response.msg);
  870 + } else {
  871 + $.modal.alertError('打印失败:' + response.msg);
  872 + }
  873 + }
  874 + })
  875 + }
865 876  
866 877  
867 878 /* 单个删除 */
... ...