From 7b0769acd672f39b970d9b4af0f661eaed68158e Mon Sep 17 00:00:00 2001 From: chenhc <2369838784@qq.com> Date: Wed, 16 Oct 2024 18:05:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8D=AF=E5=93=81=E5=85=B3=E8=81=94?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collect/RelCodeBatchController.java | 94 +++++++++++++++++++ .../collect/RelCodeDetailController.java | 70 ++++++++++++++ .../service/collect/RelCodeBatchService.java | 55 ++++++----- 3 files changed, 197 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeBatchController.java create mode 100644 src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeDetailController.java diff --git a/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeBatchController.java b/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeBatchController.java new file mode 100644 index 0000000..a4f209c --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeBatchController.java @@ -0,0 +1,94 @@ +package com.glxp.udidl.admin.controller.collect; + +import com.github.pagehelper.PageInfo; +import com.glxp.udidl.admin.entity.collect.RelCodeBatch; +import com.glxp.udidl.admin.req.collect.RelCodeBatchRequest; +import com.glxp.udidl.admin.req.collect.RelCodeDetailRequest; +import com.glxp.udidl.admin.res.BaseResponse; +import com.glxp.udidl.admin.res.PageSimpleResponse; +import com.glxp.udidl.admin.res.collect.RelCodeBatchResponse; +import com.glxp.udidl.admin.service.collect.RelCodeBatchService; +import com.glxp.udidl.admin.util.ResultVOUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; + +@Slf4j +@RestController +public class RelCodeBatchController { + + @Resource + private RelCodeBatchService relCodeBatchService; + + + /** + * 手动添加 + * @param relCodeBatchRequest + * @return + */ + @PostMapping("/udiwms/relCode/batch/add") + public BaseResponse add(@RequestBody @Valid RelCodeBatchRequest relCodeBatchRequest, BindingResult bindingResult) { + relCodeBatchService.add(relCodeBatchRequest); + return ResultVOUtils.success("添加成功!"); + } + + /** + * 添加拼箱 + * @param relCodeBatchRequest + * @return + */ + @PostMapping("/udiwms/relCode/batch/addList") + public BaseResponse addRelCodeSpellBox(@RequestBody @Valid List relCodeBatchRequest,BindingResult bindingResult) { + relCodeBatchService.addRelCodeSpellBox(relCodeBatchRequest); + return ResultVOUtils.success("添加成功!"); + } + + @GetMapping("/udiwms/relCode/batch/filter") + public BaseResponse list(RelCodeBatchRequest relCodeBatchRequest, BindingResult bindingResult) { + List relCodeBatchResponses = relCodeBatchService.filterList(relCodeBatchRequest); + PageInfo pageInfo = new PageInfo<>(relCodeBatchResponses); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(relCodeBatchResponses); + return ResultVOUtils.success(pageSimpleResponse); + } + + @GetMapping("/udiwms/relCode/batch/get") + public BaseResponse get(@RequestParam("id") Long id) { + RelCodeBatch relCodeBatch = relCodeBatchService.getById(id); + return ResultVOUtils.success(relCodeBatch); + } + + @GetMapping("/udiwms/relCode/batch/delete") + public BaseResponse delete(@RequestParam("id") Long id) { + relCodeBatchService.delete(id); + return ResultVOUtils.success("删除成功"); + } + + + @PostMapping("/udiwms/relCode/batch/update") + public BaseResponse update(@RequestBody @Valid RelCodeBatch relCodeBatch) { + relCodeBatchService.updateById(relCodeBatch); + return ResultVOUtils.success("修改成功!"); + } + + + + @GetMapping("/udiwms/relCode/batch/deleteDetail") + public BaseResponse deleteDetail(@RequestParam("curCode") String curCode) { + relCodeBatchService.deleteDetail(curCode); + return ResultVOUtils.success("删除成功"); + } + + + @PostMapping("/udiwms/relCode/batch/deleteAllDetail") + public BaseResponse deleteAllDetail(@RequestBody List detailList) { + relCodeBatchService.deleteAllDetail(detailList); + return ResultVOUtils.success("清空成功"); + } + +} diff --git a/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeDetailController.java b/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeDetailController.java new file mode 100644 index 0000000..30edf9e --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/controller/collect/RelCodeDetailController.java @@ -0,0 +1,70 @@ +//package com.glxp.udidl.admin.controller.collect; +// +// +//import com.github.pagehelper.PageInfo; +//import com.glxp.api.annotation.RepeatSubmit; +//import com.glxp.api.common.res.BaseResponse; +//import com.glxp.api.common.util.ResultVOUtils; +//import com.glxp.api.controller.BaseController; +//import com.glxp.api.entity.collect.RelCodeDetail; +//import com.glxp.api.req.collect.RelCodeDetailRequest; +//import com.glxp.api.res.PageSimpleResponse; +//import com.glxp.api.res.collect.RelCodeDetailResponse; +//import com.glxp.api.service.collect.RelCodeDetailService; +//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 javax.annotation.Resource; +//import javax.validation.Valid; +//import java.util.List; +// +//@Slf4j +//@RestController +//public class RelCodeDetailController extends BaseController { +// +// @Resource +// private RelCodeDetailService relCodeDetailService; +// +// +// +// /** +// * 扫码 +// * @param relCodeDetailRequest +// * @return +// */ +// @RepeatSubmit() +// @PostMapping("/udiwms/relCode/detail/scanCode") +// public BaseResponse scanCode(@RequestBody @Valid RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) { +// RelCodeDetailResponse relCodeDetailResponse = relCodeDetailService.scanCode(relCodeDetailRequest); +// return ResultVOUtils.success(relCodeDetailResponse); +// } +// +// +// @GetMapping("/udiwms/relCode/detail/filter") +// public BaseResponse list(RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) { +// List relCodeDetailResponses = relCodeDetailService.filterList(relCodeDetailRequest); +// PageInfo pageInfo = new PageInfo<>(relCodeDetailResponses); +// PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); +// pageSimpleResponse.setTotal(pageInfo.getTotal()); +// pageSimpleResponse.setList(relCodeDetailResponses); +// return ResultVOUtils.success(pageSimpleResponse); +// } +// +// +// @GetMapping("/udiwms/relCode/detail/get") +// public BaseResponse get(Long id) { +// RelCodeDetail relCodeDetail = relCodeDetailService.getById(id); +// return ResultVOUtils.success(relCodeDetail); +// } +// +// +// @PostMapping("/udiwms/relCode/detail/update") +// public BaseResponse update(@RequestBody @Valid RelCodeDetail relCodeDetail) { +// relCodeDetailService.updateById(relCodeDetail); +// return ResultVOUtils.success("修改成功!"); +// } +//} diff --git a/src/main/java/com/glxp/udidl/admin/service/collect/RelCodeBatchService.java b/src/main/java/com/glxp/udidl/admin/service/collect/RelCodeBatchService.java index 0115cf8..c6f7cbd 100644 --- a/src/main/java/com/glxp/udidl/admin/service/collect/RelCodeBatchService.java +++ b/src/main/java/com/glxp/udidl/admin/service/collect/RelCodeBatchService.java @@ -144,28 +144,39 @@ public class RelCodeBatchService extends ServiceImpl detailList = relCodeBatchRequest.getDetailList(); -// if(CollUtil.isEmpty(detailList)){ -// throw new JsonException("关联明细不能为空!"); -// } -// AuthAdmin user = customerService.getUserBean(); -// RelCodeBatch relCodeBatch = new RelCodeBatch(); -// BeanUtils.copyProperties(relCodeBatchRequest,relCodeBatch); -// relCodeBatch.setCreateTime(new Date()); -// relCodeBatch.setCreateUser(user.getUserName()); -// relCodeBatch.setUpdateTime(new Date()); -// relCodeBatch.setUpdateUser(user.getUserName()); -// this.save(relCodeBatch); -// List relCodeDetails = new ArrayList<>(); -// for(RelCodeDetailRequest request : detailList){ -// RelCodeDetail relCodeDetail = new RelCodeDetail(); -// String parentCode = request.getParentCode(); -// request.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0"); -// BeanUtils.copyProperties(request,relCodeDetail); -// relCodeDetail.setBatchIdFk(relCodeBatch.getId()); -// relCodeDetails.add(relCodeDetail); -// } -// relCodeDetailService.saveBatch(relCodeDetails); + String productCode = relCodeBatchRequest.getProductCode(); + String subTypeNo = relCodeBatchRequest.getSubTypeNo(); + String batchNo = relCodeBatchRequest.getBatchNo(); + //如果不存在就添加 + List list = this.list(new LambdaQueryWrapper() + .eq(RelCodeBatch::getProductCode, productCode) + .eq(StrUtil.isNotBlank(subTypeNo),RelCodeBatch::getSubTypeNo, subTypeNo) + .eq(RelCodeBatch::getBatchNo, batchNo)) + ; + if (CollUtil.isNotEmpty(list)){ + throw new JsonException( "层级编码:【"+productCode + "】;类型编码:【" + subTypeNo + "】;批次号:【"+batchNo + "】已存在!"); + } + List detailList = relCodeBatchRequest.getDetailList(); + if(CollUtil.isEmpty(detailList)){ + throw new JsonException("关联明细不能为空!"); + } + RelCodeBatch relCodeBatch = new RelCodeBatch(); + BeanUtils.copyProperties(relCodeBatchRequest,relCodeBatch); + relCodeBatch.setCreateTime(new Date()); + relCodeBatch.setUpdateTime(new Date()); + relCodeBatch.setId(null); + this.save(relCodeBatch); + List relCodeDetails = new ArrayList<>(); + for(RelCodeDetailRequest request : detailList){ + RelCodeDetail relCodeDetail = new RelCodeDetail(); + String parentCode = request.getParentCode(); + request.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0"); + BeanUtils.copyProperties(request,relCodeDetail); + relCodeDetail.setBatchIdFk(relCodeBatch.getId()); + relCodeDetail.setId(null); + relCodeDetails.add(relCodeDetail); + } + relCodeDetailService.saveBatch(relCodeDetails); } public List filterList(RelCodeBatchRequest relCodeBatchRequest) {