diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java index d940104..9e55ca9 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java @@ -1,132 +1,145 @@ package org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import java.math.BigDecimal; +import java.util.List; + +import javax.annotation.Resource; + import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.system.entity.SysThirdAccount; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetail; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetailChild; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.mapper.CycleCountDetailChildMapper; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.ICycleCountDetailChildService; import org.jeecg.modules.wms.stocktaking.cycleCountHeader.entity.CycleCountHeader; import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl.CycleCountHeaderServiceImpl; +import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; +import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.math.BigDecimal; -import java.util.List; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.annotation.Resource; /** * @Description: 盘点容器明细表 - * @Author: jeecg-boot - * @Date: 2023-01-30 - * @Version: V1.0 + * @Author: jeecg-boot + * @Date: 2023-01-30 + * @Version: V1.0 */ @Service public class CycleCountDetailChildServiceImpl extends ServiceImpl<CycleCountDetailChildMapper, CycleCountDetailChild> implements ICycleCountDetailChildService { - @Autowired - private CycleCountDetailChildMapper cycleCountDetailChildMapper; - @Resource - private CycleCountDetailServiceImpl cycleCountDetailService; - @Resource - private CycleCountHeaderServiceImpl cycleCountHeaderService; - - - - @Override - public Result confirmGapQty(String id, String countedQty,String state) { - //接收子单ID和实盘数量 - //任务未完成可多次登记。 - CycleCountDetailChild detailChild=new CycleCountDetailChild(); - if (StringUtils.isNotEmpty(state)) - { - LambdaQueryWrapper<CycleCountDetailChild> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(CycleCountDetailChild::getTaskDetailId,id); - detailChild = this.getOne(queryWrapper); - }else - { - //明细子单据 - detailChild = this.getById(Integer.valueOf(id)); - } - - if(StringUtils.isNull(detailChild)){ - return Result.error("明细子单不存在!"); - } - - - BigDecimal qty=new BigDecimal(countedQty); - if(qty.compareTo(BigDecimal.ZERO) == -1){ - return Result.error("实盘登记数不能小于0"); - } - - - - - CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(detailChild.getCycleCountDetailid()); - if(StringUtils.isNull(cycleCountDetail)){ - return Result.error("盘点明细不存在。"); - } - //任务完成后再实盘登记 + @Autowired + private CycleCountDetailChildMapper cycleCountDetailChildMapper; + @Resource + private CycleCountDetailServiceImpl cycleCountDetailService; + @Resource + private CycleCountHeaderServiceImpl cycleCountHeaderService; + @Resource + private ITaskDetailService taskDetailService; + + @Override + public Result confirmGapQty(String id, String countedQty, String state) { + // 接收子单ID和实盘数量 + // 任务未完成可多次登记。 + CycleCountDetailChild detailChild = new CycleCountDetailChild(); + if (StringUtils.isNotEmpty(state)) { + LambdaQueryWrapper<CycleCountDetailChild> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CycleCountDetailChild::getTaskDetailId, id); + detailChild = this.getOne(queryWrapper); + } else { + // 明细子单据 + detailChild = this.getById(Integer.valueOf(id)); + } + + if (StringUtils.isNull(detailChild)) { + return Result.error("明细子单不存在!"); + } + + BigDecimal qty = new BigDecimal(countedQty); + if (qty.compareTo(BigDecimal.ZERO) == -1) { + return Result.error("实盘登记数不能小于0"); + } + + CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(detailChild.getCycleCountDetailid()); + if (StringUtils.isNull(cycleCountDetail)) { + return Result.error("盘点明细不存在。"); + } + // 任务完成后再实盘登记 // if(countDetailChild.getChildStatus() < QuantityConstant.CYCLECOUNT_STATUS_EXECUTING){ // return AjaxResult.error("盘点任务未执行不能登记数量!"); // } - if(detailChild.getChildStatus() >= QuantityConstant.CYCLECOUNT_STATUS_COMPLETED){ - return Result.error("盘点任务完成后不能再登记数量!"); - } - - - //实盘登记后差异数量 - BigDecimal adjQty = qty.subtract(detailChild.getSystemQty()); - detailChild.setGapQty(adjQty); - detailChild.setCountedQty(qty); - detailChild.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); - this.updateById(detailChild); - - - - LambdaQueryWrapper<CycleCountDetailChild> cycleCountDetailChildLambdaQueryWrapper = new LambdaQueryWrapper<>(); - cycleCountDetailChildLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid,cycleCountDetail.getId()); - List<CycleCountDetailChild> cycleCountDetailChildren = this.list(cycleCountDetailChildLambdaQueryWrapper); - - BigDecimal counted_qty=new BigDecimal(0); - BigDecimal ystem_qty=new BigDecimal(0); - BigDecimal gap_qty=new BigDecimal(0); - for(CycleCountDetailChild cycleCountDetailChild:cycleCountDetailChildren) - { - counted_qty=counted_qty.add(cycleCountDetailChild.getCountedQty()); - ystem_qty=ystem_qty.add(cycleCountDetailChild.getSystemQty()); - gap_qty=gap_qty.add(cycleCountDetailChild.getGapQty()); - } - //修改明细单状态 - cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); - cycleCountDetail.setCountedQty(counted_qty); - cycleCountDetail.setSystemQty(ystem_qty); - cycleCountDetail.setGapQty(gap_qty); - - cycleCountDetailService.updateById(cycleCountDetail); - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - //修改主单状态 - CycleCountHeader tmp = new CycleCountHeader(); - tmp.setCode(detailChild.getCyclecountheadcode()); - tmp.setWarehouseCode(cycleCountDetail.getWarehouseCode()); - LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(tmp); - CycleCountHeader cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper); - cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); - cycleCountHeader.setStocktakingAc(sysUser.getUsername()); - - Result<Integer> result = new Result<Integer>(); - result.setCode(200); - result.setMessage("调整成功"); - result.setResult(cycleCountHeader.getId()); - return result; - } + if (detailChild.getChildStatus() >= QuantityConstant.CYCLECOUNT_STATUS_COMPLETED) { + return Result.error("盘点任务完成后不能再登记数量!"); + } + + // 实盘登记后差异数量 + BigDecimal adjQty = qty.subtract(detailChild.getSystemQty()); + CycleCountDetailChild detailChild1 = new CycleCountDetailChild(); + detailChild1.setId(detailChild.getId()); + detailChild1.setGapQty(adjQty); + detailChild1.setCountedQty(qty); + detailChild1.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); + if (!this.updateById(detailChild)) { + throw new JeecgBootException("实盘登记更新盘点子单数量失败"); + } + + LambdaQueryWrapper<CycleCountDetailChild> cycleCountDetailChildLambdaQueryWrapper = new LambdaQueryWrapper<>(); + cycleCountDetailChildLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid, cycleCountDetail.getId()); + List<CycleCountDetailChild> cycleCountDetailChildList = this.list(cycleCountDetailChildLambdaQueryWrapper); + if (CollectionUtils.isEmpty(cycleCountDetailChildList)) { + throw new JeecgBootException("实盘登记,获取盘点明细表失败"); + } + + BigDecimal counted_qty = new BigDecimal(0); + BigDecimal ystem_qty = new BigDecimal(0); + BigDecimal gap_qty = new BigDecimal(0); + for (CycleCountDetailChild cycleCountDetailChild : cycleCountDetailChildList) { + counted_qty = counted_qty.add(cycleCountDetailChild.getCountedQty()); + ystem_qty = ystem_qty.add(cycleCountDetailChild.getSystemQty()); + gap_qty = gap_qty.add(cycleCountDetailChild.getGapQty()); + } + // 修改明细单状态 + cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); + cycleCountDetail.setCountedQty(counted_qty); + cycleCountDetail.setSystemQty(ystem_qty); + cycleCountDetail.setGapQty(gap_qty); + + if (!cycleCountDetailService.updateById(cycleCountDetail)) { + throw new JeecgBootException("实盘登记更新盘点数量失败"); + } + LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); + // 修改主单状态 + CycleCountHeader tmp = new CycleCountHeader(); + tmp.setCode(detailChild.getCyclecountheadcode()); + tmp.setWarehouseCode(cycleCountDetail.getWarehouseCode()); + LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(tmp); + CycleCountHeader cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper); + cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); + cycleCountHeader.setStocktakingAc(sysUser.getUsername()); + if (!cycleCountHeaderService.updateById(cycleCountHeader)) { + throw new JeecgBootException("更新盘点表单头失败"); + } + + TaskDetail taskDetail = new TaskDetail(); + taskDetail.setId(Integer.parseInt(id)); + taskDetail.setCircleQty(qty); + taskDetail.setCircleStatus(QuantityConstant.CIRCLE_REGISTER_STATUS_COMPLETE); + if (!taskDetailService.updateById(taskDetail)) { + throw new JeecgBootException("更新任务详情失败"); + } + Result<Integer> result = new Result<Integer>(); + result.setCode(200); + result.setMessage("调整成功"); + result.setResult(cycleCountHeader.getId()); + return result; + } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java index f0fb68c..8f58ffb 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java @@ -124,6 +124,17 @@ public class TaskDetail implements Serializable { @ApiModelProperty(value = "不合格数量") private BigDecimal unqualityfiedQty; + /** 盘点数量 */ + @Excel(name = "盘点数量", width = 15) + @ApiModelProperty(value = "盘点数量") + private BigDecimal circleQty; + + /** 盘点状态 */ + @Excel(name = "盘点状态", width = 15) + @Dict(dicCode = "circle_register_status") + @ApiModelProperty(value = "盘点状态") + private Integer circleStatus; + /** 备注 */ @Excel(name = "备注", width = 15) @ApiModelProperty(value = "备注") diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java index 72e8797..e2d4e3c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java @@ -429,6 +429,11 @@ public class QuantityConstant { // 质检完成 public static final int QUALITY_TESTING_COMPLETE = 1; + // 待登记 + public static final int CIRCLE_REGISTER_STATUS_BUILD = 0; + // 登记完成 + public static final int CIRCLE_REGISTER_STATUS_COMPLETE = 1; + /** 来料质检 */ public static final String QUALITY_TYPE_INCOMING = "QI"; /** 库内全检 */