| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.BufferedWriter;
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.DataInputStream;
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.FileWriter;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.net.MalformedURLException;
|
| | | import java.net.URL;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.multipart.MultipartHttpServletRequest;
|
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.bus.user.ShamUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRankings;
|
| | | import com.yeshi.fanli.exception.UserRankingsException;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankingsService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/rankings")
|
| | | public class UserRankingsAdminController {
|
| | |
|
| | | @Resource
|
| | | private UserRankingsService userRankingsService;
|
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | |
|
| | | |
| | | @RequestMapping(value = "saveAdd")
|
| | | public void saveAdd(String callback, UserRankings userRankings, HttpServletRequest request, PrintWriter out) {
|
| | | |
| | |
|
| | | try {
|
| | | |
| | | String nickName = userRankings.getNickName();
|
| | | |
| | | if (StringUtil.isNullOrEmpty(nickName)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户名称不能为空"));
|
| | | return;
|
| | | } |
| | | |
| | | // 查询昵称是否已存在
|
| | | List<UserRankings> listRankings = userRankingsService.selectByNickName(nickName.trim());
|
| | | |
| | | if (listRankings != null && listRankings.size() > 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("["+ nickName +"] 此昵称已存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | |
|
| | | List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
|
| | |
|
| | | if (files != null && files.size() > 0) {
|
| | | userRankingsService.insertAndUploadFile(userRankings, files.get(0));
|
| | | } else {
|
| | | userRankingsService.insertAndUploadFile(userRankings, null);
|
| | | }
|
| | |
|
| | | } else {
|
| | | userRankingsService.insertAndUploadFile(userRankings, null);
|
| | | }
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("添加失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, UserRankings userRankings, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | Long id = userRankings.getId();
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数"));
|
| | | return;
|
| | | }
|
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除"));
|
| | | return;
|
| | | } |
| | | |
| | | String nickName = userRankings.getNickName();
|
| | | if (!StringUtil.isNullOrEmpty(nickName)) {
|
| | | // 查询昵称是否已存在
|
| | | List<UserRankings> listRankings = userRankingsService.selectByNickName(nickName.trim());
|
| | | |
| | | if (listRankings != null && listRankings.size() > 0) {
|
| | | boolean proess = false;
|
| | | for (UserRankings userRanking: listRankings) {
|
| | | Long objid = userRanking.getId();
|
| | | if (id.equals(objid)){
|
| | | proess = true;
|
| | | }
|
| | | }
|
| | | |
| | | if (!proess){
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("["+ nickName +"] 此昵称已存在"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | } |
| | | |
| | | Integer shareState = userRankings.getShareState();
|
| | | if (shareState != null && (shareState.equals(1) || shareState == 1)){
|
| | | userRankings.setShareTime(new Date());
|
| | | }
|
| | | |
| | | Integer tradeState = userRankings.getTradeState();
|
| | | if (tradeState != null && (tradeState.equals(1) || tradeState == 1)){
|
| | | userRankings.setTradeTime(new Date());
|
| | | }
|
| | | |
| | | userRankingsService.updateByPrimaryKeySelective(userRankings);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | |
|
| | | } catch (UserRankingsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "deleteBatch")
|
| | | public void deleteBatch(String callback, String idArray, PrintWriter out) {
|
| | | |
| | | try {
|
| | | |
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> arrayID = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | if (arrayID == null || arrayID.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | userRankingsService.deleteBatchByPrimaryKey(arrayID);
|
| | | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("删除成功")));
|
| | |
|
| | | } catch (UserRankingsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @RequestMapping(value = "uploadPicture")
|
| | | public void uploadImg(String callback, Long id, @RequestParam("file") CommonsMultipartFile file,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | |
| | | if (file == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("上传文件不能为空"));
|
| | | return;
|
| | | } |
| | | |
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数"));
|
| | | return;
|
| | | }
|
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除"));
|
| | | return;
|
| | | } |
| | | |
| | | userRankingsService.uploadPicture(file, resultObj);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("图片上传成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("图片上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "removePicture")
|
| | | public void uploadImg(String callback, Long id, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数"));
|
| | | return;
|
| | | }
|
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除"));
|
| | | return;
|
| | | } |
| | | |
| | | userRankingsService.removePicture(resultObj);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("图片删除成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("图片删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | |
| | | /**
|
| | | * 查找所有标签
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param key
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key,
|
| | | Integer tradeState, Integer shareState, Integer sort, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | | if (pageIndex == null || pageIndex < 1) |
| | | pageIndex = 1;
|
| | | |
| | | if (pageSize == null || pageSize < 1) |
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | if (sort == null || sort < 1 || sort >8) |
| | | sort = 1;
|
| | | |
| | | |
| | | List<UserRankings> userRankingsList = userRankingsService.query((pageIndex - 1) * pageSize,
|
| | | pageSize, key, tradeState, shareState, sort);
|
| | | |
| | | if (userRankingsList == null || userRankingsList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无相关数据")));
|
| | | return;
|
| | | }
|
| | | |
| | | long count = userRankingsService.queryCount(key, tradeState, shareState);
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(userRankingsList));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * (随机权奖金)
|
| | | * @param callback
|
| | | * @param request
|
| | | * @param out @param 大值
|
| | | * @param 小值
|
| | | */
|
| | | @RequestMapping(value = "setRewardtBatch")
|
| | | public void setRewardtBatch(String callback,String ids, Integer type, Double reward,
|
| | | Double startReward, Double endReward, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未选择需操作的用户"));
|
| | | return;
|
| | | }
|
| | | |
| | | // type : 1 自购 2 分享
|
| | | if (type == null || type <1 || type >2) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确的类型"));
|
| | | return;
|
| | | } |
| | | |
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | |
| | | if (idList == null || idList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的用户"));
|
| | | return;
|
| | | } |
| | | |
| | | userRankingsService.setRewardtBatch(idList, type, reward, startReward, endReward);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | |
| | | } catch ( Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * (随机权奖金)
|
| | | * @param callback
|
| | | * @param request
|
| | | * @param out @param 大值
|
| | | * @param 小值
|
| | | */
|
| | | @RequestMapping(value = "setStateBatch")
|
| | | public void setStateBatch(String callback, String ids, Integer type, Integer state, PrintWriter out) {
|
| | |
|
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未选择需操作的用户"));
|
| | | return;
|
| | | }
|
| | | |
| | | // type : 1 自购 2 分享
|
| | | if (type == null || type <1 || type >2) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确的类型"));
|
| | | return;
|
| | | } |
| | | |
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | |
| | | if (idList == null || idList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的用户"));
|
| | | return;
|
| | | } |
| | | |
| | | userRankingsService.setStateBatch(idList, type, state);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | |
| | | } catch ( Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | @RequestMapping(value = "batchUpFile")
|
| | | public void batchUpFile(PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | | File file = new File("E:\\test");// 需要查找的文件夹
|
| | | |
| | | userRankingsService.uploadFile(file);
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("图片上传成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @RequestMapping(value = "batchUpShowID")
|
| | | public void batchUpShowID(PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | | File file = new File("E:\\idtest\\IDS.txt");//Text文件
|
| | | |
| | | userRankingsService.updateShowID(file);
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "batchUpNickName")
|
| | | public void batchUpNickName(PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | | File file = new File("E:\\idtest\\Names.txt");//Text文件
|
| | | |
| | | userRankingsService.batchUpNickName(file);
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | @RequestMapping(value = "downPic")
|
| | | public void downPic(PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | List<ShamUser> list = shamUserService.findShamUserList(100000);
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(0, 10000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(10000, 20000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(20000, 30000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(30000, 40000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | |
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(40000, 50000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(50000, 60000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(60000, 70000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(70000, 80000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(80000, 90000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | /* 读入TXT文件 */
|
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outWriter;
|
| | |
|
| | | outWriter = new BufferedWriter(new FileWriter(writename));
|
| | |
|
| | | /* 读入TXT文件 */
|
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
|
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件
|
| | |
|
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID));
|
| | | List<ShamUser> subList = list.subList(90000, 100000);
|
| | | for (ShamUser shamUser : subList) {
|
| | | String picUrl = shamUser.getPicUrl();
|
| | | if (!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | long id = shamUser.getId();
|
| | | String path = "E:/test/" + id + ".jpg";
|
| | | // 下载图片
|
| | | downloadPicture(picUrl, path);
|
| | | // 下载文字
|
| | | outID.write(id + "\r\n");
|
| | | outWriter.write(shamUser.getName() + "\r\n");
|
| | | }
|
| | | }
|
| | | outID.flush();// 把缓存区内容压入文件
|
| | | outID.close(); // 最后记得关闭文件
|
| | |
|
| | | outWriter.flush(); // 把缓存区内容压入文件
|
| | | outWriter.close(); // 最后记得关闭文件
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("下载成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | //链接url下载图片
|
| | | private void downloadPicture(String picUrl,String path) {
|
| | | URL url = null;
|
| | | try {
|
| | | url = new URL(picUrl);
|
| | | |
| | | DataInputStream dataInputStream = new DataInputStream(url.openStream());
|
| | | |
| | | FileOutputStream fileOutputStream = new FileOutputStream(new File(path));
|
| | | ByteArrayOutputStream output = new ByteArrayOutputStream();
|
| | | |
| | | byte[] buffer = new byte[1024];
|
| | | int length;
|
| | | |
| | | while ((length = dataInputStream.read(buffer)) > 0) {
|
| | | output.write(buffer, 0, length);
|
| | | }
|
| | | fileOutputStream.write(output.toByteArray());
|
| | | dataInputStream.close();
|
| | | fileOutputStream.close();
|
| | | |
| | | } catch (MalformedURLException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.admin; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.DataInputStream; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.fanli.entity.bus.user.ShamUser; |
| | | import com.yeshi.fanli.entity.bus.user.UserRankings; |
| | | import com.yeshi.fanli.exception.user.UserRankingsException; |
| | | import com.yeshi.fanli.service.inter.user.ShamUserService; |
| | | import com.yeshi.fanli.service.inter.user.UserRankingsService; |
| | | import com.yeshi.common.entity.PageEntity; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/v1/rankings") |
| | | public class UserRankingsAdminController { |
| | | |
| | | @Resource |
| | | private UserRankingsService userRankingsService; |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "saveAdd") |
| | | public void saveAdd(AdminAcceptData acceptData, String callback, UserRankings userRankings, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | |
| | | try { |
| | | |
| | | String nickName = userRankings.getNickName(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(nickName)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户名称不能为空")); |
| | | return; |
| | | } |
| | | |
| | | // 查询昵称是否已存在 |
| | | List<UserRankings> listRankings = userRankingsService.selectByNickName(nickName.trim()); |
| | | |
| | | if (listRankings != null && listRankings.size() > 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("["+ nickName +"] 此昵称已存在")); |
| | | return; |
| | | } |
| | | |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | |
| | | List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file"); |
| | | |
| | | if (files != null && files.size() > 0) { |
| | | userRankingsService.insertAndUploadFile(userRankings, files.get(0)); |
| | | } else { |
| | | userRankingsService.insertAndUploadFile(userRankings, null); |
| | | } |
| | | |
| | | } else { |
| | | userRankingsService.insertAndUploadFile(userRankings, null); |
| | | } |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功")); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("添加失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "saveModify") |
| | | public void saveModify(AdminAcceptData acceptData,String callback, UserRankings userRankings, PrintWriter out) { |
| | | |
| | | try { |
| | | Long id = userRankings.getId(); |
| | | if (id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数")); |
| | | return; |
| | | } |
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id); |
| | | if (resultObj == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除")); |
| | | return; |
| | | } |
| | | |
| | | String nickName = userRankings.getNickName(); |
| | | if (!StringUtil.isNullOrEmpty(nickName)) { |
| | | // 查询昵称是否已存在 |
| | | List<UserRankings> listRankings = userRankingsService.selectByNickName(nickName.trim()); |
| | | |
| | | if (listRankings != null && listRankings.size() > 0) { |
| | | boolean proess = false; |
| | | for (UserRankings userRanking: listRankings) { |
| | | Long objid = userRanking.getId(); |
| | | if (id.equals(objid)){ |
| | | proess = true; |
| | | } |
| | | } |
| | | |
| | | if (!proess){ |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("["+ nickName +"] 此昵称已存在")); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Integer shareState = userRankings.getShareState(); |
| | | if (shareState != null && (shareState.equals(1) || shareState == 1)){ |
| | | userRankings.setShareTime(new Date()); |
| | | } |
| | | |
| | | Integer tradeState = userRankings.getTradeState(); |
| | | if (tradeState != null && (tradeState.equals(1) || tradeState == 1)){ |
| | | userRankings.setTradeTime(new Date()); |
| | | } |
| | | |
| | | userRankingsService.updateByPrimaryKeySelective(userRankings); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功")); |
| | | |
| | | } catch (UserRankingsException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "deleteBatch") |
| | | public void deleteBatch(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(idArray)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择删除的数据")); |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | List<Long> arrayID = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType()); |
| | | if (arrayID == null || arrayID.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据")); |
| | | return; |
| | | } |
| | | |
| | | userRankingsService.deleteBatchByPrimaryKey(arrayID); |
| | | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("删除成功"))); |
| | | |
| | | } catch (UserRankingsException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "uploadPicture") |
| | | public void uploadImg(AdminAcceptData acceptData,String callback, Long id, @RequestParam("file") CommonsMultipartFile file, |
| | | PrintWriter out) { |
| | | try { |
| | | |
| | | if (file == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("上传文件不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数")); |
| | | return; |
| | | } |
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id); |
| | | if (resultObj == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除")); |
| | | return; |
| | | } |
| | | |
| | | userRankingsService.uploadPicture(file, resultObj); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("图片上传成功")); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("图片上传失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "removePicture") |
| | | public void uploadImg(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数")); |
| | | return; |
| | | } |
| | | |
| | | UserRankings resultObj = userRankingsService.selectByPrimaryKey(id); |
| | | if (resultObj == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据不存在或已被删除")); |
| | | return; |
| | | } |
| | | |
| | | userRankingsService.removePicture(resultObj); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("图片删除成功")); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("图片删除失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查找所有标签 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param key |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "query") |
| | | public void query(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, |
| | | Integer tradeState, Integer shareState, Integer sort, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) |
| | | pageIndex = 1; |
| | | |
| | | if (pageSize == null || pageSize < 1) |
| | | pageSize = Constant.PAGE_SIZE; |
| | | |
| | | if (sort == null || sort < 1 || sort >8) |
| | | sort = 1; |
| | | |
| | | |
| | | List<UserRankings> userRankingsList = userRankingsService.query((pageIndex - 1) * pageSize, |
| | | pageSize, key, tradeState, shareState, sort); |
| | | |
| | | if (userRankingsList == null || userRankingsList.size() == 0) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无相关数据"))); |
| | | return; |
| | | } |
| | | |
| | | long count = userRankingsService.queryCount(key, tradeState, shareState); |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder(); |
| | | gsonBuilder.serializeNulls(); |
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(userRankingsList)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * (随机权奖金) |
| | | * @param callback |
| | | * @param request |
| | | * @param out @param 大值 |
| | | * @param 小值 |
| | | */ |
| | | @RequestMapping(value = "setRewardtBatch") |
| | | public void setRewardtBatch(AdminAcceptData acceptData,String callback,String ids, Integer type, Double reward, |
| | | Double startReward, Double endReward, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未选择需操作的用户")); |
| | | return; |
| | | } |
| | | |
| | | // type : 1 自购 2 分享 |
| | | if (type == null || type <1 || type >2) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确的类型")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | Gson gson = new Gson(); |
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType()); |
| | | |
| | | if (idList == null || idList.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的用户")); |
| | | return; |
| | | } |
| | | |
| | | userRankingsService.setRewardtBatch(idList, type, reward, startReward, endReward); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); |
| | | |
| | | } catch ( Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * (随机权奖金) |
| | | * @param callback |
| | | * @param request |
| | | * @param out @param 大值 |
| | | * @param 小值 |
| | | */ |
| | | @RequestMapping(value = "setStateBatch") |
| | | public void setStateBatch(AdminAcceptData acceptData,String callback, String ids, Integer type, Integer state, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未选择需操作的用户")); |
| | | return; |
| | | } |
| | | |
| | | // type : 1 自购 2 分享 |
| | | if (type == null || type <1 || type >2) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确的类型")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | Gson gson = new Gson(); |
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType()); |
| | | |
| | | if (idList == null || idList.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的用户")); |
| | | return; |
| | | } |
| | | |
| | | userRankingsService.setStateBatch(idList, type, state); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); |
| | | |
| | | } catch ( Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "batchUpFile") |
| | | public void batchUpFile(AdminAcceptData acceptData,PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | File file = new File("E:\\test");// 需要查找的文件夹 |
| | | |
| | | userRankingsService.uploadFile(file); |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("图片上传成功")); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "batchUpShowID") |
| | | public void batchUpShowID(AdminAcceptData acceptData,PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | File file = new File("E:\\idtest\\IDS.txt");//Text文件 |
| | | |
| | | userRankingsService.updateShowID(file); |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功")); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "batchUpNickName") |
| | | public void batchUpNickName(AdminAcceptData acceptData,PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | File file = new File("E:\\idtest\\Names.txt");//Text文件 |
| | | |
| | | userRankingsService.batchUpNickName(file); |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功")); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("图片上传失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "downPic") |
| | | public void downPic(AdminAcceptData acceptData,PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | List<ShamUser> list = shamUserService.findShamUserList(100000); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(0, 10000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(10000, 20000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(20000, 30000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(30000, 40000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(40000, 50000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(50000, 60000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(60000, 70000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(70000, 80000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(80000, 90000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | /* 读入TXT文件 */ |
| | | String pathname = "E:\\name.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writename = new File(pathname); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outWriter; |
| | | |
| | | outWriter = new BufferedWriter(new FileWriter(writename)); |
| | | |
| | | /* 读入TXT文件 */ |
| | | String pathID = "E:\\id.txt"; // 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径 |
| | | File writeID = new File(pathID); // 要读取以上路径的input。txt文件 |
| | | |
| | | BufferedWriter outID = new BufferedWriter(new FileWriter(writeID)); |
| | | List<ShamUser> subList = list.subList(90000, 100000); |
| | | for (ShamUser shamUser : subList) { |
| | | String picUrl = shamUser.getPicUrl(); |
| | | if (!StringUtil.isNullOrEmpty(picUrl)) { |
| | | long id = shamUser.getId(); |
| | | String path = "E:/test/" + id + ".jpg"; |
| | | // 下载图片 |
| | | downloadPicture(picUrl, path); |
| | | // 下载文字 |
| | | outID.write(id + "\r\n"); |
| | | outWriter.write(shamUser.getName() + "\r\n"); |
| | | } |
| | | } |
| | | outID.flush();// 把缓存区内容压入文件 |
| | | outID.close(); // 最后记得关闭文件 |
| | | |
| | | outWriter.flush(); // 把缓存区内容压入文件 |
| | | outWriter.close(); // 最后记得关闭文件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("下载成功")); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | //链接url下载图片 |
| | | private void downloadPicture(String picUrl,String path) { |
| | | URL url = null; |
| | | try { |
| | | url = new URL(picUrl); |
| | | |
| | | DataInputStream dataInputStream = new DataInputStream(url.openStream()); |
| | | |
| | | FileOutputStream fileOutputStream = new FileOutputStream(new File(path)); |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | |
| | | byte[] buffer = new byte[1024]; |
| | | int length; |
| | | |
| | | while ((length = dataInputStream.read(buffer)) > 0) { |
| | | output.write(buffer, 0, length); |
| | | } |
| | | fileOutputStream.write(output.toByteArray()); |
| | | dataInputStream.close(); |
| | | fileOutputStream.close(); |
| | | |
| | | } catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |