QuYueTing 1 неделя назад
Родитель
Сommit
0b2d6bde4d

+ 0 - 101
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/WxCorpInfoController.java

@@ -1,101 +0,0 @@
-package com.management.platform.controller;
-
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.management.platform.entity.User;
-import com.management.platform.entity.WxCorpInfo;
-import com.management.platform.mapper.UserMapper;
-import com.management.platform.service.WxCorpInfoService;
-import com.management.platform.task.TimingTask;
-import com.management.platform.util.HttpRespMsg;
-import com.management.platform.util.ListUtil;
-import org.springframework.http.HttpRequest;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author Seyason
- * @since 2021-07-14
- */
-@RestController
-@RequestMapping("/wx-corp-info")
-public class WxCorpInfoController {
-
-    @Resource
-    WxCorpInfoService wxCorpInfoService;
-    @Resource
-    UserMapper userMapper;
-    @Resource
-    private TimingTask timingTask;
-
-    @RequestMapping("/testDownload")
-    public HttpRespMsg testDownload() {
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.data = wxCorpInfoService.testDownloadFile();
-        return msg;
-    }
-
-    @RequestMapping("/saveContactSecret")
-    public HttpRespMsg saveContactSecret(WxCorpInfo info) {
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.data = wxCorpInfoService.updateById(info);
-        return msg;
-    }
-
-    @RequestMapping("/get")
-    public HttpRespMsg get(Integer companyId) {
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.data = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
-        return msg;
-    }
-
-    @RequestMapping("/testSendTemplateMsg")
-    public HttpRespMsg testSendTemplateMsg(String userId) {
-        int companyId=7;
-        WxCorpInfo corpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
-        String corpwxuserIds = "woy9TkCAAAPD6149u46N_Yi5ARSA4VFw";
-        System.out.println("发送给:"+corpwxuserIds);
-        //推送到企业微信
-//        String corpUid = user.getCorpwxUserid();
-        JSONObject json=new JSONObject();
-        JSONArray dataJson=new JSONArray();
-        JSONObject item=new JSONObject();
-        item.put("key","审核人");
-        item.put("value","$userName=woy9TkCAAAPD6149u46N_Yi5ARSA4VFw$");
-        dataJson.add(item);
-        json.put("template_id","tty9TkCAAANpvEtLrkPUGeOEd1-U7W2w");
-        JSONObject item2=new JSONObject();
-        item2.put("key","日期");
-        item2.put("value","2021-07-14");
-        dataJson.add(item2);
-        json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=0#wechat_redirect");
-        json.put("content_item",dataJson);
-        wxCorpInfoService.sendWXCorpTemplateMsg(corpInfo,corpwxuserIds,json);
-        return new HttpRespMsg();
-    }
-
-    @RequestMapping("/wxLeaveTest")
-    public void wxLeaveTest() throws Exception {
-        timingTask.synWxLeave();
-    }
-
-    @RequestMapping("/batchTransferLicense")
-    public HttpRespMsg batchTransferLicense(HttpServletRequest request,String handoverId,String takeoverId) throws Exception {
-        return wxCorpInfoService.batchTransferLicense(request,handoverId,takeoverId);
-    }
-}
-

+ 58 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/aop/NewLimitRequestAspect.java

@@ -0,0 +1,58 @@
+package com.management.platform.aop;
+
+import com.management.platform.config.NewLimitRequest;
+import com.management.platform.util.HttpRespMsg;
+import com.management.platform.util.MessageUtils;
+import net.jodah.expiringmap.ExpirationPolicy;
+import net.jodah.expiringmap.ExpiringMap;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+@Aspect
+@Component
+public class NewLimitRequestAspect {
+    private static ConcurrentHashMap<String, ExpiringMap<String, Integer>> book = new ConcurrentHashMap<>();
+    // 定义切点
+    // 让所有有@NewLimitRequest注解的方法都执行切面方法
+    @Pointcut("@annotation(newLimitRequest)")
+    public void excudeService(NewLimitRequest newLimitRequest) {
+    }
+
+    @Around("excudeService(newLimitRequest)")
+    public Object doAround(ProceedingJoinPoint pjp, NewLimitRequest newLimitRequest) throws Throwable {
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        // 获得request对象
+        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
+        HttpServletRequest request = sra.getRequest();
+
+        // 获取Map对象, 如果没有则返回默认值
+        // 第一个参数是key, 第二个参数是默认值
+        ExpiringMap<String, Integer> map = book.getOrDefault(request.getRequestURI(), ExpiringMap.builder().variableExpiration().build());
+        Integer uCount = map.getOrDefault(request.getRemoteAddr(), 0);
+        if (uCount >= newLimitRequest.count()) { // 超过次数,不执行目标方法
+            //这里的返回对象类型根据controller方法的返回方式一致
+            httpRespMsg.setError(MessageUtils.message("request.countLimit"));
+            return httpRespMsg;
+        } else if (uCount == 0){ // 第一次请求时,设置开始有效时间
+            map.put(request.getRemoteAddr(), uCount + 1, ExpirationPolicy.CREATED, newLimitRequest.time(), TimeUnit.MILLISECONDS);
+        } else { // 未超过次数, 记录数据加一
+            map.put(request.getRemoteAddr(), uCount + 1);
+        }
+        book.put(request.getRequestURI(), map);
+
+        // result的值就是被拦截方法的返回值
+        return pjp.proceed();
+    }
+    
+}

+ 12 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/config/NewLimitRequest.java

@@ -0,0 +1,12 @@
+package com.management.platform.config;
+
+import java.lang.annotation.*;
+
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NewLimitRequest {
+    //毫秒,分钟,小时 之间的转换用算数
+    long time() default 60000; // 限制时间 单位:毫秒
+    int count() default Integer.MAX_VALUE; // 允许请求的次数
+}

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/components/taskComponent.vue

@@ -34,7 +34,7 @@
                         <el-option v-for="item in relationdata" :key="item.id" :label="item.name" :value="item.id"></el-option>
                     </el-select>
                 </el-form-item>
-                <el-form-item :label="$t('types')" v-if="!showMmeiLaiDe">
+                <el-form-item :label="$t('types')" >
                     <el-select v-model="addForm.taskType" style="width:100%;" :disabled="((this.addForm.id != null && user.id != this.addForm.createrId && currentProject.inchargerId != user.id) && !permissions.projectManagement && !permissions.editAnyTask) && !(groupResponsibleId == user.id)" @change="selchg()">
                         <el-option v-for="item in taskTypeList" :key="item.id" :label="item.name" :value="item.id">
                             <i :class="item.icon" ></i>

+ 30 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -575,6 +575,12 @@
                                     </el-option>
                                 </el-select>
                             </template>
+
+                            <template v-if="user.companyId == 10 || user.companyId == 862">
+                                <span style="margin-left:10px;">剩余工时:{{ workForm.domains[index].remainingTime }}</span>
+                                <el-button type="default" style="margin-left:5px;" size="small" icon="el-icon-refresh" v-if="workForm.domains[index].projectId"
+                                @click="getProjectRemainingTime(workForm.domains[index])"></el-button>
+                            </template>
                             
                             <el-link v-if="(index >= 1 || workForm.domains.length > 1)&&domain.canEdit" type="primary" :underline="false" @click="delDomain(index)" style="float:right;margin-right:15%;"
                                 :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)">
@@ -3981,6 +3987,26 @@
                     }
                 );
             },
+            //获取项目剩余工时
+            getProjectRemainingTime(domain) {
+                var projectId = domain.projectId;
+                this.http.post('/project/getRemainingTime',{projectId},
+                res => {
+                    if (res.code == "ok") {
+                        this.$set(domain, 'remainingTime', res.data);
+                    } else {
+                        this.$set(domain, 'remainingTime', res.msg);
+                    }
+                },
+                error => {
+                    this.checkinLoading = false;
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                    }
+                );
+            },
            
             loadCheckInData() {
                 if (this.importWxParam.date == null) {
@@ -5280,6 +5306,10 @@
                 if((reportExtraField4Name || reportExtraField5Name) && domain.groupId) {
                     this.getInfoByProjectId(domain, index)
                 }
+                //获取剩余工时
+                if (this.user.companyId == 10 || this.user.companyId == 862) {
+                    this.getProjectRemainingTime(domain);
+                }
             },
             getInfoByProjectId(domain, index, flag = true) {
                 const { projectId } = domain