第一步://离职流程举例子
String code = data.get(0).getDd_create_time(); //系统时间
String nextCursor="0"; 第几页开始
@Override
public void listidsByAppId(String code,String nextCursor){
//批量获取某个审批的实例id列表
List<HCM_process_seatData> ls = dataDao.findAll();
String list=null;
String process_code = "PROC-6F784EBC-71FC-43E5-8E3A-E832C52A14A7";
String process_name = "钉钉离职流程清空座位列表";
int type = 0;
String userString = "";
String jsonData = "{"+
"\"appId\": \"Ck1zMiKTMI4PYZEq\","+ //生产对应的appid
// "\"appId\": \"W35NeGkdb6fPJzSi\","+ //uat对应的appid
"\"process_code\": \""+process_code+"\","+
"\"cursor\": \""+nextCursor+"\","+
"\"start_time\": \""+code+"\","+
"}";
userString = HttpUtil.doPost("http://dingtalk.yundasys.com:9091/approve/listidsByAppId", jsonData);
// userString = HttpUtil.doPost("http://10.19.160.169:9091/approve/listidsByAppId", jsonData); //uat
if(userString!=null){
JSONObject jsonObject1 = JSONObject.parseObject(userString);
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.get("data")+"");
if(jsonObject2!=null||jsonObject2.equals(null)){
list = jsonObject2.get("list")+""; //拿到审批实例列表
//判断实例id是否有值,页数size=10去判断
String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
if(jsonObject2.get("nextCursor")+"" == ""||(jsonObject2.get("nextCursor")+"").equals("")){
String rep = list.replaceAll("[\\[\\]]",""); //中括号去掉
String rep1= rep.replace("\"", ""); //去掉双引号,两边加双引号
String[] str =(rep1.split(",")); //存数据在数组里面
for(int i=0;i<str.length;i++){
getDetailByAppId(str[i],process_name,type);
}
entryDingProcess(code,"0");
}else{
String rep = list.replaceAll("[\\[\\]]",""); //中括号去掉
String rep1= rep.replace("\"", ""); //去掉双引号,两边加双引号
String[] str =(rep1.split(",")); //存数据在数组里面
for(int i=0;i<str.length;i++){
getDetailByAppId(str[i],process_name,type); //根据id查详情
}
nextCursor = jsonObject2.get("nextCursor")+"";
listidsByAppId(code,nextCursor);
}
}else{
return ;
}
}
return ;
}
//根据审核id获取详情
@Override
public void getDetailByAppId(String appiddate,String process_name, int type){
String workplace=null;
String seat_num=null;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String userString = "";
String jsonData = "{"+
"\"appId\": \"Ck1zMiKTMI4PYZEq\","+ //生产对应的appid
// "\"appId\": \"W35NeGkdb6fPJzSi\","+ //uat对应的appid
"\"process_instance_id\":\""+appiddate+"\""+
"}";
userString = HttpUtil.doPost("http://dingtalk.yundasys.com:9091/approve/getDetailByAppId", jsonData); //线上
// userString = HttpUtil.doPost("http://10.19.160.169:9091/approve/getDetailByAppId", jsonData); //uat
if(userString!=null){
JSONObject jsonObject1 = JSONObject.parseObject(userString);
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.get("data")+"");
if(jsonObject2==null){
return ;
}else{
JSONObject process_instance = JSONObject.parseObject(jsonObject2.get("process_instance")+"");
String originator_dept_id = process_instance.get("originator_dept_id")+""; //部门id
String originator_dept_name = process_instance.get("originator_dept_name")+""; //部门name
String originator_userid = null; //工号
String originator_username = null; //姓名
String value = process_instance.get("form_component_values")+"";
int ces = 0 ;
if(type==0){
for (int j=0;j<10;j++) {
JSONArray jsonArray = JSONArray.parseArray(value) ;
if(jsonArray.getJSONObject(j).getString("component_type").equals("DDSelectField")&&jsonArray.getJSONObject(j).getString("id").equals("DDSelectField-KE41HJI6")){
workplace = jsonArray.getJSONObject(j).getString("value");
}else{
if(jsonArray.getJSONObject(j).getString("component_type").equals("TextField")&&jsonArray.getJSONObject(j).getString("id").equals("TextField-K6ABCM3N")){
originator_username = jsonArray.getJSONObject(j).getString("value");
}else{
if(jsonArray.getJSONObject(j).getString("component_type").equals("TextField")&&jsonArray.getJSONObject(j).getString("id").equals("TextField-KDXZ6CFK")){
seat_num = jsonArray.getJSONObject(j).getString("value");
}else{
if(jsonArray.getJSONObject(j).getString("component_type").equals("NumberField")&&jsonArray.getJSONObject(j).getString("id").equals("NumberField-K6AC7JQ8")){
originator_userid = jsonArray.getJSONObject(j).getString("value");
}else{
continue ;
}
}
}
}
}
以下开始是业务逻辑
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now_date = dateFormat.format(now);
//离职--这个座位的工号,姓名,所属机构是空的
dataDao.update(seat_num,now_date); //离职表根据座位号清空座位列表