领料管理--增加事务、异常处理
This commit is contained in:
parent
edafce611a
commit
b099235b48
|
|
@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||||
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
||||||
import com.bonus.material.lease.domain.LeaseApplyInfo;
|
import com.bonus.material.lease.domain.LeaseApplyInfo;
|
||||||
import com.bonus.material.lease.service.ILeaseApplyInfoService;
|
import com.bonus.material.lease.service.ILeaseApplyInfoService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -140,6 +141,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
||||||
* @param leaseApplyInfo 领料任务info
|
* @param leaseApplyInfo 领料任务info
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public AjaxResult publish(LeaseApplyInfo leaseApplyInfo) {
|
public AjaxResult publish(LeaseApplyInfo leaseApplyInfo) {
|
||||||
if (leaseApplyInfo.getId() == null) {
|
if (leaseApplyInfo.getId() == null) {
|
||||||
return AjaxResult.error("ID为空,请完善后重新发布!");
|
return AjaxResult.error("ID为空,请完善后重新发布!");
|
||||||
|
|
@ -150,16 +152,22 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
||||||
|
|
||||||
leaseApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
leaseApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
||||||
leaseApplyInfo.setStatus(String.valueOf(PurchaseTaskStatusEnum.LEASE_TASK_PUBLISHED.getStatus()));
|
leaseApplyInfo.setStatus(String.valueOf(PurchaseTaskStatusEnum.LEASE_TASK_PUBLISHED.getStatus()));
|
||||||
int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
|
try {
|
||||||
if (result > 0) {
|
int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
|
||||||
// 同步修改tm_task任务状态
|
if (result > 0) {
|
||||||
TmTask tmTask = new TmTask();
|
// 同步修改tm_task任务状态
|
||||||
tmTask.setTaskId(leaseApplyInfo.getTaskId());
|
TmTask tmTask = new TmTask();
|
||||||
tmTask.setStatus(String.valueOf(PurchaseTaskStatusEnum.LEASE_TASK_PUBLISHED.getStatus()));
|
tmTask.setTaskId(leaseApplyInfo.getTaskId());
|
||||||
tmTaskMapper.updateTmTask(tmTask);
|
tmTask.setStatus(String.valueOf(PurchaseTaskStatusEnum.LEASE_TASK_PUBLISHED.getStatus()));
|
||||||
return AjaxResult.success("发布成功");
|
tmTaskMapper.updateTmTask(tmTask);
|
||||||
} else {
|
return AjaxResult.success("发布成功");
|
||||||
|
}
|
||||||
return AjaxResult.error("发布失败");
|
return AjaxResult.error("发布失败");
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
// 抛出异常、回滚数据
|
||||||
|
throw new RuntimeException();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("发布失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue