|
@@ -0,0 +1,98 @@
|
|
|
+package com.fjhx.oa.flow;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.file.entity.FileInfoVo;
|
|
|
+import com.fjhx.file.entity.ObsFile;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.flow.core.FlowDelegate;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
+import com.fjhx.oa.entity.adjust.dto.AdjustSalaryApplyDto;
|
|
|
+import com.fjhx.oa.entity.adjust.po.AdjustSalaryApply;
|
|
|
+import com.fjhx.oa.entity.adjust.po.AdjustSalaryDetail;
|
|
|
+import com.fjhx.oa.entity.user.dto.UserSalaryManageDto;
|
|
|
+import com.fjhx.oa.entity.user.po.UserSalaryDetail;
|
|
|
+import com.fjhx.oa.service.adjust.AdjustSalaryApplyService;
|
|
|
+import com.fjhx.oa.service.adjust.AdjustSalaryDetailService;
|
|
|
+import com.fjhx.oa.service.user.UserSalaryManageService;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class AdjustSalaryApplyFlow extends FlowDelegate {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AdjustSalaryApplyService adjustSalaryApplyService;
|
|
|
+ @Resource
|
|
|
+ private AdjustSalaryDetailService adjustSalaryDetailService;
|
|
|
+ @Resource
|
|
|
+ private UserSalaryManageService userSalaryManageService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getFlowKey() {
|
|
|
+ return "adjust_salary_apply_flow";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long start(Long flowId, JSONObject submitData) {
|
|
|
+ AdjustSalaryApplyDto dto = submitData.toJavaObject(AdjustSalaryApplyDto.class);
|
|
|
+ dto.setFlowId(flowId);
|
|
|
+ dto.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
|
|
|
+ dto.setUserId(SecurityUtils.getUserId());
|
|
|
+
|
|
|
+ //回填用户名
|
|
|
+ String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
|
|
|
+ submitData.put("userName", nickName);
|
|
|
+
|
|
|
+ adjustSalaryApplyService.saveOrUpdate(dto);
|
|
|
+ ObsFileUtil.copyFileAndSave(dto.getFileList(), dto.getId(), 10);
|
|
|
+
|
|
|
+ //保存明细
|
|
|
+ List<AdjustSalaryDetail> userSalaryDetailList = dto.getUserSalaryDetailList();
|
|
|
+ userSalaryDetailList.forEach(item -> item.setAdjustSalaryId(dto.getId()));
|
|
|
+ adjustSalaryDetailService.editLinked(userSalaryDetailList, AdjustSalaryDetail::getAdjustSalaryId, dto.getId());
|
|
|
+ return dto.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ adjustSalaryApplyService.update(q -> q
|
|
|
+ .eq(AdjustSalaryApply::getId, businessId)
|
|
|
+ .set(AdjustSalaryApply::getStatus, FlowStatusEnum1.REJECT.getKey())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ adjustSalaryApplyService.update(q -> q
|
|
|
+ .eq(AdjustSalaryApply::getId, businessId)
|
|
|
+ .set(AdjustSalaryApply::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
+ adjustSalaryApplyService.update(q -> q
|
|
|
+ .eq(AdjustSalaryApply::getId, businessId)
|
|
|
+ .set(AdjustSalaryApply::getStatus, FlowStatusEnum1.PASS.getKey())
|
|
|
+ );
|
|
|
+ //获取数据
|
|
|
+ AdjustSalaryApply byId = adjustSalaryApplyService.getById(businessId);
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(Collections.singletonList(businessId), 10);
|
|
|
+ List<AdjustSalaryDetail> list = adjustSalaryDetailService.list(q -> q.eq(AdjustSalaryDetail::getAdjustSalaryId, businessId));
|
|
|
+
|
|
|
+ //更新用户薪资
|
|
|
+ UserSalaryManageDto userSalaryManageDto = BeanUtil.copyProperties(byId, UserSalaryManageDto.class);
|
|
|
+ userSalaryManageDto.setFileList(BeanUtil.copyToList(fileMap.get(businessId), ObsFile.class));
|
|
|
+ userSalaryManageDto.setUserSalaryDetailList(BeanUtil.copyToList(list, UserSalaryDetail.class));
|
|
|
+ userSalaryManageDto.getUserSalaryDetailList().forEach(item -> item.setId(null));
|
|
|
+
|
|
|
+ userSalaryManageService.edit(userSalaryManageDto);
|
|
|
+ }
|
|
|
+}
|