赵士淞
2023-01-03 3c049c574ae7f8f0dba0fc91339bbfb6e795ad67
项目日报
7 files modified
200 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/domain/TaskDaliy.java 10 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java 27 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/dto/TaskDaliyDto.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/dto/TaskDaliyQueryCriteria.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java 57 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/task/taskDaliy/index.vue 83 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/task/taskUser/index.vue 11 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/domain/TaskDaliy.java
@@ -72,6 +72,16 @@
    @ApiModelProperty(value = "消耗工作量")
    private Double consumedWorkload;
    @Column(name = "`task_progress`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务进度")
    private Double taskProgress;
    @Column(name = "`settlement_status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "结算状态")
    private String settlementStatus;
    @Column(name = "`remarks`")
    @ApiModelProperty(value = "备注")
    private String remarks;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java
@@ -18,6 +18,10 @@
import me.zhengjie.modules.task.domain.TaskDaliy;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* @website https://eladmin.vip
@@ -25,4 +29,27 @@
* @date 2022-12-30
**/
public interface TaskDaliyRepository extends JpaRepository<TaskDaliy, Long>, JpaSpecificationExecutor<TaskDaliy> {
    /**
     * 根据项目ID、任务ID、用户ID查询填报日期前最近的任务日报信息
     * @param userId
     * @return
     */
    @Query(value = "SELECT * FROM task_daliy WHERE project_id = ?1 AND task_id = ?2 AND user_id = ?3 AND fill_date < ?4 ORDER BY fill_date DESC LIMIT 1", nativeQuery = true)
    TaskDaliy findPreviousByProjectIdAndTaskIdAndAndUserId(Long projectId, Long taskId, Long userId, Timestamp fillDate);
    /**
     * 根据项目ID、任务ID、用户ID查询填报日期后最近的任务日报信息
     * @param userId
     * @return
     */
    @Query(value = "SELECT * FROM task_daliy WHERE project_id = ?1 AND task_id = ?2 AND user_id = ?3 AND fill_date > ?4 ORDER BY fill_date ASC LIMIT 1", nativeQuery = true)
    TaskDaliy findNextByProjectIdAndTaskIdAndAndUserId(Long projectId, Long taskId, Long userId, Timestamp fillDate);
    /**
     * 根据项目ID、任务ID、用户ID、填报日期查询
     * @param userId
     * @return
     */
    List<TaskDaliy> findByProjectIdAndTaskIdAndAndUserIdAndFillDate(Long projectId, Long taskId, Long userId, Timestamp fillDate);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/dto/TaskDaliyDto.java
@@ -51,6 +51,12 @@
    /** 消耗工作量 */
    private Double consumedWorkload;
    /** 任务进度 */
    private Double taskProgress;
    /** 结算状态 */
    private String settlementStatus;
    /** 备注 */
    private String remarks;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/dto/TaskDaliyQueryCriteria.java
@@ -16,6 +16,8 @@
package me.zhengjie.modules.task.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
@@ -29,6 +31,10 @@
    /** 精确 */
    @Query
    private Timestamp fillDate;
    /** 精确 */
    @Query
    private Long userId;
    /** 精确 */
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java
@@ -15,9 +15,13 @@
*/
package me.zhengjie.modules.task.service.impl;
import com.sun.jna.platform.win32.Sspi;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.project.domain.Project;
import me.zhengjie.modules.project.repository.ProjectRepository;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.task.domain.Task;
import me.zhengjie.modules.task.domain.TaskDaliy;
@@ -36,12 +40,11 @@
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.function.Function;
/**
@@ -59,6 +62,7 @@
    private final ProjectRepository projectRepository;
    private final TaskRepository taskRepository;
    private final UserRepository userRepository;
    private final DictDetailRepository dictDetailRepository;
    @Override
    public Map<String,Object> queryAll(TaskDaliyQueryCriteria criteria, Pageable pageable){
@@ -109,6 +113,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TaskDaliyDto create(TaskDaliy resources) {
        // 新增修改验证
        checkAddOrUpdate(resources);
        return taskDaliyMapper.toDto(taskDaliyRepository.save(resources));
    }
@@ -117,14 +123,54 @@
    public void update(TaskDaliy resources) {
        TaskDaliy taskDaliy = taskDaliyRepository.findById(resources.getId()).orElseGet(TaskDaliy::new);
        ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",resources.getId());
        // 修改删除验证
        checkUpdateOrDelete(taskDaliy);
        // 新增修改验证
        checkAddOrUpdate(resources);
        taskDaliy.copy(resources);
        taskDaliyRepository.save(taskDaliy);
    }
    /**
     * 新增修改验证
     * @param resources
     */
    private void checkAddOrUpdate(TaskDaliy resources) {
        // 根据项目ID、任务ID、用户ID、填报日期查询
        List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByProjectIdAndTaskIdAndAndUserIdAndFillDate(resources.getProjectId(), resources.getTaskId(), resources.getUserId(), resources.getFillDate());
        // 判断是否已有日报
        if (taskDaliyList.size() > 1 || (taskDaliyList.size() == 1 && taskDaliyList.get(0).getId() != resources.getId())) {
            throw new BadRequestException("每个任务每天只能填写一次日报!");
        }
        // 根据项目ID、任务ID、用户ID查询填报日期前最近的任务日报信息
        TaskDaliy previousTaskDaliy = taskDaliyRepository.findPreviousByProjectIdAndTaskIdAndAndUserId(resources.getProjectId(), resources.getTaskId(), resources.getUserId(), resources.getFillDate());
        // 根据项目ID、任务ID、用户ID查询填报日期后最近的任务日报信息
        TaskDaliy nextTaskDaliy = taskDaliyRepository.findNextByProjectIdAndTaskIdAndAndUserId(resources.getProjectId(), resources.getTaskId(), resources.getUserId(), resources.getFillDate());
        // 判断任务进度是否比前一次多,比后一次少
        if ((previousTaskDaliy != null && resources.getTaskProgress() <= previousTaskDaliy.getTaskProgress()) || (nextTaskDaliy != null && resources.getTaskProgress() >= nextTaskDaliy.getTaskProgress())) {
            throw new BadRequestException("任务进度必须比前一次多且比后一次少!");
        }
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            TaskDaliy taskDaliy = taskDaliyRepository.findById(id).orElseGet(TaskDaliy::new);
            ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",id);
            // 修改删除验证
            checkUpdateOrDelete(taskDaliy);
            taskDaliyRepository.deleteById(id);
        }
    }
    /**
     * 修改删除验证
     * @param resources
     */
    private void checkUpdateOrDelete(TaskDaliy resources) {
        // 判断旧记录结算状态
        if (Constant.SETTLEMENT_STATUS_SETTLED.equals(resources.getSettlementStatus())) {
            throw new BadRequestException("已结算的任务日报无法修改/删除!");
        }
    }
@@ -135,6 +181,7 @@
            String projectName = taskDaliy.getProjectId() != null ? projectRepository.findById(taskDaliy.getProjectId()).orElseGet(Project::new).getName() : "";
            String taskName = taskDaliy.getTaskId() != null ? taskRepository.findById(taskDaliy.getTaskId()).orElseGet(Task::new).getName() : "";
            String userNickName = taskDaliy.getUserId() != null ? userRepository.findById(taskDaliy.getUserId()).orElseGet(User::new).getNickName() : "";
            String settlementStatus = taskDaliy.getSettlementStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.SETTLEMENT_STATUS, taskDaliy.getSettlementStatus()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("填写日期", taskDaliy.getFillDate());
            map.put("项目名称", projectName);
@@ -142,6 +189,8 @@
            map.put("员工姓名", userNickName);
            map.put("消耗工时", taskDaliy.getConsumedHours());
            map.put("消耗工作量", taskDaliy.getConsumedWorkload());
            map.put("任务进度", taskDaliy.getTaskProgress());
            map.put("结算状态", settlementStatus);
            map.put("备注", taskDaliy.getRemarks());
            map.put("创建者", taskDaliy.getCreateBy());
            map.put("创建时间", taskDaliy.getCreateTime());
eladmin-web-master/src/views/task/taskDaliy/index.vue
@@ -78,6 +78,21 @@
          <el-form-item label="消耗工作量单位" prop="consumedWorkloadUnit">
            {{ dict.label[standardWorkloadUnit][form.consumedWorkloadUnit] }}
          </el-form-item>
          <el-form-item label="任务进度" prop="taskProgress">
            <el-input v-model="form.taskProgress" style="width: 340px;">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="结算状态" prop="settlementStatus">
            <el-select v-model="form.settlementStatus" filterable placeholder="请选择" style="width: 340px;">
              <el-option
                v-for="item in dict[settlementStatus]"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
          </el-form-item>
@@ -90,12 +105,12 @@
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column :show-overflow-tooltip="true" prop="fillDate" label="填写日期">
        <el-table-column :show-overflow-tooltip="true" prop="fillDate" label="填写日期" fixed="left" width="100">
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.fillDate) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" width="100">
        <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" fixed="left" width="100">
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userNickName }}</el-tag>
          </template>
@@ -110,16 +125,26 @@
            <el-tag>{{ scope.row.taskName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="consumedHours" label="消耗工时" />
        <el-table-column :show-overflow-tooltip="true" prop="consumedWorkload" label="消耗工作量" />
        <el-table-column :show-overflow-tooltip="true" prop="consumedHours" label="消耗工时" width="80" />
        <el-table-column :show-overflow-tooltip="true" prop="consumedWorkload" label="消耗工作量" width="80" />
        <el-table-column :show-overflow-tooltip="true" prop="taskWorkloadUnit" label="消耗工作量单位" width="110">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.taskWorkloadUnit != null && scope.row.taskWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.taskWorkloadUnit] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度">
          <template slot-scope="scope">
            {{ scope.row.taskProgress }}%
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="settlementStatus" label="结算状态">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[settlementStatus][scope.row.settlementStatus] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="remarks" label="备注" width="140" />
        <el-table-column prop="createTime" label="创建时间" width="140" />
        <el-table-column v-if="checkPer(['admin','taskDaliy:edit','taskDaliy:del'])" label="操作" width="150px" align="center">
        <el-table-column v-if="checkPer(['admin','taskDaliy:edit','taskDaliy:del'])" label="操作" width="150px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
@@ -146,12 +171,12 @@
import crudProject from '@/api/project/project'
import crudTask from '@/api/task/task'
const defaultForm = { id: null, projectId: null, taskId: null, userId: null, fillDate: null, consumedHours: null, consumedWorkload: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, projectId: null, taskId: null, userId: null, fillDate: null, consumedHours: null, consumedWorkload: null, taskProgress: null, settlementStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'TaskDaliy',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.STANDARD_WORKLOAD_UNIT],
  dicts: [constant.STANDARD_WORKLOAD_UNIT, constant.SETTLEMENT_STATUS],
  cruds() {
    return CRUD({ title: '任务日报', url: 'api/taskDaliy', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTaskDaliy }})
  },
@@ -161,6 +186,15 @@
      const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/
      if (value != null && value !== '' && !reg.test(value)) {
        callback(new Error('请输入 一千 以内的正整数或两位小数'))
      } else {
        callback()
      }
    }
    // 比例(百内)验证
    var proportionValidate = (rule, value, callback) => {
      const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/
      if (value != null && value !== '' && !reg.test(value)) {
        callback(new Error('请输入 一百 以内的正整数或两位小数'))
      } else {
        callback()
      }
@@ -191,6 +225,13 @@
        ],
        consumedWorkload: [
          { validator: durationValidate, trigger: 'blur' }
        ],
        taskProgress: [
          { required: true, message: '任务进度不能为空', trigger: 'blur' },
          { validator: proportionValidate, trigger: 'blur' }
        ],
        settlementStatus: [
          { required: true, message: '结算状态不能为空', trigger: 'change' }
        ]
      },
      queryTypeOptions: [
@@ -200,6 +241,8 @@
      ],
      // 字典:标准工作量单位
      standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
      // 字典:结算状态
      settlementStatus: constant.SETTLEMENT_STATUS,
      // 用户列表
      users: [],
      // 检索项目列表
@@ -253,6 +296,26 @@
        })
      }
    },
    // 钩子:新建 - 之前
    [CRUD.HOOK.beforeToAdd]() {
      // 表单赋值
      this.form.consumedWorkloadUnit = null
    },
    // 钩子:编辑 - 之前
    [CRUD.HOOK.beforeToEdit]() {
      // 获取项目
      crudProject.getPartake({ taskUserId: this.form.userId, approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => {
        // 表单项目列表
        this.formProjects = res
      })
      // 获取任务
      crudTask.getPartake({ taskUserId: this.form.userId, projectId: this.form.projectId }).then(res => {
        // 表单任务列表
        this.formTasks = res
        // 表单任务变更
        this.formTaskChange()
      })
    },
    // 表单用户变更
    formUserChange() {
      // 表单赋值
@@ -296,6 +359,12 @@
        if (this.formTasks[i].id === this.form.taskId) {
          // 表单赋值
          this.form.consumedWorkloadUnit = this.formTasks[i].planWorkloadUnit
          return
        }
        // 判断循环是否结束
        if (i === this.formTasks.length - 1) {
          // 表单赋值
          this.form.consumedWorkloadUnit = null
        }
      }
    }
eladmin-web-master/src/views/task/taskUser/index.vue
@@ -301,6 +301,11 @@
        })
      }
    },
    // 钩子:新建 - 之前
    [CRUD.HOOK.beforeToAdd]() {
      // 表单赋值
      this.form.taskWorkloadUnit = null
    },
    // 钩子:编辑 - 之前
    [CRUD.HOOK.beforeToEdit]() {
      // 获取父级任务
@@ -335,6 +340,12 @@
        if (this.formTasks[i].id === this.form.taskId) {
          // 表单赋值
          this.form.taskWorkloadUnit = this.formTasks[i].planWorkloadUnit
          return
        }
        // 判断循环是否结束
        if (i === this.formTasks.length - 1) {
          // 表单赋值
          this.form.taskWorkloadUnit = null
        }
      }
    }