Merge branch 'zhaoss' of http://192.168.1.110:5678/r/pms-upgrade into master
| | |
| | | /** 任务合计 */ |
| | | private Double totalTaskTime; |
| | | |
| | | /** 任务合计(实际) */ |
| | | private Double actualTaskTime; |
| | | |
| | | /** 成本合计 */ |
| | | private BigDecimal totalLaborCost; |
| | | |
| | | /** 成本合计(实际) */ |
| | | private BigDecimal actualLaborCost; |
| | | |
| | | /** 责任人ID */ |
| | | private Long liableUserId; |
| | | |
| | |
| | | package me.zhengjie.modules.project.service.impl; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.Map.Entry; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import me.zhengjie.modules.project.service.ProjectCostService; |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskInterface; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final ProjectCostRepository projectCostRepository; |
| | | private final TaskRepository taskRepository; |
| | | private final TaskDaliyRepository taskDaliyRepository; |
| | | private final ProjectCostService projectCostService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ProjectQueryCriteria criteria, Pageable pageable) { |
| | |
| | | // 负责人名称 |
| | | projectDto.setLiableUserName(user.getNickName()); |
| | | } |
| | | |
| | | ProjectTaskSummary projectTaskSummary = projectTaskRepository.findSummaryByProjectId(project.getId()); |
| | | projectDto.setTaskStartDate(projectTaskSummary.getTaskStartDate()); |
| | | projectDto.setTaskEndDate(projectTaskSummary.getTaskEndDate()); |
| | |
| | | ProjectCostSummary projectCostSummary = projectCostRepository.findSummaryByProjectId(project.getId()); |
| | | projectDto.setTotalLaborCost(projectCostSummary.getTotalLaborCost()); |
| | | |
| | | // 查询项目的任务数据 |
| | | TaskInterface taskInterface = taskRepository.collectByProjectId(project.getId()); |
| | | projectDto.setActualTaskTime(taskInterface.getPlanHours()); |
| | | |
| | | // 根据日期和项目ID取得日报信息 |
| | | List<TaskDailyInterface> taskDailyInterfaceList = taskDaliyRepository.collectByProjectIdGroupByUserIdAndFillDate(project.getId()); |
| | | Map<Long, List<TaskDailyInterface>> collectMap = taskDailyInterfaceList.stream().collect(Collectors.groupingBy(TaskDailyInterface::getUserId)); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 实际消耗成本 |
| | | BigDecimal actualCost = BigDecimal.valueOf(0.0); |
| | | for (Entry<Long, List<TaskDailyInterface>> entry : collectMap.entrySet()) { |
| | | List<TaskDailyInterface> taskDaliyListSub = entry.getValue(); |
| | | // 最小日期 |
| | | TaskDailyInterface taskDaliyFirst = taskDaliyListSub.stream().min(Comparator.comparing(taskDaliy -> taskDaliy.getFillDate())).get(); |
| | | // 最大日期 |
| | | TaskDailyInterface taskDaliyLast = taskDaliyListSub.stream().max(Comparator.comparing(taskDaliy -> taskDaliy.getFillDate())).get(); |
| | | Map<String, Double> costHourMap = new HashMap<String, Double>(); |
| | | taskDaliyListSub.forEach(taskDaliy -> { |
| | | costHourMap.put(sdf.format(taskDaliy.getFillDate()), taskDaliy.getConsumedHours()); |
| | | }); |
| | | // 根据员工成本单金算出当前工作的成本 |
| | | actualCost = actualCost.add(projectCostService.calcUserCostByDate(entry.getKey(), new Timestamp(taskDaliyFirst.getFillDate().getTime()), new Timestamp(taskDaliyLast.getFillDate().getTime()), costHourMap)); |
| | | } |
| | | // 实际消耗成本 |
| | | projectDto.setActualLaborCost(actualCost); |
| | | |
| | | // 返回处理好的Dto |
| | | return projectDto; |
| | | } |
| | |
| | | List<TaskDailyInterface> collectByProjectIdAndFillDateLessThanGroupByUserIdAndFillDate(Long projectId, Timestamp fillDate); |
| | | |
| | | /** |
| | | * 根据项目ID查询任务日报信息 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT user_id AS userId, fill_date AS fillDate, COALESCE(SUM(consumed_hours), 0) AS consumedHours FROM task_daliy WHERE project_id = ?1 GROUP BY user_id, fill_date", nativeQuery = true) |
| | | List<TaskDailyInterface> collectByProjectIdGroupByUserIdAndFillDate(Long projectId); |
| | | |
| | | /** |
| | | * 根据项目ID、任务ID查询 |
| | | * @param projectId |
| | | * @param taskId |
| | |
| | | public ResponseEntity<Object> queryCompletedWork(TaskDaliyQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskDaliyService.queryCompletedWork(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/taskTotalConsumedHours") |
| | | @Log("查询任务的总消耗工时") |
| | | @ApiOperation("查询任务的总消耗工时") |
| | | @PreAuthorize("@el.check('taskDaliy:list')") |
| | | public ResponseEntity<Object> queryTaskTotalConsumedHours(TaskDaliyQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskDaliyService.queryTaskTotalConsumedHours(criteria),HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | * @return List<TaskDaliyDto> |
| | | */ |
| | | Double queryCompletedWork(TaskDaliyQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询任务的总消耗工时 |
| | | * @param criteria 条件参数 |
| | | * @return List<TaskDaliyDto> |
| | | */ |
| | | Double queryTaskTotalConsumedHours(TaskDaliyQueryCriteria criteria); |
| | | } |
| | |
| | | import me.zhengjie.modules.system.service.RoleService; |
| | | import me.zhengjie.modules.system.service.dto.RoleSmallDto; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | |
| | | // 日历类 |
| | | return cal; |
| | | } |
| | | |
| | | @Override |
| | | public Double queryTaskTotalConsumedHours(TaskDaliyQueryCriteria criteria) { |
| | | // 根据项目ID、任务ID、用户ID查询总消耗工时、总消耗工作量、最大任务进度 |
| | | TaskDailyInterface taskDailyInterface = taskDaliyRepository.findSumConsumedHoursAndSumConsumedWorkloadAndMaxTaskProgressByProjectIdAndTaskIdAndUserId(criteria.getProjectId(), criteria.getTaskId(), criteria.getUserId()); |
| | | // 返回 |
| | | return taskDailyInterface.getConsumedHours(); |
| | | } |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, completedWork, complianceWork } |
| | | export function taskTotalConsumedHours(params) { |
| | | return request({ |
| | | url: 'api/taskDaliy/taskTotalConsumedHours', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, completedWork, complianceWork, taskTotalConsumedHours } |
| | |
| | | {{ scope.row.contractPrice != null && scope.row.contractPrice != '' ? crud.toMoney(scope.row.contractPrice) : '' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalTaskTime" label="任务总工时" width="100" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalTaskTime" label="计划任务总工时" width="110" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="actualTaskTime" label="实际任务总工时" width="110" /> |
| | | <el-table-column v-if="checkPer([permission.master])" label="报价"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="quotationPrice" label="单金" width="100"> |
| | | <template slot-scope="scope"> |
| | |
| | | <el-tag>{{ dict.label[standardUnitCurrency][scope.row.unitCurrency] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="总金额" width="100"> |
| | | <el-table-column :show-overflow-tooltip="true" label="计划总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.quotationPrice * scope.row.totalTaskTime / 160) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="实际总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.quotationPrice * scope.row.actualTaskTime / 160) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | |
| | | <el-table-column :show-overflow-tooltip="true" label="币种" width="100"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][standardUnitCurrencyRenminbi] }}</el-tag> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="总金额" width="100"> |
| | | <el-table-column :show-overflow-tooltip="true" label="计划总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.performancePrice * scope.row.totalTaskTime / 160) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="实际总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.performancePrice * scope.row.actualTaskTime / 160) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalLaborCost" label="项目总成本" width="100"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalLaborCost" label="计划项目总成本" width="110"> |
| | | <template slot-scope="scope"> |
| | | <span :style="{ color: scope.row.performancePrice * scope.row.totalTaskTime < scope.row.totalLaborCost ? 'red' : '' }"> |
| | | {{ crud.toMoney(scope.row.totalLaborCost) }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="actualLaborCost" label="实际项目总成本" width="110"> |
| | | <template slot-scope="scope"> |
| | | <span :style="{ color: scope.row.performancePrice * scope.row.actualTaskTime < scope.row.actualLaborCost ? 'red' : '' }"> |
| | | {{ crud.toMoney(scope.row.actualLaborCost) }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="liableUserName" label="责任人" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.liableUserName != null && scope.row.liableUserName != ''"> |
| | |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | 已消耗工时:{{ form.alreadyConsumedHours }} / 任务工时:{{ form.taskHours }} |
| | | </el-form-item> |
| | | <el-form-item label="消耗工作量" prop="consumedWorkload"> |
| | | <el-input v-model="form.consumedWorkload" style="width: 340px;" :disabled="disabledFlagBySettlement" /> |
| | | </el-form-item> |
| | | <el-form-item label="消耗工作量单位" prop="consumedWorkloadUnit"> |
| | | <el-form-item label="消耗工作量单位"> |
| | | {{ dict.label[standardWorkloadUnit][form.consumedWorkloadUnit] }} |
| | | </el-form-item> |
| | | <el-form-item label="任务进度" prop="taskProgress"> |
| | |
| | | import crudUser from '@/api/system/user' |
| | | import crudProject from '@/api/project/project' |
| | | import crudTask from '@/api/task/task' |
| | | import crudTaskUser from '@/api/task/taskUser' |
| | | |
| | | const defaultForm = { id: null, projectId: null, taskId: null, userId: null, fillDate: null, consumedHours: null, consumedWorkload: null, taskProgress: null, settlementStatus: constant.SETTLEMENT_STATUS_UNSETTLED, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | const defaultForm = { id: null, projectId: null, taskId: null, userId: null, fillDate: null, consumedHours: null, alreadyConsumedHours: 0, taskHours: 0, consumedWorkload: null, consumedWorkloadUnit: null, taskProgress: null, settlementStatus: constant.SETTLEMENT_STATUS_UNSETTLED, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'TaskDaliy', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 表单赋值 |
| | | this.form.consumedWorkloadUnit = null |
| | | // 判断用户最大角色级别是否是角色级别:超级管理员或角色级别:总经理 |
| | | if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) { |
| | | // 表单赋值 |
| | |
| | | if (this.formTasks[i].id === this.form.taskId) { |
| | | // 表单赋值 |
| | | this.form.consumedWorkloadUnit = this.formTasks[i].planWorkloadUnit |
| | | return |
| | | break |
| | | } |
| | | // 判断循环是否结束 |
| | | if (i === this.formTasks.length - 1) { |
| | |
| | | this.form.consumedWorkloadUnit = null |
| | | } |
| | | } |
| | | // 查询任务的总消耗工时 |
| | | crudTaskDaliy.taskTotalConsumedHours({ userId: this.form.userId, projectId: this.form.projectId, taskId: this.form.taskId }).then(res => { |
| | | // 表单赋值 |
| | | this.form.alreadyConsumedHours = res |
| | | }) |
| | | // 查询任务分配 |
| | | crudTaskUser.getAll({ userId: this.form.userId, projectId: this.form.projectId, taskId: this.form.taskId }).then(res => { |
| | | // 表单赋值 |
| | | this.form.taskHours = res[0].taskHours |
| | | }) |
| | | } |
| | | } |
| | | } |