//package com.sunxung.factoring.service.acceptancesheet.impl;
//
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.sunxung.factoring.component.exception.ValidatorException;
//import com.sunxung.factoring.component.util.CodeUtil;
//import com.sunxung.factoring.component.util.ConstantConversionUtil;
//import com.sunxung.factoring.component.util.ConstantUtil;
//import com.sunxung.factoring.entity.acceptance.AcceptanceBasicInfo;
//import com.sunxung.factoring.entity.acceptance.AcceptanceChangePersonApproval;
//import com.sunxung.factoring.mapper.acceptancesheet.AcceptanceChangePersonApprovalMapper;
//import com.sunxung.factoring.service.acceptancesheet.AcceptanceBasicInfoService;
//import com.sunxung.factoring.service.acceptancesheet.IAcceptanceChangePersonApprovalService;
//import com.sunxung.factoring.service.project.BusinessAssigneeService;
//import com.sunxung.factoring.service.sys.flowable.FlowableService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * <p>
// * --验收单人员变更审核表 服务实现类
// * </p>
// *
// * @author liutao
// * @since 2023-06-07
// */
//@Service("person_change_approvalService")
//public class AcceptanceChangePersonApprovalServiceImpl extends ServiceImpl<AcceptanceChangePersonApprovalMapper, AcceptanceChangePersonApproval> implements IAcceptanceChangePersonApprovalService {
//
//    @Autowired
//    private BusinessAssigneeService assigneeService;
//
//    @Autowired
//    private AcceptanceBasicInfoService acceptanceBasicInfoService;
//
//    @Autowired
//    private FlowableService flowableService;
//
//    @Override
//    public void personChangeApproval(AcceptanceChangePersonApproval acceptanceChangePersonApproval) {
//        //保存审核信息
//        Long businessKey = acceptanceChangePersonApproval.getBusinessKey();
//        String taskId = acceptanceChangePersonApproval.getTaskId();
//        acceptanceChangePersonApproval.setAcceptanceBasicInfoId(businessKey);
//        save(acceptanceChangePersonApproval);
//        AcceptanceBasicInfo acceptanceBasicInfo = acceptanceBasicInfoService.getById(businessKey);
//        //完成流程
//        Map<String, Object> procVariables = new HashMap<>();
//        Map<String, Object> msgVariables = new HashMap<>();
//        String result;
//        if (acceptanceChangePersonApproval.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)) {
//            procVariables.put(ConstantUtil.ACCEPTANCE_SIGN_CONFIRM_ASSIGNEE,
//                    assigneeService.getIdByBusiness(acceptanceBasicInfo.getId(), ConstantUtil.ACCEPTANCE_SHEET, ConstantUtil.ASSIGNEE_PROJECT_MANAGER));
//            result =  ConstantConversionUtil.APPROVAL_RESULT_PASS_DISPLAY;
//            msgVariables.put(ConstantUtil.FLOWABLE_MSG_TITLE, "验收单编号：" + acceptanceBasicInfo.getAcceptanceNumber());
//            msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
//                    "验收单编号为“" + acceptanceBasicInfo.getAcceptanceNumber() + "”的验收单已进入“"
//                            + ConstantConversionUtil.flowBusinessKeyNames.get(ConstantUtil.ACCEPTANCE_SHEET) + "—签署确认阶段，"
//                            + ConstantUtil.FLOWABLE_MSG_ASSIGNEE);
//        } else if (acceptanceChangePersonApproval.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_BACK)) {
//            result = ConstantConversionUtil.APPROVAL_RESULT_BACK_DISPLAY;
//            msgVariables.put(ConstantUtil.FLOWABLE_MSG_TITLE, "验收单编号：" + acceptanceBasicInfo.getAcceptanceNumber());
//            msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
//                    "验收单编号为“" + acceptanceBasicInfo.getAcceptanceNumber() + "”的验收单被退回已进入“"
//                            + ConstantConversionUtil.flowBusinessKeyNames.get(ConstantUtil.ACCEPTANCE_SHEET) + "—验收单录入阶段，"
//                            + ConstantUtil.FLOWABLE_MSG_ASSIGNEE);
//        } else {
//            throw new ValidatorException(CodeUtil.FAIL, "审核结论有误！");
//        }
//        flowableService.completeMyTask(taskId, acceptanceBasicInfo, procVariables, result, acceptanceChangePersonApproval.getId(), msgVariables, ConstantUtil.ACCEPTANCE_SHEET);
//    }
//
//    @Override
//    public AcceptanceChangePersonApproval getView(Long id) {
//        return getById(id);
//    }
//}
