Prechádzať zdrojové kódy

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

zhouyy 3 týždňov pred
rodič
commit
f67b26adef

+ 107 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/WechatAccountController.java

@@ -1,6 +1,7 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -436,6 +437,112 @@ public class WechatAccountController {
         return msg;
     }
 
+    // 创建微信公众号菜单
+    @RequestMapping("/createMenu")
+    public HttpRespMsg createMenu(Integer companyId)  {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        WechatAccount wechatAccount = wechatAccountService.getOne(new QueryWrapper<WechatAccount>().eq("company_id", companyId));
+        if (wechatAccount==null){
+            httpRespMsg.setError("该公司没有配置公众号相关的参数");
+            return httpRespMsg;
+        }
+        String accessToken = wechatAccountService.getAccessToken(companyId, wechatAccount.getAppId());
+        log.info("accessToken==>{}", accessToken);
+        boolean menuWithMiniProgram = createMenuWithMiniProgram(accessToken);
+        if (menuWithMiniProgram){
+            return httpRespMsg;
+        }else {
+            httpRespMsg.setError("创建失败");
+            return httpRespMsg;
+        }
+
+    }
+
+    /**
+     * 创建包含小程序链接的菜单
+     * @param accessToken 微信access_token
+     * @return 是否创建成功
+     */
+    public  boolean createMenuWithMiniProgram(String accessToken) {
+        // 构建菜单JSON
+        String menuJson = buildMenuJson();
+
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_JSON);
+
+        // 创建请求实体
+        HttpEntity<String> requestEntity = new HttpEntity<>(menuJson, headers);
+
+        // 构建完整URL
+        String requestUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken;
+
+        try {
+            // 发送POST请求
+            ResponseEntity<String> responseEntity = restTemplate.exchange(
+                    requestUrl,
+                    HttpMethod.POST,
+                    requestEntity,
+                    String.class
+            );
+            log.info("responseEntity==>" + responseEntity);
+
+            // 解析响应
+            if (responseEntity.getStatusCode() == HttpStatus.OK) {
+                JSONObject jsonResult = JSON.parseObject(responseEntity.getBody());
+                log.info("解析响应"+jsonResult.toJSONString());
+                return jsonResult.getInteger("errcode") == 0;
+            }
+            return false;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+
+    }
+
+    /**
+     * 构建包含小程序链接的菜单JSON
+     */
+    private static String buildMenuJson() {
+        // 示例菜单结构:主菜单包含3个子菜单,其中一个是小程序链接
+        JSONObject menu = new JSONObject();
+
+        // 第一个菜单项 - 普通点击菜单
+        /*JSONObject button1 = new JSONObject();
+        button1.put("type", "click");
+        button1.put("name", "今日新闻");
+        button1.put("key", "V1001_TODAY_NEWS");*/
+
+        // 第二个菜单项 - 包含子菜单
+        JSONObject button2 = new JSONObject();
+        button2.put("name", "关于我们");
+
+        /*JSONObject subButton1 = new JSONObject();
+        subButton1.put("type", "view");
+        subButton1.put("name", "官网首页");
+        subButton1.put("url", "https://www.yourdomain.com");*/
+
+        JSONObject subButton2 = new JSONObject();
+        subButton2.put("type", "miniprogram");
+        subButton2.put("name", "打开小程序");
+        subButton2.put("url", "https://mp.weixin.qq.com/"); // 不支持小程序的老版本客户端将打开此url
+        subButton2.put("appid", "wxaaf19cfbbe1ff950"); // 小程序appid
+        subButton2.put("pagepath", "pages/training/training"); // 小程序页面路径
+
+        button2.put("sub_button", new JSONObject[]{ subButton2});
+
+        // 第三个菜单项 - 普通点击菜单
+        JSONObject button3 = new JSONObject();
+        button3.put("type", "click");
+        button3.put("name", "联系我们");
+        button3.put("key", "V1001_CONTACT_US");
+
+        menu.put("button", new JSONObject[]{button2,button3});
+
+        return menu.toJSONString();
+    }
+
 
     private String getUserIp(HttpServletRequest request) {
         // 1. 检查云服务商特殊头部

+ 25 - 23
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1554,32 +1554,34 @@ public class ReportController {
         }
         //针对泓浒(苏州),需要按照工单号的部门来设置工时所属部门,同时设置是否是协作工时
         if (Constant.HONG_HU_COMPANY_ID == company.getId()) {
-            List<String> collect = reportList.stream().map(Report::getExtraField4).collect(Collectors.toList());
-            List<ErpOrderInfo> orderList = erpOrderInfoMapper.selectList(new QueryWrapper<ErpOrderInfo>().in("order_id", collect));
-            for (Report report : reportList) {
-                String errorMsg = null;
-                Optional<ErpOrderInfo> first = orderList.stream().filter(order -> order.getOrderId().equals(report.getExtraField4())).findFirst();
-                if (first.isPresent()) {
-                    if (first.get().getDeptId() == null) {
-                        errorMsg = "工单号:"+report.getExtraField4()+"无部门id";
-                    } else {
-                        Department deptItem = departmentMapper.selectOne(new QueryWrapper<Department>().eq("dept_code", first.get().getDeptId()));
-                        if (deptItem != null) {
-                            if (!deptItem.getDepartmentId().equals(report.getDeptId())) {
-                                report.setDeptId(deptItem.getDepartmentId());
-                                report.setIsAssist(true);
-                            }
+            List<String> collect = reportList.stream().filter(r -> !StringUtils.isEmpty(r.getExtraField4())).map(Report::getExtraField4).collect(Collectors.toList());
+            if (collect.size() > 0) {
+                List<ErpOrderInfo> orderList = erpOrderInfoMapper.selectList(new QueryWrapper<ErpOrderInfo>().in("order_id", collect));
+                for (Report report : reportList) {
+                    String errorMsg = null;
+                    Optional<ErpOrderInfo> first = orderList.stream().filter(order -> order.getOrderId().equals(report.getExtraField4())).findFirst();
+                    if (first.isPresent()) {
+                        if (first.get().getDeptId() == null) {
+                            errorMsg = "工单号:"+report.getExtraField4()+"无部门id";
                         } else {
-                            errorMsg = "工时系统中尚未给部门:"+first.get().getDeptName()+"设置部门编号";
+                            Department deptItem = departmentMapper.selectOne(new QueryWrapper<Department>().eq("dept_code", first.get().getDeptId()));
+                            if (deptItem != null) {
+                                if (!deptItem.getDepartmentId().equals(report.getDeptId())) {
+                                    report.setDeptId(deptItem.getDepartmentId());
+                                    report.setIsAssist(true);
+                                }
+                            } else {
+                                errorMsg = "工时系统中尚未给部门:"+first.get().getDeptName()+"设置部门编号";
+                            }
                         }
+                    } else {
+                        errorMsg = "erpOrderInfo表中工单号不存在:"+report.getExtraField4();
+                    }
+                    if (errorMsg != null) {
+                        HttpRespMsg httpRespMsg = new HttpRespMsg();
+                        httpRespMsg.setError(errorMsg);
+                        return httpRespMsg;
                     }
-                } else {
-                    errorMsg = "erpOrderInfo表中工单号不存在:"+report.getExtraField4();
-                }
-                if (errorMsg != null) {
-                    HttpRespMsg httpRespMsg = new HttpRespMsg();
-                    httpRespMsg.setError(errorMsg);
-                    return httpRespMsg;
                 }
             }
         }

+ 25 - 22
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceMonthlyWorktimeServiceImpl.java

@@ -131,12 +131,17 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
     @Override
     public HttpRespMsg getByMonth(Integer companyId, String ymonth, Integer reGenerate, HttpServletRequest request) throws Exception {
         //获取该月份的数据,如果没有自动生成
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
         String token = request.getHeader("token");
         User user = userMapper.selectById(token);
         FinanceMonthlyWorktime financeMonthlyWorktime = financeMonthlyWorktimeMapper.selectOne(new LambdaQueryWrapper<FinanceMonthlyWorktime>().eq(FinanceMonthlyWorktime::getCompanyId, companyId).eq(FinanceMonthlyWorktime::getYmonth, ymonth));
         Integer detailCount = 0;
         if (financeMonthlyWorktime != null) {
             if (reGenerate== 1) {
+                if (financeMonthlyWorktime.getStatus() == 1) {
+                    httpRespMsg.setError("已定稿,无法重置");
+                    return httpRespMsg;
+                }
                 //删除明细数据
                 fmwDetailMapper.delete(new LambdaQueryWrapper<FmwDetail>().eq(FmwDetail::getFmwId, financeMonthlyWorktime.getId()));
             } else {
@@ -203,10 +208,6 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
                     departmentList.stream().filter(d->d.getDepartmentId().equals(report.getDeptId())).findFirst().ifPresent(d->{
                         fmwDetail.setDeptCode(d.getDeptCode());
                         fmwDetail.setDeptName(d.getDepartmentName());
-                        //为提高可读性,从erpOrderInfo表中获取部门名称
-                        erpOrderInfoList.stream().filter(e->e.getDeptId().equals(d.getDeptCode())).findFirst().ifPresent(e->{
-                            fmwDetail.setDeptName(e.getDeptName());
-                        });
                     });
                     setFmwTime(fmwDetail, report);
                     //从assistList中获取协作工时
@@ -301,23 +302,26 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
                                         }
                                     }
                                 }
-                            }
-
-                            List<FmwDetail> fmwDetails = insertDataList.stream().filter(fmwDetail -> fmwDetail.getDeptId().equals(deptId)).collect(Collectors.toList());
-                            double assistDeptTotalTime = fmwDetails.stream().reduce(0.0, (a, b) -> a + b.getMaintanceTime() + b.getDebugTime() + b.getWaitingTime(), Double::sum);
-                            if (assistDeptTotalTime > 0) {
-                                //计算总工时: 用维修组装工时,调试工时和等料工时相加
-                                insertDataList.forEach(fmwDetail -> {
-                                    //计算每一个项目的部门内部工时占比,按比例分摊公共工时
-                                    if (fmwDetail.getProjectId().equals(publicReportDeptItem.getProjectId())) {
-                                        double curProjectTime = fmwDetail.getMaintanceTime() + fmwDetail.getDebugTime() + fmwDetail.getWaitingTime();
-                                        double assignTime = curProjectTime / assistDeptTotalTime * publicReportDeptItem.getWorkingTime();
-                                        fmwDetail.setPublicTime(assignTime);
-                                    }
-                                });
                             } else {
-                                throw new Exception("存在部门公共工时无法分配,来源deptId=="+deptId);
+                                //本部门也没有协作其他部门产生工单工时
+                                throw new Exception("公共工时无法分配,因为本部门没有协作其他部门产生工单工时,deptId=="+deptId);
                             }
+
+//                            List<FmwDetail> fmwDetails = insertDataList.stream().filter(fmwDetail -> fmwDetail.getDeptId().equals(deptId)).collect(Collectors.toList());
+//                            double assistDeptTotalTime = fmwDetails.stream().reduce(0.0, (a, b) -> a + b.getAssistTime(), Double::sum);
+//                            if (assistDeptTotalTime > 0) {
+//                                //计算总工时: 用维修组装工时,调试工时和等料工时相加
+//                                insertDataList.forEach(fmwDetail -> {
+//                                    //计算每一个项目的部门内部工时占比,按比例分摊公共工时
+//                                    if (fmwDetail.getProjectId().equals(publicReportDeptItem.getProjectId())) {
+//                                        double curProjectTime = fmwDetail.getMaintanceTime() + fmwDetail.getDebugTime() + fmwDetail.getWaitingTime();
+//                                        double assignTime = curProjectTime / assistDeptTotalTime * publicReportDeptItem.getWorkingTime();
+//                                        fmwDetail.setPublicTime(assignTime);
+//                                    }
+//                                });
+//                            } else {
+//                                throw new Exception("存在部门公共工时无法分配,来源deptId=="+deptId);
+//                            }
                         }
                     }
                 }
@@ -330,9 +334,8 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
         //查询数据
         List<FmwDetail> details = fmwDetailMapper.selectList(new QueryWrapper<FmwDetail>().eq("fmw_id", financeMonthlyWorktime.getId()));
         financeMonthlyWorktime.setDetailList(details);
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.data = financeMonthlyWorktime;
-        return msg;
+        httpRespMsg.data = financeMonthlyWorktime;
+        return httpRespMsg;
     }
 
     private void setFmwTime(FmwDetail fmwDetail, Report report) {

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -2125,7 +2125,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 String name = (String)a.get("name");
                 String uid = (String)a.get("userId");
                 String corpwxUserid = (String)a.get("corpwxUserid");
-
+                System.out.println("createDate=="+createDate + " name=="+name+" uid=="+uid+" corpwxUserid=="+corpwxUserid);
                 if (lastName == null || !(lastName.get("name").equals(name) && lastName.get("dateStr").equals(createDate))) {
                     lastName = new HashMap<String, Object>();
                     lastName.put("dateStr", createDate);

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -739,6 +739,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             });
             functionQueryWrapper.orderByAsc("seq");
             List<SysFunction> functionList = sysFunctionMapper.selectList(functionQueryWrapper);
+            //对于一些特定功能的权限做判断过滤
+            if (timeType.getTaskFileCharge() == 0) {
+                functionList = functionList.stream().filter(f -> !f.getName().equals("查看他人审核文件")).collect(Collectors.toList());
+            }
             functionList = functionList.stream().filter(f->functionIdList.contains(f.getId())).collect(Collectors.toList());
             user.setFunctionList(functionList);
         } else {

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/MD5Util.java

@@ -22,7 +22,7 @@ public class MD5Util {
     }
 
     public static void main(String[] args) throws ParseException {
-        System.out.println(getPassword("工时管家"));
+        System.out.println(getPassword("Dy890606@1"));
 
     }
 

+ 12 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue

@@ -238,7 +238,7 @@
             <div class="monthlyFinance">
               <div class="monthlyFinance-item">
                 <el-date-picker v-model="obtainMonthlyFinancialStatementsYmonth" type="month" placeholder="选择月" :clearable="false" @change="selcts()" size="small" value-format="yyyy-MM" style="width: 160px"></el-date-picker>
-                <el-button size="small" style="margin-left: 15px;" @click="getObtainMonthlyFinancialStatements(1)">重置工时</el-button>
+                <el-button size="small" style="margin-left: 15px;" @click="resetWorkingHours()">重置工时</el-button>
                 <el-tooltip class="item" effect="dark" placement="bottom">
                   <div slot="content">
                     以当月人工填报工时进行统计,公共工时自动分摊 <br/><br/>
@@ -4952,6 +4952,16 @@ export default {
         this.projectMainIdList = res.data || []
       })
     },
+    // 重置工时
+    resetWorkingHours() {
+      this.$confirm('确定重置工时吗?', '重置工时', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.getObtainMonthlyFinancialStatements(1)
+      })
+    },
     // 获取月度财务工时表
     getObtainMonthlyFinancialStatements(reGenerate = '') {
       this.obtainMonthlyFinancialStatementsLoading = true
@@ -4971,7 +4981,7 @@ export default {
           detailList: (res.data.detailList || []).map(item => {
             const timeFields = ['maintanceTime', 'debugTime', 'waitingTime', 'assistTime', 'publicTime'];
             const totalTime = timeFields.reduce((sum, key) => sum + (item[key] || 0), 0);
-            return { ...item, totalTime };
+            return { ...item, totalTime: (totalTime + '' || '0').toFixed(2) };
           })
         };
       }).finally(() => {

+ 9 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -43,6 +43,13 @@
                         <el-button @click="backToParentDept" size="small">返回上级</el-button>
                     </div>
 
+                    <el-select v-model="projectStatus" placeholder="请选择项目状态" clearable @change="filterConditionSwitching" v-if="singleChoiceType == '项目'" size="small" style="margin-right: 10px">
+                        <el-option label="进行中" value="1"></el-option>
+                        <el-option label="已完成" value="2"></el-option>
+                        <el-option label="已撤销" value="3"></el-option>
+                        <el-option label="暂停" value="4"></el-option>
+                    </el-select>
+
                     <select-project v-model="chartProjectId" :size="'small'" :placeholder="'请选择项目'" clearable
                         v-if="singleChoiceType == '项目' || singleChoiceType == '设备' || singleChoiceType == namess"
                         @change="filterConditionSwitching"></select-project>
@@ -141,6 +148,7 @@ export default {
             reportExportVisable: false,
             hasReportUserList: [],
             theCustomListFlgBtnLoading: false,
+            projectStatus: '',
         }
     },
 
@@ -188,7 +196,7 @@ export default {
             const urlMap = {
                 ['项目']: {
                     url: this.port.project.listCost,
-                    extraParams: { projectId: this.chartProjectId, type: this.chartYAxisVal[this.chartYAxis] }
+                    extraParams: { projectId: this.chartProjectId, type: this.chartYAxisVal[this.chartYAxis], status: this.projectStatus ? this.projectStatus : '0' }
                 },
                 ['主项目']: { url: '/project/getTimeCostByMainProject' },
                 ['项目分类']: { url: '/project/getTimeCostByCategory' },