Commit c14807f3bd9091d6730bf2d571d87d37cf20ecd7

Authored by xqs
1 parent be934f91

盘点登记,任务执行状态

src/main/java/com/huaheng/pc/inventory/cycleCountDetail/controller/CycleCountDetailController.java
... ... @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
34 34 import org.springframework.web.bind.annotation.ResponseBody;
35 35  
36 36 import javax.annotation.Resource;
  37 +import java.math.BigDecimal;
37 38 import java.util.Collections;
38 39 import java.util.List;
39 40  
... ... @@ -118,7 +119,6 @@ public class CycleCountDetailController extends BaseController {
118 119  
119 120 }
120 121  
121   -
122 122 /**
123 123 * 新增盘点明细
124 124 */
... ... @@ -215,7 +215,18 @@ public class CycleCountDetailController extends BaseController {
215 215 return cycleCountDetailService.createCycleCoutTaskByDetailId(cycleCoutdetailId);
216 216 }
217 217  
218   -
  218 + /**
  219 + *实盘登记
  220 + * @param detailId
  221 + * @param qty
  222 + * @return
  223 + */
  224 + @RequiresPermissions("inventory:cyclecountDetail:confirm")
  225 + @PostMapping("/confirmGapQty")
  226 + @ResponseBody
  227 + public AjaxResult confirmGapQty(Integer detailId, BigDecimal qty){
  228 + return cycleCountDetailService.confirmGapQty(detailId,qty);
  229 + }
219 230  
220 231  
221 232  
... ...
src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailService.java
... ... @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4 import com.huaheng.framework.web.domain.AjaxResult;
5 5 import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
6 6  
  7 +import java.math.BigDecimal;
7 8  
8 9  
9 10 public interface CycleCountDetailService extends IService<CycleCountDetail> {
... ... @@ -15,9 +16,9 @@ public interface CycleCountDetailService extends IService&lt;CycleCountDetail&gt; {
15 16  
16 17 AjaxResult createCycleCoutTaskByDetailId(Integer cycleCoutdetailId);
17 18  
  19 + AjaxResult confirmGapQty(Integer detailId, BigDecimal qty);
18 20  
19   -
20   -
  21 + void updataDetailStatus(Integer detailid,Integer status);
21 22  
22 23 }
23 24  
... ...
src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailServiceImpl.java
... ... @@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
23 23 import org.springframework.transaction.annotation.Transactional;
24 24  
25 25 import javax.annotation.Resource;
  26 +import java.math.BigDecimal;
26 27 import java.util.ArrayList;
27 28 import java.util.Date;
28 29 import java.util.List;
... ... @@ -46,6 +47,43 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
46 47  
47 48  
48 49  
  50 +
  51 +
  52 +
  53 +
  54 +
  55 + /**
  56 + * 执行任务修改状态为10
  57 + * @param detailid
  58 + */
  59 + @Transactional
  60 + @Override
  61 + public void updataDetailStatus(Integer detailid,Integer status) {
  62 + /*传入明细ID,状态,通过明细ID修改状态,并修改主单状态 */
  63 + if(detailid == null || status == null){
  64 + throw new ServiceException("明细ID和状态不能为空!");
  65 + }
  66 + CycleCountDetail cycleCountDetail = this.getById(detailid) ;//盘点明细单
  67 + cycleCountDetail.setEnableStatus(status);
  68 + cycleCountDetail.setLastUpdated(new Date());
  69 + cycleCountDetail.setLastUpdatedBy(ShiroUtils.getLoginName());//更新用户
  70 + //主单
  71 + CycleCountHeader cycleCountHeader = new CycleCountHeader();
  72 + cycleCountHeader.setCode(cycleCountDetail.getCycleCountHeadCode());
  73 + cycleCountHeader.setWarehouseCode(cycleCountDetail.getWarehouseCode());
  74 + cycleCountHeader.setCompanyCode(cycleCountDetail.getCompanyCode());
  75 + LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountHeader);
  76 + cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper);
  77 + if(cycleCountHeader.getStatusCyc() < 10 ){
  78 + //主单状态小于10则修改
  79 + cycleCountHeader.setStatusCyc(status); //主单状态
  80 + cycleCountHeaderService.saveOrUpdate(cycleCountHeader);
  81 + }
  82 + if(!this.saveOrUpdate(cycleCountDetail)){
  83 + throw new ServiceException("更新盘点执行状态失败!");
  84 + }
  85 + }
  86 +
49 87 /**
50 88 * 新增盘点明细
51 89 * */
... ... @@ -118,7 +156,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
118 156 return AjaxResult.success("生成盘点明细成功");
119 157 }
120 158  
121   -
122 159 /**
123 160 * 生成全部盘点任务
124 161 * @param cycleCountHeadCode
... ... @@ -196,7 +233,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
196 233 }
197 234  
198 235 //查询任务头和明细有相同容器,没有就新增任务头和明细
199   -
200 236 LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
201 237 taskHeaderLambdaQueryWrapper
202 238 .lt(TaskHeader::getStatus,100)
... ... @@ -207,12 +243,9 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
207 243 .eq(TaskHeader::getContainerCode,cycleCountDetail.getContainerCode());//容器
208 244 List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
209 245  
210   -
211 246 TaskHeader task = new TaskHeader();
212 247 TaskDetail taskDetail = new TaskDetail();
213   -
214 248 if(taskHeaderList.size() <= 0){
215   -
216 249 //存在相同容器的主任务直接加入该条主任务的明细
217 250 task.setWarehouseCode(ShiroUtils.getWarehouseCode());
218 251 task.setCompanyCode(cycleCountDetail.getCompanyCode());
... ... @@ -242,7 +275,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
242 275 taskDetail.setWarehouseCode(task.getWarehouseCode());
243 276 cycleCountDetail.setTaskHeaderId(task.getId()); //盘点明细修改状态task数据源
244 277 }else{
245   -
246 278 //取其中一条主单即可
247 279 TaskHeader taskHeader = taskHeaderList.get(0);
248 280 taskDetail.setTaskId(taskHeader.getId());//主单ID
... ... @@ -254,7 +286,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
254 286 taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
255 287 cycleCountDetail.setTaskHeaderId(taskHeader.getId());//盘点明细修改状态taskHeader数据源
256 288 }
257   -
258 289 taskDetail.setBillCode(cycleCountDetail.getCycleCountHeadCode());
259 290 taskDetail.setBillDetailId(cycleCountDetail.getId());
260 291 taskDetail.setMaterialCode(cycleCountDetail.getMaterialCode());
... ... @@ -273,7 +304,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
273 304 if(taskDetailService.save(taskDetail) == false){
274 305 throw new ServiceException("盘点任务明细生成失败!");
275 306 }
276   -
277 307 //修改细单状态
278 308 cycleCountDetail.setTaskHeaderId(taskDetail.getId());
279 309 //cycleCountDetail.setTaskHeaderId(task.getId());
... ... @@ -283,7 +313,6 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
283 313 cycleCountDetail.setTaskHeaderId(task.getId());
284 314 cycleCountDetail.setTaskDetailId(taskDetail.getId());
285 315 this.saveOrUpdate(cycleCountDetail);
286   -
287 316 //修改主单状态
288 317 CycleCountHeader cycleCountHeader = new CycleCountHeader();
289 318 cycleCountHeader.setCode(cycleCountDetail.getCycleCountHeadCode());
... ... @@ -296,7 +325,59 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
296 325 return AjaxResult.success("盘点任务生成成功");
297 326 }
298 327  
  328 + /**
  329 + * 实盘登记
  330 + * @param detailId
  331 + * @param qty
  332 + * @return
  333 + */
  334 + @Transactional
  335 + @Override
  336 + public AjaxResult confirmGapQty(Integer detailId, BigDecimal qty) {
  337 + CycleCountDetail cyclecountDetail = this.getById(detailId); //明细单据
  338 + CycleCountHeader cycleCountHeader =new CycleCountHeader();
  339 + cycleCountHeader.setWarehouseCode(cyclecountDetail.getWarehouseCode());
  340 + cycleCountHeader.setCompanyCode(cyclecountDetail.getCompanyCode());
  341 + cycleCountHeader.setCode(cyclecountDetail.getCycleCountHeadCode());
  342 + LambdaQueryWrapper<CycleCountHeader> cycleCountHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountHeader);
  343 + cycleCountHeader = cycleCountHeaderService.getOne(cycleCountHeaderLambdaQueryWrapper); //主单
  344 + //任务执行后不能再实盘登记
  345 +
  346 + if(cyclecountDetail.getEnableStatus() <= 10){
  347 + return AjaxResult.error("盘点任务未执行不能登记数量!");
  348 + }
  349 + if(cyclecountDetail.getEnableStatus() == 40){
  350 + return AjaxResult.error("盘点任务完成后不能再登记数量!");
  351 + }
  352 + if(cycleCountHeader==null){
  353 + return AjaxResult.error("主单据不存在");
  354 + }
  355 + if(cyclecountDetail.getEnableStatus() == 10){
  356 + return AjaxResult.error("该条已调整,不能重复调整!");
  357 + }
  358 + if(qty.compareTo(new BigDecimal("0"))<0){
  359 + return AjaxResult.error("实盘登记数不能小于0");
  360 + }
  361 + if(cyclecountDetail.getInventoryDetailId() != null){
  362 + InventoryDetail inventoryDetail = inventoryDetailService.getById(cyclecountDetail.getInventoryDetailId());
  363 + if (inventoryDetail == null) {
  364 + return AjaxResult.error("没有对应库存信息,请重建盘点单");
  365 + }
  366 + if(qty.compareTo(inventoryDetail.getTaskQty()) < 0){
  367 + return AjaxResult.error("登记数量不能小于任务分配数量");
  368 + }
  369 + }
  370 + cyclecountDetail.setCountedQty(qty);
  371 + cyclecountDetail.setGapQty(qty.subtract(cyclecountDetail.getSystemQty()));
  372 + cyclecountDetail.setEnableStatus(10);
  373 + cyclecountDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
  374 + cyclecountDetail.setLastUpdated(new Date());
  375 + this.saveOrUpdate(cyclecountDetail);
  376 + //修改主单状态
  377 + cycleCountHeaderService.updataHeaderStatus(cycleCountHeader.getCode());
299 378  
  379 + return AjaxResult.success("登记成功");
  380 + }
300 381  
301 382  
302 383  
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... ... @@ -312,10 +312,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
312 312 }
313 313  
314 314 /**
315   - * 下发WCS执行任务
316   - */
317   - /**
318   - *
  315 + *下发WCS执行任务
319 316 * 执行任务
320 317 * */
321 318 @Override
... ... @@ -324,6 +321,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
324 321 TaskHeader task = null;
325 322 for (Integer taskId : taskIds) {
326 323 task = taskHeaderService.getById(taskId);
  324 +
327 325 if (task.getStatus() > 9) {
328 326 return AjaxResult.error("任务" + taskId + "已经下发,请不要重复下发,操作中止");
329 327 }
... ... @@ -340,6 +338,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
340 338 record.setLastUpdated(new Date());
341 339 record.setLastUpdatedBy(ShiroUtils.getLoginName());
342 340 record.setProcessStamp("100");
  341 + //盘点执行修改盘点单据状态为10
  342 + if(task.getTaskType() == 700){
  343 + cycleCountDetailService.updataDetailStatus(record.getBillDetailId(),10);
  344 + }
343 345 taskDetailService.updateById(record);
344 346 LambdaUpdateWrapper<TaskDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
345 347 lambdaUpdateWrapper.eq(TaskDetail::getTaskId, task.getId());
... ... @@ -416,7 +418,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
416 418 * 完成任务
417 419 *
418 420 * @param task
419   - * @throws Exception
420 421 */
421 422 @Transactional
422 423 public void completeTask(TaskHeader task) {
... ... @@ -429,7 +430,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
429 430 // 出库任务
430 431 completeShipmentTask(task);
431 432 }
432   - // 900 出库查看,包过空托出库查看
  433 + // 900 出库查看,空托出库查看
433 434 if ( task.getTaskType() == 900) {
434 435 completeSeeOutTask(task);
435 436 }
... ... @@ -1004,10 +1005,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1004 1005 @Transactional
1005 1006 public void completeEmptyIn(TaskHeader taskHeader) {
1006 1007  
1007   - //解锁容器,更新库位
1008   - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),taskHeader.getToLocation(),"empty");
1009   - //解锁库位,更新容器
1010   - locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(),taskHeader.getContainerCode(),"empty");
1011 1008 //完成任务,修改主单和明细状态
1012 1009 taskHeader.setStatus(100);
1013 1010 taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
... ... @@ -1026,9 +1023,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1026 1023 item.setLastUpdated(new Date()); //更新时间
1027 1024 taskDetailList.add(item);
1028 1025 }
1029   - if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || taskHeaderService.saveOrUpdate(taskHeader) == false) {
  1026 + if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false ||
  1027 + taskHeaderService.saveOrUpdate(taskHeader) == false) {
1030 1028 throw new ServiceException("任务单据状态更新失败!");
1031 1029 }
  1030 + //解锁容器,更新库位
  1031 + containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),taskHeader.getToLocation(),"empty");
  1032 + //解锁库位,更新容器
  1033 + locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(),taskHeader.getContainerCode(),"empty");
1032 1034  
1033 1035 }
1034 1036  
... ... @@ -1038,10 +1040,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1038 1040 */
1039 1041 @Transactional
1040 1042 public void completeEmptyOut(TaskHeader taskHeader) {
1041   - //更新货位
1042   - locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "", "empty");
1043   - //更新容器信息
1044   - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), "", "empty");
1045 1043  
1046 1044 taskHeader.setStatus(100);
1047 1045 taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
... ... @@ -1063,6 +1061,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1063 1061 if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || taskHeaderService.saveOrUpdate(taskHeader) == false) {
1064 1062 throw new ServiceException("任务单据状态更新失败!");
1065 1063 }
  1064 + //更新货位
  1065 + locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "", "empty");
  1066 + //更新容器信息
  1067 + containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), "", "empty");
  1068 +
1066 1069 }
1067 1070  
1068 1071 /**
... ...