Browse Source

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

Min 1 year ago
parent
commit
676d66c319

+ 16 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java

@@ -903,8 +903,22 @@ public class TaskController {
     }
 
     @RequestMapping("/importTask")
-    public HttpRespMsg importUser(Integer projectId, Integer groupId, @RequestParam MultipartFile file) {
-        return taskService.importTask(projectId, groupId, file, request);
+    public HttpRespMsg importUser(@RequestParam(required = false,defaultValue = "0")Integer isMultiProject, Integer projectId, Integer groupId, @RequestParam MultipartFile file) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            httpRespMsg = taskService.importTask(isMultiProject, projectId, groupId, file, request);
+            return httpRespMsg;
+        } catch (NullPointerException e) {
+            e.printStackTrace();
+            //httpRespMsg.setError("数据格式有误或存在空数据 导入失败");
+            httpRespMsg.setError(MessageUtils.message("file.dataFormatError"));
+            return httpRespMsg;
+        } catch (Exception e) {
+            e.printStackTrace();
+            //httpRespMsg.setError("发生其他错误");
+            httpRespMsg.setError(e.getMessage());
+            return httpRespMsg;
+        }
     }
 
 

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

@@ -37,7 +37,7 @@ public interface TaskService extends IService<Task> {
 
     HttpRespMsg exportTask(Integer projectId, Integer taskType);
 
-    HttpRespMsg importTask(Integer projectId, Integer groupId, MultipartFile file, HttpServletRequest request);
+    HttpRespMsg importTask(Integer isMultiProject, Integer projectId, Integer groupId, MultipartFile file, HttpServletRequest request) throws Exception;
 
     HttpRespMsg delete(TaskGroup item);
 

+ 86 - 33
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -386,7 +386,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     }
 
     @Override
-    public HttpRespMsg importTask(Integer projectId, Integer groupId, MultipartFile multipartFile, HttpServletRequest request) {
+    public HttpRespMsg importTask(Integer isMultiProject, Integer projectId, Integer groupId, MultipartFile multipartFile, HttpServletRequest request) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
 
         //首先先搞到公司id
@@ -394,6 +394,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         User creator = userMapper.selectById(userId);
         Integer companyId = creator.getCompanyId();
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",companyId));
+        List<Project> allProjectList = null;
+        List<TaskGroup> allGroupList = null;
+        if (isMultiProject == 1) {
+            allProjectList = projectMapper.selectList(new QueryWrapper<Project>().select("id, project_code, project_name").eq("company_id", companyId));
+            //全部任务分组
+            allGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().select("id, name, project_id").in("project_id", allProjectList.stream().map(Project::getId).collect(Collectors.toList())));
+        }
         List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
         HashMap<String, Integer> taskTypeMap = new HashMap<>();
         //taskTypeMap.put("任务", 0);
@@ -433,6 +440,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             //要插入的账号列表
             List<Task> taskList = new ArrayList<>();
             List<String> userNameList=new ArrayList<>();
+            //Excel列下标从1开始
+            int taskListNameIndex = isMultiProject==0?0:3;//项目编号,项目名称,任务分组,任务列表; 在项目内导入时,任务列表作为第一列
             for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
                 XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
@@ -442,12 +451,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     continue;
                 }
                 System.out.println("rowIndex==="+rowIndex);
-                XSSFCell nameCell = row.getCell(1);
+                XSSFCell nameCell = row.getCell(taskListNameIndex+1);
                 if (nameCell == null) {
                     break;
                 }
                 System.out.println("name==="+nameCell.getStringCellValue());
-                XSSFCell executorCell = row.getCell(3);
+                XSSFCell executorCell = row.getCell(taskListNameIndex + 3);
                 if (executorCell != null) {
                     String[] executorNameArray = executorCell.getStringCellValue().split(",");
                     for (String s : executorNameArray) {
@@ -478,34 +487,95 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 if (row == null) {
                     continue;
                 }
-                //此处新建账号 默认密码为000000 默认 姓名第一列 手机号第二列 月薪第三列
-                XSSFCell stagesCell = row.getCell(0);
-                XSSFCell nameCell = row.getCell(1);
+
+                XSSFCell stagesCell = row.getCell(taskListNameIndex);
+                XSSFCell nameCell = row.getCell(taskListNameIndex + 1);
                 if (nameCell == null || stagesCell == null) {
                     break;
                 }
-                XSSFCell typeCell = row.getCell(2);
-                XSSFCell executorCell = row.getCell(3);
-                XSSFCell levelCell = row.getCell(4);
-                XSSFCell startDateCell = row.getCell(5);
-                XSSFCell endDateCell = row.getCell(6);
-                XSSFCell planHoursCell = row.getCell(7);
-                XSSFCell descCell = row.getCell(8);
+                XSSFCell typeCell = row.getCell(taskListNameIndex + 2);
+                XSSFCell executorCell = row.getCell(taskListNameIndex + 3);
+                XSSFCell levelCell = row.getCell(taskListNameIndex + 4);
+                XSSFCell startDateCell = row.getCell(taskListNameIndex + 5);
+                XSSFCell endDateCell = row.getCell(taskListNameIndex + 6);
+                XSSFCell planHoursCell = row.getCell(taskListNameIndex + 7);
+                XSSFCell descCell = row.getCell(taskListNameIndex + 8);
                 nameCell.setCellType(CellType.STRING);
                 stagesCell.setCellType(CellType.STRING);
-                typeCell.setCellType(CellType.STRING);
-                endDateCell.setCellType(CellType.NUMERIC);
+
+                String type = "任务";//默认类型
+                if (typeCell != null) {
+                    typeCell.setCellType(CellType.STRING);
+                    type = typeCell.getStringCellValue();
+                }
+                if (endDateCell != null) {
+                    endDateCell.setCellType(CellType.NUMERIC);
+                }
                 if(planHoursCell!=null){
                     planHoursCell.setCellType(CellType.STRING);
                 }
                 String name = nameCell.getStringCellValue();
-                String type = typeCell.getStringCellValue();
+
                 //忽略表头
                 if ((name.equals("任务内容") || name.equals("Task content")) && (type.equals("类型") || type.equals("type")) && rowIndex == 0) {
                     continue;
                 }
                 Task task = new Task();
                 task.setCompanyId(companyId);
+                //多项目下任务导入和单项目下任务导入,两种模式的taskListNameIndex值不一样
+                String projectCode = null;
+                String projectName = null;
+                String taskGroupName = null;
+                //设置所属项目和任务分组ID
+                if (isMultiProject == 1) {
+                    XSSFCell codeCell = row.getCell(0);
+                    XSSFCell pnameCell = row.getCell(1);
+                    XSSFCell tgoupNameCell = row.getCell(2);
+                    if (codeCell != null) {
+                        codeCell.setCellType(CellType.STRING);
+                        projectCode = codeCell.getStringCellValue().trim();
+                    }
+                    if (pnameCell != null) {
+                        pnameCell.setCellType(CellType.STRING);
+                        projectName = pnameCell.getStringCellValue().trim();
+                    }
+                    if (tgoupNameCell != null) {
+                        tgoupNameCell.setCellType(CellType.STRING);
+                        taskGroupName = tgoupNameCell.getStringCellValue().trim();
+                    }
+
+                    //定位项目
+                    projectId = null;
+                    if (!StringUtil.isEmpty(projectCode)) {
+                        final String code = projectCode;
+                        Optional<Project> first = allProjectList.stream().filter(project -> code.equals(project.getProjectCode())).findFirst();
+                        if (first.isPresent()) {
+                            projectId = first.get().getId();
+                        }
+                    } else if (!StringUtil.isEmpty(projectName)) {
+                        final String pname = projectName;
+                        Optional<Project> first = allProjectList.stream().filter(project -> pname.equals(project.getProjectName())).findFirst();
+                        if (first.isPresent()) {
+                            projectId = first.get().getId();
+                        }
+                    }
+                    if (projectId == null) {
+                        throw new Exception("项目不存在:(编号:"+projectCode+",名称:"+projectName+")");
+                    }
+                    //任务分组
+                    groupId = null;//先清空
+                    if (!StringUtil.isEmpty(taskGroupName)) {
+                        final String groupName = taskGroupName;
+                        final int pid = projectId;
+                        Optional<TaskGroup> first = allGroupList.stream().filter(group -> groupName.equals(group.getName()) && group.getProjectId().equals(pid)).findFirst();
+                        if (first.isPresent()) {
+                            groupId = first.get().getId();
+                        }
+                    }
+                    if (groupId == null) {
+                        throw new Exception("任务分组不存在:"+taskGroupName);
+                    }
+                }
                 task.setProjectId(projectId);
                 task.setGroupId(groupId);
                 if(executorCell!=null){
@@ -606,29 +676,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 for (List<TaskExecutor> executorList : executorListAll) {
                     taskExecutorService.saveBatch(executorList);
                 }
-
             }
-            //最后删掉这个文件
-//            if (!file.delete()) {
-//                System.out.println("临时文件" + file.getName() + "删除失败");
-//            }
-            //校验是否有重复账号
-
         } catch (IOException e) {
             e.printStackTrace();
             //httpRespMsg.setError("文件处理出错");
             httpRespMsg.setError(MessageUtils.message("file.error"));
             return httpRespMsg;
-        } catch (NullPointerException e) {
-            e.printStackTrace();
-            //httpRespMsg.setError("数据格式有误或存在空数据 导入失败");
-            httpRespMsg.setError(MessageUtils.message("file.dataFormatError"));
-            return httpRespMsg;
-        } catch (Exception e) {
-            e.printStackTrace();
-            //httpRespMsg.setError("发生其他错误");
-            httpRespMsg.setError(MessageUtils.message("other.error"));
-            return httpRespMsg;
         } finally {
             //关闭流
             try {

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1770,7 +1770,7 @@
     </select>
     <!--获取员工的项目分类工时统计数据 -->
     <select id="getMembProjectCateTime" resultType="com.management.platform.entity.vo.UserCateTimeVo">
-        SELECT user.id AS userId, user.`name`, project.`category`, project.`category_name` AS categoryName, SUM(report.`working_time`) AS workingTime FROM report LEFT JOIN USER ON user.id = report.`creator_id`
+        SELECT user.id AS userId, user.`name`, project.`category`, project.`category_name` AS categoryName, SUM(report.`working_time`) AS workingTime FROM report LEFT JOIN `user` ON user.id = report.`creator_id`
         LEFT JOIN project ON project.id = report.`project_id`
         WHERE report.`company_id` = #{companyId}
         AND report.`create_date` BETWEEN #{startDate} and #{endDate}

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

@@ -3438,7 +3438,7 @@ export default {
     },
     // 获取项目分类
     async getProjectSort() {
-      let { data } = await this.postData('project-category/list', {})
+      let { data } = await this.postData('/project-category/list', {})
       let dataList = data || []
       dataList.push({id: 'null', name: '未分类'})
       this.projectSortList = dataList

+ 103 - 12
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -85,7 +85,7 @@
                                 <el-link type="primary" :underline="false" @click="projectLevelDialog = true">{{ $t('projectlevelmanagement') }}</el-link>
                             </el-dropdown-item>
                             <el-dropdown-item v-if="user.timeType.syncFanwei==1||user.timeType.syncSap==1">
-                                <el-link type="primary" :underline="false" @click="syncProjectDig=true">{{'同步项目信息'}}</el-link>
+                                <el-link type="primary" :underline="false" @click="syncProjectDig=true, synchronizationInputVal = ''">{{'同步项目信息'}}</el-link>
                             </el-dropdown-item>
                             <el-dropdown-item v-if="user.companyId==3385 && permissions.projectClassification">
                                 <el-link type="primary" :underline="false" @click="functionalDivisionDig=true,getFunctionalList()">{{'职能分工设置'}}</el-link>
@@ -93,6 +93,9 @@
                             <el-dropdown-item v-if="user.timeType.projectManDay == 1 && permissions.projectClassification">
                                 <el-link type="primary" :underline="false" @click="projectManDaySettingDialog = true;getManDaySetting()">{{ '预估工时配置' }}</el-link>
                             </el-dropdown-item>
+                            <el-dropdown-item v-if="user.companyId == 10 || user.companyId == 5608">
+                                <el-link type="primary" :underline="false" @click="importTaskDialog = true">{{ '项目任务导入' }}</el-link>
+                            </el-dropdown-item>
                         </el-dropdown-menu>
                         </el-dropdown>
                 </el-form-item>
@@ -1636,21 +1639,45 @@
         </el-dialog>
         <!-- 项目同步弹窗 -->
         <el-dialog title="项目服务同步" :visible.sync="syncProjectDig" width="600px" :before-close="handleClose">
-            <el-form label-width="100px">
-                <el-form-item :label="'项目编号:'">
-                     <el-select filterable collapse-tags clearable  v-model="hasChooseProjectCode" multiple placeholder="请选择" style="width:100%">
-                        <el-option v-for="item in allProjectList" :key="item.id" :label="item.projectName  + '\u3000' + item.projectCode" :value="item.projectCode">
-                            <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
-                            <span style="float: left;">{{ item.projectName }}</span>
-                        </el-option>
-                    </el-select>
-                </el-form-item>
+            <el-form label-width="0">
+                <div class="synchronization">
+                    <div class="synchronizationLabel">
+                        <el-select v-model="synchronizationVal" placeholder="请选择" @change="synchronizationChange()">
+                            <el-option label="已同步项目" value="0"></el-option>
+                            <el-option label="未同步项目" value="1"></el-option>
+                        </el-select>
+                    </div>
+                    <el-form-item style="flex: 1" v-if="synchronizationVal == 0">
+                        <el-select filterable collapse-tags clearable  v-model="hasChooseProjectCode" multiple placeholder="请选择" style="width:100%">
+                            <el-option v-for="item in allProjectList" :key="item.id" :label="item.projectName  + '\u3000' + item.projectCode" :value="item.projectCode">
+                                <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
+                                <span style="float: left;">{{ item.projectName }}</span>
+                            </el-option>
+                        </el-select>
+                    </el-form-item>
+                    <el-form-item style="flex: 1" v-if="synchronizationVal == 1">
+                        <el-input placeholder="请输入项目编号" v-model="synchronizationInputVal" clearable></el-input>
+                    </el-form-item>
+                </div>
             </el-form>
             <span slot="footer" class="dialog-footer">
                 <el-button @click="syncProjectDig = false">取 消</el-button>
                 <el-button type="primary" @click="syncProjectForThird(hasChooseProjectCode)">开始同步</el-button>
             </span>
         </el-dialog>
+        <!--导入数据,下载模板 -->
+        <el-dialog :title="$t('wdorkplanimport')" v-if="importTaskDialog" :visible.sync="importTaskDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            <el-form ref="form4" >
+                <el-form-item :label="'1. '+$t('qing-xian-xia-zai-mo-ban-bing-tian-xie-hou-shang-chuan')" >
+                    <el-link type="primary" :underline="false" href="./upload/多项目任务导入模板.xlsx" download="多项目任务模板.xlsx'">下载多项目任务模板</el-link>
+                </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-upload ref="upload" action="#" :limit="1" :http-request="importTask" :show-file-list="false">
+                        <el-button type="primary" :underline="false" style="width:100%;" :loading="loadingExport">{{ $t('uoloadFiles') }}</el-button>
+                </el-upload>
+            </div>
+        </el-dialog>
     </section>
 </template>
 <style scoped>
@@ -1692,6 +1719,7 @@ a {
         },
         data() {
             return {
+                importTaskDialog: false,
                 manDaySetting:{},
                 projectManDaySettingDialog: false,
                 projectListPageComponentKey: 1,
@@ -1948,6 +1976,8 @@ a {
                 syncProjectDig:false,
                 allProjectList:[],
                 hasChooseProjectCode:[],
+                synchronizationVal: '0',
+                synchronizationInputVal: ''
             };
         },
         // 过滤器
@@ -1999,6 +2029,52 @@ a {
             })
         },
         methods: {
+            // 批量导入任务
+            importTask(item) {
+                //首先判断文件类型
+                this.loadingExport = true
+                let str = item.file.name.split(".");
+                let format = str[str.length - 1];
+                if (format != "xls" && format != "xlsx") {
+                    this.loadingExport = false
+                    this.$message({
+                        message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
+                        type: "error"
+                    });
+                } else {
+                    this.listLoading = true;
+                    let formData = new FormData();
+                    formData.append("file", item.file);
+                    formData.append("isMultiProject", 1);
+                    this.http.uploadFile('/task/importTask', formData,
+                    res => {
+                        this.$refs.upload.clearFiles();
+                        this.listLoading = false;
+                        this.loadingExport = false
+                        if (res.code == "ok") {
+                            this.$message({
+                                message: this.$t('other.importSuccess'),
+                                type: "success"
+                            });
+                            this.importTaskDialog = false;
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.$refs.upload.clearFiles();
+                        this.listLoading = false;
+                        this.loadingExport = false
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                    });
+                }
+            },
             saveProjectManDaySetting() {
                 this.http.post('/estimate-time-setting/save', this.manDaySetting,
                 res => {
@@ -3987,7 +4063,7 @@ a {
                     url='/project/syncProjectWithSap'
                     if(hasChooseProjectCode){
                         param={
-                            projectCodes:hasChooseProjectCode.toString()
+                            projectCodes: this.synchronizationVal == '0' ? hasChooseProjectCode.toString() : this.synchronizationInputVal
                         }
                     }
                 }
@@ -5680,8 +5756,15 @@ a {
                     });
                     }
                 );
+            },
+            
+            synchronizationChange() {
+                if(this.synchronizationVal == '1') {
+                    this.hasChooseProjectCode = []
+                } else {
+                    this.synchronizationInputVal = ''
+                }
             }
-
         },
         created() {
             let height = window.innerHeight;
@@ -5751,6 +5834,14 @@ a {
 </script>
 
 <style lang="scss" scoped>
+.synchronization {
+    display: flex;
+    justify-content: space-between;
+    // align-items: center;
+    .synchronizationLabel {
+        width: 140px;
+    }
+}
 .rg_span{
     display: inline-block;
 }

+ 7 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/project/projectInside.vue

@@ -2951,6 +2951,13 @@
                         remark:groupBudgetData.remark,
                     }
                 }
+                if(!groupBudgetData.remark) {
+                    this.$message({
+                        message: '请输入变更理由',
+                        type: "error"
+                    });
+                    return
+                }
                 this.http.post('/group-budget-review/add',param,
                 res => {
                     if (res.code == "ok") {