diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceCollectOrderDetailDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceCollectOrderDetailDao.java index b6651d77..a3494ccd 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceCollectOrderDetailDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/inventory/DeviceCollectOrderDetailDao.java @@ -62,4 +62,11 @@ public interface DeviceCollectOrderDetailDao { * @return */ DeviceCollectOrderDetailEntity findOneByCode(@Param("code") String code); + + /** + * 批量更新编码 + * + * @param details + */ + void updateCodeBatch(List details); } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceCollectOrderServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceCollectOrderServiceImpl.java index 5d3081b7..36b50e61 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceCollectOrderServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/inventory/impl/DeviceCollectOrderServiceImpl.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -95,11 +96,27 @@ public class DeviceCollectOrderServiceImpl implements DeviceCollectOrderService if (CollUtil.isEmpty(detailList)) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请添加领用设备!"); } + + List details = new ArrayList<>(detailList.size()); + //检验序列号,校验通过更新无序列号产品编码 for (DeviceCollectOrderDetailEntity deviceCollectOrderDetailEntity : detailList) { if (StrUtil.isBlank(deviceCollectOrderDetailEntity.getSerialNo())) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "领用设备中存在无序列号设备,无法提交审核,请完善设备信息!"); + } else if (StrUtil.isBlank(deviceCollectOrderDetailEntity.getCode())) { + //有自定义序列号,重新生成码 + WarehouseEntity warehouseEntity = new WarehouseEntity(); + BeanUtil.copyProperties(deviceCollectOrderDetailEntity, warehouseEntity); + String code = FilterUdiUtils.transGlxpHasSerStr(warehouseEntity); + deviceCollectOrderDetailEntity.setCode(code); + details.add(deviceCollectOrderDetailEntity); } } + + if (CollUtil.isNotEmpty(details)) { + //更新自定义码详情 + deviceCollectOrderDetailDao.updateCodeBatch(details); + } + //更新领用记录状态为待审核 deviceCollectOrderDao.updateStatusById(1, id); return ResultVOUtils.success("提交成功!"); @@ -112,21 +129,8 @@ public class DeviceCollectOrderServiceImpl implements DeviceCollectOrderService } DeviceCollectOrderEntity deviceCollectOrderEntity = deviceCollectOrderDao.selectByPrimaryKey(id); if (null == deviceCollectOrderEntity) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "领用记录不出存在!"); + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "领用记录不存在!"); } - //查询此领用记录详情中定义序列号的记录,重新生成码 - List detailEntityList = deviceCollectOrderDetailDao.selectByOrderId(deviceCollectOrderEntity.getOrderId()); - detailEntityList.forEach(detailEntity -> { - if (StrUtil.isBlank(detailEntity.getCode())) { - WarehouseEntity warehouseEntity = new WarehouseEntity(); - BeanUtil.copyProperties(detailEntity, warehouseEntity); - String code = FilterUdiUtils.transGlxpHasSerStr(warehouseEntity); - detailEntity.setCode(code); - //更新详情的条码信息 - deviceCollectOrderDetailDao.updateByPrimaryKey(detailEntity); - } - }); - String auditUser = customerService.getUserBean().getUserName(); deviceCollectOrderEntity.setAuditUser(auditUser); deviceCollectOrderEntity.setStatus(status); diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceCollectOrderDetailDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceCollectOrderDetailDao.xml index 6d987320..51e4bf47 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceCollectOrderDetailDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/DeviceCollectOrderDetailDao.xml @@ -395,4 +395,16 @@ limit 1 + + + + update device_collect_order_detail + + + code = #{item.code} + + + where id = #{item.id} + + \ No newline at end of file