汪菘 1 year ago
parent
commit
a40d8425ad
  1. 2
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java
  2. 88
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDeviceDriver.java
  3. 6
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java
  4. 288
      acs/nladmin-ui/src/views/acs/device/driver/lnsh/package_site.vue

2
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java

@ -372,7 +372,7 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
request.setWeight(String.valueOf(weight));
request.setWeight(String.valueOf(unqualified));
request.setOrder_code(String.valueOf(order_No));
request.setMaterial_code(String.valueOf(material));
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)), ApplyTaskResponse.class);

88
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/package_site/PackageSiteDeviceDriver.java

@ -1,5 +1,7 @@
package org.nl.acs.device_driver.lnsh.package_site;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@ -8,9 +10,12 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskRequest;
import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
@ -19,9 +24,12 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -48,6 +56,9 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
//放货准备锁
String putReadyLock = null;
//有货标记
@ -136,7 +147,7 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
action = this.itemProtocol.getAction();
ioaction = this.itemProtocol.getIoaction();
error = this.itemProtocol.getError();
vehicle_code = this.itemProtocol.getVehicle_code();
vehicle_code = this.itemProtocol.getBarcode();
vehicle_type = this.itemProtocol.getVehicle_type();
if (mode != last_mode) {
@ -188,13 +199,22 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
message = "";
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
break;
case 5:
if (mode > 2 && !requireSucess) {
if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get(String.valueOf(mode)))) {
String modethod = this.device.getExtraValue().get(String.valueOf(mode)).toString();
try {
applyRequest(modethod);
} catch (Exception e) {
message = "错误:" + e.getMessage();
this.setIserror(true);
}
} else {
message = "无效模式请求,驱动未配置此请求方法";
}
} else {
message = "无请求";
}
}
@ -211,6 +231,58 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
}
/**
* 请求
*
* @param
*/
public synchronized boolean applyRequest(String modethod) throws Exception {
Object obj1 = this;
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
Object obj = this.getClass().getDeclaredConstructor().newInstance();
Method method1 = this.getClass().getMethod(modethod, null);
method1.invoke(this, null);
return true;
}
}
public synchronized boolean apply_labelling() {
if(move == 1) {
ApplyTaskRequest request = new ApplyTaskRequest();
request.setDevice_code(this.getDevice_code());
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
request.setVehicle_code(String.valueOf(vehicle_code));
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
if (resp.getCode() == 200) {
this.writing("to_message",resp.getLabel_message());
this.writing(200);
this.setRequireSucess(true);
} else {
this.writing(400);
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求失败" + resp.getMessage();
}
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(resp)));
return true;
} else {
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 设备无货未请求LMS...";
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
return false;
}
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.lnsh.lnsh_station.ItemProtocol.item_to_command;

6
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java

@ -23,7 +23,9 @@ public class ApplyTaskResponse extends BaseResponse {
private String weight;
//private String is_order_finish;
/**
* 贴标新鲜
*/
private String label_message;
}

288
acs/nladmin-ui/src/views/acs/device/driver/lnsh/package_site.vue

@ -1,7 +1,6 @@
<template>
<!--晟华-包装机工位-->
<!--晟华包装码垛机械手-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
@ -85,21 +84,78 @@
<el-row>
<el-col :span="8">
<el-form-item label="申请任务">
<el-form-item label="呼叫">
<el-switch v-model="form.apply_task" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="手动生成任务" label-width="150px">
<el-form-item label="响应" label-width="150px">
<el-switch v-model="form.manual_create_task" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="申请空盘" prop="device_code">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
<el-select
v-model="form.link_three_lamp"
filterable
clearable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="是否输入物料" label-width="150px">
<el-switch v-model="form.input_material" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="取货设备" prop="device_code">
<el-select
v-model="form.link_get_station"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="放货设备" prop="device_code">
<el-select
v-model="form.apply_empty"
v-model="form.link_put_station"
filterable
multiple
placeholder="请选择"
@ -125,7 +181,7 @@
<el-row>
<el-col :span="8">
<el-form-item label="取货">
<el-switch v-model="form.pickup" />
<el-switch v-model="form.is_pickup" />
</el-form-item>
</el-col>
<el-col :span="8">
@ -136,7 +192,67 @@
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">交互相关</span>
</div>
<div class="crud-opts2" style="margin-bottom: 5px;">
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="insertdtl()"
>
新增一行
</el-button>
</span>
</div>
<div class="app-container">
<el-table :data="modeform.tableData" border fit highlight-current-row style="width: 100%;" class="tb-edit">
<el-table-column label="mode" prop="模式" width="180">
<template scope="scope">
<el-input-number value="3" :min="3" v-model="scope.row.mode" size="mini" />
<span v-show="scope.row.edit">{{ scope.row.mode }}</span>
</template>
</el-table-column>
<el-table-column label="request" prop="请求方法" width="500">
<template scope="scope">
<el-select
v-model="scope.row.request"
filterable
clearable
placeholder="请选择"
style="width: 450px"
>
<el-option
v-for="item in requestMethodList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="170" >
<template scope="scope">
<el-button
type="danger"
class="filter-item"
size="mini"
icon="el-icon-delete"
@click.native.prevent="deleteRow(scope.$index, modeform.tableData)"
/>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC读取字段</span>
@ -154,7 +270,12 @@
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].db" size="mini" class="edit-input" @input="finishReadEdit(data1[scope.$index])" />
<el-input
v-model="data1[scope.$index].db"
size="mini"
class="edit-input"
@input="finishReadEdit(data1[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbr_value">
@ -186,7 +307,12 @@
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].db" size="mini" class="edit-input" @input="finishWriteEdit(data2[scope.$index])" />
<el-input
v-model="data2[scope.$index].db"
size="mini"
class="edit-input"
@input="finishWriteEdit(data2[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbr_value2">
@ -242,7 +368,7 @@ import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
export default {
name: 'LnshPackageSite',
name: 'LnshPackagePalletManipulator',
mixins: [crud],
props: {
parentForm: {
@ -261,17 +387,72 @@ export default {
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
deviceList: [],
data1: [],
data2: [],
requestMethodList: [],
modeform: {
tableData: [
{
mode: '3',
request: 'order_verify'
},
{
mode: '4',
request: 'order_finish'
},
{
mode: '5',
request: 'apply_put_full_vehicle'
},
{
mode: '6',
request: 'apply_put_empty_vehicle'
},
{
mode: '7',
request: 'apply_take_empty_vehicle'
},
{
mode: '8',
request: 'apply_take_full_vehicle'
},
{
mode: '9',
request: 'apply_force_take_full_vehicle'
},
{
mode: '10',
request: 'apply_force_take_full_vehicle_in_storage'
},
{
mode: '11',
request: 'barcode_success_apply'
},
{
mode: '12',
request: 'get_vehicle_info'
},
{
mode: '13',
request: 'force_no_package'
},
{
mode: '14',
request: 'apply_labelling'
}
]
},
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
apply_empty: [],
link_three_lamp: '',
manual_create_task: true,
is_pickup: true,
is_release: true
is_release: true,
link_device_code: []
},
rules: {}
}
@ -302,6 +483,13 @@ export default {
}
this.data1 = data.rs
this.data2 = data.ws
if (data.modeform) {
const arr = Object.keys(data.modeform)
//
if (arr.length > 0) {
this.modeform.tableData = data.modeform
}
}
this.sliceItem()
})
selectPlcList().then(data => {
@ -315,15 +503,26 @@ export default {
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
deviceCrud.selectRequestMethodList().then(data => {
this.requestMethodList = data
})
})
},
methods: {
insertdtl() {
this.modeform.tableData.push({mode: '', request: '' })
},
deleteRow(index, rows) {
debugger
rows.splice(index, 1)
},
finishReadEdit(data) {
// code,mode
if (data.code.indexOf('mode') !== -1) {
debugger
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
@ -332,35 +531,17 @@ export default {
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('heartbeat') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) - 1)
}
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('action') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('ioaction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 5)
}
if (this.data1[val].code.indexOf('weight') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 9)
}
if (this.data1[val].code.indexOf('material') !== -1) {
this.data1[val].db = beforeStr + '.' + 'STRING' + (parseInt(endNumber) + 13) + '.50'
}
if (this.data1[val].code.indexOf('barcode') !== -1) {
this.data1[val].db = beforeStr + '.' + 'W' + (parseInt(endNumber) + 65)
}
}
// for (const val in this.data1) {
// if (this.data1[val].code.indexOf('move') !== -1) {
// this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
// }
// if (this.data1[val].code.indexOf('error') !== -1) {
// this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
// }
// if (this.data1[val].code.indexOf('task') !== -1) {
// this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 7)
// }
// }
}
},
finishWriteEdit(data) {
@ -368,7 +549,7 @@ export default {
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
@ -377,17 +558,14 @@ export default {
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 4)
}
if (this.data2[val].code.indexOf('to_is_package') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 8)
}
}
// for (const val in this.data2) {
// if (this.data2[val].code.indexOf('to_target') !== -1) {
// this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
// }
// if (this.data2[val].code.indexOf('to_task') !== -1) {
// this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
// }
// }
}
},
changeOpc(val) {
@ -450,7 +628,7 @@ export default {
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {

Loading…
Cancel
Save