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.flow.core.FlowDelegate; import com.fjhx.flow.enums.FlowStatusEnum; import com.fjhx.oa.entity.promotion.dto.PromotionApplyDto; import com.fjhx.oa.entity.promotion.po.PromotionApply; import com.fjhx.oa.entity.user.dto.UserSalaryDto; import com.fjhx.oa.entity.user.vo.UserSalaryVo; import com.fjhx.oa.service.promotion.PromotionApplyService; import com.fjhx.oa.service.user.UserSalaryService; import com.ruoyi.common.utils.SecurityUtils; import org.springframework.stereotype.Component; import javax.annotation.Resource; @Component public class PromotionApplyFlow extends FlowDelegate { @Resource private PromotionApplyService promotionApplyService; @Resource private UserSalaryService userSalaryService; @Override public String getFlowKey() { return "promotion_apply_flow"; } @Override public Long start(Long flowId, JSONObject submitData) { PromotionApplyDto dto = submitData.toJavaObject(PromotionApplyDto.class); dto.setFlowId(flowId); dto.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey()); dto.setUserId(SecurityUtils.getUserId()); //回填用户名 String nickName = SecurityUtils.getLoginUser().getUser().getNickName(); submitData.put("userName", nickName); promotionApplyService.saveOrUpdate(dto); return dto.getId(); } @Override public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) { promotionApplyService.update(q -> q .eq(PromotionApply::getId, businessId) .set(PromotionApply::getStatus, FlowStatusEnum1.REJECT.getKey()) ); } @Override public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) { promotionApplyService.update(q -> q .eq(PromotionApply::getId, businessId) .set(PromotionApply::getStatus, FlowStatusEnum1.CANCELLATION.getKey()) ); } @Override public void end(Long flowId, Long businessId, JSONObject submitData) { PromotionApply byId = promotionApplyService.getById(businessId); promotionApplyService.update(q -> q .eq(PromotionApply::getId, businessId) .set(PromotionApply::getStatus, FlowStatusEnum1.PASS.getKey()) ); //更新用户薪资 UserSalaryVo detail = userSalaryService.detail(byId.getCreateUser()); UserSalaryDto userSalaryManageDto = BeanUtil.copyProperties(detail, UserSalaryDto.class); userSalaryManageDto.setEmployeeType(byId.getEmployeeType()); userSalaryManageDto.setFullTimeDate(byId.getPromotionDate()); userSalaryManageDto.setEffectiveDate(byId.getPromotionDate()); userSalaryService.edit(userSalaryManageDto); } }