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