| | |
| | | package com.mes.workstation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.workstation.entity.UpWorkSequence; |
| | | import com.mes.common.S7object; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.uppattenusage.entity.UpPattenUsage; |
| | | import com.mes.uppattenusage.mapper.UpPattenUsageMapper; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | import com.mes.workstation.mapper.UpWorkstationMapper; |
| | | import com.mes.workstation.service.UpWorkstationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | |
| | | public class UpWorkstationServiceImpl extends ServiceImpl<UpWorkstationMapper, UpWorkstation> implements UpWorkstationService { |
| | | |
| | | public static final String DB_100_10 = "DB_100_10"; |
| | | |
| | | //判断是否可以吸片进行任务 |
| | | public boolean isCanLoadGlass() { |
| | | String loadstart = "吸片信号";//plcmes.getPlcParameter("吸片信号").getValue(); |
| | | return "1".equals(loadstart); |
| | | |
| | | } |
| | | //显示正在进行任务的工程信息 |
| | | @Resource |
| | | UpPattenUsageMapper upPattenUsageMapper; |
| | | @Resource |
| | | UpWorkstationMapper upWorkstationMapper; |
| | | |
| | | |
| | | //判断优先吸片位置后发送出片任务 |
| | | public UpWorkSequence selectPriority() { |
| | | UpWorkSequence upwork= this.baseMapper.selectPriority(1); |
| | | String start = "吸片信号";//plcmes.getPlcParameter("吸片信号").getValue(); |
| | | if(upwork!=null&&start.equals("1")){ |
| | | //发送出片任务 |
| | | //plcmes.getPlcParameter("出片信号").setValue("1"); |
| | | } |
| | | return upwork; |
| | | |
| | | @Override |
| | | public UpPattenUsage selectPriority(Engineering engineering) { |
| | | QueryWrapper<UpPattenUsage> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("state", 0) |
| | | .eq("engineering_id", engineering.getEngineerId()) |
| | | .orderByAsc("layout_sequence") |
| | | .last("limit 1"); |
| | | return upPattenUsageMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | //判断工位是否有符合条件的玻璃 |
| | | @Override |
| | | public UpWorkstation selectWorkstation(UpPattenUsage upPattenUsage) { |
| | | QueryWrapper<UpWorkstation> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("pattern_width", upPattenUsage.getWidth()) |
| | | .eq("pattern_height", upPattenUsage.getHeight()) |
| | | .eq("pattern_thickness", upPattenUsage.getThickness()) |
| | | .eq("films_id", upPattenUsage.getFilmsId()) |
| | | .gt("number", 0) |
| | | .orderByAsc("number") |
| | | .last("limit 1"); |
| | | return this.baseMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void reduceWorkstationNumber(Integer upworkId) { |
| | | UpdateWrapper<UpWorkstation> wrapper = new UpdateWrapper<>(); |
| | | wrapper.eq("id", upworkId) |
| | | .setSql("number = number - 1"); |
| | | boolean updateResult = upWorkstationMapper.update(null, wrapper) > 0; |
| | | log.info("减少工位数量{}", updateResult); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 增加人工输入的工位玻璃信息/删除人工搬走的玻璃信息 |
| | | * @param upwork |
| | | */ |
| | | @Override |
| | | public void updateGlassMessage(UpWorkstation upwork) { |
| | | UpdateWrapper<UpWorkstation> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("workstation_id", upwork.getWorkstationId()); |
| | | int update = this.baseMapper.update(upwork, updateWrapper); |
| | | if (upwork.getWorkstationId() == 1 || upwork.getWorkstationId() == 3) { |
| | | updateWrapper.eq("workstation_id", upwork.getWorkstationId()); |
| | | int update = this.baseMapper.update(upwork, updateWrapper); |
| | | } else { |
| | | if (upwork.getPatternHeight() > 2700 || upwork.getPatternHeight() == 0) { |
| | | updateWrapper.eq("workstation_id", upwork.getWorkstationId()); |
| | | int update = this.baseMapper.update(upwork, updateWrapper); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String updateMesInkageLoad(short inKageWord) { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | log.info("修改设备联动请求为{}:0离线;1联动", inKageWord); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("InkageStatus").getAddress(), inKageWord); |
| | | //读取plc的值 |
| | | return plcParameterObject.getPlcParameter("InkageStatus").getValue(); |
| | | } |
| | | |
| | | } |
| | | } |