jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
@@ -9,6 +9,8 @@ import com.jcdm.framework.websocket.WebSocketUsers; import com.jcdm.main.da.paramCollection.domain.DaParamCollection; import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.service.MiloService; import org.aspectj.weaver.loadtime.Aj; @@ -37,6 +39,9 @@ @Autowired private MiloService miloService; @Autowired private DaPassingStationCollectionMapper daPassingStationCollectionMapper; Map<String, Session> map = WebSocketUsers.getUsers(); @@ -151,8 +156,6 @@ bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); addParameterCollection(bsFormulaChildInfo); // BsFormulaChildInfo count = bsFormulaChildInfoMapper.getCount(checkInfo); // Integer i = count.getCounts(); }else { return AjaxResult.error("非本工位物料,请重新扫描"); } @@ -198,6 +201,12 @@ // 执行操作 if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ try { // //更新过站记录表出站时间 // DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); // daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); // List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); // daPassingStationCollections.get(0).setOutboundTime(new Date()); // daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("OP."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT"); } catch (Exception e) { jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/controller/DaParamCollectionController.java
@@ -96,6 +96,15 @@ } /** * 出战时间参数增加 */ @PostMapping("/saveCampaignTimeParameters") public void saveCampaignTimeParameters(@RequestBody DaParamCollection daParamCollection) { daParamCollectionService.saveCampaignTimeParameters(daParamCollection); } /** * 修改设备产品过程参数采集 */ @PreAuthorize("@ss.hasPermi('main:paramCollection:edit')") jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/IDaParamCollectionService.java
@@ -63,4 +63,6 @@ void addBasicParameters(DaParamCollection daParamCollection); void addTighteningParameters(DaParamCollection daParamCollection); void saveCampaignTimeParameters(DaParamCollection daParamCollection); } jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
@@ -9,6 +9,11 @@ import com.jcdm.main.da.paramCollection.domain.DaParamCollection; import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.service.MiloService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -31,6 +36,12 @@ @Autowired private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; @Autowired private MiloService miloService; @Autowired private DaPassingStationCollectionMapper daPassingStationCollectionMapper; /** * 查询设备产品过程参数采集 @@ -151,4 +162,45 @@ daParamCollectionMapper.insertDaParamCollection(daParamCollection); } } @Override public void saveCampaignTimeParameters(DaParamCollection daParamCollection) { BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo(); bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode()); bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode()); bsFormulaChildInfo.setSpareField4("1"); List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); String result = bsFormulaChildInfos.get(0).getResults(); if(result != null && !result.isEmpty()){ try { //过站参数采集记录出站时间 DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); daCollectionParamConf.setCollectParameterId("OUTT"); List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); DaParamCollection saveData = new DaParamCollection(); saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); saveData.setProductCode(daParamCollection.getProductCode()); saveData.setLocationCode(daParamCollection.getLocationCode()); saveData.setSfcCode(daParamCollection.getProductBarcode()); saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); saveData.setCollectionTime(new Date()); saveData.setParamValue(DateUtil.formatDateTime(new Date())); daParamCollectionMapper.insertDaParamCollection(saveData); //更新过站记录表出站时间 DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); daPassingStationCollections.get(0).setOutboundTime(new Date()); int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); //给opc发21 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("OP."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); } catch (Exception e) { throw new RuntimeException(e); } } } } jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -16,15 +16,15 @@ import org.springframework.stereotype.Component; import javax.websocket.Session; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.*; import java.util.stream.Collectors; @Component public class OPCUaSubscription implements SubscriptionCallback { //自动工位 public List<String> automaticList = Arrays.asList("OP230","OP300","OP280", "OP320", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); public static MiloService miloService; @@ -77,26 +77,32 @@ if("1".equals(tabVlaue)){ recordDataDoneValue = "11"; //校验入站是否可以工作 //进站保存数据 // inSaveDate(thoroughfare,device) //记录数据完成 // String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; // miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build()); String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); //给前端发工件到位信号 WebSocketUsers.sendMessageToUserByText(map.get(device), "IN"); if(automaticList.stream().noneMatch(s -> s.equals(device))){ //给前端发工件到位信号 WebSocketUsers.sendMessageToUserByText(map.get(device), "IN"); } //请求工单 }else if("2".equals(tabVlaue)){ //出站保存数据 recordDataDoneValue = outSaveDate(thoroughfare,device); //记录数据完成 String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build()); if(automaticList.stream().anyMatch(s -> s.equals(device))){ //自动工位 //出站保存数据 recordDataDoneValue = outSaveDate(thoroughfare,device); //记录数据完成 String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(RecordDataDoneAddress)).build()); }else { //手动工位 WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); } }else { System.out.println("^"); } @@ -104,15 +110,22 @@ //保存拧紧数据 else if (("AngleResult").equals(tab)) { if("1".equals(tabVlaue)||"2".equals(tabVlaue)){ String Torque = thoroughfare + "." + device + ".Torque"; String Angle = thoroughfare + "." + device + ".Angle"; String Result = thoroughfare + "." + device + ".Result"; String Result1 = thoroughfare + "." + device + ".Result1"; List<String> list = new ArrayList(); list.add(Torque); list.add(Angle); list.add(Result); list.add(Result1); // String Torque = thoroughfare + "." + device + ".Torque"; // String Angle = thoroughfare + "." + device + ".Angle"; // String Result = thoroughfare + "." + device + ".Result"; // String Result1 = thoroughfare + "." + device + ".Result1"; // List<String> list = new ArrayList(); // list.add(Torque); // list.add(Angle); // list.add(Result); // list.add(Result1); List<String> list = new ArrayList<>(); String[] suffixes = {"Torque", "Angle", "Result", "Result1"}; for (String suffix : suffixes) { String string = thoroughfare + "." + device + "." + suffix; list.add(string); } List<ReadWriteEntity> list1 = miloService.readFromOpcUa(list); List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList()); String joinedString = String.join(",", collect.toString()); @@ -143,18 +156,18 @@ String result = ""; try { //读取SNCode String SNCodeAddress = thoroughfare + "." + device + ".SNCode"; Object SNCodeObject = miloService.readFromOpcUa(SNCodeAddress).getValue(); if(null == SNCodeObject || "".equals(SNCodeObject)){ String PACKCode = thoroughfare + "." + device + ".PACKCode"; Object PACKCodeObject = miloService.readFromOpcUa(PACKCode).getValue(); if(null == PACKCodeObject || "".equals(PACKCodeObject)){ result = "22"; }else{ String SNCode = SNCodeObject.toString(); String PACKCodeParam = PACKCodeObject.toString(); //1、更新工单信息 //updateOrderInfo(); //2、保存过站采集数据 saveStationInfo(SNCode,thoroughfare,device); saveStationInfo(PACKCodeParam,thoroughfare,device); //3、保存参数采集数据 SaveParamData(SNCode,thoroughfare,device); SaveParamData(PACKCodeParam,thoroughfare,device); result = "21"; @@ -169,16 +182,23 @@ /** * 保存过站采集 */ public void saveStationInfo(String SNCode,String thoroughfare,String device){ public void saveStationInfo(String packCode,String thoroughfare,String device) throws Exception { String prefix = thoroughfare+"."+device+"."; String workOrderNo = miloService.readFromOpcUa(prefix + "WorkOrderNumber").getValue().toString(); String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString(); String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString(); String stationStatus = miloService.readFromOpcUa(prefix + "StationStatus").getValue().toString(); DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); daPassingStationCollection.setSfcCode(SNCode); //daPassingStationCollection.setInboundTime();//入站时间 daPassingStationCollection.setOutboundTime(new Date());//出站时间 //daPassingStationCollection.setOutRsSign();//出站是否合格 daPassingStationCollection.setSfcCode(packCode); daPassingStationCollection.setWorkOrderNo(workOrderNo); // daPassingStationCollection.setInboundTime(startTime);//入站时间 // daPassingStationCollection.setOutboundTime(stopTime);//出站时间 daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格 daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection); } public void SaveParamData(String SNCode,String thoroughfare,String device) throws Exception { public void SaveParamData(String packCode,String thoroughfare,String device) throws Exception { List<DaCollectionParamConf> list; DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); daCollectionParamConf.setGatherAddress(thoroughfare+ "." + device); @@ -193,12 +213,13 @@ List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList); List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); for(int i=0;i<nodeIdList.size();i++){ DaParamCollection ParamCollection = new DaParamCollection(); if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]); DaParamCollection ParamCollection = new DaParamCollection(); // ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]); ParamCollection.setParamCode(list.get(i).getCollectParameterId()); ParamCollection.setLocationCode(device); ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); ParamCollection.setSfcCode(SNCode); ParamCollection.setSfcCode(packCode); ParamCollection.setParamName(list.get(i).getCollectParameterName()); ParamCollection.setParamUpper(list.get(i).getParamUpper()); ParamCollection.setParamLower(list.get(i).getParamLower()); @@ -206,10 +227,10 @@ //ParamCollection.setState("合格"); ParamCollection.setType(list.get(i).getCollectParameterType()); ParamCollection.setCollectionTime(new Date()); daParamCollectionlist.add(ParamCollection); daParamCollectionService.insertDaParamCollection(ParamCollection); } } //daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist); // daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist); } } jcdm-main/src/main/resources/mapper/bs/formulaChild/BsFormulaChildInfoMapper.xml
@@ -50,6 +50,8 @@ <if test="results != null and result != ''"> and result = #{results}</if> <if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if> <if test="paramCode != null and paramCode != ''"> and param_code = #{paramCode}</if> <if test="spareField4 != null and spareField4 != ''"> and spare_field_4 = #{spareField4}</if> </where> jcdm-main/src/main/resources/mapper/da/collectionParamConf/DaCollectionParamConfMapper.xml
@@ -58,6 +58,8 @@ <if test="contrastParameterFlag != null and contrastParameterFlag != ''"> and contrast_parameter_flag like concat('%', #{contrastParameterFlag}, '%')</if> <if test="collectParameterType != null and collectParameterType != ''"> and collect_parameter_type like concat('%', #{collectParameterType}, '%')</if> <if test="productCode != null and productCode != ''"> and product_code like concat('%', #{productCode}, '%')</if> <if test="gatherAddress != null and gatherAddress != ''"> and gather_address like concat('%', #{gatherAddress}, '%')</if> </where> </select> jcdm-ui/src/api/main/da/paramCollection/paramCollection.js
@@ -35,7 +35,16 @@ }) } // 新增设备产品过程参数采集 // 新增设备产品过程参数采集 saveCampaignTimeParameters export function saveCampaignTimeParameters(data) { return request({ url: '/main/paramCollection/saveCampaignTimeParameters', method: 'post', data: data }) } // 新增设备产品过程参数采集 saveCampaignTimeParameters export function addTighteningParameters(data) { return request({ url: '/main/paramCollection/addTighteningParameters', jcdm-ui/src/views/main/kb/stationTerminal/index.vue
@@ -306,7 +306,8 @@ import { addBasicParameters, addParamCollection, addTighteningParameters addTighteningParameters, saveCampaignTimeParameters } from "@/api/main/da/paramCollection/paramCollection"; export default { @@ -541,52 +542,12 @@ locationCode: this.headContent.processesCode, model: this.workpieceInformation.productModel, productBarcode: this.headContent.sfcCode, sfcCode: this.headContent.sfcCode, inboundTime: new Date() } addPassingStationCollection(this.passingStationForm).then(response => {}); addBasicParameters(this.passingStationForm).then(response => {}); }, allowRelease(){ clearInterval(this.timer); this.$message('保存节拍为'+this.workpieceInformation.beat+'秒'); }, /** 查询工位终端配置列表 */ // async getStationConfList() { // await getIpv4().then(response => { // this.StationConfQueryParams.ipAddress = response.msg // console.log('查询到本工位IP为'+this.StationConfQueryParams.ipAddress) // }); // listStationConf(this.StationConfQueryParams).then(response => { // let rows = response.rows[0] // if(response.rows.length===0){ // this.$message('该工位没有配置IP,请联系管理员配置IP'); // return // } // this.headContent.processesName = rows.processesName // this.headContent.processesCode = rows.processesCode // console.log('设置工位编码'+this.headContent.processesCode) // // }); // }, // connectWebsocket() { // console.log('websocket连接工位为'+this.headContent.processesCode) // const wsuri = this.url + this.headContent.processesCode; // this.ws = new WebSocket(wsuri); // const self = this; // this.ws.onopen = function (event) { // // self.text_content = self.text_content + "已经打开连接!" + "\n"; // this.$message('websocket连接成功!'); // }; // this.ws.onmessage = function (event) { // self.text_content = event.data + "\n"; // console.log(event.data) // if(event.data === "IN"){ // self.cakeLamp.InPlace = "1" // }else if(event.data === "OUT"){ // self.cakeLamp.outRsSign = "1" // } // }; // }, exit() { if (this.ws) { this.ws.close(); @@ -631,16 +592,15 @@ self.cakeLamp.InPlace = 0; } else if (event.data === "OUT") { self.cakeLamp.release = 1; // setTimeout(() => { // self.cakeLamp.InPlace = 0; // self.cakeLamp.release = 0; // self.cakeLamp.startWork = 0; // self.cakeLamp.scanFinish = 0; // self.Release(); // }, DELAY_TIME); } else if (event.data === "TIGHTEN") { this.formulaChildList = []; self.getListFormulaChild(); } else if (event.data === "END") { const param = { workOrderNo: self.workpieceInformation.workOrderNo, productCode: self.workpieceInformation.productCode, locationCode: self.headContent.processesCode, productBarcode: self.headContent.sfcCode, } saveCampaignTimeParameters(param).then(response => {}); } else if (event.data.includes("[")) { let formulaChilds = ""; self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort); @@ -654,16 +614,6 @@ break; } } // self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort); // self.formulaChildList.forEach((formulaChild) => { // let operationType = formulaChild.operationType; // let results = formulaChild.results; // if(operationType === '1' && (results === '' || results === null || results === 'NG')){ // formulaChilds = formulaChild; // return; // 使用return代替break // } // // 执行其他操作 // }); const param = { tightenTheArray: event.data, paramCode: formulaChilds.paramCode, @@ -674,6 +624,8 @@ } addTighteningParameters(param).then(response => {}); updateTighteningFormula(param).then(response => { self.getListFormulaChild() }).catch(error =>{ self.getListFormulaChild() }); } @@ -686,7 +638,7 @@ else { const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, ''); console.log("串口收到数据-------------------"+scanValue) if(this.cakeLamp.InPlace=== 1){ // if(this.cakeLamp.InPlace=== 1){ if(this.headContent.sfcCode !== ''){ console.log(scanValue) this.serialPortMethod(scanValue) @@ -698,9 +650,9 @@ this.cakeLamp.scanFinish = 1 this.cakeLamp.startWork = 1 } }else { this.$message('工件未到位禁止扫码!'); } // }else { // this.$message('工件未到位禁止扫码!'); // } } }, clearHistory() {