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

import java.text.ParseException;

import org.springframework.beans.factory.annotation.Autowired;import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.timer.api.controller.yggl.service.YgglService;
import cn.timer.api.dto.spmk.FromData;
import cn.timer.api.dto.yggl.LzygQueryDto;
import cn.timer.api.utils.DateFormatUtils;
import lombok.Builder;

/**
 * 离职-业务
 * @author Tang
 *
 */
@Builder
public class ResignationBusiness extends SpmkAssoBusiness {

	@Autowired
	private YgglService ygglService;
	
	@Override
	public void handleApprove(JSONObject jsonObj) throws Exception {
		// 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("",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 terminationDate = ObjectUtil.isNull(jsonObj.get("__terminationDate",FromData.class)) ? null : jsonObj.get("__terminationDate",FromData.class).getValue();
		// 离职原因
		String ReasonForResignation = ObjectUtil.isNull(jsonObj.get("__ReasonForResignation",FromData.class)) ? null : jsonObj.get("__ReasonForResignation",FromData.class).getValue();
		// 备注
		String Remarks = ObjectUtil.isNull(jsonObj.get("Remarks",FromData.class)) ? null : jsonObj.get("Remarks",FromData.class).getValue();
		
		LzygQueryDto dto = LzygQueryDto.builder()
					.orgCode(orgCode)
					.empNum(id)
					.lzTime(DateFormatUtils.getDateByString(terminationDate))
					.lzyy(ReasonForResignation)
					.lzbz(Remarks)
					.build();
		// 调 员工管理 业务
		ygglService.applicationResignation(dto);
		
		
	}

}