批量删除和激活禅道上的任务
public class PmTest {
public static void main(String[] args) throws Exception {
active();
}
private static void active () throws Exception {
// 读取任务id列表
final List<String> lines = FileUtils.readLines(new File("/Users/xiaodx/test/pm.active"), "utf8");
for (String line : lines) {
line = line.trim();
if(StringUtils.hasText(line)) {
// 模拟删除
String url = "https://pm.yjzhixue.com/task-activate-"+line+".html?onlybody=yes";
HttpPost post = new HttpPost(url);
HashMap<String,String> bodyMap = new HashMap<>();
bodyMap.put("assignedTo","xiaodaxin");
bodyMap.put("left","8");
bodyMap.put("status","doing");
bodyMap.put("uid","62621c48c72fe");
// 请求过程需要使用arraylist的方式传递参数,需要进行转换
ArrayList<NameValuePair> bodyList = new ArrayList<>();
Set<String> keySet = bodyMap.keySet();
for(String key:keySet){
bodyList.add(new BasicNameValuePair(key,bodyMap.get(key)));
}
UrlEncodedFormEntity entityBody = new UrlEncodedFormEntity(bodyList);
post.setEntity(entityBody);
post.setHeader("cookie","lang=zh-cn; device=desktop; theme=default; keepLogin=on; preBranch=0; checkedItem=; zentaosid=9ne05vhoju1kjn3d7qgfdo5cru; preProductID=7; storyModule=0; storyBranch=0; treeBranch=0; productStoryOrder=id_desc; za=xiaodaxin; zp=144411e51f4514d0ec2742767343b2053f922b84; lastProduct=20; productBrowseParam=0; storyPreProjectID=93; storyProductParam=0; storyBranchParam=0; projectStoryOrder=order_desc; pagerProjectStory=500; selfClose=0; windowHeight=978; storyModuleParam=345; moduleBrowseParam=0; lastProject=93; preProjectID=93; projectTaskOrder=id_desc; pagerProjectTask=1000; windowWidth=1244");
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
final CloseableHttpResponse response = closeableHttpClient.execute(post);
final int statusCode = response.getStatusLine().getStatusCode();
System.err.println("请求响应:"+statusCode);
closeableHttpClient.close();
TimeUnit.MILLISECONDS.sleep(50);
}
}
}
private static void delete () throws Exception {
// 读取任务id列表
final List<String> lines = FileUtils.readLines(new File("/Users/xiaodx/test/pm.delete"), "utf8");
for (String line : lines) {
line = line.trim();
if(StringUtils.hasText(line)) {
// 模拟删除
String url = "https://pm.yjzhixue.com/task-delete-93-"+line+"-yes.html";
HttpGet get = new HttpGet(url);
get.setHeader("cookie","lang=zh-cn; device=desktop; theme=default; keepLogin=on; preBranch=0; checkedItem=; zentaosid=9ne05vhoju1kjn3d7qgfdo5cru; preProductID=7; storyModule=0; storyBranch=0; treeBranch=0; productStoryOrder=id_desc; za=xiaodaxin; zp=144411e51f4514d0ec2742767343b2053f922b84; lastProduct=20; productBrowseParam=0; storyPreProjectID=93; storyProductParam=0; storyBranchParam=0; projectStoryOrder=order_desc; pagerProjectStory=500; selfClose=0; windowHeight=978; storyModuleParam=345; moduleBrowseParam=0; lastProject=93; preProjectID=93; projectTaskOrder=id_desc; pagerProjectTask=1000; windowWidth=1244");
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
final CloseableHttpResponse response = closeableHttpClient.execute(get);
final int statusCode = response.getStatusLine().getStatusCode();
System.err.println("请求响应:"+statusCode);
closeableHttpClient.close();
TimeUnit.MILLISECONDS.sleep(50);
}
}
}
}
注意:本文归作者所有,未经作者允许,不得转载