|
@@ -0,0 +1,183 @@
|
|
|
+package io.platform.app.web.controller;
|
|
|
+
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import io.platform.app.web.query.AgentLongQuery;
|
|
|
+import io.platform.app.web.query.QueryAgentStock;
|
|
|
+import io.platform.app.web.query.QueryAppAgentStock;
|
|
|
+import io.platform.base.common.annotation.CountUse;
|
|
|
+import io.platform.base.common.annotation.SysLog;
|
|
|
+import io.platform.base.common.utils.R;
|
|
|
+import io.platform.base.common.utils.StringUtils;
|
|
|
+import io.platform.store.dto.BizBasicMsgDto;
|
|
|
+import io.platform.store.dto.BizStoreAgentDto;
|
|
|
+import io.platform.store.dto.QueryAgentStockDto;
|
|
|
+import io.platform.store.dto.StoreAgentBrandLvDto;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/appAgent")
|
|
|
+public class AppAgentController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Value("${QueryAgentStock}")
|
|
|
+ private String QueryAgentStock;
|
|
|
+ @Value("${clientBasicMsg}")
|
|
|
+ private String clientBasicMsg;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AppAgentServiceRemote appAgentServiceRemote;
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 通商APP-首页轮播图接口
|
|
|
+// */
|
|
|
+// @CountUse(fundesc = "通商APP-首页轮播图",username = "username")
|
|
|
+// @RequestMapping("/getAgentBanner")
|
|
|
+// @ResponseBody
|
|
|
+// public R getAgentBanner(@RequestBody Map<String,Object> map){
|
|
|
+// if (map.get("KUNNR") == null){
|
|
|
+// return R.error("没有接收到参数");
|
|
|
+// }
|
|
|
+// return R.ok().put("agentBanner",appAgentServiceRemote.selectAgentBanner(map));
|
|
|
+// }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 通商APP-首页跑马灯连接
|
|
|
+// */
|
|
|
+// @CountUse(fundesc = "通商APP-首页跑马灯连接",username = "username")
|
|
|
+// @RequestMapping("/getAgentMessage")
|
|
|
+// @ResponseBody
|
|
|
+// public R getAgentMessage(@RequestParam Integer contentType){
|
|
|
+// if (contentType == null){
|
|
|
+// return R.error("没有接收到参数");
|
|
|
+// }
|
|
|
+// return R.ok().put("agentBanner",appAgentServiceRemote.selectAgentMessage(contentType));
|
|
|
+// }
|
|
|
+
|
|
|
+ @CountUse(fundesc = "通商APP首页-经销商信息",username = "username")
|
|
|
+ @SysLog("通商APP首页-获取经销商信息")
|
|
|
+ @RequestMapping("/getClientBasicMsg")
|
|
|
+ @ResponseBody
|
|
|
+ public R getClientBasicMsg(@RequestBody AgentLongQuery agentLongQuery) {
|
|
|
+ String postResposts = "";
|
|
|
+ BizBasicMsgDto bizBasicMsgDto = new BizBasicMsgDto();
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("token", agentLongQuery.getToken());
|
|
|
+ try {
|
|
|
+ long startDate = System.currentTimeMillis();
|
|
|
+ logger.info("开始调用B2B获取经销商信息接口" + startDate);
|
|
|
+ postResposts = HttpUtil.post(clientBasicMsg, map);
|
|
|
+ bizBasicMsgDto = JSON.parseObject(postResposts, BizBasicMsgDto.class);
|
|
|
+ logger.info("调用B2B获取经销商信息接口结束耗时为" + (System.currentTimeMillis() - startDate));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (bizBasicMsgDto.getCode()==1){
|
|
|
+ return R.ok().put("data", bizBasicMsgDto);
|
|
|
+ }else {
|
|
|
+ return R.error().put("data","查询经销商信息有误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @CountUse(fundesc = "通商APP首页-经销商查询旗下门店进货量",username = "username")
|
|
|
+ @SysLog("通商APP首页-经销商查询旗下门店进货量")
|
|
|
+ @RequestMapping("/agentSelectStoreRecord")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> agentSelectStoreRecord(@RequestBody BizStoreAgentDto bizStoreAgentDto) {
|
|
|
+ Map selectStoreRecord = appAgentServiceRemote.agentSelectStoreRecord(bizStoreAgentDto);
|
|
|
+ return selectStoreRecord;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SysLog("通商APP-经销商库存")
|
|
|
+ @PostMapping("/getAgentStock")
|
|
|
+ @ResponseBody
|
|
|
+ public R getAgentStock(@RequestBody QueryAppAgentStock queryAppAgentStock){
|
|
|
+ QueryAgentStockDto.Data queryAgentStockData = new QueryAgentStockDto.Data();
|
|
|
+ List<String> brands = new ArrayList<>();
|
|
|
+ List<String> patterns = new ArrayList<>();
|
|
|
+ List<String> specs = new ArrayList<>();
|
|
|
+ List<Integer> stocks = new ArrayList<>();
|
|
|
+ List<QueryAgentStockDto.Data.stockList> stockLists = new ArrayList<>();
|
|
|
+ String s = JSONObject.toJSONString(queryAppAgentStock);
|
|
|
+ try {
|
|
|
+ String postman = HttpUtil.post(QueryAgentStock,s);
|
|
|
+ QueryAgentStockDto queryAgentStockDto = JSON.parseObject(postman,QueryAgentStockDto.class);
|
|
|
+ patterns.addAll(queryAgentStockDto.getData().getPatternList());
|
|
|
+ specs.addAll(queryAgentStockDto.getData().getSpecList());
|
|
|
+ stockLists.addAll(queryAgentStockDto.getData().getList());
|
|
|
+ stocks.add(queryAgentStockDto.getData().getStock());
|
|
|
+ return R.ok().put("data",queryAgentStockDto);
|
|
|
+ }catch (Exception e){
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SysLog("门店APP-门店查经销商库存")
|
|
|
+ @PostMapping("/getStoreAgentStock")
|
|
|
+ @ResponseBody
|
|
|
+ public R getStoreAgentStock(@RequestBody QueryAgentStock queryAgentStock){
|
|
|
+ List<Long> agentIdList = new ArrayList<>();
|
|
|
+// List<QueryAgentStockDto> queryAgentStockDtos = new ArrayList<>();
|
|
|
+ QueryAgentStockDto.Data queryAgentStockData = new QueryAgentStockDto.Data();
|
|
|
+ String postman = "";
|
|
|
+ QueryAgentStockDto queryAgentStockDto = new QueryAgentStockDto();
|
|
|
+ List<String> brands = new ArrayList<>();
|
|
|
+ List<String> patterns = new ArrayList<>();
|
|
|
+ List<String> specs = new ArrayList<>();
|
|
|
+ List<Integer> stocks = new ArrayList<>();
|
|
|
+ List<QueryAgentStockDto.Data.stockList> stockLists = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ List<StoreAgentBrandLvDto> bizStoreAgentDtoList = appAgentServiceRemote.selectAgency(queryAgentStock.getStoreId());
|
|
|
+ if (bizStoreAgentDtoList!=null && bizStoreAgentDtoList.size()>0){
|
|
|
+ for(StoreAgentBrandLvDto item : bizStoreAgentDtoList){
|
|
|
+ agentIdList.add(item.getAgentId());
|
|
|
+ }
|
|
|
+ agentIdList = agentIdList.stream().distinct().collect(Collectors.toList());
|
|
|
+ for(Long itemAgent : agentIdList){
|
|
|
+ List<StoreAgentBrandLvDto> storeBrands = appAgentServiceRemote.selectStoreBrand(queryAgentStock.getStoreId(),itemAgent);
|
|
|
+ if(storeBrands!=null && storeBrands.size()>0){
|
|
|
+ storeBrands = storeBrands.stream().distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ for(StoreAgentBrandLvDto itemBrand : storeBrands){
|
|
|
+ if(StringUtils.isNotEmpty(itemBrand.getBrand())){
|
|
|
+ String a = "000";
|
|
|
+ queryAgentStock.setKunnr(a+itemAgent.toString());
|
|
|
+ queryAgentStock.setBrand(itemBrand.getBrandCode());
|
|
|
+ String s = JSONObject.toJSONString(queryAgentStock);
|
|
|
+ postman = HttpUtil.post(QueryAgentStock,s);
|
|
|
+ brands.add(itemBrand.getBrandCode());
|
|
|
+
|
|
|
+ queryAgentStockDto = JSON.parseObject(postman,QueryAgentStockDto.class);
|
|
|
+ patterns.addAll(queryAgentStockDto.getData().getPatternList());
|
|
|
+ specs.addAll(queryAgentStockDto.getData().getSpecList());
|
|
|
+ stockLists.addAll(queryAgentStockDto.getData().getList());
|
|
|
+ stocks.add(queryAgentStockDto.getData().getStock());
|
|
|
+// queryAgentStockDtos.add(queryAgentStockDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer sum = 0;
|
|
|
+ for(Integer item : stocks){
|
|
|
+ sum+=item;
|
|
|
+ }
|
|
|
+ queryAgentStockData.setBrandList(brands);
|
|
|
+ queryAgentStockData.setPatternList(patterns);
|
|
|
+ queryAgentStockData.setSpecList(specs);
|
|
|
+ queryAgentStockData.setList(stockLists);
|
|
|
+ queryAgentStockData.setStock(sum);
|
|
|
+ }
|
|
|
+ return R.ok().put("data",queryAgentStockData);
|
|
|
+ }catch (Exception e){
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|