package com.blueland.render.rest;


/**
 * @author usm to erp 数据查询控制器
 * @version 1.0
 * @since  
 */
import cn.hutool.core.util.ObjectUtil;
import com.blueland.annotation.ApiVersion;
import com.blueland.bo.Org;
import com.blueland.bo.TucStaffEntity;
import com.blueland.constant.Constant;
import com.blueland.enums.Version;
import com.blueland.model.TPfParameter;
import com.blueland.model.TUcOrg;
import com.blueland.result.R;
import com.blueland.service.IParameterService;
import com.blueland.service.ITucOrgService;
import com.blueland.service.ITucStaffService;
import com.blueland.vo.StaffNumVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(value = "usm to erp 数据查询控制器")
@RestController
@RequestMapping(value = "/usmToErp")
public class UsmErpController {

	@Autowired
	ITucOrgService iTucOrgService;

	@Autowired
	ITucStaffService iTucStaffService;

	@Autowired
	IParameterService parameterService;

	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据部门id集合查询部门信息", notes="根据部门id集合查询部门信息")
	@PostMapping("/selectOrgByDeptIds")
	public R<List<Org>> selectOrgByDeptIds(@RequestBody List<String> ids){
		List<Org> list = iTucOrgService.selectOrgByDeptIds(ids);
		return R.ok(list);
	}

	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据部门id集合查询部门信息", notes="根据部门id集合查询部门信息")
	@PostMapping("/selectOrgByErpCodes")
	public R<List<Org>> selectOrgByErpCodes(@RequestBody List<String> erpCodes){
		List<Org> list = iTucOrgService.selectOrgByErpCodes(erpCodes);
		return R.ok(list);
	}


	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据岗位编码集合查询工号", notes="根据岗位编码集合查询工号")
	@PostMapping("/selectStaffNumByPostCodes")
	public R<List<TucStaffEntity>> selectStaffNumByPostCodes(@RequestBody List<String> postCodes){
		List<TucStaffEntity> list = iTucStaffService.selectStaffByPostCodes(postCodes);
		return R.ok(list);
	}

	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据工号和部门id获取员工信息", notes="根据工号和部门id获取员工信息")
	@GetMapping("/selectStaffByNumAndDept/{staffNum}/{deptId}")
	public R<TucStaffEntity> selectStaffByNumAndDept(@PathVariable("staffNum") String staffNum, @PathVariable("deptId") String deptId) {
		TucStaffEntity vo = iTucStaffService.selectStaffByNumAndDept(staffNum, deptId);
		return R.ok(vo);
	}

	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据工号获取员工信息", notes="根据工号获取员工信息")
	@GetMapping("/selectStaffByNum/{staffNum}")
	public R<TucStaffEntity> selectStaffByNum(@PathVariable("staffNum") String staffNum) {
		TucStaffEntity vo = iTucStaffService.selectStaffByNum(staffNum);
		return R.ok(vo);
	}


	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据key查询配置", notes="根据key查询配置")
	@PostMapping("/selectConfigByKeys")
	public R<List<TPfParameter>> selectConfigByKey(@RequestBody List<String> keys) {
		return R.ok(parameterService.selectConfigByKey(keys));
	}

	@ApiVersion(groups = Version.SIX)
	@ApiOperation(value="根据value查询配置", notes="根据value查询配置")
	@PostMapping("/selectConfigByValues")
	public R<List<TPfParameter>> selectConfigByValue(@RequestBody List<String> values) {
		return R.ok(parameterService.selectConfigByValue(values));
	}


}



