|
|
|
|
@ -35,7 +35,9 @@ import org.springframework.context.event.EventListener;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.dromara.oa.erp.domain.bo.ErpTimesheetInfoBo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpTimesheetInfoVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpProjectInfo;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpTimesheetInfo;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpProjectInfoMapper;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpTimesheetInfoMapper;
|
|
|
|
|
import org.dromara.oa.erp.service.IErpTimesheetInfoService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -56,6 +58,8 @@ public class ErpTimesheetInfoServiceImpl implements IErpTimesheetInfoService {
|
|
|
|
|
|
|
|
|
|
private final ErpTimesheetInfoMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
private final ErpProjectInfoMapper projectInfoMapper;
|
|
|
|
|
|
|
|
|
|
@DubboReference(timeout = 30000)
|
|
|
|
|
private RemoteWorkflowService remoteWorkflowService;
|
|
|
|
|
|
|
|
|
|
@ -158,7 +162,7 @@ public class ErpTimesheetInfoServiceImpl implements IErpTimesheetInfoService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean insertByBo(ErpTimesheetInfoBo bo) {
|
|
|
|
|
ErpTimesheetInfo add = MapstructUtils.convert(bo, ErpTimesheetInfo.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
validEntityBeforeSave(add, bo);
|
|
|
|
|
// 自动生成工时单号
|
|
|
|
|
if (StringUtils.isBlank(add.getTimesheetCode())) {
|
|
|
|
|
String timesheetCode = remoteCodeRuleService.selectCodeRuleCode("1015");
|
|
|
|
|
@ -201,7 +205,7 @@ public class ErpTimesheetInfoServiceImpl implements IErpTimesheetInfoService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateByBo(ErpTimesheetInfoBo bo) {
|
|
|
|
|
ErpTimesheetInfo update = MapstructUtils.convert(bo, ErpTimesheetInfo.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
validEntityBeforeSave(update, bo);
|
|
|
|
|
int row = baseMapper.updateById(update);
|
|
|
|
|
|
|
|
|
|
if (row > 0) {
|
|
|
|
|
@ -241,8 +245,24 @@ public class ErpTimesheetInfoServiceImpl implements IErpTimesheetInfoService {
|
|
|
|
|
/**
|
|
|
|
|
* 保存前的数据校验
|
|
|
|
|
*/
|
|
|
|
|
private void validEntityBeforeSave(ErpTimesheetInfo entity) {
|
|
|
|
|
// TODO 做一些数据校验,如唯一约束
|
|
|
|
|
private void validEntityBeforeSave(ErpTimesheetInfo entity, ErpTimesheetInfoBo bo) {
|
|
|
|
|
if (bo == null || CollUtil.isEmpty(bo.getTimesheetProjectList())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (ErpTimesheetProjectBo line : bo.getTimesheetProjectList()) {
|
|
|
|
|
Long projectId = line.getProjectId();
|
|
|
|
|
if (projectId == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ErpProjectInfo project = projectInfoMapper.selectById(projectId);
|
|
|
|
|
if (project == null) {
|
|
|
|
|
throw new ServiceException("项目工时所选项目不存在或已删除");
|
|
|
|
|
}
|
|
|
|
|
// sub_project_flag=1:主项目标记「含有子项目」,工时须报在研发子项目上
|
|
|
|
|
if ("1".equals(project.getSubProjectFlag())) {
|
|
|
|
|
throw new ServiceException("项目工时必须填报在研发子项目上,不能选择研发主项目");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|