|
|
@@ -1,7 +1,11 @@
|
|
|
package com.uas.platform.b2b.controller;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -13,6 +17,7 @@ import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
|
|
|
@@ -25,6 +30,7 @@ import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.platform.b2b.service.EnterpriseService;
|
|
|
import com.uas.platform.b2b.service.MonthProdioService;
|
|
|
import com.uas.platform.b2b.service.UserService;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
|
|
|
/**
|
|
|
* 对外公开的资料查询接口
|
|
|
@@ -44,7 +50,7 @@ public class PublicQueryController {
|
|
|
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private MonthProdioService monthProdIoService;
|
|
|
|
|
|
@@ -57,17 +63,21 @@ public class PublicQueryController {
|
|
|
@RequestMapping(value = "/members", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@ResponseStatus(value = HttpStatus.OK)
|
|
|
- public ModelMap queryEnterprise(String name, String shortName, Long uu) throws UnsupportedEncodingException {
|
|
|
+ public ModelMap queryEnterprise(String name, String shortName, Long uu)
|
|
|
+ throws UnsupportedEncodingException {
|
|
|
ModelMap returnMap = new ModelMap();
|
|
|
if (!StringUtils.isEmpty(name)) {
|
|
|
- List<Enterprise> enterprises = enterpriseService.findByName(SearchKeyUtils.decodeURL(name));
|
|
|
+ List<Enterprise> enterprises = enterpriseService
|
|
|
+ .findByName(SearchKeyUtils.decodeURL(name));
|
|
|
if (!CollectionUtils.isEmpty(enterprises))
|
|
|
returnMap.put("name", QueriableMember.getMembers(enterprises));
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(shortName)) {
|
|
|
- Set<Enterprise> enterprises = enterpriseService.findByShortName(SearchKeyUtils.decodeURL(shortName));
|
|
|
+ Set<Enterprise> enterprises = enterpriseService
|
|
|
+ .findByShortName(SearchKeyUtils.decodeURL(shortName));
|
|
|
if (!CollectionUtils.isEmpty(enterprises))
|
|
|
- returnMap.put("shortName", QueriableMember.getMembers(enterprises));
|
|
|
+ returnMap.put("shortName",
|
|
|
+ QueriableMember.getMembers(enterprises));
|
|
|
}
|
|
|
if (uu != null) {
|
|
|
Enterprise enterprise = enterpriseService.findById(uu);
|
|
|
@@ -77,6 +87,39 @@ public class PublicQueryController {
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按企业名称企业UU号,全名匹配
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/batch/members", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> queryEnterprises(
|
|
|
+ @RequestParam("data") String data)
|
|
|
+ throws UnsupportedEncodingException {
|
|
|
+ if (!StringUtils.isEmpty(data)) {
|
|
|
+ List<String> accounts = null;
|
|
|
+ data = SearchKeyUtils.decodeURL(data);
|
|
|
+ // 多个
|
|
|
+ if (data.startsWith("[")) {
|
|
|
+ accounts = FlexJsonUtils.fromJsonArray(data, String.class);
|
|
|
+ } else {// 单个
|
|
|
+ accounts = new ArrayList<String>();
|
|
|
+ accounts.add(FlexJsonUtils.fromJson(data, String.class));
|
|
|
+ }
|
|
|
+ List<Object[]> backInfo = enterpriseService
|
|
|
+ .findByEnNames(accounts);
|
|
|
+ System.out.println(FlexJsonUtils.toJson(backInfo));
|
|
|
+ Map<String, Object> infos = new HashMap<String, Object>();
|
|
|
+ for (Object[] objs : backInfo) {
|
|
|
+ infos.put(objs[1].toString(), objs[0]);
|
|
|
+ }
|
|
|
+ return infos;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按UU号查找企业信息
|
|
|
*
|
|
|
@@ -100,7 +143,8 @@ public class PublicQueryController {
|
|
|
@RequestMapping(value = "/members/{enUU}/users/{userUU}", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@ResponseStatus(value = HttpStatus.OK)
|
|
|
- public QueriableUser getUser(@PathVariable("enUU") Long enUU, @PathVariable("userUU") Long userUU) {
|
|
|
+ public QueriableUser getUser(@PathVariable("enUU") Long enUU,
|
|
|
+ @PathVariable("userUU") Long userUU) {
|
|
|
User user = userService.findUserByEnUUAndUserUU(enUU, userUU);
|
|
|
if (user != null)
|
|
|
return new QueriableUser(user);
|
|
|
@@ -121,8 +165,10 @@ public class PublicQueryController {
|
|
|
|
|
|
@RequestMapping(value = "/search", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public JSONObject getMonthProdio(Long month, String brand, String vendor,String date) {
|
|
|
- JSONObject json=monthProdIoService.getMonthProdio(month, brand, vendor ,date);
|
|
|
+ public JSONObject getMonthProdio(Long month, String brand, String vendor,
|
|
|
+ String date) {
|
|
|
+ JSONObject json = monthProdIoService.getMonthProdio(month, brand,
|
|
|
+ vendor, date);
|
|
|
return json;
|
|
|
}
|
|
|
}
|