| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CheckTaskListParam; |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.entity.result.CheckOrderExportDTO; |
| | | import com.zy.asrs.service.*; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.zy.common.entity.NodeExcel; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | |
| | | |
| | | |
| | | @PostMapping(value = "/checkOrder/createTask/auth") |
| | | @ManagerAuth |
| | | public R checkOrderCreateTask(@RequestParam("orderId") Long orderId) { |
| | | CheckOrder checkOrder = checkOrderService.selectById(orderId); |
| | | if (Cools.isEmpty(checkOrder)) { |
| | | throw new CoolException("数据错误"); |
| | | } |
| | | checkOrder.setSettle(11L); |
| | | checkOrderService.updateById(checkOrder); |
| | | @PostMapping(value = "/checkOrder/pdaComplete/auth") |
| | | @ManagerAuth(memo = "pda:完成盘点") |
| | | public R checkOrderPdaComplete(@RequestBody CheckTaskListParam checkTaskListParam) { |
| | | checkOrderService.pdaComplete(checkTaskListParam); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping(value = "/checkOrder/preview/auth") |
| | | @ManagerAuth(memo = "盘点单出库预览") |
| | | public R checkOrderPreview(@RequestParam("orderId") Long orderId) { |
| | | List<LocDto> locDtos = checkOrderService.preview(orderId); |
| | | return R.ok(locDtos); |
| | | } |
| | | @PostMapping(value = "/checkOrder/getTaskList/auth") |
| | | @ManagerAuth(memo = "pda:获取盘点任务列表") |
| | | public R checkOrderGetTaskList(@RequestBody CheckTaskListParam checkTaskListParam) { |
| | | List<CheckOrderDetl> list = checkOrderService.getTaskList(checkTaskListParam.getBarcode()); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @PostMapping(value = "/checkOrder/complete/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "完成盘点单") |
| | | public R checkOrderComplete(@RequestParam("orderId") Long orderId) { |
| | | CheckOrder checkOrder = checkOrderService.selectById(orderId); |
| | | if (Cools.isEmpty(checkOrder)) { |
| | |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | @RequestMapping(value = "/checkOrder/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<CheckOrder> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("checkOrder")); |
| | | convert(map, wrapper); |
| | | List<CheckOrder> list = checkOrderService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | |
| | | |
| | | @PostMapping(value = "/checkOrder/export/auth") |
| | | @ManagerAuth(memo = "盘点单导出") |
| | | public void export(@RequestParam("orderId") Long orderId, HttpServletResponse response) throws IOException { |
| | | CheckOrder checkOrder = checkOrderService.selectById(orderId); |
| | | if (Cools.isEmpty(checkOrder)) { |
| | | throw new CoolException("数据错误"); |
| | | } |
| | | List<CheckOrderDetl> checkOrderDetls = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId)); |
| | | |
| | | ArrayList<CheckOrderExportDTO> checkOrderExportDTOS = new ArrayList<>(); |
| | | for (CheckOrderDetl checkOrderDetl : checkOrderDetls) { |
| | | CheckOrderExportDTO checkOrderExportDTO = new CheckOrderExportDTO(); |
| | | checkOrderExportDTO.sync(checkOrderDetl); |
| | | checkOrderExportDTOS.add(checkOrderExportDTO); |
| | | } |
| | | |
| | | String fileName = "盘点差异单_"+checkOrder.getOrderNo() + ".xlsx"; |
| | | |
| | | // 设置响应头,指定文件名 |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | // 防止中文乱码 |
| | | fileName = java.net.URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-Disposition", "attachment;filename*=" + fileName); |
| | | |
| | | EasyExcel.write(response.getOutputStream(), CheckOrderExportDTO.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("sheet1") |
| | | .doWrite(checkOrderExportDTOS); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/checkOrderQuery/auth") |