Browse Source

下发计划

Min 1 year ago
parent
commit
b026d12ae8

+ 5 - 12
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/PlanServiceImpl.java

@@ -184,18 +184,11 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
             for (Plan plan : planList) {
                 Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(plan.getForemanId())).findFirst();
                 if(first.isPresent()){
-                    //推送到企业微信
-                    JSONObject json=new JSONObject();
-                    JSONArray dataJson=new JSONArray();
-                    JSONObject jsonObj=new JSONObject();
-                    jsonObj.put("key",planType==0?"今日计划":planType==1?"明日计划":"插单计划");
-                    jsonObj.put("value",planType==2?"任务名称"+plan.getTaskName()+"\n"+"任务变更通知号"+plan.getTaskChangeNoticeNum():"产品名称"+plan.getProductName()+"\n"+"排产工单号"+plan.getProductSchedulingNum());
-                    dataJson.add(jsonObj);
-                    //todo:配置消息模板以及推送后入口
-                    json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
-                    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=expense#wechat_redirect");
-                    json.put("content_item",dataJson);
-                    wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,first.get().getCorpwxUserid(), json);
+                    //todo:推送到企业微信
+                    StringBuilder stringBuilder=new StringBuilder();
+                    stringBuilder.append(planType==0?"今日计划":planType==1?"明日计划":"插单计划"+": ");
+                    stringBuilder.append(planType==2?"任务名称"+plan.getTaskName()+"\n"+"任务变更通知号"+plan.getTaskChangeNoticeNum():"产品名称"+plan.getProductName()+"\n"+"排产工单号"+plan.getProductSchedulingNum());
+                    wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,first.get().getCorpwxUserid(),stringBuilder.toString(),planType==0?"plan/today":planType==1?"plan/tomorrow":"plan/orderInsert",null);
                 }else msg.setError("验证失败");
             }
         }

+ 38 - 10
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -74,6 +74,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     //获取日程
     public static final String ADD_SCHEDULE = " https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add?access_token=ACCESS_TOKEN";
 
+    public static final String GET_CORP_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET";
+
 
     public static final int TEXT_CARD_MSG_BUSTRIP_WAITING_AUDIT = 0;//出差待审核
     public static final int TEXT_CARD_MSG_BUSTRIP_AGREE = 1;//出差审核通过
@@ -250,7 +252,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
             if (isDev) return;
             log.info("发送企业微信消息===" + corpUserid);
             System.out.println("发送企业微信消息===" + corpUserid);
-            String accessToken = getCorpAccessToken(corpInfo);
+            String accessToken = getAppConcactAccessToken(corpInfo);
             String url = URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
             HttpHeaders headers = new HttpHeaders();
             headers.setContentType(MediaType.APPLICATION_JSON);
@@ -267,15 +269,17 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
             }else {
                 jumpUrl="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=STATE#wechat_redirect";
             }
-
-            if (StringUtils.isEmpty(pageRouter)) {
-                title = "消息通知";
-                jumpUrl = jumpUrl.replace("STATE", "0");
-                if (msgType.equals(TEXT_CARD_MSG_REPORT_DENY)) {
-                    title = "日报驳回";
-                } else if (msgType.equals(TEXT_CARD_MSG_REPORT_AGREE)) {
-                    title = "日报审核通过";
-                }
+            jumpUrl = jumpUrl.replace("STATE", pageRouter);
+            if ("plan/today".equals(pageRouter)) {
+                //出差
+                title = "收到新的今日计划";
+            } else if ("plan/tomorrow".equals(pageRouter)) {
+                //费用报销
+                title = "收到新的明日计划";
+            }
+            else if ("plan/orderInsert".equals(pageRouter)) {
+                //费用报销
+                title = "收到新的插单计划";
             }
             cardJson.put("title", title);
             cardJson.put("description", msg);
@@ -505,6 +509,30 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         return userOpenIdList;
     }
 
+    /**
+     * 获取应用的AccessToken
+     * @param corpInfo
+     * @return
+     * @throws Exception
+     */
+    private String getAppConcactAccessToken(WxCorpInfo corpInfo) throws Exception {
+        String url = GET_CORP_TOKEN.replace("ID", corpInfo.getCorpid()).replace("SECRET", corpInfo.getAgentSecret());
+        ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
+                HttpMethod.GET, null, String.class);
+        if (responseEntity.getStatusCode() == HttpStatus.OK) {
+            String resp = responseEntity.getBody();
+            JSONObject json = JSONObject.parseObject(resp);
+            if (json.getIntValue("errcode") == 0) {
+                String access_token = json.getString("access_token");
+                System.out.println("获取到access_token=="+access_token);
+                corpInfo.setAccessToken(access_token);
+            } else {
+                throw new Exception(json.toJSONString());
+            }
+        }
+        return corpInfo.getAccessToken();
+    }
+
     //获取企业AccessToken
     private String getCorpAccessToken(WxCorpInfo corpInfo) throws Exception {
         if (corpInfo.getExpireTime().isBefore(LocalDateTime.now())) {

+ 39 - 1
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/plan/planComponent.vue

@@ -68,6 +68,7 @@
         :data="tableData"
         style="width: 100%; flex: 1"
         v-loading="tableDataLoading"
+        @selection-change="handleSelectionChange"
       >
         <el-table-column type="selection" width="55"> </el-table-column>
         <el-table-column
@@ -104,6 +105,7 @@
       </el-table>
     </div>
     <div class="layout-container-floor">
+      <el-button type="primary" size="mini" @click="allocationPlan">下发计划</el-button>
       <el-pagination
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
@@ -328,6 +330,7 @@ export default {
       total: 0,
       hasChooseDept: "",
       productList: [],
+      multipleSelection: [],
       // 表单规则验证
       todayPlanFormrules: {
         productSchedulingNum: [
@@ -737,7 +740,42 @@ export default {
           });
           }
       );
-    }
+    },
+    handleSelectionChange(val) {
+        this.multipleSelection = val.map(item => item.id);
+        console.log(this.multipleSelection)
+    },
+    allocationPlan(){
+      if(this.multipleSelection.length==0){
+          return
+      }
+      this.http.post(
+        "/plan/allocationPlan",
+        {
+          ids:this.multipleSelection.join(","),
+          planType:this.planType
+        },
+        (res) => {
+          if (res.code == "ok") {
+            this.$message({
+              message:'下发成功',
+              type: "success",
+            });
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error",
+            });
+          }
+        },
+        (error) => {
+          this.$message({
+            message: error,
+            type: "error",
+          });
+        }
+      );
+    },
   },
 };
 </script>

+ 19 - 19
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/product/list.vue

@@ -1211,7 +1211,7 @@ a {
                 this.cateId =  this.$route.params.cateId;
                 console.log('分类参数', this.cateId);
                 this.getCateName();
-                this.userssHu()
+                // this.userssHu()
                 this.getDepartment();
                 this.getDepartment2();
                 this.projectListPageComponentKey++;
@@ -1742,24 +1742,24 @@ a {
                     }
                 );
             },
-            userssHu() {
-                this.http.post('/time-type/getCompanyTimeSetting',{ 
-                    companyId: this.user.companyId
-                },
-                res => {
-                    if (res.code == "ok") {
-                        this.yonghuUser = res.data
-                        // console.log(this.yonghuUser)
-                    } 
-                },
-                error => {
-                    this.$message({
-                        message: error,
-                        type: "error"
-                    });
-                    }
-                );
-            },
+            // userssHu() {
+            //     this.http.post('/time-type/getCompanyTimeSetting',{ 
+            //         companyId: this.user.companyId
+            //     },
+            //     res => {
+            //         if (res.code == "ok") {
+            //             this.yonghuUser = res.data
+            //             // console.log(this.yonghuUser)
+            //         } 
+            //     },
+            //     error => {
+            //         this.$message({
+            //             message: error,
+            //             type: "error"
+            //         });
+            //         }
+            //     );
+            // },
             yanjiuzx() {
                 this.http.post('/report-extra-degree/getAll ',{},
                 res => {

+ 64 - 64
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/workReport/daily.vue

@@ -2138,13 +2138,13 @@
             var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
             this.exportParam.dateRange = [startStr,t];
             this.getAllDate(1);
-            this.getReportList();
+            // this.getReportList();
             this.getProjectList();
             this.getFillProjectList();
-            this.getTimeType();
+            // this.getTimeType();
             this.getDepartment();
             this.scrollFunction()
-            this.userssHu();
+            // this.userssHu();
             if(this.user.timeType.reportAuditType == 3){
                 this.getAllUsersList()
             }
@@ -2903,23 +2903,23 @@
                     });
                 }
             },
-            userssHu() {
-                this.http.post('/time-type/getCompanyTimeSetting',{ 
-                    companyId: this.user.companyId
-                },
-                res => {
-                    if (res.code == "ok") {
-                        this.yonghuUser = res.data
-                    } 
-                },
-                error => {
-                    this.$message({
-                        message: error,
-                        type: "error"
-                    });
-                    }
-                );
-            },
+            // userssHu() {
+            //     this.http.post('/time-type/getCompanyTimeSetting',{ 
+            //         companyId: this.user.companyId
+            //     },
+            //     res => {
+            //         if (res.code == "ok") {
+            //             this.yonghuUser = res.data
+            //         } 
+            //     },
+            //     error => {
+            //         this.$message({
+            //             message: error,
+            //             type: "error"
+            //         });
+            //         }
+            //     );
+            // },
             iptBlur(i) {
                 if(this.isBatch == 0) {
                     return
@@ -4506,50 +4506,50 @@
                     }
                 }
             },
-            getTimeType() {
-                this.http.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId},
-                    res => {
-                        if (res.code == "ok") {
-                            var t = res.data;
-                            this.reportTimeType = t;
-                            if (this.reportTimeType.type > 0) {
-                                this.showAddMore = true;
-                            }
-                            //转化时间格式
-                            if (t.allday != null) {
-                                this.timeType.push({value:0, label:this.$t('other.allDay') +' - '+t.allday+this.$t('time.hour'), hours:t.allday});
-                            }
-                            if (t.am != null) {
-                                this.timeType.push({value:1, label:this.$t('other.morning') +' - '+t.am+this.$t('time.hour'), hours: t.am});
-                            }
-                            if (t.pm != null) {
-                                this.timeType.push({value:2, label:this.$t('other.afternoon') +' - '+t.pm+this.$t('time.hour'), hours: t.pm});
-                            }
-
-                            let arr = []
-                            for(var i in res.data.excludeTimeList) {
-                                let obj = {
-                                    s: res.data.excludeTimeList[i].startTime,
-                                    e: res.data.excludeTimeList[i].endTime,
-                                }
-                                arr.push(obj)
-                            }
-                            this.vacationTime = arr
-                        } else {
-                            this.$message({
-                                message: res.msg,
-                                type: "error"
-                            });
-                        }
-                    },
-                    error => {
-                        this.listLoading = false;
-                        this.$message({
-                            message: error,
-                            type: "error"
-                        });
-                    });
-            },  
+            // getTimeType() {
+            //     this.http.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId},
+            //         res => {
+            //             if (res.code == "ok") {
+            //                 var t = res.data;
+            //                 this.reportTimeType = t;
+            //                 if (this.reportTimeType.type > 0) {
+            //                     this.showAddMore = true;
+            //                 }
+            //                 //转化时间格式
+            //                 if (t.allday != null) {
+            //                     this.timeType.push({value:0, label:this.$t('other.allDay') +' - '+t.allday+this.$t('time.hour'), hours:t.allday});
+            //                 }
+            //                 if (t.am != null) {
+            //                     this.timeType.push({value:1, label:this.$t('other.morning') +' - '+t.am+this.$t('time.hour'), hours: t.am});
+            //                 }
+            //                 if (t.pm != null) {
+            //                     this.timeType.push({value:2, label:this.$t('other.afternoon') +' - '+t.pm+this.$t('time.hour'), hours: t.pm});
+            //                 }
+
+            //                 let arr = []
+            //                 for(var i in res.data.excludeTimeList) {
+            //                     let obj = {
+            //                         s: res.data.excludeTimeList[i].startTime,
+            //                         e: res.data.excludeTimeList[i].endTime,
+            //                     }
+            //                     arr.push(obj)
+            //                 }
+            //                 this.vacationTime = arr
+            //             } else {
+            //                 this.$message({
+            //                     message: res.msg,
+            //                     type: "error"
+            //                 });
+            //             }
+            //         },
+            //         error => {
+            //             this.listLoading = false;
+            //             this.$message({
+            //                 message: error,
+            //                 type: "error"
+            //             });
+            //         });
+            // },  
             // 改变月份     -------
             changeMonthOut() {
                 this.getAllDate();