package cn.timer.api.utils.router.business;

import org.springframework.beans.factory.annotation.Autowired;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.timer.api.controller.zzgl.service.ZzglBmgwMService;
import cn.timer.api.dto.spmk.FromData;
import cn.timer.api.dto.zzgl.UpEmpDeptDto;
import lombok.Builder;

/**
 * 调岗-业务
 * @author Tang
 *
 */
@Builder
public class TransferPositionBusiness extends SpmkAssoBusiness {

	@Autowired
	ZzglBmgwMService zzglBmgwMService;
	
	@Override
	public void handleApprove(JSONObject jsonObj) {
		// TODO Auto-generated method stub
		// 发起人企业id
		Integer orgCode = ObjectUtil.isNull(jsonObj.get("orgCode",FromData.class)) ? null : Integer.parseInt(jsonObj.get("orgCode",FromData.class).getValue());
		// 发起人id
		Integer id = ObjectUtil.isNull(jsonObj.get("id",FromData.class)) ? null : Integer.parseInt(jsonObj.get("id",FromData.class).getValue());
		// 发起人名称
		String initiator = ObjectUtil.isNull(jsonObj.get("initiator",FromData.class)) ? null : jsonObj.get("initiator",FromData.class).getValue();
		
		// 申请人
		String applicant = ObjectUtil.isNull(jsonObj.get("__applicant",FromData.class)) ? null : jsonObj.get("__applicant",FromData.class).getValue();
		// 申请原因
		String ReasonForApplication = ObjectUtil.isNull(jsonObj.get("__ReasonForApplication",FromData.class)) ? null : jsonObj.get("__ReasonForApplication",FromData.class).getValue();
		// 调入部门
		Integer TransferInDepartment = ObjectUtil.isNull(jsonObj.get("__TransferInDepartment",FromData.class)) ? null : Integer.parseInt(jsonObj.get("__TransferInDepartment",FromData.class).getValue());
		// 调入岗位
		String TransferInPosition = ObjectUtil.isNull(jsonObj.get("__TransferInPosition",FromData.class)) ? null : jsonObj.get("__TransferInPosition",FromData.class).getValue();
		// 生效日期
		String effectiveDate = ObjectUtil.isNull(jsonObj.get("__effectiveDate",FromData.class)) ? null : jsonObj.get("__effectiveDate",FromData.class).getValue();
		// 备注
		String Remarks = ObjectUtil.isNull(jsonObj.get("Remarks",FromData.class)) ? null : jsonObj.get("Remarks",FromData.class).getValue();
		// 上传文件
		String UploadAttachment = ObjectUtil.isNull(jsonObj.get("UploadAttachment",FromData.class)) ? null : jsonObj.get("UploadAttachment",FromData.class).getValue();
		
		UpEmpDeptDto upEmpDeptDto = UpEmpDeptDto.builder()
				.dpetId(TransferInDepartment)
				.isdg(1)
				.build();
		
		// 调 员工管理 业务
		zzglBmgwMService.applicationTransferPosition(id, orgCode, upEmpDeptDto);
	}

}