Browse Source

新增/编辑账号的时候 根据设置的任务开始日期 生成任务排期

lqc 5 years ago
parent
commit
4a2be82988

+ 65 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxFlowListController.java

@@ -1,11 +1,14 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.entity.pangu.FosterwxFlowListHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxFlowList;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
 import com.mokamrp.privates.service.pangu.FosterwxFlowListService;
+import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.time.LocalDateTime;
 import java.util.Map;
 
 
@@ -32,6 +36,9 @@ public class FosterwxFlowListController extends BaseController<FosterwxFlowList>
     @Autowired
     public FosterwxFlowListService fosterwxFlowListService;
 
+    @Autowired
+    public FosterwxMobilePoolService fosterwxMobilePoolService;
+
     /*
      * @fast
      * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
@@ -47,6 +54,64 @@ public class FosterwxFlowListController extends BaseController<FosterwxFlowList>
         return AjaxResult.success(res);
     }
 
+    @PostMapping("/changeStatus")
+    public Object changeStatus(FosterwxFlowList fosterwxFlowList) {
+        // 先从个微池中获取进粉阈值
+        FosterwxMobilePool fosterwxMobilePool = fosterwxMobilePoolService.getOne(new QueryWrapper<FosterwxMobilePool>().eq("pool_index", fosterwxFlowList.getPoolId()).last("Limit 1"));
+
+        // 最大进粉阈值
+        Integer maxFans = Integer.valueOf(fosterwxMobilePool.getMaxFans());
+
+        // 查看是否超过百分之五十
+        if (fosterwxFlowList.getBusFans() > maxFans / 2.0) {
+            // 超过
+            // 更新个微池状态为停用
+            fosterwxMobilePool.setStatus(0);
+            fosterwxMobilePool.setUpdateUid(fosterwxFlowList.getUpdateUid());
+            fosterwxMobilePool.setUpdateAt(LocalDateTime.now());
+            fosterwxMobilePoolService.updateById(fosterwxMobilePool);
+
+            // 更新
+            FosterwxFlowList lastPosition = fosterwxFlowListService.getOne(new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
+            String position = "";
+            if (null == lastPosition) {
+                // 新开账号 需要激活个微池状态
+                position = "1001";
+            } else {
+                position = String.valueOf(Integer.parseInt(lastPosition.getFlowPosition()) + 1);
+            }
+            // 设置流量位置
+            fosterwxFlowList.setFlowPosition(position);
+            // 设置状态
+            fosterwxFlowList.setStatus(0);
+            fosterwxFlowListService.save(fosterwxFlowList);
+            // 更新全部位置为超限
+            fosterwxFlowListService.update(new FosterwxFlowList(1), new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
+        } else {
+            // 未超过
+            // 查找上一个流量位置
+            FosterwxFlowList lastPosition = fosterwxFlowListService.getOne(new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
+            String position = "";
+            if (null == lastPosition) {
+                // 新开账号 需要激活个微池状态
+                position = "1001";
+                fosterwxMobilePool.setStatus(2);
+                fosterwxMobilePool.setUpdateUid(fosterwxFlowList.getUpdateUid());
+                fosterwxMobilePool.setUpdateAt(LocalDateTime.now());
+                fosterwxMobilePoolService.updateById(fosterwxMobilePool);
 
+            } else {
+                position = String.valueOf(Integer.parseInt(lastPosition.getFlowPosition()) + 1);
+            }
+            // 设置流量位置
+            fosterwxFlowList.setFlowPosition(position);
+            // 设置状态
+            fosterwxFlowList.setStatus(1);
+            fosterwxFlowListService.save(fosterwxFlowList);
+        }
+
+
+        return AjaxResult.success("操作成功!");
+    }
 }
 

+ 12 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobilePoolController.java

@@ -65,6 +65,18 @@ public class FosterwxMobilePoolController extends BaseController<FosterwxMobileP
         return AjaxResult.success("新增成功!");
     }
 
+    @PostMapping("/getOutOfServerList")
+    public Object getOutOfServerList(@Valid @RequestBody FosterwxMobilePoolHandle fosterwxMobilePoolHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        fosterwxMobilePoolHandle.setStatus(0);
+        fosterwxMobilePoolHandle.setPage(1);
+        fosterwxMobilePoolHandle.setPageSize(999999999);
+        Map<String, Object> res = fosterwxMobilePoolService.getList(fosterwxMobilePoolHandle);
+        return AjaxResult.success(res);
+    }
+
 
 }
 

+ 4 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxFlowList.java

@@ -21,6 +21,10 @@ public class FosterwxFlowList extends Model<FosterwxFlowList> {
 
     private static final long serialVersionUID = 1L;
 
+    public FosterwxFlowList(Integer status) {
+        this.status = status;
+    }
+
     /**
      * ID
      */

+ 2 - 2
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxFlowListServiceImpl.java

@@ -34,9 +34,9 @@ public class FosterwxFlowListServiceImpl extends ServiceImpl<FosterwxFlowListMap
      */
     @Override
     public Map<String, Object> getList(FosterwxFlowListHandle handle) {
-        Integer pageSizeize = handle.getPageSize();
+        Integer pageSize = handle.getPageSize();
         Integer page = handle.getPage();
-        Page<FosterwxFlowList> pageObj = new Page<FosterwxFlowList>(page, pageSizeize);
+        Page<FosterwxFlowList> pageObj = new Page<FosterwxFlowList>(page, pageSize);
         LambdaQueryWrapper<FosterwxFlowList> fosterwxFlowListLambdaQueryWrapper = new LambdaQueryWrapper<>();
         fosterwxFlowListLambdaQueryWrapper.eq(FosterwxFlowList::getPoolId, handle.getPoolIndex());
         pageObj = fosterwxFlowListMapper.selectPage(pageObj, fosterwxFlowListLambdaQueryWrapper);

+ 4 - 1
src/main/resources/application-local.properties

@@ -52,7 +52,10 @@ xxl-sso.excluded.paths=/healthy,\
   /pangu/fosterwxMobile/delMobile,\
   /pangu/fosterwxMobile/editMobile,\
   /pangu/fosterwxMobile/mobileInfo,\
-  /pangu/fosterwxMobile/addMobilePro
+  /pangu/fosterwxMobile/addMobilePro,\
+  /pangu/fosterwxFlowList/changeStatus,\
+  /pangu/fosterwxFlowList/list,\
+  /pangu/fosterwxMobilePool/getOutOfServerList
 #xxl.sso.redis.address=redis://xxl-sso:Jch9shshl@r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com:6379/0
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72pd.redis.rds.aliyuncs.com:23563/0
 menu.host=http://space-server.mokamrp.com/space/menu/getMenuInterface?sysCode=1006&userId=

+ 4 - 11
src/main/resources/application-prod.properties

@@ -1,32 +1,26 @@
 server.port=8085
 api.host=http://127.0.0.1
 api.wechatcallback=/weWork/callback
-
 spring.datasource.druid.max-idle=10
 spring.datasource.druid.max-wait=10000
 spring.datasource.druid.min-idle=5
 spring.datasource.druid.initial-size=5
 spring.datasource.druid.strict=false
-
 spring.datasource.dynamic.primary=db
-
 #后台数据库
 spring.datasource.dynamic.datasource.db.driverClassName=com.mysql.cj.jdbc.Driver
 spring.datasource.dynamic.datasource.db.url=jdbc:mysql://rm-uf6s9smcl373jjenc35930.mysql.rds.aliyuncs.com:3306/mochat?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=UTF-8
 spring.datasource.dynamic.datasource.db.username=mochat
 spring.datasource.dynamic.datasource.db.password=MoChat666$%MOchaT
-
 #大数据数据库
 spring.datasource.dynamic.datasource.datadb.url=jdbc:postgresql://hgmc-cn-7mz27ayc6003-cn-shanghai.hologres.aliyuncs.com:80/galaxy
 spring.datasource.dynamic.datasource.datadb.username=LTAI5tEWU1j9H2poG4zWgfEP
 spring.datasource.dynamic.datasource.datadb.password=p9tVmeDeeEENKhfsBsSeYc0F0ggH5b
 spring.datasource.dynamic.datasource.datadb.driverClassName=org.postgresql.Driver
-
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
 spring.jpa.properties.hibernate.hbm2ddl.auto=update
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 mybatis-plus.configuration.map-underscore-to-camel-case=true
-
 spring.redis.host=r-uf6k0vhplkv7otzrjd.redis.rds.aliyuncs.com
 spring.redis.port=6379
 spring.redis.password=MoChat_RediS666MOchaT_Rd
@@ -36,7 +30,6 @@ spring.redis.jedis.pool.min-idle=0
 spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-active=20
 spring.redis.jedis.pool.max-wait=-1ms
-
 #阿里云oss配置(增加一个cdn地址配置)
 aliyun.host=https://mochat-oss.mokamrp.com/
 aliyun.endpoint=https://oss-cn-shanghai-internal.aliyuncs.com
@@ -45,7 +38,6 @@ aliyun.accessKeySecret=m7p2WBJXZuNon9stiuw494MnZQaT1N
 aliyun.bucketName=moka-mochat
 spring.servlet.multipart.max-request-size=10MB
 spring.servlet.multipart.max-file-size=10MB
-
 xxl.sso.server=https://sso.mokamrp.com/sso
 xxl.sso.logout.path=/logout
 xxl-sso.excluded.paths=/healthy,\
@@ -56,11 +48,12 @@ xxl-sso.excluded.paths=/healthy,\
   /pangu/fosterwxMobile/delMobile,\
   /pangu/fosterwxMobile/editMobile,\
   /pangu/fosterwxMobile/mobileInfo,\
-  /pangu/fosterwxMobile/addMobilePro
+  /pangu/fosterwxMobile/addMobilePro,\
+  /pangu/fosterwxFlowList/changeStatus,\
+  /pangu/fosterwxFlowList/list,\
+  /pangu/fosterwxMobilePool/getOutOfServerList
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72.redis.rds.aliyuncs.com:6379/0
-
 menu.host=http://space-server-in-svc/space/menu/getMenuInterface?sysCode=1006&userId=
-
 datahub.endpoint=https://dh-cn-shanghai.aliyuncs.com
 datahub.accessId=LTAI5tEWU1j9H2poG4zWgfEP
 datahub.accessSecret=p9tVmeDeeEENKhfsBsSeYc0F0ggH5b

+ 4 - 13
src/main/resources/application-test.properties

@@ -1,33 +1,26 @@
 server.port=8085
 api.host=http://127.0.0.1
 api.wechatcallback=/weWork/callback
-
 spring.datasource.druid.max-idle=10
 spring.datasource.druid.max-wait=10000
 spring.datasource.druid.min-idle=5
 spring.datasource.druid.initial-size=5
 spring.datasource.druid.strict=false
-
 spring.datasource.dynamic.primary=db
-
 #后台数据库
 spring.datasource.dynamic.datasource.db.driverClassName=com.mysql.cj.jdbc.Driver
 spring.datasource.dynamic.datasource.db.url=jdbc:mysql://172.18.71.27:3306/mochat?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=UTF-8
 spring.datasource.dynamic.datasource.db.username=typer
 spring.datasource.dynamic.datasource.db.password=jch9sh_shl
-
 #大数据数据库
 spring.datasource.dynamic.datasource.datadb.url=jdbc:postgresql://hgmc-cn-7mz27ayc6003-cn-shanghai.hologres.aliyuncs.com:80/galaxy
 spring.datasource.dynamic.datasource.datadb.username=LTAI5tEWU1j9H2poG4zWgfEP
 spring.datasource.dynamic.datasource.datadb.password=p9tVmeDeeEENKhfsBsSeYc0F0ggH5b
 spring.datasource.dynamic.datasource.datadb.driverClassName=org.postgresql.Driver
-
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
 spring.jpa.properties.hibernate.hbm2ddl.auto=update
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 mybatis-plus.configuration.map-underscore-to-camel-case=true
-
-
 spring.redis.host=172.18.71.26
 spring.redis.port=6379
 spring.redis.password=Jch9shshl
@@ -37,7 +30,6 @@ spring.redis.jedis.pool.min-idle=0
 spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-active=20
 spring.redis.jedis.pool.max-wait=-1ms
-
 #阿里云oss配置(增加一个cdn地址配置)
 aliyun.host=http://mini-short-video-oss.lushenjin.cn/
 aliyun.endpoint=https://oss-cn-hangzhou.aliyuncs.com
@@ -46,7 +38,6 @@ aliyun.accessKeySecret=irLfHOni7ffLU3yAf3LsKEXwQLfrNc
 aliyun.bucketName=mini-short-video-test
 spring.servlet.multipart.max-request-size=10MB
 spring.servlet.multipart.max-file-size=10MB
-
 xxl.sso.server=https://sso.mokamrp.com/sso
 xxl.sso.logout.path=/logout
 xxl-sso.excluded.paths=/healthy,\
@@ -57,13 +48,13 @@ xxl-sso.excluded.paths=/healthy,\
 /pangu/fosterwxMobile/delMobile,\
 /pangu/fosterwxMobile/editMobile,\
 /pangu/fosterwxMobile/mobileInfo,\
-/pangu/fosterwxMobile/addMobilePro
+/pangu/fosterwxMobile/addMobilePro,\
+/pangu/fosterwxFlowList/changeStatus,\
+/pangu/fosterwxFlowList/list,\
+/pangu/fosterwxMobilePool/getOutOfServerList
 #xxl.sso.redis.address=redis://xxl-sso:Jch9shshl@r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com:6379/0
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72pd.redis.rds.aliyuncs.com:23563/0
-
 menu.host=http://space-server-in-svc/space/menu/getMenuInterface?sysCode=1006&userId=
-
-
 #dataHub
 datahub.endpoint=https://dh-cn-shanghai.aliyuncs.com
 datahub.accessId=LTAI5tEWU1j9H2poG4zWgfEP