From 52e1ffd273859bea2af456ca25123d56a8991ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Tue, 29 Aug 2023 14:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceReceiveOrderDetailServiceImpl.java | 89 +++++++++++++------ 1 file changed, 63 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/glxp/api/service/inv/impl/DeviceReceiveOrderDetailServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/DeviceReceiveOrderDetailServiceImpl.java index 288de482..175828a3 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/DeviceReceiveOrderDetailServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/DeviceReceiveOrderDetailServiceImpl.java @@ -2,6 +2,7 @@ package com.glxp.api.service.inv.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; @@ -79,36 +80,53 @@ public class DeviceReceiveOrderDetailServiceImpl implements DeviceReceiveOrderDe return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请添加领用设备!"); } if (StrUtil.isNotBlank(addDetailRequest.getCode())) { - //通过条码添加 - //解析此条码,判断此条码是否已经存在 - UdiEntity udi = FilterUdiUtils.getUdi(addDetailRequest.getCode()); - if (StrUtil.isNotBlank(udi.getSerialNo())) { - //条码为完整码,查询此条码在当前领用记录中是否存在,如果存在则无法添加 - FilterDeviceReceiveOrderDetailRequest detailRequest = new FilterDeviceReceiveOrderDetailRequest(); - detailRequest.setOrderIdFk(addDetailRequest.getOrderIdFk()); - detailRequest.setCode(addDetailRequest.getCode()); - List list = deviceReceiveOrderDetailDao.filterList(detailRequest); - if (CollUtil.isNotEmpty(list)) { - return ResultVOUtils.error(ResultEnum.DATA_REPEAT, "条码重复!"); + if(addDetailRequest.getType() == 1){ + //通过条码添加 + //解析此条码,判断此条码是否已经存在 + UdiEntity udi = FilterUdiUtils.getUdi(addDetailRequest.getCode()); + if (StrUtil.isNotBlank(udi.getSerialNo())) { + //条码为完整码,查询此条码在当前领用记录中是否存在,如果存在则无法添加 + FilterDeviceReceiveOrderDetailRequest detailRequest = new FilterDeviceReceiveOrderDetailRequest(); + detailRequest.setOrderIdFk(addDetailRequest.getOrderIdFk()); + detailRequest.setCode(addDetailRequest.getCode()); + List list = deviceReceiveOrderDetailDao.filterList(detailRequest); + if (CollUtil.isNotEmpty(list)) { + return ResultVOUtils.error(ResultEnum.DATA_REPEAT, "条码重复!"); + } } - } - //设置库存详情查询参数 - FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest(); - invProductDetailRequest.setCode(addDetailRequest.getCode()); + //设置库存详情查询参数 + FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest(); + invProductDetailRequest.setCode(addDetailRequest.getCode()); - //判断是否有选入的仓库信息,如果没有,说明此条码仅存在一条仓库信息,直接使用即可 - if (StrUtil.isNotBlank(addDetailRequest.getInvCode())) { - invProductDetailRequest.setDeptCode(addDetailRequest.getDeptCode()); - invProductDetailRequest.setInvCode(addDetailRequest.getInvCode()); - invProductDetailRequest.setInvSpaceCode(addDetailRequest.getInvSpaceCode()); - invProductDetailRequest.setSupId(addDetailRequest.getSupId()); + //判断是否有选入的仓库信息,如果没有,说明此条码仅存在一条仓库信息,直接使用即可 + if (StrUtil.isNotBlank(addDetailRequest.getInvCode())) { + invProductDetailRequest.setDeptCode(addDetailRequest.getDeptCode()); + invProductDetailRequest.setInvCode(addDetailRequest.getInvCode()); + invProductDetailRequest.setInvSpaceCode(addDetailRequest.getInvSpaceCode()); + invProductDetailRequest.setSupId(addDetailRequest.getSupId()); + } + //查询库存详情 + List invProductDetailEntities = invProductDetailDao.filterInvProductDetailList(invProductDetailRequest); + InvProductDetailEntity invProductDetailEntity = invProductDetailEntities.get(0); + DeviceReceiveOrderDetailEntity orderDetail = getDeviceReceiveOrderDetailEntity(addDetailRequest.getOrderIdFk(), addDetailRequest.getCode(), invProductDetailEntity); + deviceReceiveOrderDetailDao.insert(orderDetail); + }else if(addDetailRequest.getType() == 2){ + DeptDeviceDetailEntity deptDeviceDetailEntity= deptDeviceDetailDao.selectOne(new QueryWrapper().eq("originCode", addDetailRequest.getCode()).last("limit 1")); + DeviceReceiveOrderDetailEntity deviceReceiveOrderDetailEntity = getDeviceReceiveOrderDetailAndDelectEntity(addDetailRequest.getOrderIdFk(),deptDeviceDetailEntity); + deviceReceiveOrderDetailDao.insert(deviceReceiveOrderDetailEntity); + }else if(addDetailRequest.getType() == 3){ + UdiEntity udi = FilterUdiUtils.getUdi(addDetailRequest.getCode()); + UdiProductEntity udiProductEntity = udiProductService.selectUdiByName(udi.getUdi()); + DeviceReceiveOrderDetailEntity deviceReceiveOrderDetailEntity = new DeviceReceiveOrderDetailEntity(); + deviceReceiveOrderDetailEntity.setNameCode(udiProductEntity.getNameCode()); + deviceReceiveOrderDetailEntity.setRelId(Long.valueOf(udiProductEntity.getRelId())); + deviceReceiveOrderDetailEntity.setOrderIdFk(addDetailRequest.getOrderIdFk()); + deviceReceiveOrderDetailEntity.setSupId(udiProductEntity.getSupId()); + deviceReceiveOrderDetailEntity.setCreateTime(new Date()); + deviceReceiveOrderDetailEntity.setUpdateTime(new Date()); + deviceReceiveOrderDetailDao.insert(deviceReceiveOrderDetailEntity); } - //查询库存详情 - List invProductDetailEntities = invProductDetailDao.filterInvProductDetailList(invProductDetailRequest); - InvProductDetailEntity invProductDetailEntity = invProductDetailEntities.get(0); - DeviceReceiveOrderDetailEntity orderDetail = getDeviceReceiveOrderDetailEntity(addDetailRequest.getOrderIdFk(), addDetailRequest.getCode(), invProductDetailEntity); - deviceReceiveOrderDetailDao.insert(orderDetail); } else { SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("device_product"); if(systemParamConfigEntity.getParamValue().equals("0") || addDetailRequest.getType() == 1){ @@ -190,6 +208,25 @@ public class DeviceReceiveOrderDetailServiceImpl implements DeviceReceiveOrderDe return orderDetail; } + private static DeviceReceiveOrderDetailEntity getDeviceReceiveOrderDetailAndDelectEntity(String orderIdFk,DeptDeviceDetailEntity deptDeviceDetailEntity) { + + DeviceReceiveOrderDetailEntity deviceReceiveOrderDetailEntity = new DeviceReceiveOrderDetailEntity(); + //查询库存详情 + deviceReceiveOrderDetailEntity.setNameCode(deptDeviceDetailEntity.getNameCode()); + deviceReceiveOrderDetailEntity.setRelId(Long.valueOf(deptDeviceDetailEntity.getRelId())); + deviceReceiveOrderDetailEntity.setOriginCode(deptDeviceDetailEntity.getOriginCode()); + deviceReceiveOrderDetailEntity.setCode(deptDeviceDetailEntity.getCode()); + deviceReceiveOrderDetailEntity.setOrderIdFk(orderIdFk); + deviceReceiveOrderDetailEntity.setSupId(deptDeviceDetailEntity.getSupId()); + deviceReceiveOrderDetailEntity.setBatchNo(deptDeviceDetailEntity.getBatchNo()); + deviceReceiveOrderDetailEntity.setProductionDate(deptDeviceDetailEntity.getProductionDate()); + deviceReceiveOrderDetailEntity.setExpireDate(deptDeviceDetailEntity.getExpireDate()); + deviceReceiveOrderDetailEntity.setSerialNo(deptDeviceDetailEntity.getSerialNo()); + deviceReceiveOrderDetailEntity.setCreateTime(new Date()); + deviceReceiveOrderDetailEntity.setUpdateTime(new Date()); + return deviceReceiveOrderDetailEntity; + } + @Override public BaseResponse updateOrderDetail(DeviceReceiveOrderDetailEntity detailEntity) { if (null == detailEntity || null == detailEntity.getId()) {