Procházet zdrojové kódy

Merge branch 'develop'

沈静伟 před 3 roky
rodič
revize
afba99cfc3

+ 11 - 0
src/dsb/com/cnd3b/common/BaseClass.java

@@ -166,6 +166,17 @@ public class BaseClass {
         return paoSetRemote;
     }
 
+    public ArrayList<Object> getP2FieldValues(PaoSetRemote paoSetRemote, String fieldname) throws P2Exception {
+        ArrayList<Object> list = new ArrayList<>();
+        int i = 0;
+        PaoRemote pao = null;
+        while ((pao = paoSetRemote.getPao(i)) != null) {
+            list.add(pao.getDatabaseValue(fieldname));
+            i++;
+        }
+        return list;
+    }
+
 
     public HashMap<String, PaoRemote> getPaoMap(PaoSetRemote paoSetRemote, String keyfieldname) throws P2Exception {
         HashMap<String, PaoRemote> map = new HashMap<>();

+ 1 - 1
src/dsb/com/cnd3b/common/D3BReturnObject_Suc.java

@@ -71,7 +71,7 @@ public class D3BReturnObject_Suc extends D3BReturnObject {
     }
 
     public D3BReturnObject_Suc setData(String data) {
-        this.put("msg", data);
+        this.put("data", data);
         return this;
     }
 

+ 23 - 1
src/dsb/com/cnd3b/common/data/Row.java

@@ -9,6 +9,7 @@ import org.dom4j.Element;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -48,13 +49,34 @@ public class Row extends HashMap<String, Object> {
         }
     }
 
+    public Float getFloat(String fieldname) {
+        Object object = getValueAsObject(fieldname);
+        if (object != null) {
+            if (object instanceof String) {
+                return Float.parseFloat(object.toString());
+            }
+            if (object instanceof Integer) {
+                return Float.valueOf((Integer) object);
+            }
+            if (object instanceof Long) {
+                return Float.valueOf((Long) object);
+            }
+            return (Float) object;
+        } else {
+            return 0F;
+        }
+    }
+
     public String getString(String fieldname) {
         Object object = getValueAsObject(fieldname);
         if (object == null || java.lang.String.valueOf(object).equalsIgnoreCase("null")) {
             return "";
         } else {
+            if (object instanceof Float || object instanceof Double) {
+                DecimalFormat df = new DecimalFormat("#");
+                return df.format(object);
+            }
             return java.lang.String.valueOf(object);
-
         }
     }
 

+ 4 - 1
src/dsb/com/cnd3b/common/data/db/DBConnect.java

@@ -4,9 +4,9 @@
 package com.cnd3b.common.data.db;
 
 import com.cnd3b.common.BaseClass;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
-import com.cnd3b.common.data.Row;
 import p2.p2server.P2Server;
 
 import java.sql.*;
@@ -110,6 +110,9 @@ public class DBConnect extends BaseClass {
                         case "smallint":
                             value = resultSet.getShort(colNameList.get(i));
                             break;
+                        case "float":
+                            value = resultSet.getFloat(colNameList.get(i));
+                            break;
                         case "numeric":
                             value = resultSet.getDouble(colNameList.get(i));
                             break;

+ 4 - 3
src/dsb/com/cnd3b/restcontroller/enterprise/webclient/workers/SQL/统计_经销商合伙人信息统计.sql

@@ -2,10 +2,11 @@ select t1.tagentsid,t1.fagentshortname,t2.fname as fsaler,t1.fprovince,t1.fcity,
        count(distinct t3.tagents_workersid)fworkercount,
        count(distinct t4.tagents_workersubmitid)fmonthsubmitcount,
        count(distinct t5.tagents_workersubmitid)fyearsubmitcount,
-       isnull(t3.fsubmitcount,0)as fsubmitcount from tagents t1
+       count(distinct t6.tagents_workersubmitid)as fsubmitcount from tagents t1
 left join tenterprise_users t2 on t1.siteid=t2.siteid and t1.fsaleruserid=t2.tenterprise_userid
 left join tagents_workers t3 on t1.siteid=t3.siteid and t1.tagentsid=t3.tagentsid and t3.fiscooperation=1
 left join tagents_workersubmit t4 on t1.siteid=t4.siteid and t1.tagentsid=t4.tagentsid and t4.fismodify=0 and convert(varchar(7),t4.createdate,120)=convert(varchar(7),GETDATE(),120)
 left join tagents_workersubmit t5 on t1.siteid=t5.siteid and t1.tagentsid=t5.tagentsid and t5.fismodify=0 and year(t5.createdate)=year(GETDATE())
-where t3.fsubmitcount>0 and t1.siteid=$siteid$
-group by t1.tagentsid,t1.fagentshortname,t2.fname,t1.fprovince,t1.fcity,t1.fcounty,t3.fsubmitcount
+left join tagents_workersubmit t6 on t1.siteid=t6.siteid and t1.tagentsid=t6.tagentsid and t6.fismodify=0
+where t1.siteid=$siteid$
+group by t1.tagentsid,t1.fagentshortname,t2.fname,t1.fprovince,t1.fcity,t1.fcounty

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/enterprise/webclient/workers/analysis.java

@@ -16,7 +16,7 @@ public class analysis extends Controller {
      * @return
      */
     public String worker_analysis(){
-        SQLFactory queryworker = new SQLFactory(this, "统计_经销商合伙人信息统计",pageSize,pageNumber,"t3.fsubmitcount desc");
+        SQLFactory queryworker = new SQLFactory(this, "统计_经销商合伙人信息统计",pageSize,pageNumber,"t1.tagentsid desc");
         queryworker.addParameter("siteid", siteid);
         Rows workerrows = dbConnect.runSqlQuery(queryworker.getSQL());
         return getSucReturnObject().setDataByPaging(workerrows).saveToDataPool().preloading(1).toString();

+ 11 - 0
src/dsb/com/cnd3b/service/MessageSendService.java

@@ -24,6 +24,7 @@ public class MessageSendService extends BaseClass implements Runnable {
                 message2(hour, minute);
                 message3(hour, minute);
                 message4(hour, minute);
+                messageClean();
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -85,4 +86,14 @@ public class MessageSendService extends BaseClass implements Runnable {
             message4_sendflag = true;
         }
     }
+
+    /**
+     * 系统消息清理
+     */
+    public void messageClean() {
+        //自动清理1月前的系统消息
+        new DBConnect().runSqlUpdate("delete from tmessage where DATEADD(MM,1, createdate)<GETDATE() and ftype='系统'");
+        //自动清理3月前的非系统消息
+        new DBConnect().runSqlUpdate("delete from tmessage where DATEADD(MM,3, createdate)<GETDATE() and ftype!='系统'");
+    }
 }

+ 8 - 5
src/dsb/com/cnd3b/service/SQL/失效账号查询.sql

@@ -3,10 +3,13 @@ from tenterprise_users t1
          inner join tenterprise t2 on t1.siteid = t2.siteid and (fenddate is null or fenddate > getdate())
          inner join tuserrequestlog t3 on t1.siteid=t3.siteid and t1.tenterprise_userid=t3.tenterprise_userid
          inner join tappmodelauth t5 on t1.siteid = t5.siteid and t5.fisdefault = 1
-         left join tpayinfo t6 on t1.siteid = t6.siteid and ((t1.fusertype = '经销商' and t1.tagentsid = t6.tagentsid) or
-                                                             (t1.fusertype = '企业' and t1.tenterprise_userid = t6.tenterprise_userid)) and
-                                  t6.fbegdate <= GETDATE() and t6.fenddate >= GETDATE()
-where t6.tpayinfoid IS null
-  and ((t1.fusertype = '经销商' and t5.fagentamount > 0) or
+where  ((t1.fusertype = '经销商' and t5.fagentamount > 0) or
        (t1.fusertype = '企业' and t5.fenterpriseuseramount > 0))
+       and exists(
+		   select siteid,tpayinfoid,tagentsid,tenterprise_userid from tpayinfo
+		   where (fbegdate > GETDATE() or fenddate < GETDATE()) and t1.siteid=tpayinfo.siteid and (
+		   (t1.fusertype = '经销商' and t1.tagentsid = tpayinfo.tagentsid) or
+                                                             (t1.fusertype = '企业' and t1.tenterprise_userid = tpayinfo.tenterprise_userid)
+		   )
+        )
 group by t1.tenterprise_userid  having max(t3.flastrequestdate)>DATEADD(DAY,-3, GETDATE())

+ 1 - 0
src/dsb/com/cnd3b/service/UserAutoLogOut.java

@@ -39,6 +39,7 @@ public class UserAutoLogOut extends BaseClass implements Runnable {
             if (parameter.userIdList.containsKey(userid)) {
                 String token = parameter.userIdList.get(userid).getString("token");
                 parameter.tokenlist.remove(token);
+                parameter.userIdList.remove(userid);
                 sqllist.add("update tenterprise_users set accesstoken=null where accesstoken='" + token + "'");
             }
         }

+ 29 - 24
src/dsb/com/cnd3b/utility/kujiale/kujiale.java

@@ -8,75 +8,78 @@ import com.cnd3b.utility.WebRequest;
 import java.util.ArrayList;
 
 public class kujiale {
-    private String appKey="";
-    private String appSecret="";
+    private String appKey = "";
+    private String appSecret = "";
 
-
-    public kujiale(String appKey,String appSecret){
-        this.appKey=appKey;
-        this.appSecret=appSecret;
+    public kujiale(String appKey, String appSecret) {
+        this.appKey = appKey;
+        this.appSecret = appSecret;
     }
 
     /**
      * 获取用户列表
+     *
      * @param start
      * @param num
      */
-    public  void getUserList(int start,int num) {
+    public void getUserList(int start, int num) {
         final long timestamp = System.currentTimeMillis();
         // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
         Encryption encryption = new Encryption();
         final String sign = encryption.Encode_MD5(this.appSecret + this.appKey + timestamp);
         WebRequest webRequest = new WebRequest();
-        String a = webRequest.doGet("https://openapi.kujiale.com/v2/user?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start="+start+"&num="+num);
+        String a = webRequest.doGet("https://openapi.kujiale.com/v2/user?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num);
         System.err.println(a);
     }
 
     /**
      * 获取方案分类列表
+     *
      * @param start
      * @param num
      * @param appuid
      */
-    public void getClassList(int start,int num,String appuid) {
+    public void getClassList(int start, int num, String appuid) {
         final long timestamp = System.currentTimeMillis();
         // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
         Encryption encryption = new Encryption();
-        final String sign = encryption.Encode_MD5(appSecret + appKey +appuid+ timestamp);
+        final String sign = encryption.Encode_MD5(appSecret + appKey + appuid + timestamp);
         WebRequest webRequest = new WebRequest();
-        String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/tag/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start="+start+"&num="+num+"&appuid="+appuid);
+        String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/tag/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&appuid=" + appuid);
         System.err.println(a);
     }
 
     /**
      * 获取用户方案
+     *
      * @param start
      * @param num
      * @param appuid
      */
-    public void getDesignList(int start,int num,String appuid) {
+    public void getDesignList(int start, int num, String appuid) {
         final long timestamp = System.currentTimeMillis();
         // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
         Encryption encryption = new Encryption();
-        final String sign = encryption.Encode_MD5(appSecret + appKey +appuid+ timestamp);
+        final String sign = encryption.Encode_MD5(appSecret + appKey + appuid + timestamp);
         WebRequest webRequest = new WebRequest();
-        String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start="+start+"&num="+num+"&appuid="+appuid);
+        String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&appuid=" + appuid);
         System.err.println(a);
     }
 
     /**
      * 获取用户方案渲染图
+     *
      * @param start
      * @param num
      * @param design_id
      */
-    public void getDesignRender(int start,int num,String design_id) {
+    public void getDesignRender(int start, int num, String design_id) {
         final long timestamp = System.currentTimeMillis();
         // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
         Encryption encryption = new Encryption();
         final String sign = encryption.Encode_MD5(appSecret + appKey + timestamp);
         WebRequest webRequest = new WebRequest();
-        String a = webRequest.doGet("https://openapi.kujiale.com/v2/renderpic/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start="+start+"&num="+num+"&design_id="+design_id);
+        String a = webRequest.doGet("https://openapi.kujiale.com/v2/renderpic/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&design_id=" + design_id);
         System.err.println(a);
     }
 
@@ -94,24 +97,26 @@ public class kujiale {
 //        String a = webRequest.doGet("https://openapi.kujiale.com/v2/pano/roam/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign+"&appuid="+appuid +"&design_id="+design_id);
 //        System.err.println(a);
 //    }
+
     /**
      * 创建全屋漫游链接
+     *
      * @param picIds
      */
-    public void createDesignRoam(ArrayList<String>picIds) {
+    public void createDesignRoam(ArrayList<String> picIds) {
         final long timestamp = System.currentTimeMillis();
         // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
         Encryption encryption = new Encryption();
         final String sign = encryption.Encode_MD5(appSecret + appKey + timestamp);
         WebRequest webRequest = new WebRequest();
 
-        JSONObject requestObject=new JSONObject();
-        requestObject.put("override",false);
-        JSONArray picIdsArray=new JSONArray();
+        JSONObject requestObject = new JSONObject();
+        requestObject.put("override", false);
+        JSONArray picIdsArray = new JSONArray();
         picIdsArray.addAll(picIds);
-        requestObject.put("picIds",picIdsArray);
+        requestObject.put("picIds", picIdsArray);
         System.err.println(requestObject.toJSONString());
-        String a = webRequest.doPostKuJiaLe(requestObject.toJSONString(),"https://openapi.kujiale.com/v2/renderpic/pano?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign);
+        String a = webRequest.doPostKuJiaLe(requestObject.toJSONString(), "https://openapi.kujiale.com/v2/renderpic/pano?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign);
         System.err.println(a);
     }
 
@@ -123,12 +128,12 @@ public class kujiale {
 //        new kujiale(appKey,appSecret).getDesignList(0,10,"102415");
 //        new kujiale(appKey,appSecret).getDesignRender(0,10,"3FO49BG1RTW7");
 //        new kujiale(appKey,appSecret).getDesignRoam("102415","3FO49BG1RTW7");
-        ArrayList<String>list =new ArrayList<>();
+        ArrayList<String> list = new ArrayList<>();
         list.add("3FNYSU9NDR0R");
         list.add("3FNYSUBGODHE");
         list.add("3FNYYJ5N2WH1");
         list.add("3FNYYJ63OGMH");
-        new kujiale(appKey,appSecret).createDesignRoam(list);
+        new kujiale(appKey, appSecret).createDesignRoam(list);
 
     }
 

+ 172 - 0
src/dsb/com/cnd3b/utility/obs/BucketTest.java

@@ -0,0 +1,172 @@
+package com.cnd3b.utility.obs;
+
+import com.cnd3b.common.parameter.parameter;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BucketTest {
+    protected String bucketname;
+    ObsClient obsClient;
+
+    public BucketTest(String siteid) {
+        // 创建ObsClient实例
+        obsClient = new ObsClient("EKJMDXUVJLBGDRCVVVLP", "9EUAXeFmxKjJ5x12lYVTzCCUuIQIjrO6VAyzGr9u", "obs.cn-east-2.myhuaweicloud.com");
+        this.bucketname = siteid.toLowerCase();
+        //a();
+    }
+
+    public void setBucketCors() {
+        BucketCors cors = new BucketCors();
+
+        List<BucketCorsRule> rules = new ArrayList<BucketCorsRule>();
+        BucketCorsRule rule = new BucketCorsRule();
+
+        ArrayList<String> allowedOrigin = new ArrayList<String>();
+// 指定允许跨域请求的来源
+        allowedOrigin.add("*");
+        rule.setAllowedOrigin(allowedOrigin);
+
+        ArrayList<String> allowedMethod = new ArrayList<String>();
+// 指定允许的跨域请求方法(GET/PUT/DELETE/POST/HEAD)
+        allowedMethod.add("GET");
+        allowedMethod.add("HEAD");
+        allowedMethod.add("PUT");
+        allowedMethod.add("POST");
+        allowedMethod.add("DELETE");
+        rule.setAllowedMethod(allowedMethod);
+
+        ArrayList<String> allowedHeader = new ArrayList<String>();
+// 控制在OPTIONS预取指令中Access-Control-Request-Headers头中指定的header是否被允许使用
+        allowedHeader.add("*");
+        rule.setAllowedHeader(allowedHeader);
+
+        //ArrayList<String> exposeHeader = new ArrayList<String>();
+// 指定允许用户从应用程序中访问的header
+//        exposeHeader.add("x-obs-expose-header");
+//        rule.setExposeHeader(exposeHeader);
+
+// 指定浏览器对特定资源的预取(OPTIONS)请求返回结果的缓存时间,单位为秒
+        rule.setMaxAgeSecond(3600);
+        rules.add(rule);
+        cors.setRules(rules);
+        obsClient.setBucketCors(bucketname, cors);
+    }
+
+    public String getBucketName() {
+        return this.bucketname;
+    }
+
+
+    /**
+     * 创建桶
+     */
+    public boolean create() {
+        // 创建桶
+        try {
+            ObsBucket obsBucket = new ObsBucket();
+            obsBucket.setBucketName(bucketname);
+            // 设置桶访问权限为公共读写
+            obsBucket.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ_WRITE);
+            // 设置桶区域位置
+            obsBucket.setLocation(parameter.Bucket_location());
+            // 创建桶
+            HeaderResponse response = obsClient.createBucket(obsBucket);
+            setBucketCors();
+        } catch (ObsException e) {
+            // 创建桶失败
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            System.out.println("Error Code:" + e.getErrorCode());
+            System.out.println("Error Message: " + e.getErrorMessage());
+
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 是否已存在桶
+     *
+     * @return
+     */
+    public boolean isAllReadyUsed() {
+        return obsClient.headBucket(bucketname);
+    }
+
+
+    /**
+     * 删除桶
+     *
+     * @return
+     */
+    public void delete() {
+        // 删除桶
+        obsClient.deleteBucket(bucketname);
+    }
+
+    /**
+     * 设置桶配额,单位G
+     */
+    public void setVolume(long volume) {
+        BucketQuota quota = new BucketQuota(1024 * 1024 * 1024 * volume);
+        obsClient.setBucketQuota(bucketname, quota);
+    }
+
+    /**
+     * 获取桶配额,单位字节
+     */
+    public long getMaxVolume() {
+        BucketQuota quota = obsClient.getBucketQuota(bucketname);
+        return quota.getBucketQuota();
+    }
+
+    /**
+     * 获取桶存量
+     *
+     * @return
+     */
+    public long getVolume() {
+        BucketStorageInfo storageInfo = obsClient.getBucketStorageInfo(bucketname);
+        return storageInfo.getSize();
+    }
+
+    /**
+     * 获取文件数量
+     *
+     * @return
+     */
+    public long getFileCount() {
+        BucketStorageInfo storageInfo = obsClient.getBucketStorageInfo(bucketname);
+        return storageInfo.getObjectNumber();
+    }
+
+    public void getFiles() {
+        ListObjectsRequest request = new ListObjectsRequest(bucketname);
+        // 设置文件夹对象名"dir/"为前缀
+        //request.setPrefix("dir/");
+        request.setMaxKeys(1000);
+        ObjectListing result;
+        int i = 0;
+        do {
+            result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                String name=obsObject.getObjectKey();
+                if(!(name.contains("s_")||name.contains("c_")||name.contains("hls"))){
+                    System.out.println(obsObject.getObjectKey());
+                }
+                //System.out.println("\t" + obsObject.getOwner());
+            }
+            request.setMarker(result.getNextMarker());
+        } while (result.isTruncated());
+    }
+
+    public static void main(String[] args) {
+        BucketTest bucket = new BucketTest("BCDQ");
+        bucket.getFiles();
+    }
+}