123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package com.ruixuan.isc.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.ruixuan.common.utils.Check;
- import com.ruixuan.isc.service.IKwaiJSTService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @RestController
- @Api(tags = "聚水潭")
- @RequestMapping("/kwaixiaodian/jst")
- public class KwaiJSTController {
- @Autowired
- private IKwaiJSTService kwaiJSTService;
- static ExecutorService cleanService = Executors.newFixedThreadPool(2);
- static ExecutorService cleanCostService = Executors.newFixedThreadPool(2);
- @GetMapping(value = "/refreshToken")
- @ApiOperation(value = "refreshToken")
- public JSONObject refreshToken() {
- return kwaiJSTService.refreshToken();
- }
- @PostMapping(value = "/costDetail")
- public JSONObject costDetail(@RequestBody JSONObject requestJson) {
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(requestJson)) {
- throw new Exception("请输入参数");
- }
- String skuNick = requestJson.getString("skuNick");
- if (Check.isNull(skuNick)) {
- throw new Exception("请输入sku");
- }
- Integer dataType = requestJson.getInteger("dataType");
- if (Check.isNull(dataType)) {
- throw new Exception("请输入dataType");
- }
- Long date = requestJson.getLong("date");
- if (Check.isNull(date)) {
- throw new Exception("请输入date");
- }
- cleanService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- kwaiJSTService.costDetail(skuNick, dataType, date);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 200);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @PostMapping(value = "/cleanCost")
- public JSONObject cleanCost(@RequestBody JSONObject requestJson) {
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(requestJson)) {
- throw new Exception("请输入参数");
- }
- String skuNick = requestJson.getString("skuNick");
- if (Check.isNull(skuNick)) {
- throw new Exception("请输入sku");
- }
- cleanCostService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- kwaiJSTService.cleanCost(skuNick);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 200);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- /**
- * https://openweb.jushuitan.com/dev-doc?docType=2&docId=14
- * 普通商品资料查询(按sku查询) + 组合装商品查询
- * 对应数据表:ruixuan.kwaixiaodian_jst
- */
- @GetMapping(value = "/queryAndInsertSku")
- @ApiOperation(value = "普通商品资料查询(按sku查询)+组合装商品查询")
- public void queryAndInsertSku(@ApiParam("时间") @RequestParam(value = "date", required = false) String date) {
- // List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes("2024-01-01", "2024-11-25");
- // allDatesOfTwoTimes.forEach(dates -> dateService.submit(() -> {
- try {
- // Thread.sleep(5000L);
- kwaiJSTService.queryAndInsertSku(date);
- } catch (Exception e) {
- e.printStackTrace();
- }
- // }));
- }
- /**
- * https://openweb.jushuitan.com/dev-doc?docType=6&docId=26
- * 采购单查询
- * 对应数据表:ruixuan.kwaixiaodian_jst_purchase、kwaixiaodian_jst_purchase_item
- */
- @GetMapping(value = "/queryAndInsertPurchase")
- @ApiOperation(value = "采购单查询")
- public void queryAndInsertPurchase(@ApiParam("时间") @RequestParam(value = "date", required = false) String date) {
- try {
- kwaiJSTService.queryAndInsertPurchase(date);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|