|
|
@ -33,6 +33,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.anrui.oa.biz.oaappendix.OaAppendix; |
|
|
|
import com.yxt.anrui.oa.biz.oaappendix.OaAppendixService; |
|
|
|
import com.yxt.anrui.oa.biz.oaform.OaForm; |
|
|
|
import com.yxt.anrui.oa.biz.oaform.OaFormDto; |
|
|
|
import com.yxt.anrui.oa.biz.oaform.OaFormService; |
|
|
|
import com.yxt.anrui.oa.biz.oamendapply.flowable.*; |
|
|
|
import com.yxt.anrui.oa.feign.base.Rule; |
|
|
|
import com.yxt.anrui.oa.feign.file.OaFileEnum; |
|
|
@ -64,6 +67,7 @@ import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
@ -90,6 +94,8 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private OaAppendixService oaAppendixService; |
|
|
|
@Autowired |
|
|
|
private OaFormService oaFormService; |
|
|
|
|
|
|
|
public PagerVo<OaMendApplyVo> listPageVo(PagerQuery<OaMendApplyQuery> pq) { |
|
|
|
OaMendApplyQuery query = pq.getParams(); |
|
|
@ -100,7 +106,7 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public String saveOrUpdateDto(OaMendApplyDto dto){ |
|
|
|
public String saveOrUpdateDtoOld(OaMendApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<String> files = dto.getFiles(); |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(dto.getOrgPath()).getData(); |
|
|
@ -152,6 +158,113 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
return dtoSid; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> saveOrUpdateDto(OaMendApplyDto dto) { |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
|
String sid = dto.getSid(); |
|
|
|
List<String> files = dto.getFiles(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
// 新建操作
|
|
|
|
OaMendApply entity = new OaMendApply(); |
|
|
|
|
|
|
|
// 获取组织和部门信息
|
|
|
|
setOrgAndDeptInfo(dto); |
|
|
|
|
|
|
|
// 生成单据编号
|
|
|
|
String billNo = generateBillNo(dto); |
|
|
|
dto.setBillNo(billNo); |
|
|
|
|
|
|
|
// 复制 DTO 数据到实体
|
|
|
|
BeanUtil.copyProperties(dto, entity, "sid"); |
|
|
|
entity.setCreateBySid(dto.getUserSid()); |
|
|
|
|
|
|
|
// 获取用户信息
|
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
|
entity.setCreateByName(sysUserVo.getName()); |
|
|
|
|
|
|
|
// 创建 OA 表单
|
|
|
|
OaFormDto oaFormDto = createOaForm(dto, sysUserVo); |
|
|
|
ResultBean<String> resultBean = oaFormService.saveOrUpdateForm(oaFormDto); |
|
|
|
|
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
entity.setFormSid(resultBean.getData()); |
|
|
|
baseMapper.insert(entity); |
|
|
|
|
|
|
|
// 处理附件
|
|
|
|
saveFiles(sid, files); |
|
|
|
} else { |
|
|
|
// 更新操作
|
|
|
|
OaMendApply entity = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取组织和部门信息
|
|
|
|
private void setOrgAndDeptInfo(OaMendApplyDto dto) { |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(dto.getOrgPath()).getData(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); |
|
|
|
dto.setUseOrgSid(useOrgSid); |
|
|
|
dto.setUseOrgName(organizationVo.getName()); |
|
|
|
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
List<String> split = Arrays.asList(dto.getOrgPath().split("/")); |
|
|
|
|
|
|
|
if (split.size() > 1) { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
|
|
|
|
dto.setDeptSid(deptSid); |
|
|
|
dto.setDeptName(deptName); |
|
|
|
} |
|
|
|
|
|
|
|
// 生成单据编号
|
|
|
|
private String generateBillNo(OaMendApplyDto dto) { |
|
|
|
String billNo = "QJSQ" + dto.getUseOrgSid() + DateUtil.format(DateUtil.date(), "yyyyMM"); |
|
|
|
String i = baseMapper.selectNum(billNo); |
|
|
|
if (StringUtils.isNotBlank(i)) { |
|
|
|
return Rule.getBillNo(billNo, Integer.valueOf(i).intValue()); |
|
|
|
} |
|
|
|
return Rule.getBillNo(billNo, 0); |
|
|
|
} |
|
|
|
|
|
|
|
// 创建 OA 表单
|
|
|
|
private OaFormDto createOaForm(OaMendApplyDto dto, SysUserVo sysUserVo) { |
|
|
|
OaFormDto oaFormDto = new OaFormDto(); |
|
|
|
BeanUtil.copyProperties(dto, oaFormDto, "sid"); |
|
|
|
oaFormDto.setNodeState("待提交"); |
|
|
|
oaFormDto.setCreateBySid(dto.getUserSid()); |
|
|
|
oaFormDto.setCreateByName(sysUserVo.getName()); |
|
|
|
return oaFormDto; |
|
|
|
} |
|
|
|
|
|
|
|
// 保存文件
|
|
|
|
private void saveFiles(String sid, List<String> files) { |
|
|
|
for (String file : files) { |
|
|
|
String filePath = file.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
OaAppendix oaAppendix = new OaAppendix(); |
|
|
|
oaAppendix.setLinkSid(sid); |
|
|
|
oaAppendix.setAttachType(OaFileEnum.OAMENDAPPLY.getAttachType()); |
|
|
|
oaAppendix.setFilePath(filePath); |
|
|
|
oaAppendixService.save(oaAppendix); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String insertByDto(OaMendApplyDto dto) { |
|
|
|
OaMendApply entity = new OaMendApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
@ -198,7 +311,7 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
String businessSid = saveOrUpdateDto(dto); |
|
|
|
String businessSid = saveOrUpdateDto(dto).getData(); |
|
|
|
oaMendApply = fetchBySid(businessSid); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
@ -227,8 +340,12 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
ufVo.setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(ufVo)); |
|
|
|
//极光推送
|
|
|
|
oaMendApply = fetchBySid(businessSid); |
|
|
|
|
|
|
|
//==================================添加线程
|
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
@ -318,6 +435,9 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
ufVo.setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(ufVo)); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
|
|
|
|
} else { |
|
|
@ -428,6 +548,9 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(ufVo); |
|
|
|
//更新业务中的流程相关的参数
|
|
|
|
updateFlowFiled(map); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
ufVo.setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(ufVo)); |
|
|
|
//极光推送
|
|
|
|
oaMendApply = fetchBySid(businessSid); |
|
|
|
//==================================添加线程
|
|
|
@ -487,6 +610,9 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
resultBean.getData().setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
@ -516,6 +642,9 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|
|
|
updateFlowFiled(map); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
resultBean.getData().setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
@ -527,6 +656,9 @@ public class OaMendApplyService extends MybatisBaseService<OaMendApplyMapper, Oa |
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|
|
|
updateFlowFiled(map); |
|
|
|
//更新oaform中的流程数据
|
|
|
|
resultBean.getData().setSid(oaMendApply.getFormSid()); |
|
|
|
oaFormService.updateFlow(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|