1. HR服务管理(Since:V61)

1.1. 工资条导入接口

工资条csv文件导入接口。【注意:需要将OA下载的xls文件转换为csv文件。】

接口请求说明:

http请求方式:POST 
http://ip:port/seeyon/rest/hr/wagestrip?state={state}&accountId={accountId}&createUserId={createUserId}
参数 是否必须 说明
uploadedInputStream 二进制工资条
state 0:工资条追加,1:工资条覆盖
accountId 单位ID(org_unit中的单位ID)
createUserId 当前操作人的ID(org_member中的人员ID)

返回说明

正常情况下,返回创建工资条结果JSON信息。

工资条导入DEMO:

package com.seeyon.ctp.rest.resources;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.media.multipart.MultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
import org.junit.Test;

public class HrSalaryResourceTest {
    @Test
    public void testWagestrip() {
        HrSalaryResource();
    }

    //模拟客户端请求导入工资
  public void HrSalaryResource(){
        Long createUserId = -3941577936688034522L;//创建人ID
      Long accountId = 5269865115340261356L;//单位ID
      //http://127.0.0.1:8080/seeyon/rest/token/lsm/111111
      String tokenId = "84d6aba2-e3e8-4e40-b548-2081293d6135";//身份验证码
      String url ="http://127.0.0.1:8080/seeyon/rest/hr/wagestrip?state=0&token="+tokenId+"&accountId="+accountId+"&createUserId="+createUserId;

      Client client = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
      WebTarget webTarget = client.target(url);

      MultiPart multiPart = new MultiPart();
      multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);

      //封装文件
      String path = "F:\\UFSeeyon\\salarytemplate.csv";
      FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("uploadedInputStream",new File(path),MediaType.APPLICATION_OCTET_STREAM_TYPE);
      multiPart.bodyPart(fileDataBodyPart);
      //POST请求
      Response response = webTarget.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(multiPart, multiPart.getMediaType()));
      System.out.println("返回响应:"+response);
      //由于使用的是字节流,所以在返回实体的时候也将是字节流
      BufferedReader br = new BufferedReader(new InputStreamReader((InputStream) response.getEntity()));
      String res = "";
      try {
            while((res=br.readLine())!=null){
                    System.out.println("服务器返回结果为:"+res);
            }
        } catch (IOException e) {
            e.getStackTrace();
        }
  }
}

results matching ""

    No results matching ""