严智鑫
2025-09-04 5bd56f3ebf96aa9a71e4a452cd2402df59d17384
JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingController.java
@@ -29,159 +29,181 @@
 * @author yanzhixin
 * @since 2024-09-13
 */
    @RestController
    @RequestMapping("/tasking")
    public class TaskingController {
        @Autowired
        private TaskingService taskingService;
        @Autowired
        private ProjectService projectService;
        @Autowired
        private MachineMapper machineMapper;
        @Autowired
        private TaskingMapper taskingMapper;
        @Autowired
        private TaskingLogService taskingLogService;
        @Autowired
        private KBBTLensSortingMapper kBBTLensSortingMapper;
@RestController
@RequestMapping("/tasking")
public class TaskingController {
    @Autowired
    private TaskingService taskingService;
    @Autowired
    private ProjectService projectService;
    @Autowired
    private MachineMapper machineMapper;
    @Autowired
    private TaskingMapper taskingMapper;
    @Autowired
    private TaskingLogService taskingLogService;
    @Autowired
    private KBBTLensSortingMapper kBBTLensSortingMapper;
        @ApiOperation("查询库位信息 返回结果")
        @PostMapping("/findKBBTLensSorting")
        @ResponseBody
        public Result findKBBTLensSorting(@RequestBody Map<String, String> map) {
            try {
                String scanId=map.get("scanId").toString();
                if (!scanId.isEmpty()){
                    List<KBBTLensSorting> list=kBBTLensSortingMapper.selectList(new QueryWrapper<KBBTLensSorting>().lambda()
                            .eq(KBBTLensSorting::getBarcode,scanId));
                    return Result.build(200,"成功",list);
                }
                return Result.build(199,"前端传值NULL",map);
            }catch (Exception e){
                return Result.build(199,"异常",map);
    @ApiOperation("查询库位信息 返回结果")
    @PostMapping("/findKBBTLensSorting")
    @ResponseBody
    public Result findKBBTLensSorting(@RequestBody Map<String, String> map) {
        try {
            String scanId = map.get("scanId").toString();
            if (!scanId.isEmpty()) {
                List<KBBTLensSorting> list = kBBTLensSortingMapper.selectList(new QueryWrapper<KBBTLensSorting>().lambda()
                        .eq(KBBTLensSorting::getBarcode, scanId));
                return Result.build(200, "成功", list);
            }
            return Result.build(199, "前端传值NULL", map);
        } catch (Exception e) {
            return Result.build(199, "异常", map);
        }
        @ApiOperation("扫码成功后返回结果 machineId,scanId")
        @PostMapping("/scanMachineAdd")
        @ResponseBody
        public Result scanMachineAdd(@RequestBody Map<String, String> map) {
            try {
                String machineId=map.get("machineId").toString();
                String scanId=map.get("scanId").toString();
                if (!scanId.isEmpty()&&!machineId.isEmpty()){
                    Machine machine = machineMapper.selectById(machineId);
                    int addCount =taskingService.scanMachineAdd(machine,scanId);
                    return Result.build(200,"成功",addCount);
                }
                return Result.build(199,"前端传值NULL",map);
            }catch (Exception e){
                return Result.build(199,"异常",map);
    }
    @ApiOperation("扫码成功后返回结果 machineId,scanId")
    @PostMapping("/scanMachineAdd")
    @ResponseBody
    public Result scanMachineAdd(@RequestBody Map<String, String> map) {
        try {
            String machineId = map.get("machineId").toString();
            String scanId = map.get("scanId").toString();
            if (!scanId.isEmpty() && !machineId.isEmpty()) {
                Machine machine = machineMapper.selectById(machineId);
                int addCount = taskingService.scanMachineAdd(machine, scanId);
                return Result.build(200, "成功", addCount);
            }
            return Result.build(199, "前端传值NULL", map);
        } catch (Exception e) {
            return Result.build(199, "异常", map);
        }
        @ApiOperation("报工提交 ")
        @PostMapping("/reportForWork")
        @ResponseBody
        public Result reportForWork(@RequestBody Machine machine) {
            try {
                int deleteCount=taskingMapper.deleteJoin(new MPJLambdaWrapper<Tasking>()
                        .selectAll(Tasking.class)
                        .innerJoin(LineConfiguration.class,LineConfiguration::getId,Tasking::getLineConfigurationId)
                        .innerJoin(Machine.class,Machine::getId,LineConfiguration::getMachineId)
                        .eq(LineConfiguration::getMachineId,machine.getId())
                        .eq(Tasking::getGlassState,"正常")
                        .eq(Tasking::getState,"线上")
                        .ne(Tasking::getWorkState,"完工"));
                taskingLogService.reportTaskingLog();
                return Result.build(200,"成功",deleteCount);
            }catch (Exception e){
                return Result.build(199,"异常",machine);
            }
        }
        @ApiOperation("查询当前设备,未完工状态的线上任务")
        @PostMapping("/findMachineTask")
        @ResponseBody
        public Result findMachineTask(@RequestBody Machine machine) {
            List<Tasking> list =taskingService.findMachineTask(machine);
            return Result.build(200,"成功",list);
        }
    }
        @ApiOperation("查询当前设备,某状态的线上任务【等待/正在工作/完工】")
        @PostMapping("/findMachineWorkStateTask")
        @ResponseBody
        public Result findMachineWorkStateTask(@RequestBody Machine machine,String workState) {
            List<Tasking> list =taskingService.findMachineWorkStateTask(machine,workState);
            return Result.build(200,"成功",list);
    @ApiOperation("报工提交 ")
    @PostMapping("/reportForWork")
    @ResponseBody
    public Result reportForWork(@RequestBody Machine machine) {
        try {
            int deleteCount = taskingMapper.deleteJoin(new MPJLambdaWrapper<Tasking>()
                    .selectAll(Tasking.class)
                    .innerJoin(LineConfiguration.class, LineConfiguration::getId, Tasking::getLineConfigurationId)
                    .innerJoin(Machine.class, Machine::getId, LineConfiguration::getMachineId)
                    .eq(LineConfiguration::getMachineId, machine.getId())
                    .eq(Tasking::getGlassState, "正常")
                    .eq(Tasking::getState, "线上")
                    .ne(Tasking::getWorkState, "完工"));
            taskingLogService.reportTaskingLog();
            return Result.build(200, "成功", deleteCount);
        } catch (Exception e) {
            return Result.build(199, "异常", machine);
        }
    }
        @ApiOperation("修改玻璃状态 【破损】")
        @PostMapping("/damagedTask")
        @ResponseBody
        public Result damagedTask(@RequestBody Tasking tasking) {
            int count =taskingService.damagedTask(tasking);
            return Result.build(200,"修改成功:"+count,count);
        }
        @ApiOperation("修改任务状态 【正在工作】")
        @PostMapping("/startMachineTask")
        @ResponseBody
        public Result startMachineTask(@RequestBody Machine machine) {
            Tasking tasking =taskingService.startMachineTask(machine);
            return Result.build(200,"修改成功:",tasking);
        }
        @ApiOperation("修改任务状态 【失败】")
        @PostMapping("/loseMachineTask")
        @ResponseBody
        public Result loseMachineTask(@RequestBody Machine machine) {
            int count =taskingService.loseMachineTask(machine);
            return Result.build(200,"修改成功:"+count,count);
        }
        @ApiOperation("修改任务状态 【完工】")
        @PostMapping("/finishMachineTask")
        @ResponseBody
        public Result finishMachineTask(@RequestBody Machine machine) {
            int count =taskingService.finishMachineTask(machine);
            return Result.build(200,"修改成功:"+count,count);
        }
    @ApiOperation("查询当前设备,未完工状态的线上任务")
    @PostMapping("/findMachineTask")
    @ResponseBody
    public Result findMachineTask(@RequestBody Machine machine) {
        List<Tasking> list = taskingService.findMachineTask(machine);
        return Result.build(200, "成功", list);
    }
        @ApiOperation("修改当前设备 【上线】")
        @PostMapping("/glassTopLineList")
        @ResponseBody
        public Result glassTopLineList(@RequestBody List<Tasking> taskingList) {
            int count =taskingService.glassTopLine(taskingList);
            return Result.build(200,"修改成功:"+count,count);
        }
    @ApiOperation("查询当前设备,某状态的线上任务【等待/正在工作/完工】")
    @PostMapping("/findMachineWorkStateTask")
    @ResponseBody
    public Result findMachineWorkStateTask(@RequestBody Machine machine, String workState) {
        List<Tasking> list = taskingService.findMachineWorkStateTask(machine, workState);
        return Result.build(200, "成功", list);
    }
        @ApiOperation("修改当前设备 【上线】")
        @PostMapping("/glassTopLine")
        @ResponseBody
        public Result glassTopLine(@RequestBody Tasking tasking) {
            int count =taskingService.glassTopLine(tasking);
            return Result.build(200,"修改成功:"+count,count);
        }
    @ApiOperation("修改玻璃状态 【破损】")
    @PostMapping("/damagedTask")
    @ResponseBody
    public Result damagedTask(@RequestBody Tasking tasking) {
        int count = taskingService.damagedTask(tasking);
        return Result.build(200, "修改成功:" + count, count);
    }
        @ApiOperation("修改当前设备 【下线】")
        @PostMapping("/glassDownLine")
        @ResponseBody
        public Result glassDownLine(@RequestBody Tasking tasking) {
            int count =taskingService.glassDownLine(tasking);
            return Result.build(200,"修改成功:"+count,count);
        }
        @ApiOperation("玻璃 【下线】")
        @PostMapping("/glassAgainTopLine")
        @ResponseBody
        public Result glassAgainTopLine(@RequestBody Tasking tasking) {
            int count =taskingService.stopTasking(tasking);
            return Result.build(200,"修改成功:"+count,count);
        }
    @ApiOperation("修改任务状态 【正在工作】")
    @PostMapping("/startMachineTask")
    @ResponseBody
    public Result startMachineTask(@RequestBody Machine machine) {
        Tasking tasking = taskingService.startMachineTask(machine);
        return Result.build(200, "修改成功:", tasking);
    }
        @ApiOperation("提交 扫码报工 ")
        @PostMapping("/scanReport")
        @ResponseBody
        public Result scanReport(@RequestBody Tasking tasking) {
            int count =taskingService.stopTasking(tasking);
            return Result.build(200,"修改成功:"+count,count);
        }
    @ApiOperation("修改任务状态 【失败】")
    @PostMapping("/loseMachineTask")
    @ResponseBody
    public Result loseMachineTask(@RequestBody Machine machine) {
        int count = taskingService.loseMachineTask(machine);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("修改任务状态 【完工】")
    @PostMapping("/finishMachineTask")
    @ResponseBody
    public Result finishMachineTask(@RequestBody Machine machine) {
        int count = taskingService.finishMachineTask(machine);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("修改当前设备 【上线】")
    @PostMapping("/glassTopLineList")
    @ResponseBody
    public Result glassTopLineList(@RequestBody List<Tasking> taskingList) {
        int count = taskingService.glassTopLine(taskingList);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("修改当前设备 【上线】")
    @PostMapping("/glassTopLine")
    @ResponseBody
    public Result glassTopLine(@RequestBody Tasking tasking) {
        int count = taskingService.glassTopLine(tasking);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("修改当前设备 【下线】")
    @PostMapping("/glassDownLine")
    @ResponseBody
    public Result glassDownLine(@RequestBody Tasking tasking) {
        int count = taskingService.glassDownLine(tasking);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("玻璃 【下线】")
    @PostMapping("/glassAgainTopLine")
    @ResponseBody
    public Result glassAgainTopLine(@RequestBody Tasking tasking) {
        int count = taskingService.stopTasking(tasking);
        return Result.build(200, "修改成功:" + count, count);
    }
    @ApiOperation("查询【线下】玻璃 ")
    @PostMapping("/selectGlassDownLine")
    @ResponseBody
    public Result selectGlassDownLine() {
        List<Tasking> downLineTask = taskingService.findDownLineTask();
        return Result.build(200, "查询成功:", downLineTask);
    }
    @ApiOperation("删除【线下】玻璃 ")
    @PostMapping("/deleteGlassDownLine")
    @ResponseBody
    public Result deleteGlassDownLine() {
        int count = taskingService.deleteGlassDownLine();
        return Result.build(200, "清除成功:"+count, count);
    }
    @ApiOperation("提交 扫码报工 ")
    @PostMapping("/scanReport")
    @ResponseBody
    public Result scanReport(@RequestBody Tasking tasking) {
        int count = taskingService.stopTasking(tasking);
        return Result.build(200, "修改成功:" + count, count);
    }
}