Browse Source

开发AI智能填报功能

seyason 2 năm trước cách đây
mục cha
commit
45cc272f7d

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

@@ -201,6 +201,18 @@ public class ReportController {
         return reportService.getReport(date, request);
     }
 
+    /**
+     * AI智能填报
+     * @param date
+     * @return
+     */
+    @RequestMapping("/getAIReport")
+    public HttpRespMsg getAIReport(@RequestParam String date) {
+        return reportService.getAIReport(date, request);
+    }
+
+
+
     @RequestMapping("/getCardTime")
     public HttpRespMsg getCardTime(@RequestParam String date) {
         return reportService.getCardTime(date, request);

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -112,4 +112,6 @@ public interface ReportService extends IService<Report> {
     HttpRespMsg fillWorkingHours(String yearMonth, MonthWorkingTimeVO monthVO, HttpServletRequest request);
 
     HttpRespMsg fillAll(String month, String userId, Integer departmentId, Integer whether,HttpServletRequest request);
+
+    HttpRespMsg getAIReport(String date, HttpServletRequest request);
 }

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

@@ -5872,4 +5872,147 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         }
         return new HttpRespMsg();
     }
+
+    @Override
+    public HttpRespMsg getAIReport(String date, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        String userId = request.getHeader("token");
+        Integer companyId = userMapper.selectById(userId).getCompanyId();
+        Company company = companyMapper.selectById(companyId);
+        //先判断用户是否填写过日报
+        QueryWrapper<Report> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("creator_id",userId).orderByDesc("id").last("limit 1");
+        Report report = reportMapper.selectOne(queryWrapper);
+        if (report != null) {
+            queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("creator_id", userId).eq("create_date", report.getCreateDate());
+            //获取最近填写的那一天的全部日报
+            List<Report> reports = reportMapper.selectList(queryWrapper);
+            List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>()
+                    .eq("company_id", companyId).eq("status", 1));
+            //仅保留进行中的项目的日报
+            reports = reports.stream().filter(r->allProjectList.stream().anyMatch(p->p.getId().equals(r.getProjectId()))).collect(Collectors.toList());
+            try {
+                List<Integer> integerList = reports.stream().map(Report::getProjectId).collect(Collectors.toList());
+                //开启状态的子项目
+                List<SubProject> subProjects = subProjectMapper.selectList(new QueryWrapper<SubProject>().in("project_id", integerList).eq("status", 1));
+                List<SubProject> subProjectList = integerList.size() > 0?subProjects:new ArrayList<>();
+                List<ProjectAuditor> auditorList = integerList.size() > 0?projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().in("project_id", integerList)): new ArrayList<>();
+                List<Profession> professions = professionMapper.selectList(new QueryWrapper<Profession>().eq("company_id", companyId));
+                List<ReportExtraDegree> degreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", companyId));
+                List<TaskGroup> taskGroups = integerList.size() > 0?taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", integerList)):new ArrayList<>();
+                List<Stages> stagesList = integerList.size() > 0?stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", integerList)) : new ArrayList<>();
+                //获取当前项目的子项目列表,任务分组,任务列表,项目相关维度列表
+                reports.forEach(r->{
+                    r.setContent(null);
+                    r.setSubProjectList(subProjectList.stream().filter(s->s.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
+                    r.setTaskList(taskMapper.recentSimpleList(r.getProjectId(), userId));
+                    //获取当前项目的工程专业进度
+                    List<ReportProfessionProgress> progressList = reportProfessionProgressService.list(new QueryWrapper<ReportProfessionProgress>().eq("report_id", r.getId()));
+                    //去掉当前项目上已经不存在的专业
+                    List<ProjectProfession> projectProfessions = projectProfessionMapper.selectList(new QueryWrapper<ProjectProfession>().eq("project_id", r.getProjectId()));
+                    progressList = progressList.stream().filter(p->projectProfessions.stream().anyMatch(pp->pp.getProfessionId().equals(p.getProfessionId()))).collect(Collectors.toList());
+                    progressList.stream().forEach(p->{
+                        p.setProfessionName(professions.stream().filter(m->m.getId().equals(p.getProfessionId())).findFirst().get().getName());
+                    });
+                    r.setProfessionProgressList(progressList);
+                    //获取任务阶段列表
+                    if (company.getPackageProject() == 1 && r.getGroupId() != null && r.getGroupId() != 0) {
+                        r.setStages(stagesList.stream().filter(s->s.getGroupId() !=null && s.getGroupId().equals(r.getGroupId())).collect(Collectors.toList()));
+                    }
+
+                    //处理维度列表数据
+                    if (timeTypeMapper.selectById(companyId).getCustomDegreeActive() == 1) {
+                        Project project = allProjectList.stream().filter(p -> p.getId().equals(r.getProjectId())).findFirst().get();
+                        String associateDegrees = project.getAssociateDegrees();
+                        List<HashMap> degreeMapList = new ArrayList<>();
+                        if (associateDegrees != null) {
+                            String[] split = associateDegrees.split("\\,");
+                            for (int i=0;i<split.length; i++) {
+                                HashMap map = new HashMap();
+                                if (!StringUtils.isEmpty(split[i])) {
+                                    Integer id = Integer.parseInt(split[i]);
+                                    map.put("id", id);
+                                    map.put("name", degreeList.stream().filter(d->d.getId().equals(id)).findFirst().get().getName());
+                                    degreeMapList.add(map);
+                                }
+                            }
+                        }
+                        r.setDegreeList(degreeMapList);
+                    }
+                    int reportAuditType = timeTypeMapper.selectById(companyId).getReportAuditType();
+                    //分组
+                    if (company.getPackageProject() == 1) {
+                        if (reportAuditType == 0) {
+                            r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
+                            if (r.getGroupId() != null && r.getGroupId() != 0) {
+                                Optional<TaskGroup> optinal = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
+                                if (optinal.isPresent()) {
+                                    r.setGroupName(optinal.get().getName());
+                                }
+                            }
+                        } else if (reportAuditType == 1 || reportAuditType == 2){
+                            List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>());
+                            if (groupParticipatorList.size() > 0) {
+                                List<Integer> groupIds = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
+                                List<TaskGroup> findGroups = taskGroups.stream().filter(tg->groupIds.contains(tg.getId()) || userId.equals(tg.getInchargerId())).collect(Collectors.toList());
+                                r.setTaskGroups(findGroups);
+                                if (r.getGroupId() != null && r.getGroupId() != 0) {
+                                    Optional<TaskGroup> optinal = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
+                                    if (optinal.isPresent()) {
+                                        r.setGroupName(optinal.get().getName());
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    //项目的审核人
+                    if (reportAuditType == 0) {
+                        r.setAuditUserList(auditorList.stream().filter(au->au.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
+                        if (r.getProjectAuditorId() != null) {
+                            Optional<ProjectAuditor> auItem = auditorList.stream().filter(au->au.getAuditorId().equals(r.getProjectAuditorId())).findFirst();
+                            if (auItem.isPresent()) {
+                                r.setProjectAuditorName(auItem.get().getAuditorName());
+                            }
+                        }
+                    } else if (reportAuditType == 1 || reportAuditType == 2) {
+                        if (r.getGroupId() != null && r.getGroupId() != 0) {
+                            //直接获取分组的负责人作为审核人
+                            Optional<TaskGroup> tgoup = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
+                            if (tgoup.isPresent()) {
+                                TaskGroup curGroup = tgoup.get();
+                                if (curGroup.getInchargerId() != null) {
+                                    User user = userMapper.selectById(curGroup.getInchargerId());
+                                    HashMap map = new HashMap();
+                                    map.put("auditorId", user.getId());
+                                    map.put("auditorName", user.getName());
+                                    List list = new ArrayList();
+                                    list.add(map);
+                                    r.setAuditUserList(list);
+                                    if (r.getProjectAuditorId() != null) {
+                                        r.setProjectAuditorName(user.selectById(r.getProjectAuditorId()).getName());
+                                    }
+                                }
+                            }
+                        }
+                    } else if (reportAuditType == 3) {
+                        //获取日报对应已经设置好的审核人和抄送人
+                        r.setAuditorSetting(reportAuditorSettingMapper.selectById(r.getId()));
+                    }
+                });
+                msg.data = reports;
+            } catch (NullPointerException e) {
+                e.printStackTrace();
+                //httpRespMsg.setError("验证失败");
+                msg.setError(MessageUtils.message("Company.validationError"));
+                return msg;
+            } catch (DateTimeParseException e) {
+                //httpRespMsg.setError("日期格式有误");
+                msg.setError(MessageUtils.message("date.formatError"));
+                return msg;
+            }
+        }
+
+        return msg;
+    }
 }

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

@@ -362,6 +362,8 @@
                         <el-button type="default" style="margin-left:5px;" size="mini" :loading="syncTimeLoading" 
                         v-if="!isBatch && user.timeType.syncCorpwxTime==1 && (workForm.createDate == today || !workForm.time || workForm.time.workHours <= 0)" icon="el-icon-refresh" 
                                 @click="refreshWXCardTime(workForm.createDate)"></el-button>
+                        <!-- AI智能填报 -->
+                        <el-button type="primary" @click="getAIReport(workForm.createDate)" v-if="user.companyId == 7 || user.companyId == 10" size="mini" style="margin-left:5px;" >AI智能填报</el-button>
                     </el-form-item>
                     <!-- 000000 -->
                     <div v-for="(domain, index) in workForm.domains" :key="domain.id" :style="index>0?'margin-top:10px;':''">
@@ -1021,18 +1023,6 @@
             </span>
         </el-dialog>
 
-        <!-- 批量日报审核 -->
-        <el-dialog :title="$t('other.bulkProjectReportReview')" :visible.sync="approveDialogVisible" width="500px" >
-            
-            <el-checkbox v-model="isAllSelect" :label="$t('btn.selectAll')" style="margin-left:24px;" @change="selectAll" v-if="reportNames.length > 0"></el-checkbox>
-            <el-tree ref="approveTree" node-key="id" :data="reportNames" show-checkbox="true" @check-change="handleCheckChange" >
-            </el-tree>
-            <div style="margin-left:30px;color:#999;" v-if="user.company.packageEngineering==1">{{$t('other.responsibleForTheProjectLength')}}</div>
-            <span slot="footer" class="dialog-footer">
-                <el-button @click="approveDialogVisible = false">{{$t('btn.cancel')}}</el-button>
-                <el-button type="primary" @click="submitBatchApprove" :disabled="batchShowData.length == 0">{{$t('state.approved')}}</el-button>
-            </span>
-        </el-dialog>
         <!--导出报表条件选择 -->
         <el-dialog :title="$t('textLink.exportWork')" v-if="exportDialog" :visible.sync="exportDialog" customClass="customWidth" width="500px">
             <el-form ref="form3" :model="exportParam" >
@@ -3724,49 +3714,7 @@
                 })
                 .catch(() => {});
             },
-            //提交批量审核数据
-            submitBatchApprove() {
-                var data = this.$refs.approveTree.getCheckedNodes();
-                var ids = '';
-                if (data.length == 0) {
-                    this.$message({
-                            message: this.$t('message.Pleaseselectthepersontoreview'),
-                            type: "error"
-                        });
-                    return;
-                }
-                for (var i=0;i<data.length; i++) {
-                    ids += data[i].id;
-                    if (i < data.length-1) {
-                        ids += ',';
-                    }
-                }
-                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 => {
-                    if (res.code == "ok") {
-                        this.$message({
-                            message: this.$t('message.Reviewsucceeded'),
-                            type: "success"
-                        });
-                        this.getReportList();
-                        this.getDepartment();
-                        this.approveDialogVisible = false;
-                    } else {
-                        this.$message({
-                            message: res.msg,
-                            type: "error"
-                        });
-                    }
-                },
-                error => {
-                    this.$message({
-                        message: error,
-                        type: "error"
-                    });
-                });
-            },
+            
             selectAll() {
                 if (this.isAllSelect) {
                     var keys = [];
@@ -3778,28 +3726,7 @@
                     this.$refs.approveTree.setCheckedKeys([]);
                 }
             },
-            //批量审核
-            batchApprove() {
-                this.approveDialogVisible = true;
-                
-                this.reportNames = [];
-                for (var i=0;i<this.reportList.length; i++) {
-                    var report = this.reportList[i];
-                    var hasUnChecked =false;
-                    var id = '';
-                    for (var j=0;j<report.data.length; j++) {
-                        if (report.data[j].state == 0 
-                            && (this.user.company.packageEngineering==0 || (this.user.company.packageEngineering==1 && report.data[j].departmentAuditState == 1))
-                            && (permissions.projectReportReview || report.data[j].projectAuditorId == this.user.id)) {
-                            hasUnChecked = true;
-                            id += report.data[j].id+',';
-                        }
-                    }
-                    if (hasUnChecked) {
-                        this.reportNames.push({id:id, label: report.name});
-                    }
-                }
-            },
+            
             removeEmptyNode(list) {
                 for (var i=0;i<list.length;i++) {
                     var cnt = 0;
@@ -4559,6 +4486,91 @@
                     });
                 
             },
+            getAIReport(createDate) {
+                this.http.post('/report/getAIReport', {
+                    date: createDate
+                },
+                res => {
+                    if (res.code == "ok") {
+                        var quanbu = 0 
+                        this.jsDay = 1
+                        var zhi = ''
+                        var slp = res.data
+                        for(var i in slp) {
+                            var sp = +slp[i].workingTime + 0
+                            zhi = this.jsDay * sp
+                            quanbu = +quanbu + zhi
+                        }
+                        this.jsTime = quanbu
+                        var aiReportData = res.data;
+                        
+                        this.canCancelInDialog = false
+                        if(aiReportData.length != 0) {
+                            var arr = [];
+                            for(var i in aiReportData) {
+                                arr.push({
+                                    id: null,
+                                    projectId: aiReportData[i].projectId,
+                                    workingTime: aiReportData[i].workingTime,
+                                    content: '',
+                                    progress:100,
+                                    state: 2,
+                                    timeType: aiReportData[i].timeType,
+                                    subProjectList: aiReportData[i].subProjectList,
+                                    taskList: aiReportData[i].taskList,
+                                    subProjectId: aiReportData[i].subProjectId == 0?null:aiReportData[i].subProjectId,
+                                    groupId: aiReportData[i].groupId == 0?null:aiReportData[i].groupId,
+                                    taskId: aiReportData[i].taskId,
+                                    // startTime: `Fri May 16 2021 ${list.report[i].startTime}:12 GMT+0800 (中国标准时间)`,
+                                    startTime: aiReportData[i].startTime,
+                                    // endTime: `Fri May 16 2021 ${list.report[i].endTime}:12 GMT+0800 (中国标准时间)`,
+                                    endTime: aiReportData[i].endTime,
+                                    isOvertime: 0,
+                                    progress:aiReportData[i].progress,
+                                    professionProgress: aiReportData[i].professionProgressList,
+                                    stages:aiReportData[i].stages,
+                                    stage:aiReportData[i].stage == '-'?null:aiReportData[i].stage,
+                                    pics: null,
+                                    multiWorktime: aiReportData[i].multiWorktime,
+                                    worktimeList: [{}],
+                                    degreeId: aiReportData[i].degreeId==-1?null:aiReportData[i].degreeId,
+                                    wuduList: aiReportData[i].degreeList,
+                                    taskGroups:aiReportData[i].taskGroups,
+                                    customData: aiReportData[i].customData,//自定义的数值
+                                    auditUserList: aiReportData[i].auditUserList,
+                                    projectAuditorId: aiReportData[i].projectAuditorId,
+                                    projectAuditorName: aiReportData[i].projectAuditorName,
+                                    overtimeHours: aiReportData[i].overtimeHours,
+                                    customText: aiReportData[i].customText,
+                                    basecostId: aiReportData[i].basecostId,
+                                    auditorFirst: aiReportData[i].auditorSetting && aiReportData[i].auditorSetting.auditorFirst ? aiReportData[i].auditorSetting.auditorFirst : '',
+                                    auditorSec: aiReportData[i].auditorSetting && aiReportData[i].auditorSetting.auditorSec ? aiReportData[i].auditorSetting.auditorSec : '',
+                                    auditorThird: aiReportData[i].auditorSetting && aiReportData[i].auditorSetting.auditorThird ? aiReportData[i].auditorSetting.auditorThird : '',
+                                    ccUserid: aiReportData[i].auditorSetting && aiReportData[i].auditorSetting.ccUserid ? aiReportData[i].auditorSetting.ccUserid : '',
+                                    canEdit: true
+                                })
+                            }
+                            this.workForm.domains = arr;
+                        } else {
+                            
+                        }
+                        this.canEdit = true;
+                        this.originCanEdit = true;
+                        this.seleChn()
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
             // 获取个人某天的日报 111111
             getReport() {
                 this.http.post( this.port.report.getPort, {