Browse Source

上传财务核算数据时同步总成本到个人月成本中

seyason 3 năm trước cách đây
mục cha
commit
e010531ade

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

@@ -107,24 +107,24 @@ public class ReportController {
         User user = userService.getById(token);
         LocalDate now = LocalDate.now();
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        BigDecimal hourCost = null;
-        if (user.getCostApplyDate() != null) {
-            //检查有效期
-            if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
-                //取上一个历史成本
-                List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
-                if (list.size() > 1) {
-                    hourCost = list.get(1).getCost();
-                } else {
-                    //没有记录,又没有达到预设的起效时间,则默认为0
-                    hourCost = new BigDecimal(0);
-                }
-            } else {
-                hourCost = user.getCost();
-            }
-        } else {
-            hourCost = user.getCost();
-        }
+        BigDecimal hourCost = user.getCost();;
+//        if (user.getCostApplyDate() != null) {
+//            //检查有效期
+//            if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
+//                //取上一个历史成本
+//                List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
+//                if (list.size() > 1) {
+//                    hourCost = list.get(1).getCost();
+//                } else {
+//                    //没有记录,又没有达到预设的起效时间,则默认为0
+//                    hourCost = new BigDecimal(0);
+//                }
+//            } else {
+//                hourCost = user.getCost();
+//            }
+//        } else {
+//            hourCost = user.getCost();
+//        }
 
         if (hourCost == null) {
             hourCost = new BigDecimal(0);

+ 23 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -5,6 +5,7 @@ import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.FinanceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.service.UserService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MD5Util;
@@ -52,11 +53,15 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     @Resource
     private UserMapper userMapper;
     @Resource
+    private UserService userService;
+    @Resource
     private DepartmentMapper departmentMapper;
     @Resource
     private FinanceService financeService;
     @Resource
     private ProjectMapper projectMapper;
+    @Resource
+    private TimeTypeMapper timeTypeMapper;
     @Value(value = "${upload.path}")
     private String path;
 
@@ -103,7 +108,11 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             LocalDateTime endDate = LocalDateTime.parse(dateStr,df);
             endDate = endDate.plusMonths(1);
 
+            TimeType timeType = timeTypeMapper.selectById(companyId);
+            BigDecimal monthHours = timeType.getMonthDays().multiply(new BigDecimal(timeType.getAllday()));
 
+            //需要更新成本的人员数据
+            List<User> updateUserList = new ArrayList<>();
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
@@ -149,6 +158,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
                 Optional<User> first = first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
                 if (first.isPresent()) {
+
                     finance.setUserId(first.get().getId());
                     BigDecimal total = new BigDecimal(0);
                     if (salaryCell != null) {
@@ -215,6 +225,13 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                         total = total.add(value);
                     }
                     finance.setTotalCost(total);
+
+                    //设置人员总成本,计算时薪
+                    User localUser = new User();
+                    localUser.setId(finance.getUserId());
+                    localUser.setMonthCost(total);
+                    localUser.setCost(total.divide(monthHours, 2, BigDecimal.ROUND_HALF_UP));
+                    updateUserList.add(localUser);
                 } else {
                     msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
                     return msg;
@@ -226,6 +243,12 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
             //批量插入
             financeService.saveOrUpdateBatch(financeList);
+            userService.updateBatchById(updateUserList);
+
+            //同步个人的成本为财务上传的成本
+            financeList.stream().forEach(f->{
+
+            });
 
             //检查是否有删除的,需要删除掉
             List<Integer> readyForDelete = new ArrayList<>();

+ 5 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -179,9 +179,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                    String planStartDate,
                                    String planEndDate,
                                    Integer level,
-                                   Integer contractAmount,
+                                   Double contractAmount,
                                    String projectBaseCostData,
-                                   Integer budget,
+                                   Double budget,
                                    Integer customerId,
                                    HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -591,7 +591,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         //计算项目总成本
         projectBasecostMapper.delete(new QueryWrapper<ProjectBasecost>().eq("project_id", project.getId()));
         JSONArray array = JSONArray.parseArray(baseCostData);
-        int totalBudget = 0;
+        double totalBudget = 0;
         for (int i=0;i<array.size(); i++) {
             JSONObject obj = array.getJSONObject(i);
             ProjectBasecost cost = JSONObject.toJavaObject(obj, ProjectBasecost.class);
@@ -1056,9 +1056,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         if (cnt > 0) {
                             throw new Exception("项目编码存在重复: " + code);
                         }
-                    } else {
-                        project.setProjectCode(code);
                     }
+                    project.setProjectCode(code);
                 }
 
                 String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
@@ -1096,7 +1095,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     project.setPlanEndDate(LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                 }
                 if (amountCell !=null && !StringUtils.isEmpty(amountCell.getStringCellValue())) {
-                    project.setContractAmount(Integer.parseInt(amountCell.getStringCellValue()));
+                    project.setContractAmount(Double.parseDouble(amountCell.getStringCellValue()));
                 }
 
                 projectMapper.insert(project);

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/Login.vue

@@ -23,7 +23,7 @@
                             <p><span style="color: #333">QQ:</span><span id="QQ">3052894409</span></p>
                         </div>
                     </el-link>
-                    <span style="margin-right:5px;color:#999;">V3.4.11</span>
+                    <span style="margin-right:5px;color:#999;">V3.4.13</span>
                     <!-- <el-link type="primary" style="margin-right:5px;" @click="dialogVisible=true" :underline="false">
                         使用说明
                     </el-link> -->

+ 47 - 27
fhKeeper/formulahousekeeper/timesheet/src/views/settings/timetype.vue

@@ -9,7 +9,7 @@
                 </el-form-item>
             </el-form>
         </el-col>
-        <p style="padding-top:80px;margin-left:10px;color:#666;">员工时薪录入方式设置</p>
+        <p style="padding-top:80px;margin: 0 0 10px 10px;color:#666;">员工时薪录入方式设置</p>
         <div class="panel" style="height:120px;margin-left:20px;margin-right:20px;">
         <el-radio v-model="timeType.hourCostInputType" :label="0" style="width:100%;margin-left:10px;">方式一: 录入月成本,自动计算时薪<span class="tip">(适合企业全职员工)</span>
             <el-form ref="form0" :inline="true" :model="timeType" label-width="150px" style="margin-top:10px;">
@@ -95,14 +95,15 @@
             <p>
             展示样例
             </p>
+            
             <div style="width:500px;">
                开始时间: <el-time-picker
                     v-model="startTime"
                     :picker-options="{
                         start: '08:30',
-                        step: '00:15',
                         end: '18:30'
                     }"
+                    format="HH:mm"
                     placeholder="任意时间点">
                 </el-time-picker>
             </div>
@@ -111,43 +112,61 @@
                             v-model="endTime"
                             :picker-options="{
                                 start: '08:30',
-                                step: '00:15',
                                 end: '18:30',
                                 minTime: startTime
                             }"
+                            format="HH:mm"
                             placeholder="任意时间点">
                         </el-time-picker>
             </div>
-            <!-- <div style="width:500px;">
-                开始时间:<el-time-select
-                    placeholder="起始时间"
-                    v-model="startTime"
-                    :picker-options="{
-                    start: '08:30',
-                    step: '00:15',
-                    end: '18:30'
-                    }">
-                </el-time-select>
-            </div>
-            <div style="margin-top:5px;">
-               结束时间:<el-time-select
-                    placeholder="结束时间"
-                    v-model="endTime"
-                    :picker-options="{
-                    start: '08:30',
-                    step: '00:15',
-                    end: '18:30',
-                    minTime: startTime
-                    }">
-                </el-time-select>
-            </div> -->
                 </div>
             </el-radio> 
+        </div>
+        </el-col>
+
+        <!--选择按比例分配样式 -->
+        <el-col :span="8">  
+        <div  class="panel" >
+            <el-radio v-model="timeType.type" :label="3">按比例分配时间
+            <div class="sample">
+            <p>
+            展示样例
+            </p>
             
+            <div style="width:300px;">
+                <el-col span="6">用时占比: </el-col>
+                <el-col span="8"><el-slider v-model="progress" :step="10" style="width:100px;margin-top:-12px;" ></el-slider></el-col>
+                <el-col span="10"><span style="margin-left:10px;float:right;"><span style="margin-right:10px;">{{progress}}%</span>{{(progress*8/100).toFixed(1)}}小时</span></el-col>
+            </div>
+                </div>
+            </el-radio> 
         </div>
         </el-col>
         </el-row>
-
+        <!--设置时长样式内容-->
+        <p style="margin-left:10px;color:#666;">填报提醒时间设置</p>
+        <el-row :gutter="20" style="padding-top:10px;width:100%;margin:0 auto;padding-left:10px;padding-right:10px;">
+        <el-col :span="24" >
+            <div class="panel" style="height:60px;">
+                <el-form :inline="true" :model="timeType"  style="margin-top:10px;">
+                 
+                <el-form-item label="未填报提醒时间 " prop="alertTime">
+                    <el-time-picker 
+                            v-model="timeType.alertTime"
+                            placeholder="提醒时间"
+                            style="width:120px;"
+                            format="HH:mm"
+                            value-format="HH:mm"
+                            :picker-options="{
+                            start: '08:00',
+                            end: '23:30'
+                            }">
+                        </el-time-picker>
+                </el-form-item>
+                </el-form>
+            </div>
+        </el-col>
+        </el-row>
         <div style="width:80px;margin:0 auto;padding:20px;">
             <el-button  type="primary" @click="submitInsert" :loading="addLoading">保存</el-button>
         </div>
@@ -160,6 +179,7 @@
     export default {
         data() {
             return {
+                progress:30,
                 startTime:null,
                 endTime:null,
                 timeRange:[0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,12.5,13.0,13.5,14.0,14.5,15.0],

+ 18 - 9
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -143,15 +143,15 @@
                     </el-radio-group>
                 </el-form-item>
                 <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0 && (user.role == 4 || user.role == 6)" >
-                    <el-input v-model.number="insertForm.monthCost" @input="oninput" placeholder="请输入月成本,单位:元" clearable></el-input>
+                    <el-input v-model="insertForm.monthCost" id="mc" @input="oninput" placeholder="请输入月成本,单位:元" clearable @keyup.native="restrictNumber('mc')"></el-input>
                     <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
                     <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
                 </el-form-item>
                 <el-form-item label="时薪" prop="cost" v-if="user.role == 4 || user.role == 6">
-                    <el-input v-model.number="insertForm.cost" :disabled="insertForm.salaryType == 0" style="width:120px;"
+                    <el-input v-model="insertForm.cost" :disabled="insertForm.salaryType == 0" id="cc" style="width:120px;" @keyup.native="restrictNumber('cc')"
                      placeholder="请输入成本 单位:元/小时" clearable></el-input>
-                    <span style="margin-left:25px;">生效日期</span>
-                    <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker>
+                    <!-- <span style="margin-left:25px;">生效日期</span>
+                    <el-date-picker v-model="insertForm.costApplyDate" value-format="yyyy-MM-dd"></el-date-picker> -->
                 </el-form-item>
                 <el-form-item label="部门" prop="departmentId">
                     <el-cascader v-model="insertForm.departmentId" placeholder="请选择部门" style="width: 100%"
@@ -192,15 +192,15 @@
                     </el-radio-group>
                 </el-form-item>
                 <el-form-item label="月成本" prop="monthCost" v-if="insertForm.salaryType == 0 && (user.role == 4 || user.role == 6)" >
-                    <el-input v-model.number="insertForm.monthCost" @input="oninput" placeholder="请输入月成本,单位:元" clearable></el-input>
+                    <el-input v-model="insertForm.monthCost" id="monthCost" @input="oninput" @keyup.native="restrictNumber('monthCost')" placeholder="请输入月成本,单位:元" clearable></el-input>
                     <span style="color:orange;font-size:12px;">按照每个月工作{{timeType.monthDays}}天,每天{{timeType.allday}}小时预估时薪</span>
                     <el-link :underline="false" style="color:blue;font-size:12px;margin-left:7px;" href="#/timetype">修改工作时长</el-link>
                 </el-form-item>
                 <el-form-item label="时薪" prop="cost" v-if="user.role == 4 || user.role == 6">
-                    <el-input v-model.number="insertForm.cost" :disabled="insertForm.salaryType == 0" style="width:120px;"
+                    <el-input v-model="insertForm.cost" id="cost" :disabled="insertForm.salaryType == 0" @keyup.native="restrictNumber('cost')" style="width:120px;"
                      placeholder="请输入成本 单位:元/小时" clearable></el-input>
-                    <span style="margin-left:25px;">生效日期</span>
-                    <el-date-picker v-model="insertForm.costApplyDate"  value-format="yyyy-MM-dd"></el-date-picker>
+                    <!-- <span style="margin-left:25px;">生效日期</span>
+                    <el-date-picker v-model="insertForm.costApplyDate"  value-format="yyyy-MM-dd"></el-date-picker> -->
                 </el-form-item>
                 <el-form-item label="部门" prop="departmentId">
                     <el-cascader v-model="insertForm.departmentId" 
@@ -370,8 +370,17 @@
             };
         },
         methods: {
+            restrictNumber(targetId) {
+                let inpu = document.getElementById(targetId);
+                inpu.value = inpu.value.replace(/[^\d.]/g, "");  //仅保留数字和"."
+                inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
+                inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
+                inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
+                if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
+                    inpu.value = parseFloat(inpu.value);
+                }
+            },
             showConfirmDialog() {
-
                 if (this.toUserId == null || this.toUserId == '') {
                     this.$message({
                             message: '请选择要转让的人员',

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

@@ -654,7 +654,7 @@
                         ids += ',';
                     }
                 }
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1)> 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 
                 this.http.post("/report/batchApproveReport", {ids:ids, date:this.date + day},
                 res => {
@@ -806,7 +806,7 @@
             
             // 获取部门列表
             getDepartment() {
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 var param = {date:this.date + day};
                 if (this.user.manageDeptId != 0) {
                     param.manageDeptId = this.user.manageDeptId;
@@ -1024,7 +1024,7 @@
             // 选择日期
             choseDate(i, item) {
                 this.choseDay = i;
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 sessionStorage.msg = this.date + day,
                 this.getReportList();
                 this.getDepartment();
@@ -1090,7 +1090,7 @@
             //获取日报列表
             getReportList() {
                 this.listLoading = true;
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 let param = {date: this.date + day};
                 if (this.deptId != null) {
                     param.deptId = this.deptId;
@@ -1254,7 +1254,7 @@
                 } else {
                     this.isDisable = true;
                 }
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay +1)> 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 this.isBatch = isBatch;
                 if (this.isBatch == 0) {
                     this.workForm.createDate = this.date + day; // 获取个人某天的日报
@@ -1491,14 +1491,14 @@
             },
             // 跳转
             junpToDeskTop(id) {
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 this.$router.push("/desktop/" + id + "/" + this.date +day);
             },
 
             // 通过日报
             approve(id, item) {
                 this.logining = true;
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
 
                 var ids = '';
                 var data = item.data;
@@ -1569,7 +1569,7 @@
             // 未通过日报
             deny(id,i, item) {
                 this.logining = true;
-                let day = this.choseDay > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
+                let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 var ids = '';
                 var data = item.data;
                 data.forEach(element => {