| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.annotation.IntegrationAuth; |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.domain.type.NamespaceType; |
| | | import com.zy.acs.manager.core.integrate.dto.ConveyorQueryParam; |
| | | import com.zy.acs.manager.core.integrate.dto.ConveyorQueryResult; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.SegmentStateType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.SegmentService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | |
| | | @PostMapping("/station/checkTakeComplete") |
| | | @IntegrationAuth(name = NamespaceType.RCS_STA_QUERY) |
| | | public R checkTakeComplete(@RequestBody ConveyorQueryParam param) { |
| | | |
| | | String staNo = param.getStaNo(); |
| | | String seqNum = param.getSeqNum(); |
| | | taskService.() |
| | | |
| | | return R.ok().add(resultList); |
| | | Task task = taskService.selectBySeqNum(null, seqNum); |
| | | if (null == task) { |
| | | return R.error("task not found"); |
| | | } |
| | | List<Segment> list = segmentService.list(new LambdaQueryWrapper<Segment>().eq(Segment::getTaskId, task.getId()).eq(Segment::getPosType, TaskPosDto.PosType.ORI_STA.toString())); |
| | | for (Segment segment : list){ |
| | | if (segment.getState().equals(SegmentStateType.FINISH.toString())){ |
| | | return R.ok().add(true); |
| | | } |
| | | } |
| | | return R.ok().add(false); |
| | | } |
| | | } |
| | |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.conveyor.controller.vo.SiteTableVo; |
| | | import com.zy.acs.conveyor.core.constant.RedisConveyorConstant; |
| | | import com.zy.acs.conveyor.core.model.SafeSignal; |
| | | import com.zy.acs.conveyor.core.model.StaProtocol; |
| | | import com.zy.acs.conveyor.core.properties.DevpSlave; |
| | | import com.zy.acs.conveyor.core.properties.OutputQueue; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 输送设备接口 |
| | |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setWeight(staProtocol.getWeight() == null ? 0D : staProtocol.getWeight()); |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() ? (staProtocol.isLow() ? "低" : "高") : "-"); //高低库位 |
| | | |
| | | vo.setAllow((staProtocol.getAllowPut() ? "可放" : "不可放") + "/" + (staProtocol.getAllowTake() ? "可取" : "不可取")); |
| | | } |
| | | |
| | | return R.ok().add(list); |
| | |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setWeight(staProtocol.getWeight() == null ? 0D : staProtocol.getWeight()); |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() ? (staProtocol.isLow() ? "低" : "高") : "-"); //高低库位 |
| | | vo.setAllow((staProtocol.getAllowPut() ? "可放" : "不可放") + "/" + (staProtocol.getAllowTake() ? "可取" : "不可取")); |
| | | return R.ok().add(vo); |
| | | } |
| | | } |
| | |
| | | return R.error("plc已掉线"); |
| | | } |
| | | |
| | | @PostMapping("/detl/safe") |
| | | @ManagerAuth(memo = "补充安全信号") |
| | | public R safe(@RequestParam Integer siteId) { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(devp.getId()); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (siteId.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | boolean flag = true; |
| | | List<DevpSlave.Sta> putSta = devp.getPutSta(); |
| | | List<DevpSlave.Sta> takeSta = devp.getTakeSta(); |
| | | Optional<DevpSlave.Sta> first = takeSta.stream().filter(sta -> sta.getStaNo().equals(siteId)).findFirst(); |
| | | int i = -1; |
| | | if (first.isPresent()) { |
| | | i = takeSta.indexOf(first.get()); |
| | | if (i != -1) { |
| | | flag = false; |
| | | } |
| | | } |
| | | if (i == -1) { |
| | | first = putSta.stream().filter(sta -> sta.getStaNo().equals(siteId)).findFirst(); |
| | | if (first.isPresent()) { |
| | | i = putSta.indexOf(first.get()); |
| | | flag = true; |
| | | } |
| | | } |
| | | if (i == -1) { |
| | | return R.error("此站点无需安全信号"); |
| | | } |
| | | staProtocol.setSafeSignal(new SafeSignal(i, (short) 0, flag)); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, staProtocol); |
| | | return R.ok(); |
| | | |
| | | } |
| | | } |
| | | } |
| | | return R.error("plc已掉线"); |
| | | } |
| | | } |
| | |
| | | * 站点列表 |
| | | */ |
| | | private String staNo; |
| | | |
| | | /** |
| | | * 站点列表 |
| | | */ |
| | | private String seqNum; |
| | | /** |
| | | * 输送线编号 |
| | | */ |
| | |
| | | private String locType1 = "-"; |
| | | |
| | | private Double weight = 0D; |
| | | |
| | | //可取 |
| | | private String allow = "-"; |
| | | } |
| | |
| | | |
| | | @Data |
| | | public class SafeSignal implements Serializable { |
| | | |
| | | //是数组所在位置,就是第几个出库口或者第几个入库口 |
| | | private Integer index; |
| | | |
| | | //是写0还是1 |
| | | private short value; |
| | | |
| | | //代表写在交互1还是2 |
| | | private Boolean flag; |
| | | |
| | | |
| | |
| | | if (staProtocol.getWorkNo() == 0) { |
| | | continue; |
| | | } |
| | | if (!staProtocol.isLoading()) { |
| | | News.error("{}:站点:{},无物", config.getMark(), staProtocol.getSiteId()); |
| | | if (!staProtocol.isAutoing()) { |
| | | //News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (!staProtocol.isAutoing()) { |
| | | News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | if (!staProtocol.isLoading()) { |
| | | News.error("{}:站点:{},无物", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | String barcode = staProtocol.getBarcode(); |
| | |
| | | import com.zy.acs.conveyor.core.properties.SlaveProperties; |
| | | import com.zy.acs.conveyor.core.service.StationService; |
| | | import com.zy.acs.conveyor.entity.Job; |
| | | import com.zy.acs.conveyor.service.CtuMainService; |
| | | import com.zy.acs.conveyor.service.JobService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | @Autowired |
| | | private CtuMainService ctuMainService; |
| | | |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | |
| | | continue; |
| | | } |
| | | if (!staProtocol.isAutoing()) { |
| | | News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | //News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() > 0 && !staProtocol.isLoading()) { |
| | |
| | | News.error("{}:站点:{},任务状态不对,{}", config.getMark(), staProtocol.getSiteId(), JSON.toJSON(job)); |
| | | continue; |
| | | } |
| | | //String s = ctuMainService.checkStationStatus(takeSta.getStaNo()); |
| | | if (ctuMainService.checkComplete(job.getTaskNo())) { |
| | | staProtocol.setSafeSignal(new SafeSignal( devp.getPutSta().indexOf(takeSta) ,(short)1,false)); |
| | | |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, staProtocol); |
| | | |
| | | job.setJobSts(ConveyorStateType.CLEARSIGNAL.getStatus()); |
| | | if (!jobService.updateById(job)){ |
| | |
| | | }else { |
| | | News.info("" + config.getMark() + "站点清空:{},{}", takeSta.getStaNo(), staProtocol.getWorkNo()); |
| | | } |
| | | } else { |
| | | log.info("" + config.getMark() + "站点:{},{}", takeSta.getStaNo(), staProtocol.getWorkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | // 判断是否满足条件 |
| | | if (!staProtocol.isAutoing()) { |
| | | News.error("{},输送线未自动,需要开启:{}", config.getMark(), staProtocol.getSiteId()); |
| | | //News.error("{},输送线未自动,需要开启:{}", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | String seqNum = ctuMainService.checkStationStatus(putSta.getStaNo()); |
| | | if (seqNum != null) { |
| | | staProtocol.setSafeSignal(new SafeSignal( devp.getPutSta().indexOf(putSta) ,(short)1,true)); |
| | | //redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG,staProtocol ); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, staProtocol); |
| | | |
| | | Job job = jobService.getJobByTaskNo(seqNum); |
| | | if (job != null) { |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 判断是否满足条件 |
| | | if (!staProtocol.isAutoing()) { |
| | | //News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() == 0 && staProtocol.isLoading()) { |
| | | News.error("{},输送线上有货无任务号,需要人工处理站点:{}", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() > 0 && !staProtocol.isLoading()) { |
| | | News.error("{},输送线上无货有任务号,需要人工处理站点:{}", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (!staProtocol.isAutoing()) { |
| | | News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (!staProtocol.isInEnable()) { |
| | |
| | | continue; |
| | | } |
| | | if (!staProtocol.isAutoing()) { |
| | | News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | //News.error("{}:站点:{},非自动", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (!staProtocol.isLoading()) { |
| | |
| | | public void read(StaProtocol staProtocol, SiemensS7Net siemensS7Net) { |
| | | |
| | | } |
| | | |
| | | public void writeSafe(StaProtocol staProtocol) throws InterruptedException { |
| | | if (staProtocol == null) { |
| | | log.warn("写入数据为空,跳过 [id:{}]", JSON.toJSONString(staProtocol)); |
| | |
| | | array[4] = (short) 0; |
| | | baseOffset = SafeSignalField.SAFE_SIGNAL_TO_CONVEYOR.getOffset() +2 + safeSignal.getIndex() * SafeSignalField.SAFE_SIGNAL_TO_CONVEYOR.getByteLength(); |
| | | } |
| | | String flagAddr = TaskField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | | String flagAddr = SafeSignalField.SAFE_SIGNAL_TO_CONVEYOR.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | | + baseOffset; |
| | | |
| | | // 任务下发重试机制 |
| | |
| | | staProtocol.getPlcId(), staProtocol.getSiteId(), writeCount, |
| | | writeResult.Message); |
| | | |
| | | if (writeCount < WRITE_RETRY_MAX) { |
| | | Thread.sleep(WRITE_RETRY_INTERVAL_MS); |
| | | } |
| | | } |
| | | |
| | | if (!success) { |
| | |
| | | OutputQueue.DEVP.offer(errorMsg); |
| | | News.error("SiemensDevp - 4 - 写入安全信号输送线站点数据失败。输送线plc编号={},站点数据={}", |
| | | staProtocol.getPlcId(), JSON.toJSON(staProtocol)); |
| | | log.error(errorMsg); |
| | | } |
| | | |
| | | } |
| | |
| | | SafeSignalField.SAFE_SIGNAL_FROM_CONVEYOR.buildAddress(), |
| | | (short) (staNoSize * SafeSignalField.SAFE_SIGNAL_FROM_CONVEYOR.getByteLength())); |
| | | |
| | | |
| | | if (!result.IsSuccess) { |
| | | log.warn("读取PLC安全交互信息异常 [id:{}]", slave.getId()); |
| | | return; |
| | |
| | | staProtocolTake.setOutComplete(status2[4]); |
| | | // |
| | | if (status[3]){ |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, new SafeSignal(i,(short)0,true)); |
| | | staProtocolPut.setSafeSignal( new SafeSignal(i, (short) 0, true)); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG,staProtocolPut); |
| | | } |
| | | if (status2[4]){ |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, new SafeSignal(i, (short) 0,false)); |
| | | staProtocolTake.setSafeSignal(new SafeSignal(i, (short) 0, false)); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_SAFE_FLAG, staProtocolTake); |
| | | |
| | | } |
| | | |
| | |
| | | */ |
| | | boolean sendTask(OpenBusSubmitParam openBusSubmitParam); |
| | | |
| | | /** |
| | | * 检查任务 |
| | | * |
| | | * @param seqNum |
| | | * @return |
| | | */ |
| | | Boolean checkComplete(String seqNum); |
| | | |
| | | } |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检查站点状态 |
| | | * |
| | | * @param seqNum 任务号 |
| | | * @return 站点是否可通行 |
| | | */ |
| | | public Boolean checkComplete(String seqNum) { |
| | | StationRequestParam stationRequestParam = new StationRequestParam(); |
| | | stationRequestParam.setSeqNum(seqNum); |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(ctuUrl) |
| | | .setPath(station) |
| | | .setTimeout(timeout, TimeUnit.SECONDS) |
| | | .setJson(JSON.toJSONString(stationRequestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger(code).equals(codeValue)) { |
| | | log.info("RCS返回数据:{}", response); |
| | | if (jsonObject.getBoolean(dataCode)) { |
| | | return true; |
| | | } |
| | | } else { |
| | | log.error("调用下发任务接口报错,响应码:{},响应内容:{}", jsonObject.getInteger(code), response); |
| | | //throw new CoolException("调用下发任务接口报错,响应码:" + jsonObject.getInteger(code)); |
| | | } |
| | | } catch (CoolException e) { |
| | | log.error("调用站点状态接口异常", e); |
| | | //throw e; |
| | | } catch (Exception e) { |
| | | //log.error("检查站点状态失败,站点编号:{}", staNo, e); |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | <th>重量信号</th> |
| | | <th>空满信号</th> |
| | | <th>目标站</th> |
| | | <th>高低信号</th> |
| | | <th>可放/可取</th> |
| | | <!-- <th>高低信号</th>--> |
| | | </tr> |
| | | </thead> |
| | | <tbody> |
| | |
| | | <div class="modal-footer"> |
| | | <button type="button" class="btn btn-primary" id="save">保存</button> |
| | | <button type="button" class="btn btn-secondary" id="clear">清除</button> |
| | | <button type="button" class="btn btn-secondary" id="safe">补充安全信号</button> |
| | | <button type="button" class="btn btn-secondary" id="cancel">取消</button> |
| | | </div> |
| | | </div> |
| | |
| | | <td>${site.weight || '--'}</td> |
| | | <td>${site.emptyMk || '--'}</td> |
| | | <td>${site.staNo || '--'}</td> |
| | | <td>${site.locType1 || '--'}</td> |
| | | <td>${site.allow || '--'}</td> |
| | | </tr> |
| | | `; |
| | | } |
| | |
| | | http.post(`${baseUrl}/site/detl/update`, { |
| | | siteId: $('#siteId').val(), |
| | | workNo: $('#workNo').val(), |
| | | staNo: $('#staNo').val(), |
| | | pakMk: $('#pakMk').val() |
| | | staNo: $('#staNo').val() |
| | | }, (res) => { |
| | | showSuccessMessage("修改成功"); |
| | | setTimeout(() => { |
| | |
| | | $('#staNo').val(0); |
| | | }); |
| | | |
| | | // 补充安全信号 |
| | | $(document).on('click', '#safe', function () { |
| | | http.post(`${baseUrl}/site/detl/safe`, { |
| | | siteId: $('#siteId').val() |
| | | }, (res) => { |
| | | showSuccessMessage("补充成功"); |
| | | setTimeout(() => { |
| | | closeModal(); |
| | | }, 1500); |
| | | }); |
| | | }); |
| | | |
| | | // 取消站点信息修改 |
| | | $(document).on('click', '#cancel', function () { |
| | | closeModal(); |