|  |  | 
 |  |  | import com.zy.acs.manager.common.annotation.OperationLog; | 
 |  |  | import com.zy.acs.manager.common.domain.BaseParam; | 
 |  |  | import com.zy.acs.manager.common.domain.PageParam; | 
 |  |  | import com.zy.acs.manager.common.domain.TaskDto; | 
 |  |  | import com.zy.acs.manager.core.constant.LocGroupConstant; | 
 |  |  | import com.zy.acs.manager.core.service.MainService; | 
 |  |  | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; | 
 |  |  | import com.zy.acs.manager.manager.entity.Loc; | 
 |  |  | import com.zy.acs.manager.manager.entity.Sta; | 
 |  |  | import com.zy.acs.manager.manager.entity.Task; | 
 |  |  | import com.zy.acs.manager.manager.enums.StaStsType; | 
 |  |  | import com.zy.acs.manager.manager.service.LocService; | 
 |  |  | import com.zy.acs.manager.manager.service.StaService; | 
 |  |  | import com.zy.acs.manager.manager.service.TaskService; | 
 |  |  | import com.zy.acs.manager.system.controller.BaseController; | 
 |  |  | import com.zy.acs.manager.system.service.ConfigService; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | 
 |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
 |  |  | import org.springframework.web.bind.annotation.RestController; | 
 |  |  |  | 
 |  |  | import java.util.Collections; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * Created by vincent on 2023/6/12 | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ConfigService configService; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private TaskService taskService; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     //@PreAuthorize("hasAuthority('open:bus:submit')") | 
 |  |  |     @PostMapping("/bus/submit") | 
 |  |  |     @OperationLog("generate task from open api") | 
 |  |  |     public R save(@RequestBody OpenBusSubmitParam param) { | 
 |  |  |         if (!configService.getVal("TaskAssignMode", Boolean.class)) { | 
 |  |  |             if (configService.getVal("InAndOutMode", Boolean.class, false)) { | 
 |  |  |                 mainService.generateBusAndTask(param, null); | 
 |  |  |                 return R.ok("generate tasks success"); | 
 |  |  |             for (TaskDto taskDto : param.getTaskList()) { | 
 |  |  |                 if (Cools.isEmpty(taskDto.getSeqNum())) { | 
 |  |  |                     return R.error("缺失任务号"); | 
 |  |  |                 } | 
 |  |  |                 if(Cools.isEmpty(taskDto.getPriority())){ | 
 |  |  |                     taskDto.setPriority(1); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             mainService.generateBusAndTask(param, null); | 
 |  |  |             return R.ok("generate tasks success"); | 
 |  |  |         } | 
 |  |  |         return R.error("generate tasks error"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @OperationLog("Cancel Task") | 
 |  |  |     @PostMapping("/task/cancel") | 
 |  |  |     public R cancel(@RequestBody List<String> taskIds) { | 
 |  |  |         if (Cools.isEmpty(taskIds)) { | 
 |  |  |             return R.error("task cancel error"); | 
 |  |  |         } | 
 |  |  |         List<Boolean> data = new ArrayList<>(); | 
 |  |  |         for (String id : taskIds) { | 
 |  |  |             data.add(taskService.cancelCheckTaskSts(taskService.selectBySeqNum(id).getId(), 9527L)); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(data); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @OperationLog("updateTaskPriority") | 
 |  |  |     @PostMapping("/task/updateTaskPriority") | 
 |  |  |     public R update(@RequestBody List<TaskDto> taskDtos) { | 
 |  |  |         if (Cools.isEmpty(taskDtos)) { | 
 |  |  |             return R.error("task update error"); | 
 |  |  |         } | 
 |  |  |         List<Boolean> data = new ArrayList<>(); | 
 |  |  |         for (TaskDto taskDto : taskDtos) { | 
 |  |  |             Task task = taskService.selectBySeqNum(taskDto.getSeqNum()); | 
 |  |  |             task.setPriority(taskDto.getPriority()); | 
 |  |  |             task.setUpdateBy(9527L); | 
 |  |  |             task.setUpdateTime(new Date()); | 
 |  |  |             data.add(taskService.updateById(task)); | 
 |  |  |         } | 
 |  |  |         return R.ok("Update Success").add(data); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PostMapping("/loc/sync") | 
 |  |  |     @OperationLog("sync loc") | 
 |  |  |     public R loc(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class); | 
 |  |  |         return R.ok().add(locService.page(pageParam, pageParam.buildWrapperExcludeNull(true))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PostMapping("/sta/update") | 
 |  |  |     @OperationLog("sync sta") | 
 |  |  | 
 |  |  |         return R.error("update loc fail"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //@PreAuthorize("hasAuthority('open:bus:submit')") | 
 |  |  |     @PostMapping("/loc/sync") | 
 |  |  |     @OperationLog("sync loc") | 
 |  |  |     public R loc(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class); | 
 |  |  |         return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(true))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/loc/one") | 
 |  |  |     @OperationLog("one loc") |