| | |
| | | */ |
| | | package me.zhengjie.modules.task.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | mongoTemplate.save(resources); |
| | | TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); |
| | | byId.setCostHours(resources.getConsumedHours()); |
| | | byId.setTaskStatus("task_status_in_hand"); |
| | | if (resources.getTaskProgress().equals(100.0)){ |
| | | byId.setTaskStatus("task_status_unrecognized"); |
| | | } else { |
| | | byId.setTaskStatus("task_status_in_hand"); |
| | | } |
| | | mongoTemplate.save(byId); |
| | | return null; |
| | | } else { |
| | |
| | | //这天没填写过日报 |
| | | //check(resources, taskUserMongoList); |
| | | TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); |
| | | byId.setTaskStatus("task_status_in_hand"); |
| | | 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); |
| | |
| | | // taskDaliyMongo.setConsumedHours(resources.getConsumedHours()); |
| | | |
| | | TaskUserMongo byId = mongoTemplate.findById(resources.getTaskUserMongo().getId(), TaskUserMongo.class); |
| | | byId.setTaskStatus("task_status_in_hand"); |
| | | 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); |
| | | |
| | |
| | | TaskDaliy previousTaskDaliy = taskDaliyRepository.findPreviousByProjectIdAndTaskIdAndAndUserId(resources.getProjectId(), resources.getTaskId(), resources.getUserId(), resources.getFillDate()); |
| | | if (previousTaskDaliy != null) { |
| | | TaskUser previousTaskUser = taskUserRepository.findByTaskIdAndTaskInnerIdAndUserId(previousTaskDaliy.getTaskId(), previousTaskDaliy.getTaskInnerId(), previousTaskDaliy.getUserId()); |
| | | if (previousTaskUser != null && resources.getTaskProgress() * currentTaskUser.getTaskHours() < previousTaskDaliy.getTaskProgress() * previousTaskUser.getTaskHours()) { |
| | | if (previousTaskUser != null && new BigDecimal(resources.getTaskProgress() * currentTaskUser.getTaskHours()).compareTo(new BigDecimal(previousTaskDaliy.getTaskProgress() * previousTaskUser.getTaskHours())) < 0) { |
| | | throw new BadRequestException("任务进度必须比前一次多且比后一次少!"); |
| | | } |
| | | } |
| | |
| | | // 后日任务分配 |
| | | TaskUser nextTaskUser = taskUserRepository.findByTaskIdAndTaskInnerIdAndUserId(nextTaskDaliy.getTaskId(), nextTaskDaliy.getTaskInnerId(), nextTaskDaliy.getUserId()); |
| | | // 判断任务进度是否比前一次多,比后一次少 |
| | | if (nextTaskUser != null && resources.getTaskProgress() * currentTaskUser.getTaskHours() > nextTaskDaliy.getTaskProgress() * nextTaskUser.getTaskHours()) { |
| | | if (nextTaskUser != null && new BigDecimal(resources.getTaskProgress() * currentTaskUser.getTaskHours()).compareTo(new BigDecimal(nextTaskDaliy.getTaskProgress() * nextTaskUser.getTaskHours())) > 0) { |
| | | throw new BadRequestException("任务进度必须比前一次多且比后一次少!"); |
| | | } |
| | | } |
| | |
| | | throw new BadRequestException("任务日报进度计算存在异常!"); |
| | | } |
| | | // 判断进度是否正常 |
| | | if (taskDaliyDay.getConsumedWorkload() < taskDaliyHistory.getConsumedWorkload()) { |
| | | throw new BadRequestException("任务日报进度计算存在异常!"); |
| | | if (taskDaliyDay.getConsumedWorkload() != null && taskDaliyHistory.getConsumedWorkload() != null) { |
| | | if (taskDaliyDay.getConsumedWorkload() < taskDaliyHistory.getConsumedWorkload()) { |
| | | throw new BadRequestException("任务日报进度计算存在异常!"); |
| | | } |
| | | } |
| | | // 本日任务日报进度 |
| | | //completedWork += task.getPieceRate() * (taskDaliyDay.getConsumedWorkload() - taskDaliyHistory.getConsumedWorkload()); |
| | |
| | | Date dt = sdf.parse(criteria.getTargetYearMonth()); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(dt); |
| | | cal.add(Calendar.MONTH,1); |
| | | cal.add(Calendar.MONTH, 1); |
| | | Date nextMonth = cal.getTime(); |
| | | // daliyMongoList = mongoTemplate.find(Query.query(new Criteria("userId").is(criteria.getUserId()).and("fillDate").gte(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(criteria.getTargetYearMonth())).lte(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(nextMonth)))), TaskDaliyMongo.class); |
| | | daliyMongoList = mongoTemplate.find(Query.query(new Criteria("userId").is(criteria.getUserId()).and("fillDate").gte(dt).lte(nextMonth)), TaskDaliyMongo.class); |