From e752d45e1eb531acb14e98e8c832c72f0f59e794 Mon Sep 17 00:00:00 2001 From: lyd <1419499670@qq.com> Date: Fri, 28 Oct 2022 13:38:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lms/nladmin-system/pom.xml | 12 + .../tools/rest/LocalStorageController.java | 9 + .../tools/service/LocalStorageService.java | 6 + .../service/impl/LocalStorageServiceImpl.java | 49 +++- .../bi/rest/SubpackagerelationController.java | 66 ++++++ .../bi/service/SubpackagerelationService.java | 65 ++++++ .../bi/service/dto/SubpackagerelationDto.java | 105 +++++++++ .../impl/SubpackagerelationServiceImpl.java | 120 ++++++++++ .../template/generator/front/index.ftl | 6 +- lms/nladmin-ui/package.json | 1 + lms/nladmin-ui/src/main.js | 6 +- lms/nladmin-ui/src/utils/nladmin.js | 42 ++++ lms/nladmin-ui/src/views/wms/pdm/bi/index.vue | 214 ++++++++++++++++++ .../views/wms/pdm/bi/subpackagerelation.js | 27 +++ 14 files changed, 720 insertions(+), 8 deletions(-) create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/rest/SubpackagerelationController.java create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/SubpackagerelationService.java create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/dto/SubpackagerelationDto.java create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/impl/SubpackagerelationServiceImpl.java create mode 100644 lms/nladmin-ui/src/views/wms/pdm/bi/index.vue create mode 100644 lms/nladmin-ui/src/views/wms/pdm/bi/subpackagerelation.js diff --git a/lms/nladmin-system/pom.xml b/lms/nladmin-system/pom.xml index 6b55ef17b..a8c84288d 100644 --- a/lms/nladmin-system/pom.xml +++ b/lms/nladmin-system/pom.xml @@ -355,6 +355,18 @@ httpclient 4.5.13 + + + com.alibaba + easyexcel + 2.1.6 + + + + org.apache.poi + poi-ooxml-schemas + 3.17 + diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/tools/rest/LocalStorageController.java b/lms/nladmin-system/src/main/java/org/nl/modules/tools/rest/LocalStorageController.java index 8d7d93625..475274e80 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/tools/rest/LocalStorageController.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/tools/rest/LocalStorageController.java @@ -16,6 +16,7 @@ package org.nl.modules.tools.rest; import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaIgnore; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -97,4 +98,12 @@ public class LocalStorageController { localStorageService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } + + @ApiOperation("导入数据") + @PostMapping("/importExcel") + @SaIgnore + public ResponseEntity importExcel(@RequestBody String path) { + localStorageService.importExcel(path); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/LocalStorageService.java b/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/LocalStorageService.java index 63ee0aeba..ea1cbba36 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/LocalStorageService.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/LocalStorageService.java @@ -81,4 +81,10 @@ public interface LocalStorageService { * @throws IOException / */ void download(List localStorageDtos, HttpServletResponse response) throws IOException; + + /** + * 导入数据 + * @param path + */ + void importExcel(String path); } \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/impl/LocalStorageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/impl/LocalStorageServiceImpl.java index fdb1cb450..4753bffe4 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/impl/LocalStorageServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/tools/service/impl/LocalStorageServiceImpl.java @@ -15,21 +15,23 @@ */ package org.nl.modules.tools.service.impl; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import org.nl.modules.common.config.FileProperties; import org.nl.modules.common.exception.BadRequestException; -import org.nl.modules.common.utils.FileUtil; -import org.nl.modules.common.utils.PageUtil; -import org.nl.modules.common.utils.QueryHelp; -import org.nl.modules.common.utils.ValidationUtil; +import org.nl.modules.common.utils.*; import org.nl.modules.tools.domain.LocalStorage; import org.nl.modules.tools.repository.LocalStorageRepository; import org.nl.modules.tools.service.LocalStorageService; import org.nl.modules.tools.service.dto.LocalStorageDto; import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria; import org.nl.modules.tools.service.mapstruct.LocalStorageMapper; +import org.nl.modules.wql.core.bean.WQLObject; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -135,4 +137,43 @@ public class LocalStorageServiceImpl implements LocalStorageService { } FileUtil.downloadExcel(list, response); } + + /** + * 导入数据 + * + * @param path + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void importExcel(String path) { + WQLObject measureunitTab = WQLObject.getWQLObject("md_pb_measureunit"); + WQLObject materialbaseTab = WQLObject.getWQLObject("md_me_materialbase"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + List> listMap = EasyExcel.read(path).sheet().doReadSync(); +// listMap.remove(0); + for (int i = 0; i < listMap.size(); i++) { + Map map = listMap.get(i); + String material_code = String.valueOf(map.get(5)); + String material_name = String.valueOf(map.get(6)); + String unit_code = String.valueOf(map.get(7)); + JSONObject object = measureunitTab.query("unit_code = '" + unit_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(object)) throw new BadRequestException("空" + unit_code); + JSONObject material = new JSONObject(); + material.put("material_id", IdUtil.getSnowflake(1, 1).nextId()); + material.put("material_code", material_code); + material.put("material_name", material_name); + material.put("base_unit_id", object.getString("measure_unit_id")); + material.put("is_used", 1); + material.put("is_delete", 0); + material.put("create_id", currentUserId); + material.put("create_name", nickName); + material.put("create_time", now); + material.put("update_optid", currentUserId); + material.put("update_optname", nickName); + material.put("update_time", now); + materialbaseTab.insert(material); + } + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/rest/SubpackagerelationController.java b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/rest/SubpackagerelationController.java new file mode 100644 index 000000000..fda8addb3 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/rest/SubpackagerelationController.java @@ -0,0 +1,66 @@ + +package org.nl.wms.pdm.bi.rest; + + +import org.nl.wms.pdm.bi.service.SubpackagerelationService; +import org.nl.wms.pdm.bi.service.dto.SubpackagerelationDto; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.nl.modules.logging.annotation.Log; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; + +/** +* @author lyd +* @date 2022-10-28 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "子卷包装关系管理") +@RequestMapping("/api/subpackagerelation") +@Slf4j +public class SubpackagerelationController { + + private final SubpackagerelationService subpackagerelationService; + + @GetMapping + @Log("查询子卷包装关系") + @ApiOperation("查询子卷包装关系") + //@SaCheckPermission("@el.check('subpackagerelation:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(subpackagerelationService.queryAll(whereJson,page),HttpStatus.OK); + } + + @PostMapping + @Log("新增子卷包装关系") + @ApiOperation("新增子卷包装关系") + //@SaCheckPermission("@el.check('subpackagerelation:add')") + public ResponseEntity create(@Validated @RequestBody SubpackagerelationDto dto){ + subpackagerelationService.create(dto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PutMapping + @Log("修改子卷包装关系") + @ApiOperation("修改子卷包装关系") + //@SaCheckPermission("@el.check('subpackagerelation:edit')") + public ResponseEntity update(@Validated @RequestBody SubpackagerelationDto dto){ + subpackagerelationService.update(dto); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除子卷包装关系") + @ApiOperation("删除子卷包装关系") + //@SaCheckPermission("@el.check('subpackagerelation:del')") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + subpackagerelationService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/SubpackagerelationService.java b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/SubpackagerelationService.java new file mode 100644 index 000000000..22ac54589 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/SubpackagerelationService.java @@ -0,0 +1,65 @@ + +package org.nl.wms.pdm.bi.service; + +import org.nl.wms.pdm.bi.service.dto.SubpackagerelationDto; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @description 服务接口 +* @author lyd +* @date 2022-10-28 +**/ +public interface SubpackagerelationService { + + /** + * 查询数据分页 + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + + /** + * 查询所有数据不分页 + * @param whereJson 条件参数 + * @return List + */ + List queryAll(Map whereJson); + + /** + * 根据ID查询 + * @param workorder_id ID + * @return Subpackagerelation + */ + SubpackagerelationDto findById(Long workorder_id); + + /** + * 根据编码查询 + * @param code code + * @return Subpackagerelation + */ + SubpackagerelationDto findByCode(String code); + + + /** + * 创建 + * @param dto / + */ + void create(SubpackagerelationDto dto); + + /** + * 编辑 + * @param dto / + */ + void update(SubpackagerelationDto dto); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/dto/SubpackagerelationDto.java b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/dto/SubpackagerelationDto.java new file mode 100644 index 000000000..6df00bfd6 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/dto/SubpackagerelationDto.java @@ -0,0 +1,105 @@ +package org.nl.wms.pdm.bi.service.dto; + +import lombok.Data; +import java.math.BigDecimal; +import java.io.Serializable; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + +/** +* @description / +* @author lyd +* @date 2022-10-28 +**/ +@Data +public class SubpackagerelationDto implements Serializable { + + /** 子卷包装标识 */ + /** 防止精度丢失 */ + @JsonSerialize(using= ToStringSerializer.class) + private Long workorder_id; + + /** 木箱唯一码 */ + private String package_box_SN; + + /** 箱内子卷数量 */ + private BigDecimal quanlity_in_box; + + /** 木箱自身重量 */ + private BigDecimal box_weight; + + /** 保质期 */ + private BigDecimal quality_guaran_period; + + /** 销售订单及行号 */ + private String sale_order_name; + + /** 客户编号 */ + private String customer_name; + + /** 客户名称 */ + private String customer_description; + + /** 产品编码 */ + private String product_name; + + /** 产品描述 */ + private String product_description; + + /** 入库日期 */ + private String date_of_FG_inbound; + + /** 子卷号 */ + private String container_name; + + /** 产品规格(幅宽) */ + private String width; + + /** 产品厚度 */ + private String thickness; + + /** 单位面积质量 */ + private BigDecimal mass_per_unit_area; + + /** 净重 */ + private BigDecimal net_weight; + + /** 长度 */ + private BigDecimal length; + + /** 制造完成日期 */ + private String date_of_production; + + /** 计划外分切的子卷 */ + private String is_un_plan_production; + + /** 子卷的物性值1 */ + private String un_plan_product_property1; + + /** 子卷的物性值2 */ + private String un_plan_product_property2; + + /** 子卷的物性值3 */ + private String un_plan_product_property3; + + /** 备注 */ + private String remark; + + /** 创建人 */ + private Long create_id; + + /** 创建人姓名 */ + private String create_name; + + /** 创建时间 */ + private String create_time; + + /** 状态 */ + private String status; + + /** 是否需要重打外包装标签 */ + private String isRePrintPackageBoxLabel; + + /** 是否需要拆包重打子卷标签 */ + private String isUnPackBox; +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/impl/SubpackagerelationServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/impl/SubpackagerelationServiceImpl.java new file mode 100644 index 000000000..90e5dc585 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/bi/service/impl/SubpackagerelationServiceImpl.java @@ -0,0 +1,120 @@ + +package org.nl.wms.pdm.bi.service.impl; + + +import com.alibaba.fastjson.JSON; +import lombok.RequiredArgsConstructor; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.wms.pdm.bi.service.SubpackagerelationService; +import org.nl.wms.pdm.bi.service.dto.SubpackagerelationDto; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.nl.modules.common.utils.SecurityUtils; +import org.nl.modules.wql.core.bean.ResultBean; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.WqlUtil; +import lombok.extern.slf4j.Slf4j; +import cn.hutool.core.util.ObjectUtil; + +/** +* @description 服务实现 +* @author lyd +* @date 2022-10-28 +**/ +@Service +@RequiredArgsConstructor +@Slf4j +public class SubpackagerelationServiceImpl implements SubpackagerelationService { + + @Override + public Map queryAll(Map whereJson, Pageable page){ + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "1=1", "package_box_SN desc"); + final JSONObject json = rb.pageResult(); + return json; + } + + @Override + public List queryAll(Map whereJson){ + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + JSONArray arr = wo.query().getResultJSONArray(0); + if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(SubpackagerelationDto.class); + return null; + } + + @Override + public SubpackagerelationDto findById(Long workorder_id) { + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + JSONObject json = wo.query("workorder_id = '" + workorder_id + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(json)){ + return json.toJavaObject( SubpackagerelationDto.class); + } + return null; + } + + @Override + public SubpackagerelationDto findByCode(String code) { + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(json)){ + return json.toJavaObject( SubpackagerelationDto.class); + } + return null; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void create(SubpackagerelationDto dto) { + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + dto.setWorkorder_id(IdUtil.getSnowflake(1, 1).nextId()); + dto.setCreate_id(currentUserId); + dto.setCreate_name(nickName); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); + wo.insert(json); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(SubpackagerelationDto dto) { + SubpackagerelationDto entity = this.findById(dto.getWorkorder_id()); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); + wo.update(json); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(Long[] ids) { + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + WQLObject wo = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + for (Long workorder_id: ids) { + JSONObject param = new JSONObject(); + param.put("workorder_id", String.valueOf(workorder_id)); + param.put("is_delete", "1"); +// param.put("update_optid", currentUserId); +// param.put("update_optname", nickName); +// param.put("update_time", now); + wo.update(param); + } + } + +} diff --git a/lms/nladmin-system/src/main/resources/template/generator/front/index.ftl b/lms/nladmin-system/src/main/resources/template/generator/front/index.ftl index 1c4665fed..07d095500 100644 --- a/lms/nladmin-system/src/main/resources/template/generator/front/index.ftl +++ b/lms/nladmin-system/src/main/resources/template/generator/front/index.ftl @@ -80,15 +80,15 @@ <#list columns as column> <#if column.columnShow> <#if (column.dictName)?? && (column.dictName)!=""> - + <#elseif column.columnType != 'Timestamp'> - + <#else> - + diff --git a/lms/nladmin-ui/package.json b/lms/nladmin-ui/package.json index 81ea67be7..a92d06891 100644 --- a/lms/nladmin-ui/package.json +++ b/lms/nladmin-ui/package.json @@ -64,6 +64,7 @@ "screenfull": "4.2.0", "sortablejs": "1.8.4", "throttle-debounce": "^5.0.0", + "v-fit-columns": "^0.2.0", "vue": "2.6.10", "vue-color": "^2.8.1", "vue-count-to": "1.0.13", diff --git a/lms/nladmin-ui/src/main.js b/lms/nladmin-ui/src/main.js index 2647e8fcb..ee1942d8d 100644 --- a/lms/nladmin-ui/src/main.js +++ b/lms/nladmin-ui/src/main.js @@ -42,7 +42,7 @@ import '@logicflow/extension/lib/style/index.css' import Tinymce from '@/views/system/build/tinymce/index.vue' import request from '@/utils/request' // 实现 form generator 使用自己定义的 axios request 对象 -import { addDateRange, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels } from '@/utils/nladmin' +import { addDateRange, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels, flexWidth } from '@/utils/nladmin' import { getValueByCode } from '@/api/system/param' @@ -59,6 +59,10 @@ Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.handleTree = handleTree Vue.prototype.getValueByCode = getValueByCode +Vue.prototype.flexWidth = flexWidth + +import Plugin from 'v-fit-columns' +Vue.use(Plugin) Vue.use(scroll) diff --git a/lms/nladmin-ui/src/utils/nladmin.js b/lms/nladmin-ui/src/utils/nladmin.js index 42ee3a53f..371bcb126 100644 --- a/lms/nladmin-ui/src/utils/nladmin.js +++ b/lms/nladmin-ui/src/utils/nladmin.js @@ -222,3 +222,45 @@ export async function blobValidate(data) { return true } } + +/** + * 自动列宽 + * flexWidth: https://blog.csdn.net/luoyumeiluoyumei/article/details/125853152?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1-125853152-blog-123421632.pc_relevant_recovery_v2&spm=1001.2101.3001.4242.2&utm_relevant_index=4 + * @param prop 每列的prop 不能为空 + * @param tableData 表格数据 + * @param title 标题长内容短的,传标题 不能为空 + * @param num 列中有标签等加的富余量 + * @returns 列的宽度 + * 注:prop,title有一个必传 + */ +export function flexWidth(prop, tableData, title, num = 0) { + if (tableData.length === 0) { // 表格没数据不做处理 + return + } + let flexWidth = 0// 初始化表格列宽 + let columnContent = ''// 占位最宽的内容 + const canvas = document.createElement('canvas') + const context = canvas.getContext('2d') + context.font = '14px Microsoft YaHei' + // 获取占位最宽的内容 + let index = 0 + for (let i = 0; i < tableData.length; i++) { // 循环表格内容,获取表格内容中最长的数据 + const now_temp = tableData[i][prop] + '' + const max_temp = tableData[index][prop] + '' + const now_temp_w = context.measureText(now_temp).width + const max_temp_w = context.measureText(max_temp).width + if (now_temp_w > max_temp_w) { + index = i + } + } + columnContent = tableData[index][prop] + const column_w = context.measureText(columnContent).width + const title_w = context.measureText(title).width + if (column_w < title_w) { + columnContent = title || '留四个字' + } + // 计算最宽内容的列宽 + const width = context.measureText(columnContent) + flexWidth = width.width + 20 + num + return flexWidth + 'px' +} diff --git a/lms/nladmin-ui/src/views/wms/pdm/bi/index.vue b/lms/nladmin-ui/src/views/wms/pdm/bi/index.vue new file mode 100644 index 000000000..db18e0bbd --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/pdm/bi/index.vue @@ -0,0 +1,214 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/wms/pdm/bi/subpackagerelation.js b/lms/nladmin-ui/src/views/wms/pdm/bi/subpackagerelation.js new file mode 100644 index 000000000..987d3c5ef --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/pdm/bi/subpackagerelation.js @@ -0,0 +1,27 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/subpackagerelation', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/subpackagerelation/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/subpackagerelation', + method: 'put', + data + }) +} + +export default { add, edit, del } From 728e82f8602f36c71c6a9e95fa1e4e2b00285612 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 28 Oct 2022 14:40:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/server/NDCAgvService.java | 13 +- .../agv/server/impl/NDCAgvServiceImpl.java | 419 +++++++++--------- .../run/OneNDCSocketConnectionAutoRun.java | 242 ++++++++++ .../run/TwoNDCSocketConnectionAutoRun.java | 243 ++++++++++ .../device/device_driver/DriverTypeEnum.java | 13 +- .../agv/ndcone/AgvNdcOneDefination.java | 49 ++ .../agv/ndcone/AgvNdcOneDeviceDriver.java | 388 ++++++++++++++++ .../agv/ndctwo/AgvNdcTwoDefination.java | 49 ++ .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 386 ++++++++++++++++ .../src/views/acs/device/config.vue | 6 +- .../src/views/system/monitor/device/index.vue | 4 +- 11 files changed, 1592 insertions(+), 220 deletions(-) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index 87b0f98e6..464df2bfe 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -30,7 +30,7 @@ public interface NDCAgvService { public void deleteAgvInstToNDC(Instruction inst) throws Exception; /** - * 下发NDC agv单工动作指令,反馈信号,如能否进、能否出。 + * 下发NDC agv1楼动作指令,反馈信号,如能否进、能否出。 * 告诉AGV能否进,能否出 * * @param phase @@ -41,7 +41,17 @@ public interface NDCAgvService { public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2); /** + * 下发NDC agv2楼动作指令,反馈信号,如能否进、能否出。 + * 告诉AGV能否进,能否出 * + * @param phase + * @param index + * @param result1 + * @param result2 + */ + public byte[] sendAgvTwoModeInst(int phase, int index); + + /** * @param inst * @param inst2 */ @@ -49,6 +59,7 @@ public interface NDCAgvService { /** * 下发任务 + * * @param inst * @throws Exception */ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 714b4bd5b..700829437 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -46,70 +46,72 @@ public class NDCAgvServiceImpl implements NDCAgvService { @LokiLog(type = LokiLogType.AGV) @Override public void deleteAgvInstToNDC(Instruction inst) throws Exception { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { - int index = Integer.parseInt(inst.getAgv_jobno()); + if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { + int index = Integer.parseInt(inst.getAgv_jobno()); - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); + byte indexhigh = (byte) IntToHexHigh(index); + byte indexlow = (byte) IntToHexLow(index); - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "index:" + index; - str1 += "ikey:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF); - System.out.println(str); - System.out.println(str1); + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "index:" + index; + str1 += "ikey:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF); + System.out.println(str); + System.out.println(str1); - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X06, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6E, - (byte) 0X00, (byte) 0X02, - (byte) indexhigh, (byte) indexlow, - }; - log.info("下发删除AGV指令--{}", Bytes2HexString(b)); + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X06, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6E, + (byte) 0X00, (byte) 0X02, + (byte) indexhigh, (byte) indexlow, + }; + log.info("下发删除AGV指令--{}", Bytes2HexString(b)); // NDCSocketConnectionAutoRun.write(b); - System.out.println("下发删除agv指令数据:" + Bytes2HexString(b)); - } + System.out.println("下发删除agv指令数据:" + Bytes2HexString(b)); + } } @LokiLog(type = LokiLogType.AGV) @Override public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2) { - if (phase < 0 || index < 0) - return null; - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); - byte phasehigh = (byte) IntToHexHigh(phase); - byte phaselow = (byte) IntToHexLow(phase); - byte resulthigh1 = (byte) IntToHexHigh(result1); - byte resultlow1 = (byte) IntToHexLow(result1); - byte resulthigh2 = (byte) IntToHexHigh(result2); - byte resultlow2 = (byte) IntToHexLow(result2); + if (phase < 0 || index < 0) + return null; + byte indexhigh = (byte) IntToHexHigh(index); + byte indexlow = (byte) IntToHexLow(index); + byte phasehigh = (byte) IntToHexHigh(phase); + byte phaselow = (byte) IntToHexLow(phase); + byte resulthigh1 = (byte) IntToHexHigh(result1); + byte resultlow1 = (byte) IntToHexLow(result1); + byte resulthigh2 = (byte) IntToHexHigh(result2); + byte resultlow2 = (byte) IntToHexLow(result2); - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0D, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X08, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow, - (byte) resulthigh1, (byte) resultlow1, - (byte) resulthigh2, (byte) resultlow2 - }; + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0D, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X08, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow, + (byte) resulthigh1, (byte) resultlow1, + (byte) resulthigh2, (byte) resultlow2 + }; - log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); - //87CD 0008 000C 0001 006D 0008 0000 0114 000E 0000 - //87CD 0008 000C 0001 006D 0008 0003 0114 008F 0000 - System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); - return b; + log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); + //87CD 0008 000C 0001 006D 0008 0000 0114 000E 0000 + //87CD 0008 000C 0001 006D 0008 0003 0114 008F 0000 + System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); + return b; } + + @LokiLog(type = LokiLogType.AGV) @Override public void sendAgvOneInstToNDC(Instruction inst) { @@ -171,66 +173,67 @@ public class NDCAgvServiceImpl implements NDCAgvService { System.out.println("下发agv指令数据:" + Bytes2HexString(b)); } } + @LokiLog(type = LokiLogType.AGV) @Override public void sendAgvInstToNDC(Instruction inst) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { - String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getInstruction_type()); - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); + if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { + String instcode = inst.getInstruction_code(); + int type = Integer.parseInt(inst.getInstruction_type()); + int priority = Integer.parseInt(inst.getPriority()) + 128; + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); + int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte prioritylow = (byte) IntToHexLow(priority); + byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); + byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); + byte typehigh = (byte) IntToHexHigh(type); + byte typelow = (byte) IntToHexLow(type); + byte qhdhigh = (byte) IntToHexHigh(startAddress); + byte qhdlow = (byte) IntToHexLow(startAddress); + byte fhdhigh = (byte) IntToHexHigh(nextAddress); + byte fhdlow = (byte) IntToHexLow(nextAddress); + byte prioritylow = (byte) IntToHexLow(priority); - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "ikey:" + (Integer.parseInt(instcode)); - str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "ikey:" + (Integer.parseInt(instcode)); + str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - str += "/type:" + (type); - str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); + str += "/type:" + (type); + str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - str += "/qhd:" + (startAddress); - str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "/fhd:" + (nextAddress); - str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); + str += "/qhd:" + (startAddress); + str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); + str += "/fhd:" + (nextAddress); + str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - str += "/priority:" + (priority); - str1 += "/priority:" + hexToString(prioritylow & 0xFF); + str += "/priority:" + (priority); + str1 += "/priority:" + hexToString(prioritylow & 0xFF); - System.out.println(str); - System.out.println(str1); + System.out.println(str); + System.out.println(str1); - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X12, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X0E, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow - }; - log.info("下发AGV作业指令--{}", str1); + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X12, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X0E, + (byte) 0X01, prioritylow, + (byte) 0X00, (byte) 0X01, + (byte) ikeyhigh, (byte) ikeylow, + (byte) ikeyhigh, (byte) ikeylow, + (byte) typehigh, (byte) typelow, + (byte) qhdhigh, (byte) qhdlow, + (byte) fhdhigh, (byte) fhdlow + }; + log.info("下发AGV作业指令--{}", str1); // NDCSocketConnectionAutoRun.write(b); - System.out.println("下发agv指令数据:" + Bytes2HexString(b)); - } + System.out.println("下发agv指令数据:" + Bytes2HexString(b)); + } } @LokiLog(type = LokiLogType.AGV) @@ -276,133 +279,138 @@ public class NDCAgvServiceImpl implements NDCAgvService { return new byte[0]; } + @LokiLog(type = LokiLogType.AGV) + @Override + public byte[] sendAgvTwoModeInst(int phase, int index) { + return new byte[0]; + } @LokiLog(type = LokiLogType.AGV) @Override public byte[] sendAgvOneModeInst(int phase, int index, int result) { - if (phase < 0 || index < 0) - return null; - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); - byte phasehigh = (byte) IntToHexHigh(phase); - byte phaselow = (byte) IntToHexLow(phase); - byte resulthigh = (byte) IntToHexHigh(result); - byte resultlow = (byte) IntToHexLow(result); + if (phase < 0 || index < 0) + return null; + byte indexhigh = (byte) IntToHexHigh(index); + byte indexlow = (byte) IntToHexLow(index); + byte phasehigh = (byte) IntToHexHigh(phase); + byte phaselow = (byte) IntToHexLow(phase); + byte resulthigh = (byte) IntToHexHigh(result); + byte resultlow = (byte) IntToHexLow(result); - int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue()); - byte[] b = new byte[]{}; - switch (type) { - case 0: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 1: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0D, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X08, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow, - (byte) resulthigh, (byte) resultlow - }; - break; - case 2: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 5: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 7: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - } - log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); + int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue()); + byte[] b = new byte[]{}; + switch (type) { + case 0: + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X06, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow + }; + break; + case 1: + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0D, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X08, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow, + (byte) resulthigh, (byte) resultlow + }; + break; + case 2: + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X06, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow + }; + break; + case 5: + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X06, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow + }; + break; + case 7: + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X06, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow + }; + break; + } + log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); - System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); - return b; + System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); + return b; } @LokiLog(type = LokiLogType.AGV) @Override public String queryDoorStatus(String device) { - log.info("AGV查询自动门状态,参数:{}", device); - int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue()); - switch (type) { - case 4: - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), "1")) { - String result = acsToWmsService.queryDoorsStatus().body(); - JSONArray ja = JSONArray.parseArray(result); - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - } - return null; - default: - if (StrUtil.equals("doors", device)) { - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - - JSONObject jo = JSONObject.parseObject(mes); - ja.add(jo); - } - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - - } else { - Device doordevice = deviceAppService.findDeviceByCode(device); + log.info("AGV查询自动门状态,参数:{}", device); + int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue()); + switch (type) { + case 4: + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), "1")) { + String result = acsToWmsService.queryDoorsStatus().body(); + JSONArray ja = JSONArray.parseArray(result); + log.info("AGV查询自动门状态,反馈:{}", ja.toString()); + return ja.toString(); + } + return null; + default: + if (StrUtil.equals("doors", device)) { + List list = deviceAppService.findDevice(DeviceType.autodoor); + JSONArray ja = new JSONArray(); + for (int i = 0; i < list.size(); i++) { + Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); if (ObjectUtil.isEmpty(doordevice)) { throw new BadRequestException("未找到对应设备"); } String mes = null; + JSONObject jo = JSONObject.parseObject(mes); - log.info("AGV查询自动门状态,反馈:{}", jo.toString()); - return jo.toString(); + ja.add(jo); } - } + log.info("AGV查询自动门状态,反馈:{}", ja.toString()); + return ja.toString(); + + } else { + Device doordevice = deviceAppService.findDeviceByCode(device); + if (ObjectUtil.isEmpty(doordevice)) { + throw new BadRequestException("未找到对应设备"); + } + String mes = null; + JSONObject jo = JSONObject.parseObject(mes); + log.info("AGV查询自动门状态,反馈:{}", jo.toString()); + return jo.toString(); + } + } } @@ -499,6 +507,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { System.out.println("下发agv指令数据:" + Bytes2HexString(b)); } + @LokiLog(type = LokiLogType.AGV) @Override public Map findAllAgvFromCache() { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java new file mode 100644 index 000000000..3d1d66282 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -0,0 +1,242 @@ +package org.nl.acs.auto.run; + +import cn.hutool.core.util.ObjectUtil; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.instruction.service.impl.InstructionServiceImpl; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.impl.ParamServiceImpl; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.util.Date; +import java.util.List; + +import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; + + +@Slf4j +@Component +public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { + + Socket s; + String ip = "192.168.46.225"; + int port = 1234; + static DataOutputStream dos; + static DataInputStream dis; + private int recordTimeOut = 10000; + private Date recordTime; + String[] ERROR = new String[]{ + "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", + "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", + "抬叉停止"}; + boolean bConnected = true; + + boolean isReConnect = false; + + @Autowired + ParamService paramService; + @Autowired + AutoRunService autoRunService; + + + public OneNDCSocketConnectionAutoRun() { + this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); + } + + public String getCode() { + return OneNDCSocketConnectionAutoRun.class.getSimpleName(); + } + + public String getName() { + return "1楼NDC在线连接"; + } + + public void autoRun() throws IOException { + System.out.println("OneAgv链接开始"); + ParamService ParamService = SpringContextHolder.getBean(ParamServiceImpl.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); + ip = paramService.findByCode(AcsConfig.AGVURL).getValue(); + port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue()); + + + try { + + byte[] b = new byte[1024]; + s = new Socket(ip, port); + dos = new DataOutputStream(s.getOutputStream()); + dis = new DataInputStream(s.getInputStream()); + System.out.println("OneAgv链接成功"); + while (bConnected) { + int count = dis.read(b); + + if (count == -1) { + break; + } + + int[] arr = new int[count]; + StringBuffer bs = new StringBuffer(); + + for (int i = 0; i < count; i++) { + int temp = b[i]; + if (temp < 0) + temp += 256; + arr[i] = temp; + StringBuffer bs1 = new StringBuffer("0"); + bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); + } + + //System.out.println("收到请求参数:" + bs); + boolean flag = false; + if (arr[8] * 256 + arr[9] == 0x73) { + byte[] data = null; + System.out.println("接收agv上报信息:" + bs); + //执行阶段 + int phase = arr[16] * 256 + arr[17]; + // agv任务号 + int index = arr[12] * 256 + arr[13]; + //任务号 + int ikey = arr[26] * 256 + arr[27]; + //站点号 + int agvaddr = arr[18] * 256 + arr[19]; + //车号 + int carno = arr[20]; + Instruction link_inst = null; + List insts = null; + boolean link_flag = false; + Device agv_device = null; + if(carno != 0){ + agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); + } + if (ikey != 0) { + insts = instructionService.findByLinkNum(String.valueOf(ikey)); + } + if (!ObjectUtil.isEmpty(link_inst)) { + link_flag = true; + } + log.info("接收agv上报信息:" + bs); + log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); + Device device = null; + String device_code = null; + + + // + AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; + + //开始任务/上报订单号 + if (phase == 0x01) { + for (Instruction inst : insts) { + inst.setInstruction_status("1"); + inst.setAgv_jobno(String.valueOf(index)); + inst.setSend_status("1"); + instructionService.update(inst); + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + + } else if (phase == 0x0A) { + + for (Instruction inst : insts) { + if (!ObjectUtil.isEmpty(inst)) { + instructionService.finish(inst.getInstruction_id()); + } + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else if(phase == 0x30){ + data = NDCAgvService.sendAgvOneModeInst(143, index, 0); + + } else if(phase == 0xFF) { + + for (Instruction inst : insts) { + if (!ObjectUtil.isEmpty(inst)) { + instructionService.cancelNOSendAgv(inst.getInstruction_id()); + } + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + }else if(phase == 0x50){//离开区域 + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + }else if(phase == 0x51){//离开区域 + + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else { + + if(phase == 0x67){ + device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); + } else { + device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); + } + if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { + agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); + agvNdcOneDeviceDriver.processSocket(arr); + } + } + if (!ObjectUtil.isEmpty(data)) { + write(data); + } + + } else { +// System.out.println("agv上报不是0073类型动作,不处理"); + } + } + + } catch (Exception e) { + System.out.println("OneAgv链接异常"); + if(ObjectUtil.isNotEmpty(s)){ + s.close(); + } + System.out.println(e.getMessage()); + e.printStackTrace(); + + } finally { + + + } + + } + + + @Override + public void stop() { + super.after(); + try { + s.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static void write(byte[] b) { + try { + log.info("下发agv数据:" + Bytes2HexString(b)); + System.out.println("下发agv数据:" + Bytes2HexString(b)); + dos.write(b); + dos.flush(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java new file mode 100644 index 000000000..0749acf2e --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java @@ -0,0 +1,243 @@ +package org.nl.acs.auto.run; + +import cn.hutool.core.util.ObjectUtil; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.instruction.service.impl.InstructionServiceImpl; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.impl.ParamServiceImpl; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.util.Date; +import java.util.List; + +import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; + + +@Slf4j +@Component +public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { + + Socket s; + String ip = "192.168.46.225"; + int port = 1234; + static DataOutputStream dos; + static DataInputStream dis; + private int recordTimeOut = 10000; + private Date recordTime; + String[] ERROR = new String[]{ + "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", + "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", + "抬叉停止"}; + boolean bConnected = true; + + boolean isReConnect = false; + + @Autowired + ParamService paramService; + @Autowired + AutoRunService autoRunService; + + + public TwoNDCSocketConnectionAutoRun() { + this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); + } + + public String getCode() { + return TwoNDCSocketConnectionAutoRun.class.getSimpleName(); + } + + public String getName() { + return "2楼NDC在线连接"; + } + + public void autoRun() throws IOException { + System.out.println("OneAgv链接开始"); + ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); + ip = paramService.findByCode(AcsConfig.AGVURL2).getValue(); + port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); + + + try { + + byte[] b = new byte[1024]; + s = new Socket(ip, port); + dos = new DataOutputStream(s.getOutputStream()); + dis = new DataInputStream(s.getInputStream()); + System.out.println("TwoAgv链接成功"); + while (bConnected) { + int count = dis.read(b); + + if (count == -1) { + break; + } + + int[] arr = new int[count]; + StringBuffer bs = new StringBuffer(); + + for (int i = 0; i < count; i++) { + int temp = b[i]; + if (temp < 0) + temp += 256; + arr[i] = temp; + StringBuffer bs1 = new StringBuffer("0"); + bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); + } + + //System.out.println("收到请求参数:" + bs); + boolean flag = false; + if (arr[8] * 256 + arr[9] == 0x73) { + byte[] data = null; + System.out.println("接收agv上报信息:" + bs); + //执行阶段 + int phase = arr[16] * 256 + arr[17]; + // agv任务号 + int index = arr[12] * 256 + arr[13]; + //任务号 + int ikey = arr[26] * 256 + arr[27]; + //站点号 + int agvaddr = arr[18] * 256 + arr[19]; + //车号 + int carno = arr[20]; + Instruction link_inst = null; + List insts = null; + boolean link_flag = false; + Device agv_device = null; + if (carno != 0) { + agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); + } + if (ikey != 0) { + insts = instructionService.findByLinkNum(String.valueOf(ikey)); + } + if (!ObjectUtil.isEmpty(link_inst)) { + link_flag = true; + } + log.info("接收agv上报信息:" + bs); + log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); + Device device = null; + String device_code = null; + + + // + AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; + + //开始任务/上报订单号 + if (phase == 0x01) { + for (Instruction inst : insts) { + inst.setInstruction_status("1"); + inst.setAgv_jobno(String.valueOf(index)); + inst.setSend_status("1"); + instructionService.update(inst); + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + + } else if (phase == 0x0A) { + + for (Instruction inst : insts) { + if (!ObjectUtil.isEmpty(inst)) { + instructionService.finish(inst.getInstruction_id()); + } + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else if (phase == 0x30) { + data = NDCAgvService.sendAgvOneModeInst(143, index, 0); + + } else if (phase == 0xFF) { + + for (Instruction inst : insts) { + if (!ObjectUtil.isEmpty(inst)) { + instructionService.cancelNOSendAgv(inst.getInstruction_id()); + } + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else if (phase == 0x50) {//离开区域 + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else if (phase == 0x51) {//离开区域 + + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + } else { + + if (phase == 0x67) { + device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); + } else { + device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); + } + if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { + agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); + agvNdcOneDeviceDriver.processSocket(arr); + } + } + if (!ObjectUtil.isEmpty(data)) { + write(data); + } + + } else { +// System.out.println("agv上报不是0073类型动作,不处理"); + } + } + + } catch (Exception e) { + System.out.println("OneAgv链接异常"); + if (ObjectUtil.isNotEmpty(s)) { + s.close(); + } + System.out.println(e.getMessage()); + e.printStackTrace(); + + } finally { + + + } + + } + + + @Override + public void stop() { + super.after(); + try { + s.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static void write(byte[] b) { + try { + log.info("下发agv数据:" + Bytes2HexString(b)); + System.out.println("下发agv数据:" + Bytes2HexString(b)); + dos.write(b); + dos.flush(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 6f46adeb5..5a2b620a0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -21,18 +21,9 @@ public enum DriverTypeEnum { INSPECT_CONVEYOR_MONITOR(6, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"), - HAILIANG_SMART_PLC_TEST(7, "hailiang_smart_plc_test", "永裕共挤线-西门子SMART200PLC", "conveyor"), - - EMPTY_VEHICLE_STACKING_POSITION(8, "empty_vehicle_stacking_position", "永裕叠盘位-西门子SMART200PLC", "conveyor"), - - CARGO_LIFT_CONVEYOR(9, "cargo_lift_conveyor", "货梯对接线", "conveyor"), - - INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(10, "standard_conveyor_control_with_scanner", "货梯对接线-关联扫码", "conveyor"), - - HAOKAI_AUTO_CONVEYOR(11, "haokai_auto_conveyor", "豪恺自动线对接位", "conveyor"), - - PAINT_CONVEYOR(12, "paint_conveyor", "油漆线", "conveyor"); + AGV_NDC_ONE(7, "agv_ndc_one", "NDC1楼AGV", "agv"), + AGV_NDC_TWO(8, "agv_ndc_two", "NDC2楼AGV", "agv"); //驱动索引 private int index; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java new file mode 100644 index 000000000..7a7ec9325 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java @@ -0,0 +1,49 @@ +package org.nl.acs.device_driver.basedriver.agv.ndcone; + +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.DeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * NDC单工位AGV + */ +@Service +public class AgvNdcOneDefination implements DeviceDriverDefination { + @Override + public String getDriverCode() { + return "agv_ndc_one"; + } + + @Override + public String getDriverName() { + return "NDC1楼AGV"; + } + + @Override + public String getDriverDescription() { + return "NDC1楼AGV"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new AgvNdcOneDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return AgvNdcOneDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.agv); + return types; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java new file mode 100644 index 000000000..b7a2bc4a5 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -0,0 +1,388 @@ +package org.nl.acs.device_driver.basedriver.agv.ndcone; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.instruction.service.impl.InstructionServiceImpl; +import org.nl.acs.log.LokiLog; +import org.nl.acs.log.LokiLogType; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.impl.ParamServiceImpl; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * NDC单工位AGV + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { + + ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); + int agvaddr = 0; + int agvaddr_copy = 0; + int weight = 0; + String device_code = ""; + int phase = 0; + + int x = 0; //x坐标 + int y = 0; //y坐标 + int angle = 0; //角度 + int electric_qty = 0; //电量 + int status = 0; //三色灯状态 + int error = 0; //车辆故障 + + int last_x = 0; + int last_y = 0; + int last_angle = 0; + int last_electric_qty = 0; + int last_status = 0; + int last_error = 0; + + @LokiLog(type = LokiLogType.ACA_TO_LMS) + public synchronized void processSocket(int[] arr) throws Exception { + device_code = this.getDeviceCode(); + byte[] data = null; + phase = arr[16] * 256 + arr[17]; + // agv任务号 + int index = arr[12] * 256 + arr[13]; + //任务号 + int ikey = arr[26] * 256 + arr[27]; + //站点号 + agvaddr = arr[18] * 256 + arr[19]; + //车号 + int carno = arr[20]; + Instruction link_inst = null; + List insts = null; + boolean link_flag = false; + Device agv_device = null; + if (carno != 0) { + agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); + } + if (ikey != 0) { + insts = instructionService.findByLinkNum(String.valueOf(ikey)); + } + if (!ObjectUtil.isEmpty(link_inst)) { + link_flag = true; + } + + Device device = null; + String old_device_code = null; + String emptyNum = null; + String device_code = null; + + if (phase == 0x67) { + //故障信息 + if (arr[18] * 256 + arr[19] == 0) { + + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + + //普通站点 + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + //货架 + StandardStorageDeviceDriver standardStorageDeviceDriver; + + //开始任务/上报订单号 + if (phase == 0x02) { + for (Instruction inst : insts) { + inst.setCarno(String.valueOf(carno)); + instructionService.update(inst); + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data); + + //请求取货 + } else if (phase == 0x03) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + break; + } + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + } + + } else if (phase == 0x65) {//param,重量待定 + //1、得到重量信息 + int weight = (arr[18] * 256 + arr[19]) * 10; + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + // 4010 待处理 + if (StrUtil.equals(inst.getStart_device_code(), device_code)) { + inst.setWeight(String.valueOf(weight)); + } + } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //取货完毕/取满框完毕1/点对点取货完毕 + } else if (phase == 0x64) {//param,agv货位id待定 + //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 + agvaddr = arr[18] * 256 + arr[19]; + agvaddr_copy = agvaddr; + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //取货完毕 + } else if (phase == 0x05) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + device = deviceAppService.findDeviceByCode(device_code); + + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + break; + } + + if (StrUtil.equals(inst.getStart_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //请求放货 + } else if (phase == 0x07) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + if (StrUtil.equals(inst.getNext_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //放货完成 + } else if (phase == 0x09) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + if (StrUtil.equals(inst.getNext_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + } else if (phase == 0x71) { + x = ikey; + if (x != last_x) { + logServer.deviceExecuteLog(this.device_code,"", "x", String.valueOf(x)); + } + } else if (phase == 0x72) { + y = ikey; + if (y != last_y) { + logServer.deviceExecuteLog(this.device_code, "","y", String.valueOf(y)); + } + } else if (phase == 0x73) { + angle = last_angle; + if (angle != last_angle) { + logServer.deviceExecuteLog(this.device_code, "","angle", String.valueOf(angle)); + } + } else if (phase == 0x74) { + electric_qty = ikey; + if (electric_qty != last_electric_qty) { + logServer.deviceExecuteLog(this.device_code, "","electric_qty", String.valueOf(electric_qty)); + } + } else if (phase == 0x75) { + status = ikey; + if (status != last_status) { + logServer.deviceExecuteLog(this.device_code, "","status", String.valueOf(status)); + } + } else if (phase == 0x76) { + error = ikey; + if (error != last_error) { + logServer.deviceExecuteLog(this.device_code, "","error", String.valueOf(error)); + } + } + if (!ObjectUtil.isEmpty(data)) { + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + OneNDCSocketConnectionAutoRun.write(data); + } + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java new file mode 100644 index 000000000..c67d99d43 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java @@ -0,0 +1,49 @@ +package org.nl.acs.device_driver.basedriver.agv.ndctwo; + +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.DeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * NDC双工位AGV + */ +@Service +public class AgvNdcTwoDefination implements DeviceDriverDefination { + @Override + public String getDriverCode() { + return "agv_ndc_two"; + } + + @Override + public String getDriverName() { + return "NDC双工位AGV"; + } + + @Override + public String getDriverDescription() { + return "NDC双工位AGV"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new AgvNdcTwoDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return AgvNdcTwoDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.agv); + return types; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java new file mode 100644 index 000000000..e91fc574c --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -0,0 +1,386 @@ +package org.nl.acs.device_driver.basedriver.agv.ndctwo; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.instruction.service.impl.InstructionServiceImpl; +import org.nl.acs.log.LokiLog; +import org.nl.acs.log.LokiLogType; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; + +import java.util.List; + +/** + * NDC单工位AGV + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { + + ParamService ParamService = SpringContextHolder.getBean(ParamService.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); + int agvaddr = 0; + int agvaddr_copy = 0; + int weight = 0; + String device_code = ""; + int phase = 0; + + int x = 0; //x坐标 + int y = 0; //y坐标 + int angle = 0; //角度 + int electric_qty = 0; //电量 + int status = 0; //三色灯状态 + int error = 0; //车辆故障 + + int last_x = 0; + int last_y = 0; + int last_angle = 0; + int last_electric_qty = 0; + int last_status = 0; + int last_error = 0; + + @LokiLog(type = LokiLogType.ACA_TO_LMS) + public synchronized void processSocket(int[] arr) throws Exception { + device_code = this.getDeviceCode(); + byte[] data = null; + phase = arr[16] * 256 + arr[17]; + // agv任务号 + int index = arr[12] * 256 + arr[13]; + //任务号 + int ikey = arr[26] * 256 + arr[27]; + //站点号 + agvaddr = arr[18] * 256 + arr[19]; + //车号 + int carno = arr[20]; + Instruction link_inst = null; + List insts = null; + boolean link_flag = false; + Device agv_device = null; + if (carno != 0) { + agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); + } + if (ikey != 0) { + insts = instructionService.findByLinkNum(String.valueOf(ikey)); + } + if (!ObjectUtil.isEmpty(link_inst)) { + link_flag = true; + } + + Device device = null; + String old_device_code = null; + String emptyNum = null; + String device_code = null; + + if (phase == 0x67) { + //故障信息 + if (arr[18] * 256 + arr[19] == 0) { + + } + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + } + + //普通站点 + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + //货架 + StandardStorageDeviceDriver standardStorageDeviceDriver; + + //开始任务/上报订单号 + if (phase == 0x02) { + for (Instruction inst : insts) { + inst.setCarno(String.valueOf(carno)); + instructionService.update(inst); + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data); + + //请求取货 + } else if (phase == 0x03) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + break; + } + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + } + + } else if (phase == 0x65) {//param,重量待定 + //1、得到重量信息 + int weight = (arr[18] * 256 + arr[19]) * 10; + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + // 4010 待处理 + if (StrUtil.equals(inst.getStart_device_code(), device_code)) { + inst.setWeight(String.valueOf(weight)); + } + } + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //取货完毕/取满框完毕1/点对点取货完毕 + } else if (phase == 0x64) {//param,agv货位id待定 + //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 + agvaddr = arr[18] * 256 + arr[19]; + agvaddr_copy = agvaddr; + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //取货完毕 + } else if (phase == 0x05) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + device = deviceAppService.findDeviceByCode(device_code); + + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + break; + } + + if (StrUtil.equals(inst.getStart_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //请求放货 + } else if (phase == 0x07) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + if (StrUtil.equals(inst.getNext_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + //放货完成 + } else if (phase == 0x09) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, "-")) { + String[] point = old_device_code.split("-"); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, ".")) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + for (Instruction inst : insts) { + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + break; + } + if (StrUtil.equals(inst.getNext_device_code(), device_code)) { + + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + data = NDCAgvService.sendAgvTwoModeInst(phase, index); + } + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + + } else if (phase == 0x71) { + x = ikey; + if (x != last_x) { + logServer.deviceExecuteLog(this.device_code, "", "x", String.valueOf(x)); + } + } else if (phase == 0x72) { + y = ikey; + if (y != last_y) { + logServer.deviceExecuteLog(this.device_code, "", "y", String.valueOf(y)); + } + } else if (phase == 0x73) { + angle = last_angle; + if (angle != last_angle) { + logServer.deviceExecuteLog(this.device_code, "", "angle", String.valueOf(angle)); + } + } else if (phase == 0x74) { + electric_qty = ikey; + if (electric_qty != last_electric_qty) { + logServer.deviceExecuteLog(this.device_code, "", "electric_qty", String.valueOf(electric_qty)); + } + } else if (phase == 0x75) { + status = ikey; + if (status != last_status) { + logServer.deviceExecuteLog(this.device_code, "", "status", String.valueOf(status)); + } + } else if (phase == 0x76) { + error = ikey; + if (error != last_error) { + logServer.deviceExecuteLog(this.device_code, "", "error", String.valueOf(error)); + } + } + if (!ObjectUtil.isEmpty(data)) { + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + TwoNDCSocketConnectionAutoRun.write(data); + } + } + +} diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index c8509485a..4c4908c50 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -85,6 +85,8 @@ import paint_conveyor from '@/views/acs/device/driver/paint_conveyor' import haokai_auto_conveyor from '@/views/acs/device/driver/haokai_auto_conveyor' import cargo_lift_conveyor from '@/views/acs/device/driver/cargo_lift_conveyor' import empty_vehicle_stacking_position from '@/views/acs/device/driver/empty_vehicle_stacking_position' +import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one' +import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two' export default { name: 'DeviceConfig', @@ -100,7 +102,9 @@ export default { paint_conveyor, haokai_auto_conveyor, cargo_lift_conveyor, - empty_vehicle_stacking_position + empty_vehicle_stacking_position, + agv_ndc_two, + agv_ndc_one }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index 8db7e17b5..28c16ab2c 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -133,7 +133,7 @@ export default { name: 'MonitorDevice', data() { return { - stageParam: 'YY', // 舞台参数 + stageParam: 'stage_code', // 舞台参数 dialogDeviceMsgVisible: false, // 显示设备信息的dialog device_code: null, tops: '20vh', // 初始top @@ -268,7 +268,7 @@ export default { if (!item.data) { return } - if (!clickObj.data.is_click) { + if (!clickObj.data.is_click) { return } if (clickObj.data.device_type === 'scanner') { // 扫码器