Commit 4598674974b5d86acb7a53ede18f8dac2d7abb1c
1 parent
842281a9
增加盘点状态
Showing
3 changed files
with
133 additions
and
104 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl; |
2 | 2 | |
3 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | +import java.math.BigDecimal; | |
4 | +import java.util.List; | |
5 | + | |
6 | +import javax.annotation.Resource; | |
7 | + | |
5 | 8 | import org.apache.shiro.SecurityUtils; |
6 | 9 | import org.jeecg.common.api.vo.Result; |
10 | +import org.jeecg.common.exception.JeecgBootException; | |
7 | 11 | import org.jeecg.common.system.vo.LoginUser; |
8 | -import org.jeecg.modules.system.entity.SysThirdAccount; | |
9 | 12 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetail; |
10 | 13 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetailChild; |
11 | 14 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.mapper.CycleCountDetailChildMapper; |
12 | 15 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.ICycleCountDetailChildService; |
13 | 16 | import org.jeecg.modules.wms.stocktaking.cycleCountHeader.entity.CycleCountHeader; |
14 | 17 | import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl.CycleCountHeaderServiceImpl; |
18 | +import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; | |
19 | +import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; | |
15 | 20 | import org.jeecg.utils.StringUtils; |
16 | 21 | import org.jeecg.utils.constant.QuantityConstant; |
22 | +import org.springframework.beans.factory.annotation.Autowired; | |
17 | 23 | import org.springframework.stereotype.Service; |
18 | 24 | |
19 | -import java.math.BigDecimal; | |
20 | -import java.util.List; | |
25 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
26 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
27 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
21 | 28 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
22 | -import org.springframework.beans.factory.annotation.Autowired; | |
23 | - | |
24 | -import javax.annotation.Resource; | |
25 | 29 | |
26 | 30 | /** |
27 | 31 | * @Description: 盘点容器明细表 |
28 | - * @Author: jeecg-boot | |
29 | - * @Date: 2023-01-30 | |
30 | - * @Version: V1.0 | |
32 | + * @Author: jeecg-boot | |
33 | + * @Date: 2023-01-30 | |
34 | + * @Version: V1.0 | |
31 | 35 | */ |
32 | 36 | @Service |
33 | 37 | public class CycleCountDetailChildServiceImpl extends ServiceImpl<CycleCountDetailChildMapper, CycleCountDetailChild> implements ICycleCountDetailChildService { |
34 | 38 | |
35 | - @Autowired | |
36 | - private CycleCountDetailChildMapper cycleCountDetailChildMapper; | |
37 | - @Resource | |
38 | - private CycleCountDetailServiceImpl cycleCountDetailService; | |
39 | - @Resource | |
40 | - private CycleCountHeaderServiceImpl cycleCountHeaderService; | |
41 | - | |
42 | - | |
43 | - | |
44 | - @Override | |
45 | - public Result confirmGapQty(String id, String countedQty,String state) { | |
46 | - //接收子单ID和实盘数量 | |
47 | - //任务未完成可多次登记。 | |
48 | - CycleCountDetailChild detailChild=new CycleCountDetailChild(); | |
49 | - if (StringUtils.isNotEmpty(state)) | |
50 | - { | |
51 | - LambdaQueryWrapper<CycleCountDetailChild> queryWrapper = new LambdaQueryWrapper<>(); | |
52 | - queryWrapper.eq(CycleCountDetailChild::getTaskDetailId,id); | |
53 | - detailChild = this.getOne(queryWrapper); | |
54 | - }else | |
55 | - { | |
56 | - //明细子单据 | |
57 | - detailChild = this.getById(Integer.valueOf(id)); | |
58 | - } | |
59 | - | |
60 | - if(StringUtils.isNull(detailChild)){ | |
61 | - return Result.error("明细子单不存在!"); | |
62 | - } | |
63 | - | |
64 | - | |
65 | - BigDecimal qty=new BigDecimal(countedQty); | |
66 | - if(qty.compareTo(BigDecimal.ZERO) == -1){ | |
67 | - return Result.error("实盘登记数不能小于0"); | |
68 | - } | |
69 | - | |
70 | - | |
71 | - | |
72 | - | |
73 | - CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(detailChild.getCycleCountDetailid()); | |
74 | - if(StringUtils.isNull(cycleCountDetail)){ | |
75 | - return Result.error("盘点明细不存在。"); | |
76 | - } | |
77 | - //任务完成后再实盘登记 | |
39 | + @Autowired | |
40 | + private CycleCountDetailChildMapper cycleCountDetailChildMapper; | |
41 | + @Resource | |
42 | + private CycleCountDetailServiceImpl cycleCountDetailService; | |
43 | + @Resource | |
44 | + private CycleCountHeaderServiceImpl cycleCountHeaderService; | |
45 | + @Resource | |
46 | + private ITaskDetailService taskDetailService; | |
47 | + | |
48 | + @Override | |
49 | + public Result confirmGapQty(String id, String countedQty, String state) { | |
50 | + // 接收子单ID和实盘数量 | |
51 | + // 任务未完成可多次登记。 | |
52 | + CycleCountDetailChild detailChild = new CycleCountDetailChild(); | |
53 | + if (StringUtils.isNotEmpty(state)) { | |
54 | + LambdaQueryWrapper<CycleCountDetailChild> queryWrapper = new LambdaQueryWrapper<>(); | |
55 | + queryWrapper.eq(CycleCountDetailChild::getTaskDetailId, id); | |
56 | + detailChild = this.getOne(queryWrapper); | |
57 | + } else { | |
58 | + // 明细子单据 | |
59 | + detailChild = this.getById(Integer.valueOf(id)); | |
60 | + } | |
61 | + | |
62 | + if (StringUtils.isNull(detailChild)) { | |
63 | + return Result.error("明细子单不存在!"); | |
64 | + } | |
65 | + | |
66 | + BigDecimal qty = new BigDecimal(countedQty); | |
67 | + if (qty.compareTo(BigDecimal.ZERO) == -1) { | |
68 | + return Result.error("实盘登记数不能小于0"); | |
69 | + } | |
70 | + | |
71 | + CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(detailChild.getCycleCountDetailid()); | |
72 | + if (StringUtils.isNull(cycleCountDetail)) { | |
73 | + return Result.error("盘点明细不存在。"); | |
74 | + } | |
75 | + // 任务完成后再实盘登记 | |
78 | 76 | // if(countDetailChild.getChildStatus() < QuantityConstant.CYCLECOUNT_STATUS_EXECUTING){ |
79 | 77 | // return AjaxResult.error("盘点任务未执行不能登记数量!"); |
80 | 78 | // } |
81 | 79 | |
82 | - if(detailChild.getChildStatus() >= QuantityConstant.CYCLECOUNT_STATUS_COMPLETED){ | |
83 | - return Result.error("盘点任务完成后不能再登记数量!"); | |
84 | - } | |
85 | - | |
86 | - | |
87 | - //实盘登记后差异数量 | |
88 | - BigDecimal adjQty = qty.subtract(detailChild.getSystemQty()); | |
89 | - detailChild.setGapQty(adjQty); | |
90 | - detailChild.setCountedQty(qty); | |
91 | - detailChild.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
92 | - this.updateById(detailChild); | |
93 | - | |
94 | - | |
95 | - | |
96 | - LambdaQueryWrapper<CycleCountDetailChild> cycleCountDetailChildLambdaQueryWrapper = new LambdaQueryWrapper<>(); | |
97 | - cycleCountDetailChildLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid,cycleCountDetail.getId()); | |
98 | - List<CycleCountDetailChild> cycleCountDetailChildren = this.list(cycleCountDetailChildLambdaQueryWrapper); | |
99 | - | |
100 | - BigDecimal counted_qty=new BigDecimal(0); | |
101 | - BigDecimal ystem_qty=new BigDecimal(0); | |
102 | - BigDecimal gap_qty=new BigDecimal(0); | |
103 | - for(CycleCountDetailChild cycleCountDetailChild:cycleCountDetailChildren) | |
104 | - { | |
105 | - counted_qty=counted_qty.add(cycleCountDetailChild.getCountedQty()); | |
106 | - ystem_qty=ystem_qty.add(cycleCountDetailChild.getSystemQty()); | |
107 | - gap_qty=gap_qty.add(cycleCountDetailChild.getGapQty()); | |
108 | - } | |
109 | - //修改明细单状态 | |
110 | - cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
111 | - cycleCountDetail.setCountedQty(counted_qty); | |
112 | - cycleCountDetail.setSystemQty(ystem_qty); | |
113 | - cycleCountDetail.setGapQty(gap_qty); | |
114 | - | |
115 | - cycleCountDetailService.updateById(cycleCountDetail); | |
116 | - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
117 | - //修改主单状态 | |
118 | - CycleCountHeader tmp = new CycleCountHeader(); | |
119 | - tmp.setCode(detailChild.getCyclecountheadcode()); | |
120 | - tmp.setWarehouseCode(cycleCountDetail.getWarehouseCode()); | |
121 | - LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(tmp); | |
122 | - CycleCountHeader cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper); | |
123 | - cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
124 | - cycleCountHeader.setStocktakingAc(sysUser.getUsername()); | |
125 | - | |
126 | - Result<Integer> result = new Result<Integer>(); | |
127 | - result.setCode(200); | |
128 | - result.setMessage("调整成功"); | |
129 | - result.setResult(cycleCountHeader.getId()); | |
130 | - return result; | |
131 | - } | |
80 | + if (detailChild.getChildStatus() >= QuantityConstant.CYCLECOUNT_STATUS_COMPLETED) { | |
81 | + return Result.error("盘点任务完成后不能再登记数量!"); | |
82 | + } | |
83 | + | |
84 | + // 实盘登记后差异数量 | |
85 | + BigDecimal adjQty = qty.subtract(detailChild.getSystemQty()); | |
86 | + CycleCountDetailChild detailChild1 = new CycleCountDetailChild(); | |
87 | + detailChild1.setId(detailChild.getId()); | |
88 | + detailChild1.setGapQty(adjQty); | |
89 | + detailChild1.setCountedQty(qty); | |
90 | + detailChild1.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
91 | + if (!this.updateById(detailChild)) { | |
92 | + throw new JeecgBootException("实盘登记更新盘点子单数量失败"); | |
93 | + } | |
94 | + | |
95 | + LambdaQueryWrapper<CycleCountDetailChild> cycleCountDetailChildLambdaQueryWrapper = new LambdaQueryWrapper<>(); | |
96 | + cycleCountDetailChildLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid, cycleCountDetail.getId()); | |
97 | + List<CycleCountDetailChild> cycleCountDetailChildList = this.list(cycleCountDetailChildLambdaQueryWrapper); | |
98 | + if (CollectionUtils.isEmpty(cycleCountDetailChildList)) { | |
99 | + throw new JeecgBootException("实盘登记,获取盘点明细表失败"); | |
100 | + } | |
101 | + | |
102 | + BigDecimal counted_qty = new BigDecimal(0); | |
103 | + BigDecimal ystem_qty = new BigDecimal(0); | |
104 | + BigDecimal gap_qty = new BigDecimal(0); | |
105 | + for (CycleCountDetailChild cycleCountDetailChild : cycleCountDetailChildList) { | |
106 | + counted_qty = counted_qty.add(cycleCountDetailChild.getCountedQty()); | |
107 | + ystem_qty = ystem_qty.add(cycleCountDetailChild.getSystemQty()); | |
108 | + gap_qty = gap_qty.add(cycleCountDetailChild.getGapQty()); | |
109 | + } | |
110 | + // 修改明细单状态 | |
111 | + cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
112 | + cycleCountDetail.setCountedQty(counted_qty); | |
113 | + cycleCountDetail.setSystemQty(ystem_qty); | |
114 | + cycleCountDetail.setGapQty(gap_qty); | |
115 | + | |
116 | + if (!cycleCountDetailService.updateById(cycleCountDetail)) { | |
117 | + throw new JeecgBootException("实盘登记更新盘点数量失败"); | |
118 | + } | |
119 | + LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); | |
120 | + // 修改主单状态 | |
121 | + CycleCountHeader tmp = new CycleCountHeader(); | |
122 | + tmp.setCode(detailChild.getCyclecountheadcode()); | |
123 | + tmp.setWarehouseCode(cycleCountDetail.getWarehouseCode()); | |
124 | + LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(tmp); | |
125 | + CycleCountHeader cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper); | |
126 | + cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); | |
127 | + cycleCountHeader.setStocktakingAc(sysUser.getUsername()); | |
128 | + if (!cycleCountHeaderService.updateById(cycleCountHeader)) { | |
129 | + throw new JeecgBootException("更新盘点表单头失败"); | |
130 | + } | |
131 | + | |
132 | + TaskDetail taskDetail = new TaskDetail(); | |
133 | + taskDetail.setId(Integer.parseInt(id)); | |
134 | + taskDetail.setCircleQty(qty); | |
135 | + taskDetail.setCircleStatus(QuantityConstant.CIRCLE_REGISTER_STATUS_COMPLETE); | |
136 | + if (!taskDetailService.updateById(taskDetail)) { | |
137 | + throw new JeecgBootException("更新任务详情失败"); | |
138 | + } | |
139 | + Result<Integer> result = new Result<Integer>(); | |
140 | + result.setCode(200); | |
141 | + result.setMessage("调整成功"); | |
142 | + result.setResult(cycleCountHeader.getId()); | |
143 | + return result; | |
144 | + } | |
132 | 145 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java
... | ... | @@ -124,6 +124,17 @@ public class TaskDetail implements Serializable { |
124 | 124 | @ApiModelProperty(value = "不合格数量") |
125 | 125 | private BigDecimal unqualityfiedQty; |
126 | 126 | |
127 | + /** 盘点数量 */ | |
128 | + @Excel(name = "盘点数量", width = 15) | |
129 | + @ApiModelProperty(value = "盘点数量") | |
130 | + private BigDecimal circleQty; | |
131 | + | |
132 | + /** 盘点状态 */ | |
133 | + @Excel(name = "盘点状态", width = 15) | |
134 | + @Dict(dicCode = "circle_register_status") | |
135 | + @ApiModelProperty(value = "盘点状态") | |
136 | + private Integer circleStatus; | |
137 | + | |
127 | 138 | /** 备注 */ |
128 | 139 | @Excel(name = "备注", width = 15) |
129 | 140 | @ApiModelProperty(value = "备注") |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
... | ... | @@ -429,6 +429,11 @@ public class QuantityConstant { |
429 | 429 | // 质检完成 |
430 | 430 | public static final int QUALITY_TESTING_COMPLETE = 1; |
431 | 431 | |
432 | + // 待登记 | |
433 | + public static final int CIRCLE_REGISTER_STATUS_BUILD = 0; | |
434 | + // 登记完成 | |
435 | + public static final int CIRCLE_REGISTER_STATUS_COMPLETE = 1; | |
436 | + | |
432 | 437 | /** 来料质检 */ |
433 | 438 | public static final String QUALITY_TYPE_INCOMING = "QI"; |
434 | 439 | /** 库内全检 */ |
... | ... |