From 1dbe3957ab28b4285870bf4c6076b31f53ec1ed8 Mon Sep 17 00:00:00 2001 From: x_z Date: Wed, 12 Oct 2022 18:22:27 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=BB=BA?= =?UTF-8?q?=E5=9E=9B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/StackCodeController.java | 7 +++ .../product/StackOrderController.java | 48 ++++++++++++++++--- .../udi/admin/dao/product/StackCodeDao.java | 8 ++++ .../admin/res/product/StackOrderResponse.java | 17 +++++++ .../service/product/StackCodeService.java | 17 +++++++ .../service/product/StackOrderService.java | 16 ++++++- .../mybatis/mapper/product/StackCodeDao.xml | 5 ++ 7 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/glxp/udi/admin/res/product/StackOrderResponse.java diff --git a/src/main/java/com/glxp/udi/admin/controller/product/StackCodeController.java b/src/main/java/com/glxp/udi/admin/controller/product/StackCodeController.java index 7630125..e37decd 100644 --- a/src/main/java/com/glxp/udi/admin/controller/product/StackCodeController.java +++ b/src/main/java/com/glxp/udi/admin/controller/product/StackCodeController.java @@ -75,6 +75,13 @@ public class StackCodeController { if (bindingResult.hasErrors()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } + if (StrUtil.isNotBlank(addStackCodeRequest.getOrderId())) { + //判断此条码是重复添加 + boolean result = stackCodeService.repeatAdd(addStackCodeRequest.getCode()); + if (result) { + return ResultVOUtils.error(500, "条码重复!"); + } + } StackCode stackCode = stackCodeService.addCode(addStackCodeRequest); return ResultVOUtils.success(stackCode); } diff --git a/src/main/java/com/glxp/udi/admin/controller/product/StackOrderController.java b/src/main/java/com/glxp/udi/admin/controller/product/StackOrderController.java index 274df76..e37a42d 100644 --- a/src/main/java/com/glxp/udi/admin/controller/product/StackOrderController.java +++ b/src/main/java/com/glxp/udi/admin/controller/product/StackOrderController.java @@ -1,11 +1,14 @@ package com.glxp.udi.admin.controller.product; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.glxp.udi.admin.annotation.AuthRuleAnnotation; import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.req.info.DeleteRequest; import com.glxp.udi.admin.req.product.StackUploadRequest; +import com.glxp.udi.admin.res.product.StackOrderResponse; import com.glxp.udi.admin.service.auth.CustomerService; import com.glxp.udi.admin.common.util.ResultVOUtils; import com.glxp.udi.admin.entity.product.StackOrder; @@ -16,12 +19,12 @@ import com.glxp.udi.admin.service.product.StackOrderService; import com.glxp.udi.admin.common.enums.ResultEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; @Slf4j @RestController @@ -42,9 +45,20 @@ public class StackOrderController { } stackOrderFilterRequest.setCustomerId(customerService.getCustomerId() + ""); IPage page = stackOrderService.filterList(stackOrderFilterRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + List responses = new ArrayList<>(); + page.getRecords().forEach(stackOrder -> { + StackOrderResponse response = new StackOrderResponse(); + BeanUtil.copyProperties(stackOrder, response); + + //查询此垛的扫码数量 + Long codeNum = stackOrderService.countCode(stackOrder.getOrderId()); + response.setCodeNum(codeNum); + responses.add(response); + }); + + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(page.getRecords()); + pageSimpleResponse.setList(responses); return ResultVOUtils.success(pageSimpleResponse); } @@ -97,4 +111,26 @@ public class StackOrderController { return ResultVOUtils.success(stackOrderId); } + /** + * 导入excel文件建垛 + * + * @param file + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/udims/stack/order/importStackOrder") + public BaseResponse importStackOrder(@RequestParam("file") MultipartFile file) { + if (file.isEmpty()) { + return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传文件不能为空"); + } + //保存文件 + String fileName = file.getOriginalFilename(); + String fileType = fileName.substring(fileName.lastIndexOf(".")); + //文件类型判断 + if (StrUtil.isBlank(fileType) || (!fileType.equals(".xls") || !fileType.equals(".xlsx"))) { + return ResultVOUtils.error(ResultEnum.DATA_ERROR, "只能上传 xlx 或 xlsx 格式文件"); + } + return ResultVOUtils.success(); + } + } diff --git a/src/main/java/com/glxp/udi/admin/dao/product/StackCodeDao.java b/src/main/java/com/glxp/udi/admin/dao/product/StackCodeDao.java index 4df3c1b..5bb06a3 100644 --- a/src/main/java/com/glxp/udi/admin/dao/product/StackCodeDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/product/StackCodeDao.java @@ -14,4 +14,12 @@ public interface StackCodeDao extends BaseMapper { * @param orderId */ void deleteByOrderId(@Param("orderId") String orderId); + + /** + * 统计此垛的码数量 + * + * @param orderId + * @return + */ + Long countByOrderId(@Param("orderId") String orderId); } diff --git a/src/main/java/com/glxp/udi/admin/res/product/StackOrderResponse.java b/src/main/java/com/glxp/udi/admin/res/product/StackOrderResponse.java new file mode 100644 index 0000000..feeba81 --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/res/product/StackOrderResponse.java @@ -0,0 +1,17 @@ +package com.glxp.udi.admin.res.product; + +import com.glxp.udi.admin.entity.product.StackOrder; +import lombok.Data; + +/** + * 建垛数据响应结果 + */ +@Data +public class StackOrderResponse extends StackOrder { + + /** + * 码数量 + */ + private Long codeNum; + +} diff --git a/src/main/java/com/glxp/udi/admin/service/product/StackCodeService.java b/src/main/java/com/glxp/udi/admin/service/product/StackCodeService.java index 42a69e1..6c0f3d1 100644 --- a/src/main/java/com/glxp/udi/admin/service/product/StackCodeService.java +++ b/src/main/java/com/glxp/udi/admin/service/product/StackCodeService.java @@ -100,4 +100,21 @@ public class StackCodeService { stackCode.setId(id); return stackCode; } + + /** + * 判断此条码是否在垛中存在 + * + * @param orderId + * @param code + * @return + */ + public boolean repeatAdd(String code) { + QueryWrapper countWrapper = new QueryWrapper<>(); + countWrapper.eq("code", code); + Long count = stackCodeDao.selectCount(countWrapper); + if (null != count && count > 0) { + return true; + } + return false; + } } diff --git a/src/main/java/com/glxp/udi/admin/service/product/StackOrderService.java b/src/main/java/com/glxp/udi/admin/service/product/StackOrderService.java index 42ca352..62f4b8b 100644 --- a/src/main/java/com/glxp/udi/admin/service/product/StackOrderService.java +++ b/src/main/java/com/glxp/udi/admin/service/product/StackOrderService.java @@ -43,7 +43,7 @@ public class StackOrderService { wrapper.eq(stackOrderFilterRequest.getId() != null, "id", stackOrderFilterRequest.getId()) .eq(StrUtil.isNotBlank(stackOrderFilterRequest.getCustomerId()), "customerId", stackOrderFilterRequest.getCustomerId()) - .eq(StrUtil.isNotBlank(stackOrderFilterRequest.getOrderId()), "orderId", stackOrderFilterRequest.getOrderId()) + .like(StrUtil.isNotBlank(stackOrderFilterRequest.getOrderId()), "orderId", stackOrderFilterRequest.getOrderId()) .eq(stackOrderFilterRequest.getExportStatus() != null, "exportStatus", stackOrderFilterRequest.getExportStatus()) .eq(stackOrderFilterRequest.getStatus() != null, "status", stackOrderFilterRequest.getStatus()) .orderByDesc("updateTime"); @@ -56,7 +56,9 @@ public class StackOrderService { stackOrderDao.updateById(stackUploadRequest.getStackOrderEntity()); //更新码详情 if (CollUtil.isNotEmpty(stackUploadRequest.getStackCodeEntityList())) { - stackUploadRequest.getStackCodeEntityList().forEach(stackCode -> {stackCode.setOrderIdFk(stackUploadRequest.getStackOrderEntity().getOrderId());}); + stackUploadRequest.getStackCodeEntityList().forEach(stackCode -> { + stackCode.setOrderIdFk(stackUploadRequest.getStackOrderEntity().getOrderId()); + }); SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED); StackCodeDao mapper = batchSession.getMapper(StackCodeDao.class); List stackCodeEntityList = stackUploadRequest.getStackCodeEntityList(); @@ -95,4 +97,14 @@ public class StackOrderService { stackCodeDao.deleteByOrderId(orderId); } + /** + * 统计此垛的码数量 + * + * @param orderId + * @return + */ + public Long countCode(String orderId) { + Long codeNum = stackCodeDao.countByOrderId(orderId); + return codeNum; + } } diff --git a/src/main/resources/mybatis/mapper/product/StackCodeDao.xml b/src/main/resources/mybatis/mapper/product/StackCodeDao.xml index f641038..bd25a00 100644 --- a/src/main/resources/mybatis/mapper/product/StackCodeDao.xml +++ b/src/main/resources/mybatis/mapper/product/StackCodeDao.xml @@ -6,4 +6,9 @@ from stack_code where orderIdFk = #{orderId} + + + \ No newline at end of file