TaskByWcsImpl.java
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.huaheng.api.wcs.service.taskByWcs;
import com.huaheng.api.wcs.service.taskAssignService.TaskAssignService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.Date;
@Service
public class TaskByWcsImpl implements TaskByWcs{
@Autowired
private TaskHeaderService taskHeaderService;
@Autowired
private TaskAssignService taskAssignService;
public static String platform = "wms";
private static final Logger
logger = LoggerFactory.getLogger(TaskAssignService.class);
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult taskByWcs(String containerCode) {
AjaxResult result = null;
try {
result = taskHeaderService.createEmptyIn(containerCode);
if(result.getCode()==200){
TaskHeader task=taskHeaderService.getById((Integer) result.getData());
taskAssignService.wcsTaskAssign(task);
//修改任务头表
task.setStatus(QuantityConstant.TASK_STATUS_RELEASE);
task.setStartPickDateTime(new Date()); //生成时间
task.setLastUpdated(new Date());
task.setLastUpdatedBy(ShiroUtils.getLoginName());
taskHeaderService.saveOrUpdate(task);
return AjaxResult.success("下发成功");
}
} catch (Exception e){
logger.info("手动回滚:{}"+e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("任务生成失败");
}
return result;
}
}