|
|
@@ -1,10 +1,12 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
import com.mokamrp.privates.entity.EditHandle;
|
|
|
import com.mokamrp.privates.entity.pangu.FosterwxMobilePoolHandle;
|
|
|
+import com.mokamrp.privates.entity.pangu.TyperBean;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxFlowList;
|
|
|
@@ -13,8 +15,9 @@ import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxFlowListService;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -24,9 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -50,6 +51,9 @@ public class FosterwxMobilePoolController extends BaseController<FosterwxMobileP
|
|
|
@Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
+ @Value("${typer.url}")
|
|
|
+ private String domain;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -110,10 +114,37 @@ public class FosterwxMobilePoolController extends BaseController<FosterwxMobileP
|
|
|
@PostMapping("/loadInTyper")
|
|
|
public Object loadInTyper(@Valid @RequestBody EditHandle<FosterwxMobilePool> editHandle) {
|
|
|
List<FosterwxMobilePool> fosterwxMobilePoolList = fosterwxMobilePoolService.list(new LambdaQueryWrapper<FosterwxMobilePool>().in(FosterwxMobilePool::getId, editHandle.getIds().split(",")));
|
|
|
+ List<TyperBean> typerBeans = new ArrayList<>();
|
|
|
+
|
|
|
+ fosterwxMobilePoolList.forEach(fosterwxMobilePool -> {
|
|
|
+ TyperBean typerBean = new TyperBean();
|
|
|
+ typerBean.setHera_id(fosterwxMobilePool.getId());
|
|
|
+ typerBean.setQrcode_id(fosterwxMobilePool.getPoolIndex());
|
|
|
+ typerBean.setSite_id(String.valueOf(fosterwxMobilePool.getStationId()));
|
|
|
+ typerBean.setQw_appid(fosterwxMobilePool.getWxAppid());
|
|
|
+ typerBean.setSite_tel(fosterwxMobilePool.getMobileNo());
|
|
|
+ typerBean.setCode_url(fosterwxMobilePool.getCodeUrl());
|
|
|
+ typerBean.setThreshold(Integer.valueOf(fosterwxMobilePool.getMaxFans()));
|
|
|
+ typerBean.setCustomer_tel(fosterwxMobilePool.getBusMobileNo());
|
|
|
+ typerBean.setStatus(0 == fosterwxMobilePool.getStatus() ? 2 : 1);
|
|
|
+
|
|
|
+ typerBeans.add(typerBean);
|
|
|
+ });
|
|
|
|
|
|
- ResponseEntity<String> result = restTemplate.exchange("", HttpMethod.POST, null, String.class);
|
|
|
+ Map<String, Object> body = new HashMap<>(1);
|
|
|
+ body.put("data", typerBeans);
|
|
|
+ HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(body, null);
|
|
|
+ JSONObject result = restTemplate.exchange(domain + "/poster/qrcode", HttpMethod.POST, httpEntity, JSONObject.class).getBody();
|
|
|
|
|
|
- return AjaxResult.success(result.getBody());
|
|
|
+ if (null != result) {
|
|
|
+ if ("200".equals(result.get("code"))) {
|
|
|
+ return AjaxResult.success(result.get("data").toString());
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(result.get("data").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error("划入失败!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|