Commit 7d881f7c2a69f9376fb625add8a8e3656834792c

Authored by 谭毅彬
1 parent 4b7efb7b

盘点添加方法事务优化

Signed-off-by: TanYibin <5491541@qq.com>
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wms/service/WmsServiceImpl.java
... ... @@ -246,8 +246,8 @@ public class WmsServiceImpl implements WmsService {
246 246 @Transactional(rollbackFor = Exception.class)
247 247 public Result createEmptyIn(WmsEntity wmsEntity) {
248 248 String warehouseCode = wmsEntity.getWarehouseCode();
249   - String toPort = wmsEntity.getToPort();
250   - String referCode = wmsEntity.getTaskNo();
  249 +// String toPort = wmsEntity.getToPort();
  250 +// String referCode = wmsEntity.getTaskNo();
251 251 String contaienrCode = wmsEntity.getContainerCode();
252 252  
253 253 Result result = taskHeaderService.createEmptyIn(contaienrCode, QuantityConstant.EMPTY_STRING, warehouseCode);
... ... @@ -259,7 +259,7 @@ public class WmsServiceImpl implements WmsService {
259 259 public Result createEmptyOut(WmsEntity wmsEntity) {
260 260 String warehouseCode = wmsEntity.getWarehouseCode();
261 261 String toPort = wmsEntity.getToPort();
262   - String referCode = wmsEntity.getTaskNo();
  262 +// String referCode = wmsEntity.getTaskNo();
263 263 String contaienrCode = wmsEntity.getContainerCode();
264 264  
265 265 Result result = taskHeaderService.createEmptyOut(contaienrCode, toPort, warehouseCode);
... ... @@ -271,7 +271,7 @@ public class WmsServiceImpl implements WmsService {
271 271 public Result createCheckOut(WmsEntity wmsEntity) {
272 272 String warehouseCode = wmsEntity.getWarehouseCode();
273 273 String toPort = wmsEntity.getToPort();
274   - String referCode = wmsEntity.getTaskNo();
  274 +// String referCode = wmsEntity.getTaskNo();
275 275 String contaienrCode = wmsEntity.getContainerCode();
276 276  
277 277 Result result = taskHeaderService.createCheckOutTask(contaienrCode, toPort, warehouseCode);
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java
... ... @@ -37,7 +37,7 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
37 37 ContainerMapper containerMapper;
38 38  
39 39 @Override
40   - public Result batchAddContainers(Container container, int number) {
  40 + public Result<?> batchAddContainers(Container container, int number) {
41 41 String containerTypeCode = container.getContainerTypeCode();
42 42 String warehouseCode = container.getWarehouseCode();
43 43 int startNumber = getStartNumber(containerTypeCode, container.getWarehouseCode());
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/controller/CycleCountDetailController.java
... ... @@ -123,7 +123,7 @@ public class CycleCountDetailController extends HuahengBaseController {
123 123 @AutoLog(value = "盘点盘盈-增加明细")
124 124 @ApiOperation(value = "盘点盘盈-增加明细", notes = "盘点盘盈-增加明细")
125 125 @RequestMapping(value = "/increaseInInventoryGain", method = {RequestMethod.PUT, RequestMethod.POST})
126   - public Result<String> increaseInInventoryGain(@RequestBody CycleCountDetailChild cycleCountDetailChild) {
  126 + public Result<?> increaseInInventoryGain(@RequestBody CycleCountDetailChild cycleCountDetailChild) {
127 127 return cycleCountDetailService.increaseInInventoryGain(cycleCountDetailChild);
128 128 }
129 129  
... ... @@ -225,25 +225,17 @@ public class CycleCountDetailController extends HuahengBaseController {
225 225 @AutoLog(value = "盘点添加")
226 226 @ApiOperation(value = "盘点添加", notes = "盘点添加")
227 227 @PostMapping(value = "/stockTakeTask")
228   - public Result<String> stockTakeTask(@RequestParam(name = "ids") String ids, @RequestParam(name = "headerId") int headerId,
229   - @RequestParam(name = "code") String code) {
  228 + public Result<?> stockTakeTask(@RequestParam(name = "ids") String ids, @RequestParam(name = "headerId") int headerId, @RequestParam(name = "code") String code) {
230 229 if (StringUtils.isEmpty(ids)) {
231 230 return Result.error("taskId不能为空");
232 231 }
233   - Result result = null;
234   - Integer[] idList = ConvertUtils.toIntArray(ids);
235   - for (int taskId : idList) {
236   - result = handleMultiProcess("cancelTask", new HuahengBaseController.MultiProcessListener() {
237   - @Override
238   - public Result doProcess() {
239   - Result result = cycleCountDetailService.stockDetailAdd(taskId, headerId, code);
240   - return result;
241   - }
242   - });
243   - }
244   - result.setResult(headerId);
  232 + Result<?> result = handleMultiProcess("stockTakeTask", new HuahengBaseController.MultiProcessListener() {
  233 + @Override
  234 + public Result<?> doProcess() {
  235 + return cycleCountDetailService.stockDetailAdd(ConvertUtils.toIntArray(ids), headerId, code);
  236 + }
  237 + });
245 238 return result;
246   -
247 239 }
248 240  
249 241 /**
... ... @@ -297,7 +289,7 @@ public class CycleCountDetailController extends HuahengBaseController {
297 289 cycleCountDetailList = queryList;
298 290 } else {
299 291 List<String> selectionList = Arrays.asList(selections.split(","));
300   - cycleCountDetailList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
  292 + cycleCountDetailList = queryList.stream().filter(item -> selectionList.contains(item.getId() + "")).collect(Collectors.toList());
301 293 }
302 294  
303 295 // Step.3 组装pageList
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/ICycleCountDetailService.java
... ... @@ -10,37 +10,35 @@ import java.util.List;
10 10  
11 11 /**
12 12 * @Description: 盘点明细表
13   - * @Author: jeecg-boot
14   - * @Date: 2023-01-30
15   - * @Version: V1.0
  13 + * @Author: jeecg-boot
  14 + * @Date: 2023-01-30
  15 + * @Version: V1.0
16 16 */
17 17 public interface ICycleCountDetailService extends IService<CycleCountDetail> {
18 18  
19   - /**
20   - * 添加一对多
21   - *
22   - */
23   - public void saveMain(CycleCountDetail cycleCountDetail,List<CycleCountDetailChild> cycleCountDetailChildList) ;
  19 + /**
  20 + * 添加一对多
  21 + */
  22 + public void saveMain(CycleCountDetail cycleCountDetail, List<CycleCountDetailChild> cycleCountDetailChildList);
24 23  
25   - /**
26   - * 修改一对多
27   - *
28   - */
29   - public void updateMain(CycleCountDetail cycleCountDetail,List<CycleCountDetailChild> cycleCountDetailChildList);
  24 + /**
  25 + * 修改一对多
  26 + */
  27 + public void updateMain(CycleCountDetail cycleCountDetail, List<CycleCountDetailChild> cycleCountDetailChildList);
30 28  
31   - /**
32   - * 删除一对多
33   - */
34   - public void delMain (String id);
  29 + /**
  30 + * 删除一对多
  31 + */
  32 + public void delMain(String id);
35 33  
36   - /**
37   - * 批量删除一对多
38   - */
39   - public void delBatchMain (Collection<? extends Serializable> idList);
  34 + /**
  35 + * 批量删除一对多
  36 + */
  37 + public void delBatchMain(Collection<? extends Serializable> idList);
40 38  
41   - Result stockDetailAdd(int taskId,int headerId,String code);
  39 + Result stockDetailAdd(Integer[] taskIdList, Integer headerId, String code);
42 40  
43   - Result createCycleCoutTaskByDetailId(Integer cycleCoutdetailId,String toPort,String warehouseCode);
  41 + Result createCycleCoutTaskByDetailId(Integer cycleCoutdetailId, String toPort, String warehouseCode);
44 42  
45 43 Result increaseInInventoryGain(CycleCountDetailChild cycleCountDetailChild);
46 44 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java
... ... @@ -128,68 +128,68 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
128 128  
129 129 @Override
130 130 @Transactional
131   - public Result stockDetailAdd(int taskId, int headerId, String code) {
132   - LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
133   - inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getInventoryHeaderId, taskId);
134   - List<InventoryDetail> inventoryDetails = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
135   -
136   - LambdaQueryWrapper<CycleCountDetail> cycleCountDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
137   - cycleCountDetailLambdaQueryWrapper.eq(CycleCountDetail::getContainerCode, inventoryDetails.get(0).getContainerCode()).ne(CycleCountDetail::getEnableStatus,
138   - QuantityConstant.CYCLECOUNT_STATUS_COMPLETED);
139   - List<CycleCountDetail> cycleCountDetails = this.list(cycleCountDetailLambdaQueryWrapper);
140   - if (cycleCountDetails.size() > 0) {
141   - return Result.error("当前容器已经在盘点队列还没有完成 盘点单号" + cycleCountDetails.get(0).getCycleCountHeadCode());
142   - }
  131 + public Result stockDetailAdd(Integer[] taskIdList, Integer headerId, String code) {
  132 + for (Integer taskId : taskIdList) {
  133 + LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
  134 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getInventoryHeaderId, taskId);
  135 + List<InventoryDetail> inventoryDetails = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
  136 +
  137 + LambdaQueryWrapper<CycleCountDetail> cycleCountDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
  138 + cycleCountDetailLambdaQueryWrapper.eq(CycleCountDetail::getContainerCode, inventoryDetails.get(0).getContainerCode())
  139 + .ne(CycleCountDetail::getEnableStatus, QuantityConstant.CYCLECOUNT_STATUS_COMPLETED);
  140 + List<CycleCountDetail> cycleCountDetails = this.list(cycleCountDetailLambdaQueryWrapper);
  141 + if (cycleCountDetails.size() > 0) {
  142 + return Result.error("当前容器已经在盘点队列还没有完成 盘点单号" + cycleCountDetails.get(0).getCycleCountHeadCode());
  143 + }
143 144  
144   - String warehouseCode = inventoryDetails.get(0).getWarehouseCode();
  145 + String warehouseCode = inventoryDetails.get(0).getWarehouseCode();
145 146  
146   - Container containerByCode = containerServiceImpl.getContainerByCode(inventoryDetails.get(0).getContainerCode(), warehouseCode);
147   - if (containerByCode.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
148   - return Result.error("当前容器已锁定 请检查数据 库存里面不是锁定 实际上容器里面锁定了");
149   - }
  147 + Container containerByCode = containerServiceImpl.getContainerByCode(inventoryDetails.get(0).getContainerCode(), warehouseCode);
  148 + if (containerByCode.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
  149 + return Result.error("当前容器已锁定 请检查数据 库存里面不是锁定 实际上容器里面锁定了");
  150 + }
150 151  
151   - Location locationByCode = locationService.getLocationByCode(inventoryDetails.get(0).getLocationCode(), warehouseCode);
152   - if (locationByCode.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
153   - return Result.error("当前库位已锁定 请检查数据 库存里面不是锁定 实际上库位里面锁定了");
154   - }
  152 + Location locationByCode = locationService.getLocationByCode(inventoryDetails.get(0).getLocationCode(), warehouseCode);
  153 + if (locationByCode.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
  154 + return Result.error("当前库位已锁定 请检查数据 库存里面不是锁定 实际上库位里面锁定了");
  155 + }
155 156  
156   - CycleCountDetail cycleCountDetail = new CycleCountDetail();
157   - cycleCountDetail.setCycleCountHeadId(headerId);
158   - cycleCountDetail.setContainerCode(inventoryDetails.get(0).getContainerCode());
159   - cycleCountDetail.setCycleCountHeadCode(code);
160   - cycleCountDetail.setCompanyCode(inventoryDetails.get(0).getCompanyCode());
161   - cycleCountDetail.setWarehouseCode(inventoryDetails.get(0).getWarehouseCode());
162   - cycleCountDetail.setInventoryHeaderId(inventoryDetails.get(0).getInventoryHeaderId());
163   - cycleCountDetail.setLocationCode(inventoryDetails.get(0).getLocationCode());
164   - cycleCountDetail.setInventorySts(inventoryDetails.get(0).getInventoryStatus());
165   - cycleCountDetail.setSystemQty(BigDecimal.ZERO);
166   - cycleCountDetail.setCountedQty(BigDecimal.ZERO);
167   - cycleCountDetail.setGapQty(BigDecimal.ZERO);
168   - cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_BUILD);
169   - this.save(cycleCountDetail);
170   -
171   - for (InventoryDetail inventoryDetail : inventoryDetails) {
172   - CycleCountDetailChild cycleCountDetailChild = new CycleCountDetailChild();
173   - cycleCountDetailChild.setCycleCountDetailid(cycleCountDetail.getId());
174   - cycleCountDetailChild.setCyclecountheadcode(code);
175   - cycleCountDetailChild.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_BUILD);
176   - cycleCountDetailChild.setLocationCode(inventoryDetail.getLocationCode());
177   - cycleCountDetailChild.setContainerCode(inventoryDetail.getContainerCode());
178   - cycleCountDetailChild.setMaterialCode(inventoryDetail.getMaterialCode());
179   - cycleCountDetailChild.setMaterialName(inventoryDetail.getMaterialName());
180   - cycleCountDetailChild.setMaterialSpec(inventoryDetail.getMaterialSpec());
181   - cycleCountDetailChild.setMaterialUnit(inventoryDetail.getMaterialUnit());
182   - cycleCountDetailChild.setInventoryStatus(inventoryDetail.getInventoryStatus());
183   - cycleCountDetailChild.setBatch(inventoryDetail.getBatch());
184   - cycleCountDetailChild.setLot(inventoryDetail.getLot());
185   - cycleCountDetailChild.setSystemQty(inventoryDetail.getQty());
186   - cycleCountDetailChild.setCountedQty(BigDecimal.ZERO);
187   - cycleCountDetailChild.setGapQty(BigDecimal.ZERO);
188   - cycleCountDetailChild.setInventoryDetaiId(inventoryDetail.getId());
189   - cycleCountDetailChildServiceImpl.save(cycleCountDetailChild);
  157 + CycleCountDetail cycleCountDetail = new CycleCountDetail();
  158 + cycleCountDetail.setCycleCountHeadId(headerId);
  159 + cycleCountDetail.setContainerCode(inventoryDetails.get(0).getContainerCode());
  160 + cycleCountDetail.setCycleCountHeadCode(code);
  161 + cycleCountDetail.setCompanyCode(inventoryDetails.get(0).getCompanyCode());
  162 + cycleCountDetail.setWarehouseCode(inventoryDetails.get(0).getWarehouseCode());
  163 + cycleCountDetail.setInventoryHeaderId(inventoryDetails.get(0).getInventoryHeaderId());
  164 + cycleCountDetail.setLocationCode(inventoryDetails.get(0).getLocationCode());
  165 + cycleCountDetail.setInventorySts(inventoryDetails.get(0).getInventoryStatus());
  166 + cycleCountDetail.setSystemQty(BigDecimal.ZERO);
  167 + cycleCountDetail.setCountedQty(BigDecimal.ZERO);
  168 + cycleCountDetail.setGapQty(BigDecimal.ZERO);
  169 + cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_BUILD);
  170 + cycleCountDetailService.save(cycleCountDetail);
  171 + for (InventoryDetail inventoryDetail : inventoryDetails) {
  172 + CycleCountDetailChild cycleCountDetailChild = new CycleCountDetailChild();
  173 + cycleCountDetailChild.setCycleCountDetailid(cycleCountDetail.getId());
  174 + cycleCountDetailChild.setCyclecountheadcode(code);
  175 + cycleCountDetailChild.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_BUILD);
  176 + cycleCountDetailChild.setLocationCode(inventoryDetail.getLocationCode());
  177 + cycleCountDetailChild.setContainerCode(inventoryDetail.getContainerCode());
  178 + cycleCountDetailChild.setMaterialCode(inventoryDetail.getMaterialCode());
  179 + cycleCountDetailChild.setMaterialName(inventoryDetail.getMaterialName());
  180 + cycleCountDetailChild.setMaterialSpec(inventoryDetail.getMaterialSpec());
  181 + cycleCountDetailChild.setMaterialUnit(inventoryDetail.getMaterialUnit());
  182 + cycleCountDetailChild.setInventoryStatus(inventoryDetail.getInventoryStatus());
  183 + cycleCountDetailChild.setBatch(inventoryDetail.getBatch());
  184 + cycleCountDetailChild.setLot(inventoryDetail.getLot());
  185 + cycleCountDetailChild.setSystemQty(inventoryDetail.getQty());
  186 + cycleCountDetailChild.setCountedQty(BigDecimal.ZERO);
  187 + cycleCountDetailChild.setGapQty(BigDecimal.ZERO);
  188 + cycleCountDetailChild.setInventoryDetaiId(inventoryDetail.getId());
  189 + cycleCountDetailChildServiceImpl.save(cycleCountDetailChild);
  190 + }
190 191 }
191   -
192   - return Result.OK("生成完成");
  192 + return Result.OK("生成完成", headerId);
193 193 }
194 194  
195 195 /**
... ...