Przeglądaj źródła

数据库定时备份脚本

seyason 1 rok temu
rodzic
commit
848602c112

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

@@ -89,6 +89,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     @Resource
     ExcelExportService excelExportService;
     @Resource
+    UserCorpwxTimeMapper userCorpwxTimeMapper;
+    @Resource
     private ProjectNotifyUserService projectNotifyUserService;
     @Resource
     private GroupParticipatorMapper groupParticipatorMapper;
@@ -7678,6 +7680,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
+        Company company = companyMapper.selectById(user.getCompanyId());
         List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
         List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
         List<Integer> deptIds=null;
@@ -7713,6 +7716,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate localStartDate = LocalDate.parse(startDate, dateTimeFormatter);
         LocalDate localEndDate = LocalDate.parse(endDate, dateTimeFormatter);
+        //如果没有开通OA模块,有开通企业微信同步考勤,从user_corpwx_time表中获取请假时长
+        List<UserCorpwxTime> userCorpwxTimeList = null;
+        if (company.getPackageOa() == 0 && allDay.getSyncCorpwxTime() == 1) {
+            userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().select("corpwx_userid, sum(ask_leave_time) as ask_leave_time").eq("company_id", companyId).between("create_date", startDate, endDate).groupBy("corpwx_userid"));
+        }
         for (Map<String, Object> map : list) {
             //取部门名
             for (Department department : deptName) {
@@ -7737,8 +7745,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             }
             int days = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 0).size();
             Float allday = allDay.getAllday();
+            float leaveSum = 0.0f;
             float standardHours = allday*days;
-            float leaveSum = leaveSheetService.leaveTimeSum(companyId,startDate,endDate,standardHours,allday,leaveSheets);
+            if (company.getPackageOa() == 1) {
+                leaveSum = leaveSheetService.leaveTimeSum(companyId,startDate,endDate,standardHours,allday,leaveSheets);
+            } else if (wxCorpInfo != null && userCorpwxTimeList != null) {
+                Optional<UserCorpwxTime> find = userCorpwxTimeList.stream().filter(uct -> uct.getCorpwxUserid().equals(map.get("corpwxUserId"))).findFirst();
+                if (find.isPresent()) {
+                    UserCorpwxTime userCorpwxTime = find.get();
+                    Double askLeaveTime = userCorpwxTime.getAskLeaveTime();
+                    if (askLeaveTime != null) {
+                        leaveSum = askLeaveTime.floatValue();
+                    }
+                }
+            }
             map.put("leaveSum",leaveSum + "h");
             double workTimeDouble = Double.parseDouble(map.get("workingTime").toString()) + leaveSum;
             BigDecimal workTimeBig = new BigDecimal(workTimeDouble);

+ 1 - 0
fhKeeper/formulahousekeeper/mysqlRollBack.cron

@@ -0,0 +1 @@
+0 2 * * * /root/mysql_dump_script.sh

+ 42 - 0
fhKeeper/formulahousekeeper/mysql_dump_script.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#保存备份个数,备份7天数据
+number=7
+#备份保存路径
+backup_dir=/www/mysqlbackup
+#日期
+dd=`date +%Y-%m-%d-%H-%M-%S`
+#备份工具
+tool=mysqldump
+#用户名
+username=数据库账号
+#密码
+password=数据库密码
+#将要备份的数据库,此处为全部数据库
+database_name=alldb
+
+#如果文件夹不存在则创建
+if [ ! -d $backup_dir ]; 
+then     
+    mkdir -p $backup_dir; 
+fi
+
+#简单写法  mysqldump -u root -p123456 users > /www/mysqlbackup/users-$filename.sql
+$tool -u $username -p$password -A > $backup_dir/$database_name-$dd.sql
+
+#写创建备份日志
+echo "create $backup_dir/$database_name-$dd.dupm" >> $backup_dir/log.txt
+
+#找出需要删除的备份
+delfile=`ls -l -crt  $backup_dir/*.sql | awk '{print $9 }' | head -1`
+
+#判断现在的备份数量是否大于$number
+count=`ls -l -crt  $backup_dir/*.sql | awk '{print $9 }' | wc -l`
+
+if [ $count -gt $number ]
+then
+  #删除最早生成的备份,只保留number数量的备份
+  rm $delfile
+  #写删除文件日志
+  echo "delete $delfile" >> $backup_dir/log.txt
+fi

+ 2 - 3
fhKeeper/formulahousekeeper/octopus/index.html

@@ -70,9 +70,8 @@
         <script src="https://cdn.staticfile.org/vuex/3.0.0/vuex.min.js"></script>
         <!-- 引入vue-router -->
         <script src="https://cdn.staticfile.org/vue-router/3.0.0/vue-router.min.js"></script>
-        <!-- 引入组件库 -->
-        <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>
+        <script src="./static/js/element-ui.js"></script>
         <!-- 引入echarts -->
-        <script src="https://cdn.staticfile.org/echarts/3.8.5/echarts.min.js"></script>
+        <script src="./static/js/echarts.min.js"></script>
     </body>
 </html>

+ 4 - 4
fhKeeper/formulahousekeeper/timesheet/index.html

@@ -148,11 +148,11 @@
     <script src="https://cdn.staticfile.org/vue-router/3.0.0/vue-router.min.js"></script>
     <!-- <script src="./static/js/vue-router.min.js"></script> -->
     <!-- 引入组件库 -->
-    <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>
-    <!-- <script src="./static/js/element-ui.js"></script> -->
+    <!-- <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script> -->
+    <script src="./static/js/element-ui.js"></script>
     <!-- 引入echarts -->
-    <script src="https://cdn.staticfile.org/echarts/3.8.5/echarts.min.js"></script>
-    <!-- <script src="./static/js/echarts.min.js"></script> -->
+    <!-- <script src="https://cdn.staticfile.org/echarts/3.8.5/echarts.min.js"></script> -->
+    <script src="./static/js/echarts.min.js"></script>
     <!-- 引入企业微信js -->
     <script
       src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"

+ 2 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/contract/index.vue

@@ -148,7 +148,7 @@
             </el-input>
           </el-form-item>
           <el-form-item :label="$t('he-tong-lei-xing')">
-            <el-select v-model="contractForm.typeId":disabled="contractForm.status == 0" :placeholder="$t('defaultText.pleaseChoose')" style="width:100%">
+            <el-select v-model="contractForm.typeId" :disabled="contractForm.status == 0" :placeholder="$t('defaultText.pleaseChoose')" style="width:100%">
               <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
             </el-select>
           </el-form-item>
@@ -735,6 +735,7 @@ export default {
         startDate: '',
         endDate: ''
       }
+      this.contractPaymentList = [];
       this.fileList = []
       this.addDialog = true
     },