|
|
@@ -1,6 +1,8 @@
|
|
|
package com.qlm.controller.jinzai;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -19,6 +21,7 @@ import com.jfinal.weixin.sdk.api.JsTicket;
|
|
|
import com.jfinal.weixin.sdk.api.JsTicketApi;
|
|
|
import com.jfinal.weixin.sdk.api.JsTicketApi.JsApiType;
|
|
|
import com.qlm.annotation.RequestUrl;
|
|
|
+import com.qlm.log.Log;
|
|
|
import com.qlm.tools.WxUtil;
|
|
|
import com.qlm.tools.ip.CityInfo;
|
|
|
import com.qlm.tools.ip.IpAddressUtil;
|
|
|
@@ -33,7 +36,9 @@ public class MobileController extends Controller{
|
|
|
}
|
|
|
@Clear
|
|
|
public void search(){
|
|
|
- String code = getPara("code");
|
|
|
+ String code = getPara("code","");
|
|
|
+
|
|
|
+
|
|
|
|
|
|
String latitude = getPara("latitude");
|
|
|
|
|
|
@@ -90,9 +95,96 @@ public class MobileController extends Controller{
|
|
|
.set("ip", ipAddress).set("location", locationProvince+locationCity);
|
|
|
Record result = new Record();
|
|
|
boolean cuan = true;
|
|
|
- Record jinzai_upload_child = Db.findFirst("select * from jinzai_upload_child where child_code = ?",code);
|
|
|
- if(jinzai_upload_child!=null){
|
|
|
- String master_code = jinzai_upload_child.getStr("master_code");
|
|
|
+ boolean isThird = false;
|
|
|
+ if(code.length() ==14){//易码
|
|
|
+ try{
|
|
|
+ isThird = true;
|
|
|
+ String jsonData = HttpKit.get("http://saas.ymbs.com.cn/ccn/sk-warehouse-out/scanCode/"+code);
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(jsonData);
|
|
|
+
|
|
|
+ JSONObject data = parseObject.getJSONObject("data");
|
|
|
+
|
|
|
+ String distributorName = data.getString("distributorName");
|
|
|
+
|
|
|
+ String operateDate = data.getString("operateDate");
|
|
|
+ String salesTerritory = data.getString("salesTerritory");
|
|
|
+
|
|
|
+
|
|
|
+ String productName = data.getString("productName");
|
|
|
+
|
|
|
+ result.set("pinxiang", productName);
|
|
|
+ Record fahuoInfo = new Record();
|
|
|
+ fahuoInfo.set("DeliveryTime", operateDate).set("CustomerName", distributorName);
|
|
|
+
|
|
|
+ Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where jxs = ?",distributorName);
|
|
|
+
|
|
|
+ if(jxsInfo != null){
|
|
|
+ String saleCity = jxsInfo.getStr("city");
|
|
|
+ String saleProvince = jxsInfo.getStr("province");
|
|
|
+
|
|
|
+ if(saleCity.equals(compareCity)){
|
|
|
+ cuan = false;
|
|
|
+ }
|
|
|
+ result.set("saleLocation", saleProvince+saleCity);
|
|
|
+
|
|
|
+ searchInfo.set("kehu", saleProvince+saleCity);
|
|
|
+ result.set("fahuoInfo", fahuoInfo);
|
|
|
+ status = true;
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ Log.info("em接口查询失败,"+code);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if(code.length() == 21){
|
|
|
+ try{
|
|
|
+ isThird = true;
|
|
|
+ Map<String,String> header =new HashMap<String,String>();
|
|
|
+ header.put("content-type", "application/json;charset=UTF-8");
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("code", code);
|
|
|
+ obj.put("latitude", 34.16559);
|
|
|
+
|
|
|
+ obj.put("longitude", 112.824936);
|
|
|
+ String jsonData = HttpKit.post("https://jinzai.oklinklink.com/api/trace/inspect/customer/find",obj.toJSONString(),header);
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(jsonData);
|
|
|
+
|
|
|
+ JSONObject data = parseObject.getJSONObject("data");
|
|
|
+
|
|
|
+ String distributorName = data.getString("bizCorpName");
|
|
|
+
|
|
|
+ String operateDate = data.getString("billTime");
|
|
|
+
|
|
|
+
|
|
|
+ String productName = data.getString("productName");
|
|
|
+
|
|
|
+ result.set("pinxiang", productName);
|
|
|
+ Record fahuoInfo = new Record();
|
|
|
+ fahuoInfo.set("DeliveryTime", operateDate).set("CustomerName", distributorName);
|
|
|
+
|
|
|
+ Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where jxs = ?",distributorName);
|
|
|
+
|
|
|
+ if(jxsInfo != null){
|
|
|
+ String saleCity = jxsInfo.getStr("city");
|
|
|
+ String saleProvince = jxsInfo.getStr("province");
|
|
|
+
|
|
|
+ if(saleCity.equals(compareCity)){
|
|
|
+ cuan = false;
|
|
|
+ }
|
|
|
+ result.set("saleLocation", saleProvince+saleCity);
|
|
|
+
|
|
|
+ searchInfo.set("kehu", saleProvince+saleCity);
|
|
|
+ result.set("fahuoInfo", fahuoInfo);
|
|
|
+ status = true;
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ Log.info("em接口查询失败,"+code);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }else if(code.length() == 22){
|
|
|
+ String master_code = code;
|
|
|
Record masterInfo = Db.findFirst("select * from jinzai_upload_master where id = ?",master_code);
|
|
|
|
|
|
String pinxiang = masterInfo.getStr("pinxiang");
|
|
|
@@ -125,18 +217,77 @@ public class MobileController extends Controller{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ else{
|
|
|
+ Record jinzai_upload_child = Db.findFirst("select * from jinzai_upload_child where child_code = ?",code);
|
|
|
+ if(jinzai_upload_child!=null){
|
|
|
+ String master_code = jinzai_upload_child.getStr("master_code");
|
|
|
+ Record masterInfo = Db.findFirst("select * from jinzai_upload_master where id = ?",master_code);
|
|
|
+
|
|
|
+ String pinxiang = masterInfo.getStr("pinxiang");
|
|
|
+ result.set("pinxiang", pinxiang);
|
|
|
+ searchInfo.set("product_name", pinxiang);
|
|
|
+ if(!WxUtil.isNull(master_code)){
|
|
|
+ status = true;
|
|
|
+ Record fahuoInfo = Db.findFirst("select * from deliveryorders where CaseCode =?",master_code);
|
|
|
+ if(fahuoInfo != null){
|
|
|
+ String CustomerNo = fahuoInfo.getStr("CustomerNo");
|
|
|
+
|
|
|
+ String ProductName = fahuoInfo.getStr("ProductName");
|
|
|
+
|
|
|
+ Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where code = ?",CustomerNo);
|
|
|
+ if(jxsInfo != null){
|
|
|
+ String saleCity = jxsInfo.getStr("city");
|
|
|
+ String saleProvince = jxsInfo.getStr("province");
|
|
|
+
|
|
|
+ if(saleCity.equals(compareCity)){
|
|
|
+ cuan = false;
|
|
|
+ }
|
|
|
+ result.set("saleLocation", saleProvince+saleCity);
|
|
|
+
|
|
|
+ searchInfo.set("kehu", saleProvince+saleCity);
|
|
|
+ result.set("fahuoInfo", fahuoInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if(cuan){
|
|
|
searchInfo.set("status", 0);
|
|
|
}else{
|
|
|
searchInfo.set("status", 1);
|
|
|
}
|
|
|
- Db.save("t_jz_searchrecord", searchInfo);
|
|
|
+ if(!isThird){
|
|
|
+ Db.save("t_jz_searchrecord", searchInfo);
|
|
|
+ }
|
|
|
+
|
|
|
result.set("status", status).set("msg", msg).set("cuan", cuan).set("location", compareProvice+compareCity);
|
|
|
renderJson(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1是我们自己的
|
|
|
+ * 2是易码
|
|
|
+ * 3是爱创
|
|
|
+ * @param code
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private int codeType(String code) {
|
|
|
+ if(code.length() == 14){
|
|
|
+ return 3;
|
|
|
+ }
|
|
|
+ if(code.length() == 22){
|
|
|
+
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
private static CityInfo getInfo(String latitude,String longitude){
|
|
|
if(latitude == null || longitude == null){
|
|
|
return null;
|