| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.query.MPJLambdaQueryWrapper; |
| | | import com.mes.common.S7object; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.md.entity.GlassInfo; |
| | | import com.mes.md.entity.Tasking; |
| | | import com.mes.md.mapper.GlassInfoMapper; |
| | | import com.mes.md.mapper.TaskingMapper; |
| | | import com.mes.md.service.GlassInfoService; |
| | | import com.mes.md.service.TaskingService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.md.entity.*; |
| | | import com.mes.md.mapper.*; |
| | | import com.mes.md.service.*; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | * @author wu |
| | | * @since 2024-08-28 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class TaskingServiceImpl extends MPJBaseServiceImpl<TaskingMapper, Tasking> implements TaskingService { |
| | | @Resource |
| | | GlassInfoMapper glassInfoMapper; |
| | | @Resource |
| | | LineConfigurationMapper lineConfigurationMapper; |
| | | @Autowired |
| | | GlassInfoService glassInfoService; |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | @Override |
| | | public boolean updateStatus(Integer state) { |
| | | //更改上片模式 |
| | | //向设备发送选择的状态 |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("Status").getAddress(), state); |
| | | //发送后重新读取判断是否更改成功 |
| | | String loadStatus = plcParameterObject.getPlcParameter("Status").getValue(); |
| | | return state == Integer.parseInt(loadStatus); |
| | | @Autowired |
| | | private PrimitiveTaskService primitiveTaskService; |
| | | |
| | | } |
| | | @Autowired |
| | | private ProjectService projectService; |
| | | @Autowired |
| | | private PrimitiveTaskMapper primitiveTaskMapper; |
| | | |
| | | @Autowired |
| | | private MachineMapper machineMapper; |
| | | @Autowired |
| | | private LineConfigurationService lineConfigurationService; |
| | | |
| | | @Autowired |
| | | KBBTLensSortingMapper kBBTLensSortingMapper; |
| | | |
| | | /** |
| | | * @param state |
| | | * @param machine |
| | | * 查询当前设备,线上未完工的任务 (线上/正常) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateLoadState(Integer state) { |
| | | //更改联机状态 |
| | | //向设备发送选择的状态 |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("loadState").getAddress(), state); |
| | | //发送后重新读取判断是否更改成功 |
| | | String loadState = plcParameterObject.getPlcParameter("loadState").getValue(); |
| | | return state == Integer.parseInt(loadState); |
| | | |
| | | public List<Tasking> findMachineTask(Machine machine) { |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,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,"完工") |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * @param machine |
| | | * 查询此线线上未完工的任务 (线上/正常) 的按扫码ID查询 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateDamage(Tasking tasking) { |
| | | UpdateWrapper<Tasking> queryWrapper = new UpdateWrapper<>(); |
| | | queryWrapper.eq("glass_id",tasking.getGlassId()) |
| | | .set("work_state",tasking.getWorkState()); |
| | | return this.update(queryWrapper); |
| | | public List<Tasking> findMachineTaskID(Machine machine,String scan_id) { |
| | | List<LineConfiguration> machineLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getMachineId,machine.getId())); |
| | | if(!machineLineConfiguration.isEmpty()){ |
| | | //此设备线路未完工的 的任务 |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .innerJoin(LineConfiguration.class,LineConfiguration::getId,Tasking::getLineConfigurationId) |
| | | .eq(LineConfiguration::getLineId,machineLineConfiguration.get(0).getLineId()) |
| | | .eq(Tasking::getScanId,scan_id) |
| | | .eq(Tasking::getGlassState,"正常") |
| | | .eq(Tasking::getState,"线上") |
| | | .ne(Tasking::getWorkState,"完工") |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | return list; |
| | | }else{ |
| | | log.info("此任务ID存在但条件不满足:{}",scan_id); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * @param tasking |
| | | * 任务结束 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int stopTasking(Tasking tasking){ |
| | | //1.标记总表任务结束 2.删除tasking 表 |
| | | tasking.setWorkState("完工"); |
| | | baseMapper.updateById(tasking); |
| | | //完工 /破损/拿走的玻璃 |
| | | List<Tasking> taskingList=baseMapper.selectList(new QueryWrapper<Tasking>().lambda() |
| | | .eq(Tasking::getScanId,tasking.getScanId()) |
| | | .and(wrapper->wrapper |
| | | .eq(Tasking::getWorkState,"完工") |
| | | .ne(Tasking::getState,"线下") |
| | | .ne(Tasking::getGlassState,"破损")) |
| | | |
| | | ); |
| | | if(!taskingList.isEmpty()){ |
| | | List<PrimitiveTask> primitiveTask=primitiveTaskMapper.selectList(new QueryWrapper<PrimitiveTask>().lambda() |
| | | .eq(PrimitiveTask::getScanId,tasking.getScanId()) |
| | | .orderByDesc(PrimitiveTask::getId)); |
| | | for(PrimitiveTask task:primitiveTask){ |
| | | if (taskingList.size()==task.getTaskQuantity()){ |
| | | task.setReportCount(taskingList.size()); |
| | | task.setEndTime(new Date()); |
| | | primitiveTaskMapper.updateById(task); |
| | | return baseMapper.delete(new QueryWrapper<Tasking>().lambda().eq(Tasking::getScanId,tasking.getScanId())); |
| | | } |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | /** |
| | | * @param machine,workState |
| | | * 查询当前设备,线上【等待/工作/完工】的任务 升序 (线上/正常) |
| | | * @return List<Tasking> |
| | | */ |
| | | @Override |
| | | public List<Tasking> findMachineWorkStateTask(Machine machine, String workState) { |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,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,"线上") |
| | | .eq(Tasking::getWorkState,workState) |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | return list; |
| | | } |
| | | /** |
| | | * |
| | | * 查询线下正常的玻璃 |
| | | * @return List<Tasking> findDownLineTask(); |
| | | */ |
| | | @Override |
| | | public List<Tasking> findDownLineTask() { |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .eq(Tasking::getGlassState,"正常") |
| | | .eq(Tasking::getState,"线下") |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * @param machine |
| | | * 当前设备标记正在工作:线上等待的任务第一条 (线上/正常) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Tasking> selectTasking() { |
| | | QueryWrapper<Tasking> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.orderByDesc("task_sequence"); |
| | | return list(queryWrapper); |
| | | public Tasking startMachineTask(Machine machine) { |
| | | List<Tasking> list=this.findMachineWorkStateTask(machine,"等待"); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("开始"); |
| | | tasking.setWorkState("正在工作"); |
| | | if(baseMapper.updateById(tasking)>0){ |
| | | return tasking; |
| | | }; |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * @param machine |
| | | * 当前设备标记正在工作:验证第此ID是否是 线上等待的任务第一条 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Tasking startMachineTask(Machine machine, String scan_id) { |
| | | List<Tasking> list=this.findMachineWorkStateTask(machine,"等待"); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | if(scan_id.equals(tasking.getScanId())){ |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("开始"); |
| | | tasking.setWorkState("正在工作"); |
| | | if(baseMapper.updateById(tasking)>0){ |
| | | return tasking; |
| | | }; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * @param machine |
| | | * 当前 扫码ID 是否在当前设备以前存在 存在则直接跳到当前设备 并且标记工作 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Tasking startScanIdMachineTask(Machine machine, String scan_id) { |
| | | //找当前设备线路 |
| | | List<LineConfiguration> machineLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getMachineId,machine.getId())); |
| | | if(!machineLineConfiguration.isEmpty()){ |
| | | //此设备线路未完工的 的任务 |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .innerJoin(LineConfiguration.class,LineConfiguration::getId,Tasking::getLineConfigurationId) |
| | | .eq(LineConfiguration::getLineId,machineLineConfiguration.get(0).getLineId()) |
| | | .eq(Tasking::getScanId,scan_id) |
| | | .eq(Tasking::getGlassState,"正常") |
| | | .eq(Tasking::getState,"线上") |
| | | .le(LineConfiguration::getProcessSequence,machineLineConfiguration.get(0).getProcessSequence()) |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | Integer taskSequence=1; |
| | | if (machine.getTodayCount()>0&&machine.getTodayCount()<5000){ |
| | | taskSequence=machine.getTodayCount()+1; |
| | | }else{ |
| | | taskSequence=1; |
| | | } |
| | | machine.setTodayCount(taskSequence); |
| | | machineMapper.updateById(machine); |
| | | tasking.setTaskSequence(taskSequence); |
| | | |
| | | tasking.setWorkState("正在工作"); |
| | | tasking.setLineConfigurationId(machineLineConfiguration.get(0).getId()); |
| | | //记录设备开始时间 |
| | | tasking.setOperationRecord(machineLineConfiguration.get(0).getRemark()+machineLineConfiguration.get(0).getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("开始"); |
| | | |
| | | if(baseMapper.updateById(tasking)>0){ |
| | | finishMachineTask(machine); |
| | | return tasking; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * @param machine |
| | | * 当前设备标记完成:正在工作的第一个任务 (线上/正常) 返回完成数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int finishMachineTask(Machine machine,Integer taskSequence) { |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,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,"线上") |
| | | .eq(Tasking::getTaskSequence,taskSequence) |
| | | .eq(Tasking::getWorkState,"正在工作") |
| | | .orderByAsc(Tasking::getTaskSequence)); |
| | | //当前设备的线路配置 |
| | | List<LineConfiguration> machineLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getMachineId,machine.getId())); |
| | | if(!machineLineConfiguration.isEmpty()){ |
| | | List<LineConfiguration> listLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getLineId,machineLineConfiguration.get(0).getLineId()) |
| | | .eq(LineConfiguration::getIsStart,1) |
| | | .gt(LineConfiguration::getProcessSequence,machineLineConfiguration.get(0).getProcessSequence()) |
| | | .orderByAsc(LineConfiguration::getProcessSequence) |
| | | .orderByAsc(LineConfiguration::getPrioritySequence) |
| | | ); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | if (!listLineConfiguration.isEmpty()){ |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("结束"); |
| | | tasking.setLineConfigurationId(listLineConfiguration.get(0).getId()); |
| | | tasking.setWorkState("等待"); |
| | | return baseMapper.updateById(tasking); |
| | | }else{ |
| | | return this.stopTasking(tasking); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * @param machine |
| | | * 当前设备标记完成:正在工作的第一个任务 (线上/正常) 返回完成数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int finishMachineTask(Machine machine) { |
| | | List<Tasking> list=this.findMachineWorkStateTask(machine,"正在工作"); |
| | | //当前设备的线路配置 |
| | | List<LineConfiguration> machineLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getMachineId,machine.getId())); |
| | | if(!machineLineConfiguration.isEmpty()){ |
| | | List<LineConfiguration> listLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getLineId,machineLineConfiguration.get(0).getLineId()) |
| | | .eq(LineConfiguration::getIsStart,1) |
| | | .gt(LineConfiguration::getProcessSequence,machineLineConfiguration.get(0).getProcessSequence()) |
| | | .orderByAsc(LineConfiguration::getProcessSequence) |
| | | .orderByAsc(LineConfiguration::getPrioritySequence) |
| | | ); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("结束"); |
| | | if (!listLineConfiguration.isEmpty()){ |
| | | tasking.setLineConfigurationId(listLineConfiguration.get(0).getId()); |
| | | tasking.setWorkState("等待"); |
| | | return baseMapper.updateById(tasking); |
| | | } |
| | | else{ |
| | | tasking.setWorkState("完工"); |
| | | return baseMapper.updateById(tasking); |
| | | //return this.stopTasking(tasking); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | /** |
| | | * @param machine |
| | | * 当前设备标记失败,正在工作的最后一个任务 (线上/正常) 返回失败数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int loseMachineTask(Machine machine) { |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,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,"线上") |
| | | .eq(Tasking::getWorkState,"正在工作") |
| | | .orderByDesc(Tasking::getTaskSequence)); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("人工"); |
| | | tasking.setWorkState("等待"); |
| | | return baseMapper.updateById(tasking); |
| | | } |
| | | return 0; |
| | | } |
| | | @Override |
| | | public int glassDownLineOne(Machine machine){ |
| | | List<Tasking> list=baseMapper.selectJoinList(Tasking.class,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,"线上") |
| | | .eq(Tasking::getWorkState,"正在工作") |
| | | .orderByDesc(Tasking::getTaskSequence)); |
| | | if(!list.isEmpty()){ |
| | | Tasking tasking=list.get(0); |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(tasking.getLineConfigurationId()); |
| | | tasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("自动"); |
| | | tasking.setState("线下"); |
| | | return baseMapper.updateById(tasking); |
| | | } |
| | | return 0; |
| | | } |
| | | /** |
| | | * @param tasking |
| | | * 破损玻璃, (线上/正常) 返回破损数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int damagedTask(Tasking tasking) { |
| | | Tasking oldTasking=baseMapper.selectById(tasking); |
| | | if(!Objects.isNull(oldTasking)){ |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(oldTasking.getLineConfigurationId()); |
| | | oldTasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | oldTasking.setOperationRecordTime(new Date()); |
| | | oldTasking.setOperationMode("人工"); |
| | | oldTasking.setGlassState("破损"); |
| | | return baseMapper.updateById(oldTasking); |
| | | } |
| | | return 0; |
| | | } |
| | | /** |
| | | * @param tasking |
| | | * 修改状态 【下线】 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int glassDownLine(Tasking tasking) { |
| | | Tasking oldTasking=baseMapper.selectById(tasking); |
| | | if (!Objects.isNull(oldTasking)){ |
| | | LineConfiguration thisLineConfiguration=lineConfigurationMapper.selectById(oldTasking.getLineConfigurationId()); |
| | | oldTasking.setOperationRecord(thisLineConfiguration.getRemark()+thisLineConfiguration.getLineId()); |
| | | oldTasking.setOperationRecordTime(new Date()); |
| | | oldTasking.setOperationMode("人工"); |
| | | oldTasking.setState("线下"); |
| | | return baseMapper.updateById(oldTasking); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * @param taskingList |
| | | * 批量修改状态 【上线】 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int glassTopLine(List<Tasking> taskingList) { |
| | | int resultCount=0; |
| | | for (Tasking tasking:taskingList){ |
| | | Tasking oldTasking=baseMapper.selectById(tasking); |
| | | if (!Objects.isNull(oldTasking)){ |
| | | oldTasking.setState(tasking.getState()); |
| | | resultCount+=baseMapper.updateById(oldTasking); |
| | | } |
| | | } |
| | | return resultCount; |
| | | } |
| | | |
| | | /** |
| | | * @param taskingList |
| | | * 批量修改状态 【上线】 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int glassTopLine(Tasking taskingList) { |
| | | //当前设备的线路配置 |
| | | Long machineId=taskingList.getLineConfigurationId(); |
| | | List<LineConfiguration> machineLineConfiguration=lineConfigurationMapper.selectJoinList(LineConfiguration.class,new MPJLambdaWrapper<LineConfiguration>() |
| | | .selectAll(LineConfiguration.class) |
| | | .eq(LineConfiguration::getMachineId,machineId)); |
| | | if(!machineLineConfiguration.isEmpty()){ |
| | | Tasking oldTasking=baseMapper.selectById(taskingList); |
| | | if (!Objects.isNull(oldTasking)){ |
| | | oldTasking.setLineConfigurationId(machineLineConfiguration.get(0).getId()); |
| | | oldTasking.setState("线上"); |
| | | oldTasking.setWorkState("等待"); |
| | | oldTasking.setGlassState("正常"); |
| | | return baseMapper.updateById(oldTasking); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param machine |
| | | * 扫码设备 添加任务 |
| | | * 查看PrimitiveTask表是否存在此扫码数据 |
| | | * 存在则根据 内容 创建 tasking任务 并排序 |
| | | * 不存在则 查询九牧数据库添加 PrimitiveTask表 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int scanMachineAdd(Machine machine, String scanId){ |
| | | String errorStr=""; |
| | | if(!Objects.isNull(scanId)){ |
| | | List<PrimitiveTask> primitiveTaskList=primitiveTaskMapper.selectList(new QueryWrapper<PrimitiveTask>().lambda() |
| | | .eq(PrimitiveTask::getScanId,scanId)); |
| | | if(primitiveTaskList.isEmpty()){ |
| | | int insertCount=projectService.insertProjectCustomization(scanId); |
| | | errorStr="扫码ID:"+scanId+" 九牧IT数据库未下发"; |
| | | if (insertCount<1&&!errorStr.equals(machine.getRemark())){ |
| | | machine.setRemark(errorStr); |
| | | machineMapper.updateById(machine); |
| | | return 0; |
| | | } |
| | | } |
| | | primitiveTaskList=primitiveTaskMapper.selectList(new QueryWrapper<PrimitiveTask>().lambda() |
| | | .eq(PrimitiveTask::getScanId,scanId)); |
| | | |
| | | if(!primitiveTaskList.isEmpty()){ |
| | | PrimitiveTask primitiveTask=primitiveTaskList.get(0); |
| | | LineConfiguration lineConfiguration=lineConfigurationService.machineLineConfiguration(machine); |
| | | List<Tasking> listTasking=baseMapper.selectList(new QueryWrapper<Tasking>().lambda() |
| | | .eq(Tasking::getScanId,scanId) |
| | | .ne(Tasking::getLineConfigurationId,113) |
| | | .ne(Tasking::getState,"线下") |
| | | .ne(Tasking::getGlassState,"破损")); |
| | | if((listTasking.size()<primitiveTaskList.get(0).getTaskQuantity())||machine.getMode()==3){ |
| | | Tasking tasking=primitiveTaskService.convertListTasking(primitiveTask,lineConfiguration.getId()); |
| | | Integer taskSequence=1; |
| | | if (machine.getTodayCount()>0&&machine.getTodayCount()<5000){ |
| | | taskSequence=machine.getTodayCount()+1; |
| | | }else{ |
| | | taskSequence=1; |
| | | } |
| | | machine.setTodayCount(taskSequence); |
| | | String Warehouse=""; |
| | | if (machine.getId()==24){ |
| | | List<KBBTLensSorting> list=kBBTLensSortingMapper.selectList(new QueryWrapper<KBBTLensSorting>().lambda() |
| | | .eq(KBBTLensSorting::getBarcode,scanId) |
| | | .notLike(KBBTLensSorting::getProductionOrder,"防碎膜")); |
| | | if (list.size()>0){ |
| | | Warehouse=list.get(0).getWarehouse(); |
| | | } |
| | | } |
| | | tasking.setWarehouse(Warehouse); |
| | | tasking.setOperationRecord(lineConfiguration.getRemark()+lineConfiguration.getLineId()); |
| | | tasking.setOperationRecordTime(new Date()); |
| | | tasking.setOperationMode("插入数据"); |
| | | |
| | | tasking.setTaskSequence(taskSequence); |
| | | machineMapper.updateById(machine); |
| | | return baseMapper.insert(tasking); |
| | | } |
| | | errorStr="扫码ID:"+scanId+" 线上玻璃已达到下发上线 下发任务数:"+primitiveTaskList.get(0).getTaskQuantity()+" 产线任务数:"+listTasking.size(); |
| | | if (!errorStr.equals(machine.getRemark())){ |
| | | machine.setRemark(errorStr); |
| | | machineMapper.updateById(machine); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Boolean insertTasking(String status) { |
| | |
| | | tasking.setSilkScreenY(glassInfo.getSilkScreenY()); |
| | | tasking.setIsMarking(glassInfo.getIsMarking()); |
| | | tasking.setIsSilkScreen(glassInfo.getIsSilkScreen()); |
| | | tasking.setCurrentCraft("上片"); |
| | | tasking.setLineConfigurationId(1L); |
| | | |
| | | } |
| | | } |
| | | else { |
| | | tasking.setTaskType("定制"); |
| | | tasking.setCurrentCraft("上片"); |
| | | tasking.setLineConfigurationId(1L); |
| | | } |
| | | return save(tasking); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean updateTasking(String scanId) { |
| | | Tasking glass=new Tasking(); |
| | | glass.setCurrentCraft("上片"); |
| | | glass.setState("完成"); |
| | | glass.setLineConfigurationId(1L); |
| | | //glass.setCurrentCraft("上片"); |
| | | glass.setWorkState("完工"); |
| | | glass.setTaskType("定制"); |
| | | //获取当前上片的定制任务id |
| | | Tasking tasking= selectTasking(glass); |
| | | //获取当前扫描的玻璃数据 |
| | | GlassInfo glassInfo = glassInfoService.selectTaskingByGlass(scanId); |
| | | if(glassInfo!=null){ |
| | | tasking.setBatchNumber(glassInfo.getBatchNumber()); |
| | | tasking.setScanId(glassInfo.getScanId()); |
| | | tasking.setProgramId(glassInfo.getProgramId()); |
| | | tasking.setTaskType(glassInfo.getTaskType()); |
| | | tasking.setTaskSequence(glassInfo.getTaskSequence()); |
| | | tasking.setTaskQuantity(glassInfo.getTaskQuantity()); |
| | | tasking.setLength(glassInfo.getLength()); |
| | | tasking.setWidth(glassInfo.getWidth()); |
| | | tasking.setThickness(glassInfo.getThickness()); |
| | | tasking.setDrawingGlue(glassInfo.getDrawingGlue()); |
| | | tasking.setDrawingMarking(glassInfo.getDrawingMarking()); |
| | | tasking.setSilkScreenX(glassInfo.getSilkScreenX()); |
| | | tasking.setSilkScreenY(glassInfo.getSilkScreenY()); |
| | | tasking.setIsMarking(glassInfo.getIsMarking()); |
| | | tasking.setIsSilkScreen(glassInfo.getIsSilkScreen()); |
| | | tasking.setCurrentCraft("扫码"); |
| | | glass.setBatchNumber(glassInfo.getBatchNumber()); |
| | | glass.setScanId(glassInfo.getScanId()); |
| | | glass.setProgramId(glassInfo.getProgramId()); |
| | | glass.setTaskType(glassInfo.getTaskType()); |
| | | glass.setTaskSequence(glassInfo.getTaskSequence()); |
| | | glass.setTaskQuantity(glassInfo.getTaskQuantity()); |
| | | glass.setLength(glassInfo.getLength()); |
| | | glass.setWidth(glassInfo.getWidth()); |
| | | glass.setThickness(glassInfo.getThickness()); |
| | | glass.setDrawingGlue(glassInfo.getDrawingGlue()); |
| | | glass.setDrawingMarking(glassInfo.getDrawingMarking()); |
| | | glass.setSilkScreenX(glassInfo.getSilkScreenX()); |
| | | glass.setSilkScreenY(glassInfo.getSilkScreenY()); |
| | | glass.setIsMarking(glassInfo.getIsMarking()); |
| | | glass.setIsSilkScreen(glassInfo.getIsSilkScreen()); |
| | | glass.setLineConfigurationId(2L); |
| | | } |
| | | return updateById(tasking); |
| | | return updateById(glass); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Tasking selectTasking(Tasking tasking) { |
| | | QueryWrapper<Tasking> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("current_craft",tasking.getCurrentCraft()) |
| | | .eq("state",tasking.getState()) |
| | | .eq("work_state",tasking.getWorkState()) |
| | | .orderByAsc("glass_id"); |
| | | return getOne(queryWrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Boolean insertTaskingPro(String tasking) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param tasking |
| | | * 查询当前工艺,线上未完工的任务 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Tasking> findCraftTasking(Tasking tasking) { |
| | | return baseMapper.selectList(new MPJLambdaQueryWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .eq(Tasking::getCurrentCraft,tasking.getCurrentCraft()) |
| | | .ne(Tasking::getWorkState,"完工") |
| | | .orderByAsc(Tasking::getGlassId)); |
| | | } |
| | | |
| | | /** |
| | | * @param tasking |
| | | * 修改任务状态 【破损/失败/完工】 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int updateCraftTasking(Tasking tasking) { |
| | | Tasking oldTasking=baseMapper.selectById(tasking); |
| | | oldTasking.setWorkState(tasking.getWorkState()); |
| | | return baseMapper.updateById(oldTasking); |
| | | } |
| | | |
| | | /** |
| | | * @param tasking |
| | | * 修改状态 【下线】 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int updateDownLine(Tasking tasking) { |
| | | Tasking oldTasking=baseMapper.selectById(tasking); |
| | | oldTasking.setState(tasking.getState()); |
| | | return baseMapper.updateById(oldTasking); |
| | | } |
| | | |
| | | } |