eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -209,6 +209,8 @@ public static final String CONFIGURATION_TYPE_MINUTE = "configuration_type_minute"; // 配置类型:次 public static final String CONFIGURATION_TYPE_FREQUENCY = "configuration_type_frequency"; // 配置类型:时 public static final String CONFIGURATION_TYPE_HOUR = "configuration_type_hour"; // 数字 public static final Double NUMBER_ONE = 1.0; eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysUserLevelOther.java
@@ -70,7 +70,7 @@ @Column(name = "`annual_leave_days`",nullable = false) @NotNull @ApiModelProperty(value = "年假天数") private Integer annualLeaveDays; private Double annualLeaveDays; @Column(name = "`remarks`") @ApiModelProperty(value = "备注") eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java
@@ -52,4 +52,12 @@ */ @Query(value = "SELECT * FROM sys_user_level_other WHERE user_id = ?1 AND start_date <= ?2 AND (end_date IS NULL OR end_date >= ?2) ORDER BY start_date DESC, create_time DESC LIMIT 1", nativeQuery = true) SysUserLevelOther findTargetYearMonth(Long userId, String targetDate); /** * 根据用户ID查询最早记录 * @param userId / * @return / */ @Query(value = "SELECT * FROM sys_user_level_other WHERE user_id = ?1 ORDER BY start_date ASC LIMIT 1", nativeQuery = true) SysUserLevelOther findOldByUserId(Long userId); } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelOtherDto.java
@@ -49,7 +49,7 @@ private Double personalPerformanceProportion; /** 年假天数 */ private Integer annualLeaveDays; private Double annualLeaveDays; /** 备注 */ private String remarks; eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -1196,10 +1196,10 @@ createNewSysUserLevelInsurance(userId, newLevelId); // 判断新旧用户级别ID是否相等 if (oldLevelId == null) { // 创建用户级别其他 createSysUserLevelOther(userId, newLevelId); } else if (oldLevelId != newLevelId) { // if (oldLevelId == null) { // // 创建用户级别其他 // createSysUserLevelOther(userId, newLevelId); // } else if (oldLevelId != newLevelId) { // // 旧用户级别其他 // SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId); // // 判断旧用户级别其他是否为空 @@ -1227,9 +1227,9 @@ // } // // 创建用户级别其他 // createSysUserLevelOther(userId, newLevelId); } else { } // } else { // // } } /** @@ -1352,6 +1352,8 @@ sysUserLevelInsuranceRepository.save(sysUserLevelInsurance); } /** * 创建用户级别其他 * @@ -1361,15 +1363,104 @@ private void createSysUserLevelOther(Long userId, Long levelId) { // 级别 SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new); // 添加两条数据 for (int i = 0; i < 2; i++) { if (i == 1) { // 用户级别其他 SysUserLevelOther sysUserLevelOther = new SysUserLevelOther(); sysUserLevelOther.setUserId(userId); sysUserLevelOther.setLevelId(levelId); sysUserLevelOther.setStartDate(new Timestamp(new Date().getTime())); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.MONTH, 1); sysUserLevelOther.setStartDate(new Timestamp(calendar.getTimeInMillis())); sysUserLevelOther.setPersonalPerformanceProportion(sysLevel.getPersonalPerformanceProportion()); sysUserLevelOther.setAnnualLeaveDays(sysLevel.getAnnualLeaveDays()); sysUserLevelOther.setAnnualLeaveDays(0.0); // 保存 sysUserLevelOtherRepository.save(sysUserLevelOther); } else { // 用户级别其他 SysUserLevelOther sysUserLevelOther = new SysUserLevelOther(); sysUserLevelOther.setUserId(userId); sysUserLevelOther.setLevelId(levelId); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DATE, -1); sysUserLevelOther.setStartDate(new Timestamp(new Date().getTime())); // 添加月末日期 sysUserLevelOther.setEndDate(new Timestamp(calendar.getTimeInMillis())); sysUserLevelOther.setPersonalPerformanceProportion(sysLevel.getPersonalPerformanceProportion()); sysUserLevelOther.setAnnualLeaveDays(0.0); // 保存 sysUserLevelOtherRepository.save(sysUserLevelOther); } } // 查询最早用户级别其他表 SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findOldByUserId(userId); Calendar calendar = Calendar.getInstance(); calendar.setTime(sysUserLevelOther.getStartDate()); int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); if (dayOfMonth <= daysInMonth / 2) { // 用户是在前半个月加入的,算上本月获取两个月之后的日期 getYearDays(3, userId); } else { // 用户是在后半个月加入的,不算本月获取三个月之后的日期 getYearDays(4, userId); } } // 获取用户的年假天数 public void getYearDays(int num, Long userId){ Calendar calendar1 = Calendar.getInstance(); calendar1.add(Calendar.MONTH, num); int currentYear = calendar1.get(calendar1.YEAR); calendar1.set(Calendar.DAY_OF_MONTH, 1); // 设置为月初 calendar1.set(Calendar.HOUR_OF_DAY, 0); calendar1.set(Calendar.MINUTE, 0); calendar1.set(Calendar.SECOND, 0); calendar1.set(Calendar.MILLISECOND, 0); Timestamp timestamp = new Timestamp(calendar1.getTimeInMillis()); Calendar joinDate = Calendar.getInstance(); joinDate.setTime(timestamp); // 三个月后转正的日期 int joinMonth = joinDate.get(Calendar.MONTH); // 获取明年的年份 Calendar calendar2 = Calendar.getInstance(); calendar2.add(Calendar.YEAR, 1); int nextYear = calendar2.get(Calendar.YEAR); // 计算剩余的月份 int remainingMonths = 0; if (currentYear != nextYear) { if (joinMonth == Calendar.DECEMBER) { // 如果用户在12月转正 remainingMonths = 1; } else { // 否则,剩余的月份是 12 减去加入的月份加上本月 remainingMonths = 12 - joinMonth; } } // 计算年假天数 double annualLeave = (5.0 / 12) * remainingMonths; BigDecimal big = new BigDecimal(annualLeave); big = big.setScale(1, BigDecimal.ROUND_HALF_UP); annualLeave = big.doubleValue(); // 查询用户级别其他表(修改年假) List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId); for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) { sysUserLevelOther.setAnnualLeaveDays(annualLeave); sysUserLevelOtherRepository.save(sysUserLevelOther); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/rest/TaskUserController.java
@@ -188,7 +188,7 @@ } @GetMapping("/exportUser") public void exportUser(HttpServletResponse response) throws IOException { taskUserService.exportUser(response); public void exportUser(HttpServletResponse response, String taskId) throws IOException { taskUserService.exportUser(response, taskId); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/TaskUserService.java
@@ -132,5 +132,5 @@ void generate(TaskGenerateDto taskGenerateDto) throws ParseException; void exportUser(HttpServletResponse response) throws IOException; void exportUser(HttpServletResponse response, String taskId) throws IOException; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java
@@ -218,7 +218,11 @@ mongoTemplate.save(resources); TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); byId.setCostHours(resources.getConsumedHours()); if (resources.getTaskProgress().equals(100.0)){ byId.setTaskStatus("task_status_unrecognized"); } else { byId.setTaskStatus("task_status_in_hand"); } mongoTemplate.save(byId); return null; } else { @@ -228,7 +232,11 @@ //这天没填写过日报 //check(resources, taskUserMongoList); TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); if (resources.getTaskProgress().equals(100.0)){ byId.setTaskStatus("task_status_unrecognized"); } else { byId.setTaskStatus("task_status_in_hand"); } byId.setCostHours(byId.getCostHours() + resources.getConsumedHours()); mongoTemplate.save(byId); mongoTemplate.save(resources); @@ -242,7 +250,11 @@ // taskDaliyMongo.setConsumedHours(resources.getConsumedHours()); TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); if (resources.getTaskProgress().equals(100.0)){ byId.setTaskStatus("task_status_unrecognized"); } else { byId.setTaskStatus("task_status_in_hand"); } byId.setCostHours(byId.getCostHours() - taskDaliyMongo.getConsumedHours() + resources.getConsumedHours()); mongoTemplate.save(byId); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java
@@ -587,15 +587,23 @@ } @Override public void exportUser(HttpServletResponse response) throws IOException { public void exportUser(HttpServletResponse response, String taskId) throws IOException { // try{ Workbook workbook = new XSSFWorkbook(); // 创建一个新的工作表来存储下拉列表的数据 Sheet dataSheet = workbook.createSheet("员工详细信息"); Query query = new Query(Criteria.where("id").is(taskId)); List<TaskMongo> taskMongos = mongoTemplate.find(query, TaskMongo.class); // 查询数据 List<User> userList = userRepository.findAllByEnabled(true); // List<User> userList = userRepository.findAllByEnabled(true); List<User> userList = new ArrayList<>(); for (int i = 0; i < taskMongos.get(0).getContainUserList().size(); i++) { User user = userRepository.getById(taskMongos.get(0).getContainUserList().get(i)); userList.add(user); } for (int i = 0; i < userList.size(); i++) { User user = userList.get(i); Row row = dataSheet.createRow(i); @@ -1334,10 +1342,16 @@ taskUserMongo.setTaskStatus(resources.getTaskStatus()); Double coefficientByUserId; // if (resources.isOk()) { // taskUserMongo.setTaskStatus("task_status_completed"); // } else { // taskUserMongo.setTaskStatus("task_status_in_hand"); // } if (resources.isOk()) { taskUserMongo.setTaskStatus("task_status_completed"); } else { taskUserMongo.setTaskStatus("task_status_in_hand"); taskUserMongo.setTaskStatus("task_status_unrecognized"); } if (resources.getUserId() == null) { eladmin-web-master/src/api/task/taskUser.js
@@ -140,9 +140,9 @@ }) } export function exportUser() { export function exportUser(taskId) { return request({ url: 'api/taskUser/exportUser', url: `api/taskUser/exportUser?taskId=${taskId}`, method: 'get', responseType: 'blob' }) eladmin-web-master/src/utils/constant.js
@@ -232,6 +232,8 @@ export const CONFIGURATION_TYPE_MINUTE = 'configuration_type_minute' // 配置类型:次 export const CONFIGURATION_TYPE_FREQUENCY = 'configuration_type_frequency' // 配置类型:时 export const CONFIGURATION_TYPE_HOUR = 'configuration_type_hour' // 外出审批状态 export const GO_OUT_APPROVE_STATUS = 'go_out_approve_status' @@ -460,6 +462,7 @@ CONFIGURATION_TYPE_DAY, CONFIGURATION_TYPE_MINUTE, CONFIGURATION_TYPE_FREQUENCY, CONFIGURATION_TYPE_HOUR, GO_OUT_APPROVE_STATUS, GO_OUT_APPROVE_STATUS_REVIEWED, GO_OUT_APPROVE_STATUS_AGREE, eladmin-web-master/src/utils/trans.js
@@ -41,8 +41,19 @@ // return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date) // } // export function formatExcelDate(numb, format = '-') { // const time = new Date((numb - 25569) * 24 * 3600000); // let localTimeString = time.toISOString(); // // 格式化为"yyyy-mm-dd HH:MM:SS" // localTimeString = localTimeString.replace('T', ' ').split('.')[0].replace(/-/g, format); // return localTimeString; // } export function formatExcelDate(numb, format = '-') { const time = new Date((numb - 25569) * 24 * 3600000); const seconds = Math.round((numb - 25569) * 24 * 60 * 60); const time = new Date(seconds * 1000); let localTimeString = time.toISOString(); // 格式化为"yyyy-mm-dd HH:MM:SS" eladmin-web-master/src/views/task/task/index.vue
@@ -35,7 +35,7 @@ <el-autocomplete v-model="query.name" class="filter-item" :fetch-suggestions="querySearch" placeholder="名称" style="width: 185px;" /> <el-select v-model="query.taskStatuses" multiple collapse-tags filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item"> <el-option v-for="item in dict[taskStatus]" v-for="item in filteredDict" :key="item.id" :label="item.label" :value="item.value" @@ -151,7 +151,7 @@ <el-form-item label="任务状态" v-if="isShow"> <el-select v-model="form.taskStatus" filterable clearable placeholder="请选择" style="width: 340px;"> <el-option v-for="item in dict[taskStatus]" v-for="item in filteredDict" :key="item.id" :label="item.label" :value="item.value" @@ -533,6 +533,11 @@ created() { this.crud.optShow.reset = false }, computed: { filteredDict() { return this.dict[this.taskStatus].filter(item => item.value !== 'task_status_unrecognized'); } }, mounted() { // 获取项目 this.getProject() eladmin-web-master/src/views/task/taskUser/index.vue
@@ -485,9 +485,16 @@ </el-form-item> <el-form-item v-if="form.newTaskProgress === 100" label="任务状态"> <el-switch v-if="form.taskStatus === taskSt" v-model="form.is_ok" v-permission="permission.list" active-text="已完成" /> <el-switch v-if="form.taskStatus === taskSo" v-model="form.is_ok" v-permission="permission.list" active-text="未承认" /> </el-form-item> </el-form> @@ -829,7 +836,9 @@ total: 0, currentPage: 1, pageSize: 10, slong: false slong: false, taskSo: constant.TASK_STATUS_UNRECOGNIZED, taskSt: constant.TASK_STATUS_COMPLETED }; }, computed: { @@ -856,6 +865,15 @@ this.form.name = null; this.form.performanceHours = null; this.form.start = false; }, // 编辑之前 [CRUD.HOOK.beforeToEdit]() { if(this.form.taskStatus == this.taskSo) { this.form.is_ok = false } if(this.form.taskStatus == this.taskSt) { this.form.is_ok = true } }, [CRUD.HOOK.afterEditError]() { this.formTasks = []; @@ -995,7 +1013,7 @@ exportUser() { this.slong = true; crudTaskUser .exportUser() .exportUser(this.query.taskId) .then(res => { downloadFile(res, "测试数据", "xlsx"); this.slong = false; @@ -1144,7 +1162,6 @@ return false; } } console.log("this.generateForm2 : ", this.generateFormTwo); this.tableHeader = header.filter( item => item !== "所属员工ID" && item !== "任务状态ID" && item !== "优先度ID" && item !== "隔绝列1" && @@ -1170,7 +1187,6 @@ this.$message.warning("请选择上传的文件"); return; } console.log("dd:" + this.query.taskId); // 生成表单加载 this.generateLoading = true; this.uploading = true; @@ -1263,11 +1279,6 @@ i ].alreadyConsumeHours; } // console.log(this.taskUserDetail) // this.taskUserDetail.map((key, value) => { // console.log(key) // console.log(value) // }) // var key = this.taskUserDetail.keySet(); for (var key in this.taskUserDetail) {