| | |
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/upload")
|
| | | public class UploadController {
|
| | |
|
| | | @Resource
|
| | | private HongBaoService hongBaoService;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Resource
|
| | | private OrderProcessService orderProcessService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | |
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | // private static final String PAYSUCCESS = "支付成功";
|
| | | // private static final String ORDERCLOSE="订单关闭";
|
| | |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream,
|
| | | UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
|
| | | out.print(JsonUtil.loadTrueResult(uploadFilePath));
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream,
|
| | | UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk").getUrl();
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk")
|
| | | .getUrl();
|
| | | out.print(JsonUtil.loadTrueResult(uploadFilePath));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | | String date = TimeUtil.getyyyyMMdd(timeMillis);
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream,
|
| | | "section/" + date + "/" + timeMillis + "." + type).getUrl();
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, FilePathEnum.section.getPath() + timeMillis + "." + type).getUrl();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("original", file.getOriginalFilename());
|
| | | data.put("name", file.getOriginalFilename());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private void addOrder(List<TaoBaoOrder> orderList) {
|
| | | try {
|
| | | taoBaoOrderService.addTaoBaoOrderList(orderList);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | List<TaoBaoOrder> orders = map.get(key);
|
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue, key);
|
| | | // redis做频率限制
|
| | | if (Constant.IS_OUTNET) {
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key);
|
| | | try {
|
| | | // 6小时内不再处理
|
| | | if (Constant.IS_OUTNET) {
|
| | | redisManager.cacheCommonString(redisKey, "1", 60 * 60 * 6);
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "uploadOrder", method = RequestMethod.POST)
|
| | | public void uploadOrder(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | |
|
| | | if (file != null) {
|
| | | try {
|
| | | List<TaoBaoOrder> orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | orderProcessService.processOrder(TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList));
|
| | | // for(int i=0;i<orderList.size();i++)
|
| | | // {
|
| | | // if(!orderList.get(i).getOrderId().equalsIgnoreCase("229978886132510070")&&!orderList.get(i).getOrderId().equalsIgnoreCase("246314979024510070"))
|
| | | // {
|
| | | // orderList.remove(i--);
|
| | | // continue;
|
| | | // }
|
| | | //
|
| | | // }
|
| | | // orderProcessService.processOrder(TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList));
|
| | | addOrder(orderList);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult(e.getMessage()));
|
| | |
| | |
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 新后台端 上传订单文件
|
| | | * @param file excel文件
|
| | | * @param uid 当前用户id
|
| | | * |
| | | * @param file
|
| | | * excel文件
|
| | | * @param uid
|
| | | * 当前用户id
|
| | | * @param request
|
| | | * @param response
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadOrderFile")
|
| | | public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, Long uid,
|
| | | HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
|
| | | |
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | |
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户验证未通过"));
|
| | | return;
|
| | | }
|
| | | |
| | | public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | |
|
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<TaoBaoOrder> orderList = null ;
|
| | |
|
| | | List<TaoBaoOrder> orderList = null;
|
| | | try {
|
| | | orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | out.print(JsonUtil.loadTrueResult("上传成功,系统正在处理中..."));
|
| | |
| | | out.print(JsonUtil.loadFalseResult("上传文件失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | final List<TaoBaoOrder> list = orderList;
|
| | | |
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | |
| | |
|
| | | orderProcessService.processOrder(TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(list));
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | |
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 上传图片jsonp
|
| | | * @param file |
| | | * @param out |
| | | * |
| | | * @param file
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadPicture")
|
| | | public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, Long uid, |
| | | HttpServletResponse response, PrintWriter out) {
|
| | | |
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | |
|
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("当前账户验证失败"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl=FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
|
| | |
| | | data.put("type", "." + type);
|
| | | data.put("state", "SUCCESS");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("上传图片失败"));
|
| | | e.printStackTrace();
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "installPackage")
|
| | | public void installPackage(@RequestParam("file") CommonsMultipartFile file, Long uid, |
| | | HttpServletResponse response, PrintWriter out) {
|
| | | |
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | |
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("当前账户验证失败"));
|
| | | return;
|
| | | }
|
| | | public void installPackage(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | |
|
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件为空"));
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
|
| | | String fileUrl= FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
|
| | |
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
|