第一步://離職流程舉例子
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); //離職表根據座位號清空座位列表