|
@@ -2,13 +2,17 @@ package com.ruoyi.sim.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.hutool.http.useragent.UserAgentUtil;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.sim.domain.Fault;
|
|
|
import com.ruoyi.sim.domain.TaskFault;
|
|
|
import com.ruoyi.sim.domain.vo.FaultTreeVo;
|
|
|
import com.ruoyi.sim.domain.vo.TaskVo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.sim.mapper.TaskMapper;
|
|
@@ -78,7 +82,7 @@ public class TaskService {
|
|
|
}
|
|
|
|
|
|
// -------------------------------- tom add --------------------------------
|
|
|
-
|
|
|
+ private static final Logger l = LoggerFactory.getLogger(TaskService.class);
|
|
|
@Autowired
|
|
|
private FaultService faultService;
|
|
|
@Autowired
|
|
@@ -87,22 +91,66 @@ public class TaskService {
|
|
|
/**
|
|
|
* 新增任务
|
|
|
*
|
|
|
- * @param task 任务
|
|
|
+ * @param tv 任务
|
|
|
* @return 结果
|
|
|
+ * todo:事务有问题。
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public AjaxResult insertTask(TaskVo task) {
|
|
|
- List<FaultTreeVo> selectedData = task.getSelectedData();
|
|
|
- task.setCreateTime(DateUtils.getNowDate());
|
|
|
- task.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ public AjaxResult insertTaskByTeacher(TaskVo tv) {
|
|
|
+ l.info("task new task " + tv);
|
|
|
+ // check
|
|
|
+ if (tv == null) {
|
|
|
+ return AjaxResult.error("TaskVo empty!");
|
|
|
+ }
|
|
|
+ if (!faultService.checkSimTypeOk(tv.getSimType())) {
|
|
|
+ return AjaxResult.error("simType error!");
|
|
|
+ }
|
|
|
+ if (!Task.TASK_TYPE_TEACHER_ADD.equals(tv.getTaskType())) {
|
|
|
+ return AjaxResult.error("taskType value error!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(tv.getName())) {
|
|
|
+ return AjaxResult.error("name isEmpty!");
|
|
|
+ }
|
|
|
+ //
|
|
|
+ tv.setCreateByUserId(SecurityUtils.getUserId());
|
|
|
+ tv.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ tv.setCreateTime(DateUtils.getNowDate());
|
|
|
+ tv.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ tv.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ tv.setRemark("");
|
|
|
+ List<FaultTreeVo> selectedData = tv.getSelectedData();
|
|
|
+ taskMapper.insertTask(tv);
|
|
|
if (selectedData != null) {
|
|
|
List<FaultTreeVo> list = FaultService.flatten(selectedData);
|
|
|
- for (FaultTreeVo one : list) {
|
|
|
- TaskFault tf = one.getTaskFault();
|
|
|
+ for (FaultTreeVo ftv : list) {
|
|
|
+ if (ftv == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!Fault.FAULT_TYPE_3.equals(ftv.getFaultType())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TaskFault tf = ftv.getTaskFault();
|
|
|
+ // check
|
|
|
+ if (tf == null) {
|
|
|
+ return AjaxResult.error("TaskFault empty!");
|
|
|
+ }
|
|
|
+ String flag = tf.getFlag();
|
|
|
+ if (StringUtils.isEmpty(flag)) {
|
|
|
+ return AjaxResult.error("flag empty!");
|
|
|
+ }
|
|
|
+ if (TaskFault.UNKNOWN.equals(flag)) {
|
|
|
+ return AjaxResult.error("flag UNKNOWN!");
|
|
|
+ }
|
|
|
+ if (!TaskFault.YES.equals(flag) && !TaskFault.NO.equals(flag)) {
|
|
|
+ return AjaxResult.error("flag must YES or NO!");
|
|
|
+ }
|
|
|
+ // todo:选中数量限制
|
|
|
+
|
|
|
+ // todo:故障部位冲突
|
|
|
+ tf.setTaskId(tv.getTaskId());
|
|
|
taskFaultService.insertOrUpdateTaskFault(tf);
|
|
|
}
|
|
|
}
|
|
|
- taskMapper.insertTask(task);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|