TransferPositionBusiness.java 3.35 KB
Newer Older
1 2
package cn.timer.api.utils.router.business;

3
import org.springframework.beans.factory.annotation.Autowired;
ilal committed
4
import org.springframework.beans.factory.annotation.Value;
tangzhaoqian committed
5
import org.springframework.stereotype.Service;
6

ilal committed
7 8
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

tangzhaoqian committed
9
import cn.hutool.core.convert.Convert;
10
import cn.hutool.core.util.ObjectUtil;
11
import cn.hutool.json.JSONObject;
ilal committed
12
import cn.timer.api.bean.zzgl.ZzglBmgwM;
tangzhaoqian committed
13
import cn.timer.api.config.exception.CustomException;
14
import cn.timer.api.controller.zzgl.service.ZzglBmgwMService;
15
import cn.timer.api.dto.spmk.FromData;
16
import cn.timer.api.dto.zzgl.UpEmpDeptDto;
17 18 19 20 21 22 23
import lombok.Builder;

/**
 * 调岗-业务
 * @author Tang
 *
 */
tangzhaoqian committed
24 25

@Service
26 27
public class TransferPositionBusiness extends SpmkAssoBusiness {

28 29 30
	@Autowired
	ZzglBmgwMService zzglBmgwMService;
	
ilal committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44
	@Value("${config-8timer.environmental-science}")
	public String environmental_science;
	
	public void Logoutput(String science) {
		
		if(!("pro").equals(environmental_science)) {
			
			System.out.println(science);
		}else {
			System.out.println("");
		}
		
	}
	
45 46 47 48
	@Override
	public void handleApprove(JSONObject jsonObj) {
		// TODO Auto-generated method stub
		// 发起人企业id
tangzhaoqian committed
49
		Integer orgCode = ObjectUtil.isNull(jsonObj.get("orgCode")) ? null : Convert.toInt(jsonObj.get("orgCode"));
50
		// 发起人id
tangzhaoqian committed
51
		Integer id = jsonObj.getInt("id");
52 53
		
		// 申请人
54
		String applicant = ObjectUtil.isNull(jsonObj.get("__applicant",FromData.class)) ? null : jsonObj.get("__applicant",FromData.class).getValue();
55
		// 申请原因
56
		String ReasonForApplication = ObjectUtil.isNull(jsonObj.get("__ReasonForApplication",FromData.class)) ? null : jsonObj.get("__ReasonForApplication",FromData.class).getValue();
57
		// 调入部门
tangzhaoqian committed
58
		Integer TransferInDepartment = ObjectUtil.isNull(jsonObj.get("__TransferInDepartment",FromData.class)) ? null : Convert.toInt(jsonObj.get("__TransferInDepartment",FromData.class).getValue());
lal committed
59
		
ilal committed
60 61
		/* __TransferInPosition */
		if(!("").equals(jsonObj.get("__TransferInDepartment",FromData.class).getValue())) {
lal committed
62
			// 调入岗位
ilal committed
63
			Integer TransferInPosition = ObjectUtil.isNull(jsonObj.get("__TransferInDepartment",FromData.class)) ? null : Integer.parseInt(jsonObj.get("__TransferInDepartment",FromData.class).getValue());
lal committed
64 65
		}
		
tangzhaoqian committed
66
		if (TransferInDepartment == null) {
tangzhaoqian committed
67 68
			throw new CustomException("部门或岗位 未填写,审批失败");
		}
69
		// 生效日期
70
		String effectiveDate = ObjectUtil.isNull(jsonObj.get("__effectiveDate",FromData.class)) ? null : jsonObj.get("__effectiveDate",FromData.class).getValue();
71
		// 备注
72
		String Remarks = ObjectUtil.isNull(jsonObj.get("Remarks",FromData.class)) ? null : jsonObj.get("Remarks",FromData.class).getValue();
73
		// 上传文件
74
		String UploadAttachment = ObjectUtil.isNull(jsonObj.get("UploadAttachment",FromData.class)) ? null : jsonObj.get("UploadAttachment",FromData.class).getValue();
75
		
76 77 78 79 80
		UpEmpDeptDto upEmpDeptDto = UpEmpDeptDto.builder()
				.dpetId(TransferInDepartment)
				.isdg(1)
				.build();
		
ilal committed
81
		Logoutput("调岗:"+upEmpDeptDto);
ilal committed
82 83 84 85 86 87
		
		ZzglBmgwM bmg = ZzglBmgwM.builder().build().selectOne(new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getLeader, id));
		if(bmg != null) {
			ZzglBmgwM.builder().id(bmg.getId()).leader(0).build().updateById();
		}
		
88
		// 调 员工管理 业务
89
		zzglBmgwMService.applicationTransferPosition(id, orgCode, upEmpDeptDto);
90 91 92
	}

}