Browse Source

项目人天修改提奥

Min 2 years ago
parent
commit
9a2deeaa6a

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

@@ -957,7 +957,7 @@ public class ReportController {
         //如果开启了项目人天
         if(comTimeType.getProjectManDay()==1){
             Collection<Integer> projectIds = reportList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
-            List<Report> needCheckReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds));
+            List<Report> needCheckReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds).and(wrapper->wrapper.eq("state",0).or().eq("state",1).or().eq("state",3)));
             List<Project> targetProjectList = projectList.stream().filter(pl -> projectIds.contains(pl.getId())).collect(Collectors.toList());
             for (Report report : reportList) {
                     HttpRespMsg httpRespMsg = new HttpRespMsg();

+ 12 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Project.java

@@ -436,6 +436,18 @@ public class Project extends Model<Project> {
     @TableField(exist = false)
     private HashMap plateMap;
 
+    /**
+     * 预估工时
+     * */
+    @TableField(exist = false)
+    private String estimatedWorkTime;
+
+    /**
+     * 剩余预算工时
+     * */
+    @TableField(exist = false)
+    private String residueEstimatedWorkTime;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 30 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -387,7 +387,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 projectIds.add(-1);
             }
             List<Map<String,Object>> particpationList=participationMapper.getAllParticipator(projectIds);
+            List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id",projectIds).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
             for (Project project : projectList) {
+                //todo:计算项目预算工时
+                if(project.getManDay()!=null){
+                    BigDecimal bigDecimal=new BigDecimal(project.getManDay());
+                    bigDecimal=bigDecimal.multiply(new BigDecimal(timeType.getAllday()));
+                    String format = String.format("%.1f", bigDecimal.doubleValue());
+                    project.setEstimatedWorkTime(format);
+                    //todo:计算剩余工时
+                    List<Report> reports = reportList.stream().filter(rl -> rl.getProjectId().equals(project.getId())).collect(Collectors.toList());
+                    //已发送工时
+                    double sum = reports.stream().mapToDouble(Report::getWorkingTime).sum();
+                    bigDecimal=bigDecimal.subtract(new BigDecimal(sum));
+                    String format1 = String.format("%.1f", bigDecimal.doubleValue());
+                    project.setResidueEstimatedWorkTime(format1);
+                }
                 ProjectVO projectVO = new ProjectVO();
                 if(timeType.getProjectLevelState()==1){
                     Optional<ProjectLevel> first = projectLevelList.stream().filter(pl -> pl.getId().equals(project.getLevel())).findFirst();
@@ -1697,6 +1712,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<Project> projectList= (List<Project>) mapList.get("records");
         Project project = projectList.get(0);
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        TimeType timeType = timeTypeMapper.selectById(companyId);
+        //todo:计算项目预算工时
+        if(project.getManDay()!=null){
+            BigDecimal bigDecimal=new BigDecimal(project.getManDay());
+            bigDecimal=bigDecimal.multiply(new BigDecimal(timeType.getAllday()));
+            String format = String.format("%.1f", bigDecimal.doubleValue());
+            project.setEstimatedWorkTime(format);
+            //todo:计算剩余工时
+            List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("project_id", project.getId()).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
+            //已发送工时
+            double sum = reportList.stream().mapToDouble(Report::getWorkingTime).sum();
+            bigDecimal=bigDecimal.subtract(new BigDecimal(sum));
+            String format1 = String.format("%.1f", bigDecimal.doubleValue());
+            project.setResidueEstimatedWorkTime(format1);
+        }
         List<ProjectCustom> proCustomList = projectCustomMapper.selectList(new QueryWrapper<ProjectCustom>().eq("company_id", companyId));
         //按顺序存储项目自定义字段 对应plate
         HashMap map=new HashMap();

+ 19 - 3
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -361,9 +361,14 @@
                     {{scope.row.progress==null?"-":scope.row.progress}}%
                 </template>
             </el-table-column>
-            <el-table-column prop="manDay" :label="'预估工时'" min-width="100"   v-if="user.timeType.projectManDay == 1">
+            <el-table-column prop="manDay" :label="'预估工时'" min-width="150"   v-if="user.timeType.projectManDay == 1">
                 <template slot-scope="scope">
-                    {{scope.row.manDay==null?"":scope.row.manDay}}<span v-if="scope.row.manDay">人天</span>
+                    {{scope.row.manDay==null?"":scope.row.manDay}}<span v-if="scope.row.manDay">人天({{scope.row.estimatedWorkTime}}h)</span>
+                </template>
+            </el-table-column>
+            <el-table-column prop="residueEstimatedWorkTime" :label="'剩余预估工时'" min-width="120"   v-if="user.timeType.projectManDay == 1">
+                <template slot-scope="scope">
+                    {{scope.row.residueEstimatedWorkTime==null?"":scope.row.residueEstimatedWorkTime}}<span v-if="scope.row.residueEstimatedWorkTime">h</span>
                 </template>
             </el-table-column>
             <el-table-column :label="$t('operation')" :width="showColumnWidth" align="left" fixed="right" v-if="showColumnWidth != '0' || permissions.projectManagement">
@@ -583,7 +588,10 @@
 
                     <!-- 增加项目人天字段 绎维固定字段 -->
                     <el-form-item label="项目人天" v-if="user.timeType.projectManDay == 1">
-                        <el-input v-model.number="addForm.manDay" :placeholder="$t('peaseenterthe')"  style="width: 100px"></el-input><span style="margin-left:10px;position:absolute;">人天</span>
+                        <el-input v-model.number="addForm.manDay" :placeholder="$t('peaseenterthe')" @input="jisuanEstimatedWorkTime(addForm.manDay)"  style="width: 100px"></el-input><span style="margin-left:10px;position:absolute;">人天(预估工时:{{this.estimatedWorkTime}}小时)</span>
+                        <el-tooltip effect="dark" :content="$t('根据系统基础设置每日正常工作时长计算,1人天为一个每日正常工作时长')" placement="top-start" style="margin-left:180px">
+                                        <i class="el-icon-question" style="color:#606266"></i>
+                        </el-tooltip>
                     </el-form-item>
 
                     <el-form-item :label="$t('projectoutput')" prop="outputValue"  v-if="user.timeType.outputValueStatus == 1">
@@ -1576,6 +1584,7 @@ a {
                 dataListBf: [],
                 imgUrlLists: '',
                 imgUrlListFlg: false,
+                estimatedWorkTime:''
             };
         },
         // 过滤器
@@ -3945,6 +3954,7 @@ a {
                         manDay:0
                         // deptId: []
                     }
+                    this.estimatedWorkTime=''
                     for(var i in this.dataList) {
                         var str = 'plate' + (+i + 1)
                         this.$set(this.addForm,str, '')
@@ -3986,6 +3996,7 @@ a {
                     res => {
                     if (res.code == "ok") {
                         this.chulishuju(res.data)
+                        this.estimatedWorkTime=res.data.estimatedWorkTime==null?0:res.data.estimatedWorkTime
                     }
                     });
                     //编辑时,非 (管理全部项目,项目创建人,项目经理),有编辑项目参与人权限的人,可以进行参与人的修改
@@ -4685,6 +4696,11 @@ a {
                     }
                 );
             },
+
+            //计算预估工时
+            jisuanEstimatedWorkTime(manDay){
+                this.estimatedWorkTime=manDay*this.user.timeType.allday
+            }
         },
         created() {
             let height = window.innerHeight;