diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml
deleted file mode 100644
index 5809545..0000000
--- a/Admin.Core.Api/Admin.Core.Model.xml
+++ /dev/null
@@ -1,4240 +0,0 @@
-
-
-
- Admin.Core.Model
-
-
-
-
- ApiResponse
-
-
-
-
- Status
-
-
-
-
- Value
-
-
-
-
- MessageModel
-
-
-
-
- ApiResponse
-
-
-
-
-
-
- StatusCode
-
-
-
-
- CODE200
-
-
-
-
- CODE401
-
-
-
-
- CODE403
-
-
-
-
- CODE404
-
-
-
-
- CODE500
-
-
-
-
- 通用分页信息类
-
-
-
-
- 当前页标
-
-
-
-
- 每页大小
-
-
-
-
- 时间范围
-
-
-
-
- 排序字段
-
-
-
-
- 排序方式
-
-
-
-
- 查询条件
-
-
-
-
- 通用分页信息类
-
-
-
-
- 当前页标
-
-
-
-
- 总页数
-
-
-
-
- 数据总数
-
-
-
-
- 每页大小
-
-
-
-
- 返回数据
-
-
-
-
- ResponseEnum
-
-
-
-
- 无权限
-
-
-
-
- 找不到指定资源
-
-
-
-
- 找不到指定资源
-
-
-
-
- 表格数据,支持分页
-
-
-
-
- 返回编码
-
-
-
-
- 返回信息
-
-
-
-
- 记录总数
-
-
-
-
- 返回数据集
-
-
-
-
- TokenInfoViewModel
-
-
-
-
- success
-
-
-
-
- token
-
-
-
-
- expires_in
-
-
-
-
- token_type
-
-
-
-
- 拆分的SAP BOM 信息
-
-
-
-
- 主键标识
-
-
-
-
- BOM编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 物料类别
-
-
-
-
- 标准数量
-
-
-
-
- 父级编号
-
-
-
-
- 工厂编号
-
-
-
-
- 产线/工位
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 祖级列表
-
-
-
-
- 打印名称
-
-
-
-
- 成品信息
-
-
-
-
- 主键标识
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 物料大类(100-冷柜)
-
-
-
-
- 物料小类
-
-
-
-
- SAP物料类型
-
-
-
-
- SAP物料类型
-
-
-
-
- 物料组
-
-
-
-
- 物料型号
-
-
-
-
- 所属工厂
-
-
-
-
- 产线工位
-
-
-
-
- 是否标识
-
-
-
-
- 是否标识
-
-
-
-
- 创建时间
-
-
-
-
- 修改人
-
-
-
-
- 修改时间
-
-
-
-
- 增量日期
-
-
-
-
- 入库方向-A/B
-
-
-
-
- SAP计划员(100=成品;200=箱体;300=门体)
-
-
-
-
- SAP订单信息
-
-
-
-
- 主键标识
-
-
-
-
- 物料名称
-
-
-
-
- 销售订单编号
-
-
-
-
- 销售订单行号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 物料组
-
-
-
-
- 订单计划数量
-
-
-
-
- 完成数量
-
-
-
-
- ORDER_TYPE
-
-
-
-
- 工单状态
-
-
-
-
- 开始日期
-
-
-
-
- 结束日期
-
-
-
-
- 工厂编码
-
-
-
-
- 是否标识
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 完成日期
-
-
-
-
- 是否已下达计划(0-是,1-否)
-
-
-
-
- 接收从条码系统获取的校验字符串
-
-
-
-
- 物料完成记录
-
-
-
-
- 主键
-
-
-
-
- 订单编号
-
-
-
-
- 物料条码
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 所属工位
-
-
-
-
- 所属产线
-
-
-
-
- 完成时间
-
-
-
-
- 工单编号
-
-
-
-
- 是否下线
-
-
-
-
- 老发泡线泡前库
-
-
-
-
- 主键
-
-
-
-
- 位置;东线泡前库;西线泡前库
-
-
-
-
- 货道类型
-
-
-
-
- 库存数量
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新时间
-
-
-
-
- 产品型号
-
-
-
-
- 产品名称
-
-
-
-
- SAP BOM 信息
-
-
-
-
- 主键标识
-
-
-
-
- BOM编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 物料类别
-
-
-
-
- 标准数量
-
-
-
-
- 父级编号
-
-
-
-
- 是否标识
-
-
-
-
- 灌注设备状态表
-
-
-
-
- 主键
-
-
-
-
- 设备名称;Perfusion:灌注
-
-
-
-
- 设备状态1运行、2停机、3故障
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 打印信息表
-
-
-
-
- 主键
-
-
-
-
- SAP计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 内胆已打印数量
-
-
-
-
- 箱壳已打印数量
-
-
-
-
- 创建时间
-
-
-
-
- 箱体发泡夹具完工数据
-
-
-
-
- 主键标识
-
-
-
-
- 产线编号
-
-
-
-
- 工位编号
-
-
-
-
- 夹具编号
-
-
-
-
- 夹具箱型
-
-
-
-
- 夹具状态
-
-
-
-
- 夹具产量
-
-
-
-
- 实际产量
-
-
-
-
- 固化实际设定值
-
-
-
-
- 固化时间实际值
-
-
-
-
- 记录时间
-
-
-
-
- 钣金任务完成表
-
-
-
-
- 主键
-
-
-
-
- 计划编号
-
-
-
-
- 工单编号
-
-
-
-
- 物料编号
-
-
-
-
- 钣金任务计划表
-
-
-
-
- 主键
-
-
-
-
- 工单编号
-
-
-
-
- 计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 任务执行数量
-
-
-
-
- 完成数量
-
-
-
-
- 前板数量
-
-
-
-
- 后板数量
-
-
-
-
- 开始时间
-
-
-
-
- 执行顺序
-
-
-
-
- 创建时间
-
-
-
-
- 是否执行中:1-执行,2-完成
-
-
-
-
- 任务类型
-
-
-
-
- 计划任务执行编号
-
-
-
-
- 质检项信息
-
-
-
-
- 主键标识
-
-
-
-
- 质检项/质量缺陷编号
-
-
-
-
- 质检项/质量缺陷名字
-
-
-
-
- 父级编号
-
-
-
-
- 启用标识
-
-
-
-
- 成品下线是否校验(0-不校验;1-校验)
-
-
-
-
- 货道明细
-
-
-
-
- 主键标识
-
-
-
-
- 所属仓库
-
-
-
-
- 货道编号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 物料类型
-
-
-
-
- 物料数量
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 货道信息
-
-
-
-
- 主键标识
-
-
-
-
- 货道编号
-
-
-
-
- 货道名称
-
-
-
-
- 货道容量
-
-
-
-
- 货道库存
-
-
-
-
- 货道状态
-
-
-
-
- 货道类型
-
-
-
-
- 所属仓库
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 物料类型A
-
-
-
-
- 夹具箱型
-
-
-
-
- 在途数量
-
-
-
-
- 出库数量
-
-
-
-
- 入库标识:1-允许入库;2-禁止入库
-
-
-
-
- 出库标识:1-允许出库;2-禁止出库
-
-
-
-
- 异常标识:1-正常货道;2-异常货道
-
-
-
-
- 物料类型B
-
-
-
-
- 物料类型C
-
-
-
-
- 物料类型(名称)A
-
-
-
-
- 物料类型(名称)B
-
-
-
-
- 物料类型(名称)C
-
-
-
-
- 分垛使用字段,箱体入库旋转角度(90,180,270)
-
-
-
-
- 分垛使用字段,是否大产品占两个货道,1-是;0-否
-
-
-
-
- 分垛使用字段,记录同型号上次入的货道,如FD01_002 == >记录上次货道ObjId
-
-
-
-
- SAP BOM
-
-
-
-
- 主键标识
-
-
-
-
- 仓库编号
-
-
-
-
- 仓库名称
-
-
-
-
- 仓库类型:1-集存库、2-线边库、3-立体库
-
-
-
-
- 仓库区域
-
-
-
-
- 仓库状态:1-空余;2-已满;3-异常
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 所属工厂
-
-
-
-
- 设备
-
-
-
-
- 主键
-
-
-
-
- 产品线 1、2
-
-
-
-
- 设备编码
-
-
-
-
- 排序
-
-
-
-
- 每班发泡信息
-
-
-
-
- 主键
-
-
-
-
- 设备表主键,夹具编号
-
-
-
-
- SAP订单
-
-
-
-
- 产品线 1、2
-
-
-
-
- 夹具箱型
-
-
-
-
- 夹具状态:0:停止;1生产
-
-
-
-
- 产量
-
-
-
-
- 固化时间设定值
-
-
-
-
- 固化时间实际值
-
-
-
-
- 1小时
-
-
-
-
- 2小时
-
-
-
-
- 3小时
-
-
-
-
- 4小时
-
-
-
-
- 5小时
-
-
-
-
- 6小时
-
-
-
-
- 7小时
-
-
-
-
- 8小时
-
-
-
-
- 9小时
-
-
-
-
- 10小时
-
-
-
-
- 11小时
-
-
-
-
- 12小时
-
-
-
-
- 侧板温度
-
-
-
-
- 内模温度
-
-
-
-
- 节拍
-
-
-
-
- 更新时间
-
-
-
-
- 工位编号
-
-
-
-
- 夹具实时数据
-
-
-
-
- 主键
-
-
-
-
- 夹具序号
-
-
-
-
- 公司
-
-
-
-
- 产线编码
-
-
-
-
- 工序
-
-
-
-
- 工位
-
-
-
-
- 夹具箱型
-
-
-
-
- 夹具状态
-
-
-
-
- 夹具产量
-
-
-
-
- 夹具固化时间设定值
-
-
-
-
- 夹具固化时间显示值
-
-
-
-
- 模具内温度
-
-
-
-
- 模具外温度
-
-
-
-
- 节拍
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 每日发泡信息数据记录表
-
-
-
-
- 主键SEQ_BOX_FOAMDATARECORD
-
-
-
-
- 产线 1、2
-
-
-
-
- 订单编码
-
-
-
-
- 夹具箱型
-
-
-
-
- 夹具状态:0:停止;1生产
-
-
-
-
- 产量
-
-
-
-
- 固化时间设定值
-
-
-
-
- 固化时间实际值
-
-
-
-
- 1小时
-
-
-
-
- 2小时
-
-
-
-
- 3小时
-
-
-
-
- 4小时
-
-
-
-
- 5小时
-
-
-
-
- 6小时
-
-
-
-
- 7小时
-
-
-
-
- 8小时
-
-
-
-
- 9小时
-
-
-
-
- 10小时
-
-
-
-
- 11小时
-
-
-
-
- 12小时
-
-
-
-
- 侧板温度
-
-
-
-
- 内模温度
-
-
-
-
- 节拍
-
-
-
-
- 更新时间
-
-
-
-
- 夹具历史数据
-
-
-
-
- 主键
-
-
-
-
- 公司
-
-
-
-
- 产线编码
-
-
-
-
- 工序
-
-
-
-
- 工位
-
-
-
-
- 夹具箱型
-
-
-
-
- 夹具状态
-
-
-
-
- 夹具产量
-
-
-
-
- 夹具固化时间设定值
-
-
-
-
- 夹具固化时间显示值
-
-
-
-
- 模具内温度
-
-
-
-
- 模具外温度
-
-
-
-
- 节拍
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 发泡计划
-
-
-
-
- 主键标识
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- SAP订单编码
-
-
-
-
- MES计划编号
-
-
-
-
- 计划数量
-
-
-
-
- 当班计划
-
-
-
-
- 产线
-
-
-
-
- 更新时间
-
-
-
-
- 创建时间
-
-
-
-
- 计划完成数量
-
-
-
-
- 工位编号
-
-
-
-
- 获取发泡机最后一枪记录
-
-
-
-
- 主键
-
-
-
-
- 所属系统;1系统 2系统
-
-
-
-
- 系统状态
-
-
-
-
- 枪编号;A1枪,B1枪,A2枪,B2枪
-
-
-
-
- 产线编号
-
-
-
-
- 枪POL注料温度
-
-
-
-
- 枪POL注料压力
-
-
-
-
- 枪POL注料流量
-
-
-
-
- 枪POL原料用量
-
-
-
-
- 枪ISO注料温度
-
-
-
-
- 枪ISO注料压力
-
-
-
-
- 枪ISO注料流量
-
-
-
-
- 枪ISO原料用量
-
-
-
-
- 枪注料工位号
-
-
-
-
- 枪设定注料时间
-
-
-
-
- 枪设定注料重量
-
-
-
-
- 枪设定注料比例
-
-
-
-
- 枪实际注料重量
-
-
-
-
- 枪实际注料比例
-
-
-
-
- 枪中压循环时间
-
-
-
-
- 枪高压循环时间
-
-
-
-
- 枪液压压力
-
-
-
-
- 枪液压温度
-
-
-
-
- 枪开枪时间
-
-
-
-
- 枪关枪时间
-
-
-
-
- 枪总产量
-
-
-
-
- 枪注料结束信号
-
-
-
-
- 创建时间
-
-
-
-
- 测温历史记录
-
-
-
-
- 主键
-
-
-
-
- 线号
-
-
-
-
- 工位号
-
-
-
-
- 产品条码
-
-
-
-
- 产品型号
-
-
-
-
- 基准型号
-
-
-
-
- 工作电压
-
-
-
-
- 测试通道
-
-
-
-
- 计划测试时间
-
-
-
-
- 实际测试时间
-
-
-
-
- 环温
-
-
-
-
- 开始测试时间
-
-
-
-
- 测试结果
-
-
-
-
- 测试结束时间
-
-
-
-
- 系统用户
-
-
-
-
- 备注
-
-
-
-
- 第几次测试
-
-
-
-
- 温度数据
-
-
-
-
- 功率数据
-
-
-
-
- 部件测试数据
-
-
-
-
- 故障代码
-
-
-
-
- 内部传感器 1 名称
-
-
-
-
- 内部传感器 2 名称
-
-
-
-
- 内部传感器 3 名称
-
-
-
-
- 内部传感器 4 名称
-
-
-
-
- 内部传感器 5 名称
-
-
-
-
- 内部传感器 6 名称
-
-
-
-
- 是否测试部件(”Y”测试)
-
-
-
-
- 低压启动测试时间
-
-
-
-
- 低压启动标准下限
-
-
-
-
- 低压启动标准上限
-
-
-
-
- 低压启动实际采集值
-
-
-
-
- 低压启动测试电压
-
-
-
-
- 创建时间
-
-
-
-
- 条码绑定记录
-
-
-
-
- 主键
-
-
-
-
- 箱体条码
-
-
-
-
- 箱体名称
-
-
-
-
- 成品码
-
-
-
-
- 绑定结果
-
-
-
-
- 条码1记录时间
-
-
-
-
- 条码2记录时间
-
-
-
-
- plc放行标志,2为放行通过,1为pda提示需要放行记录
-
-
-
-
- 存储当班班组
-
-
-
-
- 主键
-
-
-
-
- 班组名称
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 电检数据明细
-
-
-
-
- 标识
-
-
-
-
- 序号
-
-
-
-
- 项目名称
-
-
-
-
- 测试条件
-
-
-
-
- 测试值
-
-
-
-
- 测试结果
-
-
-
-
- 记录时间
-
-
-
-
- 门体发泡记录
-
-
-
-
- 主键
-
-
-
-
- 台车编号
-
-
-
-
- 枪号
-
-
-
-
- 模位状态;0=>不工作,1=>A门工作;2=>B门工作;3=>AB门工作
-
-
-
-
- 模位类型
-
-
-
-
- 模具产量A
-
-
-
-
- 模具产量B
-
-
-
-
- 创建时间
-
-
-
-
- 门体发泡记录
-
-
-
-
- 主键
-
-
-
-
- 计划编码
-
-
-
-
- 订单编码
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 门体计划数
-
-
-
-
- 完成数
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 创建时间
-
-
-
-
- 更新时间
-
-
-
-
- 门体匹配记录
-
-
-
-
- 主键标识
-
-
-
-
- 计划编号
-
-
-
-
- 订单编号
-
-
-
-
- 工厂编号
-
-
-
-
- 产线
-
-
-
-
- 工位编码
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 匹配时间
-
-
-
-
- 计划执行表
-
-
-
-
- 主键标识
-
-
-
-
- 执行计划编号
-
-
-
-
- 生产计划编号
-
-
-
-
- 工单编号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 产线/工位
-
-
-
-
- 计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 是否标识
-
-
-
-
- 执行顺序
-
-
-
-
- 执行方式:1-手动;2-自动
-
-
-
-
- 执行状态:1-待执行;2-执行中;3-完成
-
-
-
-
- 创建时间
-
-
-
-
- 任务类型
-
-
-
-
- 计划任务执行编号——钣金任务
-
-
-
-
- 产品简码
-
-
-
-
- 夹具型号
-
-
-
-
- y
-
-
-
-
- 条码下线信息记录
-
-
-
-
- 主键标识
-
-
-
-
- 所属产线
-
-
-
-
- 灌注告警
-
-
-
-
- 灌注
-
-
-
-
- 箱体码
-
-
-
-
- 报警状态码
-
-
-
-
- 报警信息
-
-
-
-
- 灌注是否完成
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 灌注记录表
-
-
-
-
- 主键
-
-
-
-
- 实际灌注量
-
-
-
-
- 灌注压力_R
-
-
-
-
- 灌注压力_L
-
-
-
-
- 灌注时长
-
-
-
-
- 产量
-
-
-
-
- 箱体码
-
-
-
-
- 冷媒类型;左侧冷媒型号
-
-
-
-
- 冷媒类型;右侧侧冷媒型号
-
-
-
-
- 设置灌注量
-
-
-
-
- 系统;0,右系统 1,左系统
-
-
-
-
- 灌注结果
-
-
-
-
- 灌注完成状态字
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 打印条码信息
-
-
-
-
- 主键
-
-
-
-
- SAP计划编号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 条码
-
-
-
-
- 打印时间
-
-
-
-
- 补打个数
-
-
-
-
- 打印类型:箱壳、内胆
-
-
-
-
- 订单执行表
-
-
-
-
- 主键
-
-
-
-
- 工单编号
-
-
-
-
- 工单编号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 物料名称
-
-
-
-
- 订单计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 工单类型
-
-
-
-
- 工单状态
-
-
-
-
- 开始时间
-
-
-
-
- 完成时间
-
-
-
-
- 创建时间
-
-
-
-
- 从SAP中拆分出来的工位信息
-
-
-
-
- 主键标识
-
-
-
-
- 计划编号
-
-
-
-
- 工单编号
-
-
-
-
- 销售订单编号
-
-
-
-
- 销售订单行号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 产线/工位
-
-
-
-
- 计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 库存任务实时处理
-
-
-
-
- 主键标识
-
-
-
-
- 任务编号
-
-
-
-
- 任务形式:0-自动;1-手动
-
-
-
-
- 任务类型:1-入库;2-出库
-
-
-
-
- 任务状态:1-待执行;2-执行中;3-完成
-
-
-
-
- 计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料类型
-
-
-
-
- 货道编号
-
-
-
-
- 货道名称
-
-
-
-
- 计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 是否标识
-
-
-
-
- 仓库编号
-
-
-
-
- 创建时间
-
-
-
-
- 完成记录
-
-
-
-
- 主键标识
-
-
-
-
- 计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 计划工位
-
-
-
-
- 完成数量
-
-
-
-
- 下线数量
-
-
-
-
- 实际产量
-
-
-
-
- 记录时间
-
-
-
-
- 是否标识
-
-
-
-
- 电检数据记录
-
-
-
-
- 唯一标识
-
-
-
-
- 测试总结果
-
-
-
-
- 产品条码
-
-
-
-
- 测试时间
-
-
-
-
- 测试数据
-
-
-
-
- 记录时间
-
-
-
-
- 入库记录
-
-
-
-
- 主键标识
-
-
-
-
- 仓库编号
-
-
-
-
- 仓库区域
-
-
-
-
- 货道编号
-
-
-
-
- 物料类型
-
-
-
-
- 物料编号
-
-
-
-
- 入库数量
-
-
-
-
- 入库时间
-
-
-
-
- 物料条码编号
-
-
-
-
- 物料名称
-
-
-
-
- 入库方式(0-正常,1-异常)
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 出库记录
-
-
-
-
- 主键标识
-
-
-
-
- 仓库编号
-
-
-
-
- 仓库区域
-
-
-
-
- 货道编号
-
-
-
-
- 物料编号
-
-
-
-
- 物料名称
-
-
-
-
- 出库数量
-
-
-
-
- 出库时间
-
-
-
-
- 物料条码编号
-
-
-
-
- 物料类型
-
-
-
-
- 出库方式(0-正常,1-异常)
-
-
-
-
- 是否标识
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 完成记录
-
-
-
-
- 主键标识
-
-
-
-
- 计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 计划工位
-
-
-
-
- 完成数量
-
-
-
-
- 记录时间
-
-
-
-
- 是否标识
-
-
-
-
- 完成记录
-
-
-
-
- 主键标识
-
-
-
-
- 计划编号
-
-
-
-
- 物料编号
-
-
-
-
- 计划工位
-
-
-
-
- 完成数量
-
-
-
-
- 下线数量
-
-
-
-
- 实际产量
-
-
-
-
- 记录时间
-
-
-
-
- 是否标识
-
-
-
-
- 质检记录
-
-
-
-
- 主键
-
-
-
-
- 箱体条码
-
-
-
-
- 物料名称
-
-
-
-
- 工序编号
-
-
-
-
- 检测项(工位)编号
-
-
-
-
- 质量缺陷编码
-
-
-
-
- 质量缺陷名称
-
-
-
-
- 质检处理措施(3=合格,1=返修)
-
-
-
-
- 返修处理结果
-
-
-
-
- 是否下静态线(1-是;2-否)
-
-
-
-
- 班组编号
-
-
-
-
- 检测人员
-
-
-
-
- 检测时间
-
-
-
-
- 返修次数
-
-
-
-
- 返修完成时间
-
-
-
-
- 返修结果(1=正常,2=异常)
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
-
-
- 检测人工位编号
-
-
-
-
- 钣金每日生产记录表
-
-
-
-
- 主键-guid
-
-
-
-
- 计划编码
-
-
-
-
- 产品编码
-
-
-
-
- 产品名称
-
-
-
-
- 生产类型;0--前板,1--后板
-
-
-
-
- 生产新时间
-
-
-
-
- 上位机同步钣金设备设置的物料型号
-
-
-
-
- 主键
-
-
-
-
- 产品ID
-
-
-
-
- 同步型号
-
-
-
-
- 设置型号
-
-
-
-
- 同步时间
-
-
-
-
- 类别 1=>前板,2=》后板
-
-
-
-
- 创建时间
-
-
-
-
- bom设置
-
-
-
-
- 产品型号编码——主键产品型号
-
-
-
-
- 产品型号编码——主键产品型号
-
-
-
-
- 产品型号编码——主键产品型号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 对应型号
-
-
-
-
- 创建时间
-
-
-
-
- 用户信息
-
-
-
-
- 用户Id,自增主键
-
-
-
-
- 用户名称
-
-
-
-
- 用户密码
-
-
-
-
- 测温历史记录
-
-
-
-
- 主键
-
-
-
-
- 线号
-
-
-
-
- 工位号
-
-
-
-
- 产品条码
-
-
-
-
- 产品型号
-
-
-
-
- 基准型号
-
-
-
-
- 工作电压
-
-
-
-
- 测试通道
-
-
-
-
- 计划测试时间
-
-
-
-
- 实际测试时间
-
-
-
-
- 环温
-
-
-
-
- 开始测试时间
-
-
-
-
- 测试结果
-
-
-
-
- 测试结束时间
-
-
-
-
- 系统用户
-
-
-
-
- 备注
-
-
-
-
- 第几次测试
-
-
-
-
- 温度数据
-
-
-
-
- 功率数据
-
-
-
-
- 部件测试数据
-
-
-
-
- 故障代码
-
-
-
-
- 内部传感器 1 名称
-
-
-
-
- 内部传感器 2 名称
-
-
-
-
- 内部传感器 3 名称
-
-
-
-
- 内部传感器 4 名称
-
-
-
-
- 内部传感器 5 名称
-
-
-
-
- 内部传感器 6 名称
-
-
-
-
- 是否测试部件(”Y”测试)
-
-
-
-
- 低压启动测试时间
-
-
-
-
- 低压启动标准下限
-
-
-
-
- 低压启动标准上限
-
-
-
-
- 低压启动实际采集值
-
-
-
-
- 低压启动测试电压
-
-
-
-
- 同步标识
-
-
-
-
- 条码绑定扫描类型统计
-
-
-
-
- 箱体名称
-
-
-
-
- 数量
-
-
-
-
- 获取每日班组时间
-
-
-
-
- 开始时间
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 小时
-
-
-
-
- 班组
-
-
-
-
- 泡前库入库相信展示
-
-
-
-
- 序号
-
-
-
-
- 货道号
-
-
-
-
- 产品条码
-
-
-
-
- 产品型号
-
-
-
-
- 入库时间
-
-
-
-
- Dto
-
-
-
-
- 获取订单物料型号
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 部件型号
-
-
-
-
- 条码打印物料信息
-
-
-
-
- 订单编号
-
-
-
-
- 产品编号
-
-
-
-
- 订单数量
-
-
-
-
- 产品型号
-
-
-
-
- 内胆数量
-
-
-
-
- 箱体数量
-
-
-
-
- 完成量
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 物料数量
-
-
-
-
- 异常量
-
-
-
-
- 内胆码已打量
-
-
-
-
- 箱壳码已打量
-
-
-
-
- 剩余数量
-
-
-
-
- 打印名称
-
-
-
-
- 创建时间
-
-
-
-
- 工位信息
-
-
-
-
- 公司编码
-
-
-
-
- 产品线
-
-
-
-
- 工序
-
-
-
-
- 工位
-
-
-
-
- 公司
-
-
-
-
- 产线编码
-
-
-
-
- 工序
-
-
-
-
- 工位
-
-
-
-
- 小时
-
-
-
-
- 物料名称
-
-
-
-
- 前板数量
-
-
-
-
- 后板数量
-
-
-
-
- 计划编码
-
-
-
-
- 订单查询
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 前板数量
-
-
-
-
- 后板数量
-
-
-
-
- 物料名称
-
-
-
-
- 前板数量
-
-
-
-
- 后板数量
-
-
-
-
- 钣金计划
-
-
-
-
- 下发计划的ID
-
-
-
-
- 计划编码
-
-
-
-
- 订单编码
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 产线工位
-
-
-
-
- 计划数量
-
-
-
-
- 完成数量
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 产品型号
-
-
-
-
- 主键
-
-
-
-
- 计划Code
-
-
-
-
- 订单Code
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 物料编码
-
-
-
-
- 物料名称
-
-
-
-
- 物料名称
-
-
-
-
- 计划编码
-
-
-
-
- 开始时间
-
-
-
-
- 开始时间
-
-
-
-
- 执行状态
-
-
-
-
- 计划类型(1=联合下发;2=前板下发;3=后板下发)
-
-
-
-
- 计划数量
-
-
-
-
- 计划数量
-
-
-
-
- 任务编码
-
-
-
-
- 前板数量
-
-
-
-
- 后板数量
-
-
-
-
- 执行顺序
-
-
-
-
- 产线编码
-
-
-
-
- 产线编码
-
-
-
-
- 时间
-
-
-
-
- 小时
-
-
-
-
- 背板数量
-
-
-
-
- 前板数量
-
-
-
-
- 条码绑定扫描类型统计
-
-
-
-
- 开始时间
-
-
-
-
- 结束时间
-
-
-
-
- 工位信息
-
-
-
-
- 序号
-
-
-
-
- 计划信息
-
-
-
-
- 订单号
-
-
-
-
- 物料名称
-
-
-
-
- 物料名称
-
-
-
-
- 产品编码
-
-
-
-
- 产品名称
-
-
-
-
- 工艺编码
-
-
-
-
- 工艺编号
-
-
-
-
- 分类
-
-
-
-
- 物料大类
-
-
-
-
- 物料小类
-
-
-
-
- 订单数量
-
-
-
-
- 剩余数量
-
-
-
-
- 开始日期
-
-
-
-
diff --git a/Aucma.Core.SheetMetalTasks/Aucma.Core.SheetMetalTasks.csproj b/Aucma.Core.DataCollector/Aucma.Core.DataCollector.csproj
similarity index 62%
rename from Aucma.Core.SheetMetalTasks/Aucma.Core.SheetMetalTasks.csproj
rename to Aucma.Core.DataCollector/Aucma.Core.DataCollector.csproj
index f492bc0..16f55ec 100644
--- a/Aucma.Core.SheetMetalTasks/Aucma.Core.SheetMetalTasks.csproj
+++ b/Aucma.Core.DataCollector/Aucma.Core.DataCollector.csproj
@@ -8,7 +8,10 @@
+
+
+
diff --git a/Aucma.Core.DataCollector/DataCollectorFactory.cs b/Aucma.Core.DataCollector/DataCollectorFactory.cs
new file mode 100644
index 0000000..a6e120f
--- /dev/null
+++ b/Aucma.Core.DataCollector/DataCollectorFactory.cs
@@ -0,0 +1,152 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.DataCollector.Factory;
+using Aucma.Core.HwPLc;
+using log4net;
+using NPOI.SS.Formula.Functions;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.DataCollector
+{
+ ///
+ /// 设备数据采集
+ ///
+ public abstract class DataCollectorFactory
+ {
+ public readonly log4net.ILog _logger = LogManager.GetLogger(typeof(DataCollectorFactory));
+
+ public readonly IBaseDeviceParamServices _deviceParamServices;
+ public readonly IRecordDeviceAlarmInfoServices _deviceAlarmInfoServices;
+ public readonly IRecordDeviceElectricityServices _deviceElectricityServices;
+
+ public int AlarmReadTimer = (1000 * 5);
+ public int EleReadTimer = (1000 * 60 * 5);
+
+ public DataCollectorFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices)
+ {
+ _deviceParamServices = deviceParamServices;
+ _deviceAlarmInfoServices = deviceAlarmInfoServices;
+ _deviceElectricityServices = deviceElectricityServices;
+ }
+
+ ///
+ /// 采集设备报警信息
+ ///
+ ///
+ public abstract void CollectDeviceAlarmInfo(out List deviceAlarmInfos);
+
+ ///
+ /// 采集设备用电
+ ///
+ ///
+ public abstract void CollectDeviceElectricity(out List deviceElectricitys);
+
+ ///
+ /// 根据PLC地址读取设备用电
+ ///
+ ///
+ ///
+ ///
+ public void ReadDeviceElectricity(string[] address,IPlc plc,ref Record_DeviceElectricity deviceElectricity)
+ {
+ var ground = plc.ReadRandomInt32(address);
+ if (ground != null)
+ {
+ if (ground.Length >= 10)
+ {
+ var info = ParseAndReverseByteArray(ground, 0, address.Length * 2);
+ if(info != null)
+ {
+ if(info.Length >= 10)
+ {
+ //deviceElectricity.Glys = ground[0];
+ deviceElectricity.Va = (decimal)info[0]/100;
+ deviceElectricity.Vb = (decimal)info[1]/100;
+ deviceElectricity.Vc = (decimal)info[2]/100;
+ deviceElectricity.Ia = (decimal)info[6]/100;
+ deviceElectricity.Ib = (decimal)info[7]/100;
+ deviceElectricity.Ic = (decimal)info[8]/100;
+ deviceElectricity.Zxyg = (decimal)info[9]/100;
+ deviceElectricity.CollectType = 0;
+ deviceElectricity.CollectTime = DateTime.Now;
+ deviceElectricity.RecordTime = DateTime.Now;
+ }
+ }
+
+
+ }
+ }
+ else
+ {
+ deviceElectricity = null;
+ }
+ }
+
+ ///
+ /// 读取PLC数据
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void ReadParamValueByPlc(IPlc _plc, string addr, string dataType, out int paramValue)
+ {
+ object result = null;
+ switch (dataType)
+ {
+ case "int":
+ result = _plc.ReadInt16(addr);
+ break;
+ case "float":
+ result = _plc.ReadFloat(addr);
+ break;
+ case "bool":
+ result = _plc.ReadBool(addr);
+ break;
+ default:
+ result = _plc.ReadInt16(addr);
+ break;
+ }
+
+ if (result == null)
+ {
+ result = "0";
+ }
+
+ paramValue = Convert.ToInt32(result);
+ }
+
+ ///
+ /// 电表数据解析
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private int[] ParseAndReverseByteArray(byte[] data, int startIndex, int length)
+ {
+ if (data == null || data.Length < startIndex + length)
+ {
+ throw new ArgumentException("Invalid data or startIndex/length parameter.");
+ }
+
+ int[] resultArray = new int[length / 2];
+ for (int i = 0; i < resultArray.Length; i++)
+ {
+ byte[] subset = new byte[2];
+ Array.Copy(data, startIndex + (i * 2), subset, 0, 2);
+ Array.Reverse(subset);
+ string hexString = BitConverter.ToString(subset).Replace("-", "");
+ resultArray[i] = Convert.ToInt32(hexString, 16);
+ }
+
+ return resultArray;
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/DataCollectorSetup.cs b/Aucma.Core.DataCollector/DataCollectorSetup.cs
new file mode 100644
index 0000000..263dce6
--- /dev/null
+++ b/Aucma.Core.DataCollector/DataCollectorSetup.cs
@@ -0,0 +1,116 @@
+using Admin.Core.Common;
+using Admin.Core.IService.IService_New;
+using Aucma.Core.DataCollector.Factory;
+using log4net;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+using Org.BouncyCastle.Crypto.Tls;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.DataCollector
+{
+ public static class DataCollectorSetup
+ {
+ public static readonly log4net.ILog _logger = LogManager.GetLogger(typeof(DataCollectorSetup));
+
+ public static IApplicationBuilder UseDataCollectorExtensions(this IApplicationBuilder app)
+ {
+ if (app == null) throw new ArgumentNullException(nameof(app));
+
+ var stationCode = Appsettings.app("StationInfo", "StationCode");
+
+ var _deviceParamServices = app.ApplicationServices.GetService();
+ var _deviceAlarmInfoServices = app.ApplicationServices.GetService();
+ var _deviceElectricityServices = app.ApplicationServices.GetService< IRecordDeviceElectricityServices>();
+
+ if (!string.IsNullOrEmpty(stationCode))
+ {
+ try
+ {
+ if (stationCode == "1002") //箱壳、内胆,包含预装线、集存库
+ {
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new LinerStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+ }
+ else if (stationCode == "1005")//泡前库、发泡线、发泡机、泡后库
+ {
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new BoxFoamFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+ }
+ else if (stationCode == "1010")//成品分垛
+ {
+ //Task.Run(() =>
+ //{
+ // DataCollectorFactory collector = new PalletizFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ // Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ //});
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new LinerStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new ShellPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new LinerPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+
+ Task.Run(() =>
+ {
+ DataCollectorFactory collector = new FoamBackFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
+
+ Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
+ });
+ }
+ }catch(Exception ex)
+ {
+ _logger.Error($"UseDataCollectorExtensions逻辑执行异常:{ex.Message}");
+ }
+ }
+ else
+ {
+ new InvalidOperationException($"设备数据采集逻辑初始化失败:未获取到工位编号");
+ }
+
+
+ return app;
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/BeforeFoamFactory.cs b/Aucma.Core.DataCollector/Factory/BeforeFoamFactory.cs
new file mode 100644
index 0000000..2ed3682
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/BeforeFoamFactory.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:Aucma.Core.DataCollector.Factory
+* 唯一标识:a4c93b2e-0cca-4fc8-be63-7f560c451cd9
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-03-28 11:16:52
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 泡前数据采集
+ ///
+ public class BeforeFoamFactory
+ {
+
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/BoxFoamFactory.cs b/Aucma.Core.DataCollector/Factory/BoxFoamFactory.cs
new file mode 100644
index 0000000..302ce3b
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/BoxFoamFactory.cs
@@ -0,0 +1,91 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 箱体发泡数据采集
+ ///
+ public class BoxFoamFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
+
+ public BoxFoamFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ ///
+ /// 采集泡前库、发泡线、发泡机、泡后库设备报警信息
+ ///
+ ///
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00009");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
+ }
+ }
+ }
+
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/FoamBackFactory.cs b/Aucma.Core.DataCollector/Factory/FoamBackFactory.cs
new file mode 100644
index 0000000..1249735
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/FoamBackFactory.cs
@@ -0,0 +1,186 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:Aucma.Core.DataCollector.Factory
+* 唯一标识:d14bf35f-5d0b-4d74-a9a8-f7781f5c12cd
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-03-28 11:15:55
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 泡后数据采集
+ ///
+ public class FoamBackFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("FoamBack"));
+
+ public FoamBackFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡后库设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00009");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("FoamBack"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集泡后库设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡后库设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+ //泡后集存库(10柜-主柜)
+ string[] address_10 = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_10 = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00009_0001"
+ };
+
+ base.ReadDeviceElectricity(address_10, plc, ref _deviceElectricity_10);
+
+ if(_deviceElectricity_10 != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_10);
+ }
+
+ //泡后集存库(09柜-分柜)IP10.10.92.40
+ string[] address_09 = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
+
+ Record_DeviceElectricity _deviceElectricity_09 = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00009_0002"
+ };
+
+ base.ReadDeviceElectricity(address_09, plc, ref _deviceElectricity_09);
+
+ if (_deviceElectricity_09 != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_09);
+ }
+
+ //泡后集存库(12柜-分柜)
+ string[] address_12 = new string[] { "D7752", "D7764", "D7766", "D7768", "D7760", "D7762", "D7780", "D7784", "D7788", "D7792" };
+
+ Record_DeviceElectricity _deviceElectricity_12 = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00009_0003"
+ };
+
+ base.ReadDeviceElectricity(address_12, plc, ref _deviceElectricity_12);
+
+ if (_deviceElectricity_12 != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_12);
+ }
+
+ if(deviceElectricitys.Count > 0)
+ {
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+ }
+ else
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡后库设备用电数据失败,数据为空");
+ }
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("FoamBack"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集泡后库设备用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/LinerPreassembleFactory.cs b/Aucma.Core.DataCollector/Factory/LinerPreassembleFactory.cs
new file mode 100644
index 0000000..2823b67
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/LinerPreassembleFactory.cs
@@ -0,0 +1,167 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:Aucma.Core.DataCollector.Factory
+* 唯一标识:81c294d4-c4ab-4504-b193-9a5d013383d3
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-03-28 11:57:37
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace Aucma.Core.DataCollector.Factory
+{
+ public class LinerPreassembleFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerPreassemble"));
+ public LinerPreassembleFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆预装设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00024");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerPreassemble"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集内胆预装设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆预装设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+ // 地面内胆预装主柜
+ string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00024_0001"
+ };
+
+ base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
+
+ if(_deviceElectricity_ground != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_ground);
+ }
+
+ //平台内胆预装远程
+ string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
+
+ Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00024_0002"
+ };
+
+ base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
+
+ if (_deviceElectricity_platform != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_platform);
+ }
+
+ if(deviceElectricitys.Count > 0)
+ {
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+ }
+ else
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆预装设备用电数据失败,数据为空");
+ }
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerPreassemble"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集内胆预装用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/LinerStoreFactory.cs b/Aucma.Core.DataCollector/Factory/LinerStoreFactory.cs
new file mode 100644
index 0000000..eda4bc3
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/LinerStoreFactory.cs
@@ -0,0 +1,138 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 内胆预装、内胆库数据采集
+ ///
+ public class LinerStoreFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerStore"));
+
+ public LinerStoreFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ ///
+ /// 采集内胆库设备报警信息
+ ///
+ ///
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆库设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00032");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerStore"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集内胆库设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆库设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+ string[] address = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_address = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00032_0001"
+ };
+
+ base.ReadDeviceElectricity(address, plc, ref _deviceElectricity_address);
+
+ if( _deviceElectricity_address != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_address);
+ }
+
+ if(deviceElectricitys.Count > 0 )
+ {
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+ }
+ else
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆库设备用电数据失败,数据为空");
+ }
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerStore"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集内胆库设备用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/PalletizFactory.cs b/Aucma.Core.DataCollector/Factory/PalletizFactory.cs
new file mode 100644
index 0000000..b74c159
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/PalletizFactory.cs
@@ -0,0 +1,184 @@
+using Admin.Core.Common.Helper;
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using log4net;
+using System.Globalization;
+
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 分垛入库数据采集
+ ///
+ public class PalletizFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Palletiz"));
+
+ public PalletizFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ ///
+ /// 采集成品分垛设备报警信息
+ ///
+ ///
+ ///
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while(true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集成品分垛设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00002");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Palletiz"));
+ }
+ }
+ catch(Exception ex)
+ {
+ base._logger.Error($"采集成品分垛设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ ///
+ /// 采集设备用电信息
+ ///
+ ///
+ ///
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+
+ string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
+ {
+ MonitorId = "E0003"
+ };
+
+ base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
+
+ deviceElectricitys.Add(_deviceElectricity_ground);
+
+ string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
+
+ Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
+ {
+ MonitorId = "E0004"
+ };
+
+ base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
+
+ deviceElectricitys.Add(_deviceElectricity_platform);
+
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Palletiz"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集成品分垛设备用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+
+ public byte[] array(byte[] data)
+ {
+ if (data == null) return null;
+ for (int i = 0; i < data.Length; i += 2)
+ {
+ byte temp = data[i];
+ data[i] = data[i + 1];
+ data[i + 1] = temp;
+ }
+
+ return data;
+ }
+
+ ///
+ /// 用电数据解析
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private int[] ParseAndReverseByteArray(byte[] data, int startIndex, int length)
+ {
+ if (data == null || data.Length < startIndex + length)
+ {
+ throw new ArgumentException("Invalid data or startIndex/length parameter.");
+ }
+
+ int[] resultArray = new int[length / 2];
+ for (int i = 0; i < resultArray.Length; i++)
+ {
+ byte[] subset = new byte[2];
+ Array.Copy(data, startIndex + (i * 2), subset, 0, 2);
+ Array.Reverse(subset);
+ string hexString = BitConverter.ToString(subset).Replace("-", "");
+ resultArray[i] = Convert.ToInt32(hexString, 16);
+ }
+
+ return resultArray;
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/ShellPreassembleFactory.cs b/Aucma.Core.DataCollector/Factory/ShellPreassembleFactory.cs
new file mode 100644
index 0000000..5f672ea
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/ShellPreassembleFactory.cs
@@ -0,0 +1,166 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:Aucma.Core.DataCollector.Factory
+* 唯一标识:f88ccab0-cc8a-4d6f-8be8-1a0dbc687b9e
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-03-28 11:53:14
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 箱壳预装数据采集
+ ///
+ public class ShellPreassembleFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellPreassemble"));
+
+ public ShellPreassembleFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳预装设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00019");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellPreassemble"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集箱壳预装设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳预装设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+ // 地面箱壳预装远程
+ string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00019_0001"
+ };
+
+ base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
+
+ if(_deviceElectricity_ground != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_ground);
+ }
+
+ //平台箱壳预装主柜
+ string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
+
+ Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00019_0002"
+ };
+
+ base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
+
+ if(_deviceElectricity_platform != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_platform);
+ }
+
+ if(deviceElectricitys.Count > 0)
+ {
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+ }
+ else
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳预装设备用电数据失败,数据为空");
+ }
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellPreassemble"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集箱壳库设备用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+ }
+}
diff --git a/Aucma.Core.DataCollector/Factory/ShellStoreFactory.cs b/Aucma.Core.DataCollector/Factory/ShellStoreFactory.cs
new file mode 100644
index 0000000..2bf9978
--- /dev/null
+++ b/Aucma.Core.DataCollector/Factory/ShellStoreFactory.cs
@@ -0,0 +1,158 @@
+using Admin.Core.IService.IService_New;
+using Admin.Core.Model.Model_New;
+using Aucma.Core.HwPLc;
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.DataCollector.Factory
+{
+ ///
+ /// 箱壳库数据采集
+ ///
+ public class ShellStoreFactory : DataCollectorFactory
+ {
+ private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellStore"));
+
+ public ShellStoreFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
+ {
+ }
+
+ ///
+ /// 采集箱壳库设备报警信息
+ ///
+ ///
+ public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos)
+ {
+ while (true)
+ {
+ try
+ {
+
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳库设备报警信息");
+ var plc = _plc.plc;
+
+ var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00031");
+
+ if (deviceParams != null)
+ {
+ deviceAlarmInfos = new List();
+ string batchId = System.Guid.NewGuid().ToString("N");
+ foreach (var item in deviceParams)
+ {
+ base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
+
+ if (paramValue != 0)
+ {
+ deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
+ {
+ BatchId = batchId,
+ DeviceCode = item.DeviceCode,
+ DeviceType = "1",
+ ParamCode = item.ParamCode,
+ ParamValue = paramValue.ToString(),
+ AlarmInfo = item.ParamName,
+ AlarmTime = DateTime.Now,
+ CreadtedTime = DateTime.Now,
+ });
+ }
+
+ }
+ if (deviceAlarmInfos.Count > 0)
+ {
+ base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
+ }
+ }
+ Task.Delay(base.AlarmReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.AlarmReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellStore"));
+ }
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集箱壳库设备报警信息异常:{ex.Message}");
+ }
+ }
+ }
+
+ ///
+ /// 采集箱壳库设备用电
+ ///
+ ///
+ public override void CollectDeviceElectricity(out List deviceElectricitys)
+ {
+ while (true)
+ {
+ try
+ {
+ if (_plc != null)
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳库设备用电数据");
+ var plc = _plc.plc;
+
+ deviceElectricitys = new List();
+
+ //箱壳主柜
+ string[] mainCabinet = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
+
+ Record_DeviceElectricity _deviceElectricity_mainCabinet = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00031_0001"
+ };
+
+ base.ReadDeviceElectricity(mainCabinet, plc, ref _deviceElectricity_mainCabinet);
+
+ if(_deviceElectricity_mainCabinet != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_mainCabinet);
+ }
+
+ //箱壳远程柜
+ string[] rangeCabinet = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
+
+ Record_DeviceElectricity _deviceElectricity_rangeCabinet = new Record_DeviceElectricity()
+ {
+ MonitorId = "E00031_0002"
+ };
+
+ base.ReadDeviceElectricity(rangeCabinet, plc, ref _deviceElectricity_rangeCabinet);
+
+ if(_deviceElectricity_rangeCabinet != null)
+ {
+ deviceElectricitys.Add(_deviceElectricity_rangeCabinet);
+ }
+
+ if(deviceElectricitys.Count > 0)
+ {
+ var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
+ }
+ else
+ {
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳库设备用电数据失败,数据为空");
+ }
+
+ Task.Delay(base.EleReadTimer).Wait();
+ }
+ else
+ {
+ Task.Delay(base.EleReadTimer).Wait();
+ _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellStore"));
+ }
+
+ }
+ catch (Exception ex)
+ {
+ base._logger.Error($"采集箱壳库设备用电数据采集异常:{ex.Message}");
+ }
+ }
+ }
+ }
+}
diff --git a/Aucma.Core.SheetMetalTasks/AucamSheetMetalTaskService.cs b/Aucma.Core.SheetMetalTasks/AucamSheetMetalTaskService.cs
deleted file mode 100644
index 624ed7e..0000000
--- a/Aucma.Core.SheetMetalTasks/AucamSheetMetalTaskService.cs
+++ /dev/null
@@ -1,2036 +0,0 @@
-using Admin.Core.Common;
-using Admin.Core.IService;
-using Admin.Core.Model;
-using Admin.Core.Model.ViewModels;
-using System.Text;
-using Aucma.Core.HwPLc;
-using log4net;
-using Aucma.Core.SheetMetalTasks.Models;
-using StackExchange.Profiling.Internal;
-
-namespace Aucma.Core.SheetMetalTasks
-{
- ///
- /// 任务列表
- ///
- public class AucamSheetMetalTaskService : IAucamSheetMetalTaskService
- {
- private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(AucamSheetMetalTaskService));
-
- #region 刷新创建计划
- ///
- /// 刷新创建计划
- ///
- public delegate Task RefreshCretaePlanInfo();
- public static event RefreshCretaePlanInfo RefreshCreatePlanInfoEvent;
- #endregion
-
- #region 刷新图表
- ///
- /// 刷新创建计划
- ///
- public delegate Task RefreshChat();
- public static event RefreshChat RefreshChatEvent;
- #endregion
-
- #region 刷新创建计划
- ///
- /// 刷新创建计划
- ///
- public delegate void RefreshPlanInfo(SheetMetaSendPlanInfoView planInfo);
- public static event RefreshPlanInfo RefreshPlanInfoEvent;
- #endregion
-
- #region 刷新当前正在执行的计划
- ///
- /// 刷新当前正在执行的计划
- ///
- public delegate void RefreshCurrentPlanInfo();
- public static event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent;
-
- #endregion
-
- #region 给设备监控模块显示
- ///
- /// 刷新当前正在执行的计划
- ///
- public delegate void RefreshExecInfo(string message, string color);
- public static event RefreshExecInfo RefreshExecInfoEvent;
-
- #endregion
-
- protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
- protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
- protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
- protected readonly IProductPlanInfoServices _productPlanInfoServices;
- protected readonly ISysUserInfoServices? _sysUserInfoServices;
- protected readonly IMaterialCompletionServices? _materialCompletionServices;
- protected readonly ISmSyncModelServices? _smSyncModelServices;
- public HwPLc.PlcModel obj_backPanel = null;
- public HwPLc.PlcModel obj_sidePanel = null;
- bool backFlag = true;//后板标识
- bool sideFlag = true;//前板标识
- bool statusFlag = true;//计划任务状态标识
- bool complatePlanFlag = true;//计划完成
-
- #region 构造函数
- ///
- /// 构造函数
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public AucamSheetMetalTaskService(IExecutePlanInfoServices executePlanInfoServices, IRecordSidePanelComplateServices recordSidePanelComplateServices,
- IRecordBackPanelComplateServices recordBackPanelComplateServices, IProductPlanInfoServices productPlanInfoServices,
- ISysUserInfoServices sysUserInfoServices, IMaterialCompletionServices materialCompletionServices, ISmSyncModelServices smSyncModelServices)
- {
- _executePlanInfoServices = executePlanInfoServices;
- _sidePanelComplateServices = recordSidePanelComplateServices;
- _backPanelComplateServices = recordBackPanelComplateServices;
- _productPlanInfoServices = productPlanInfoServices;
- _sysUserInfoServices = sysUserInfoServices;
- _materialCompletionServices = materialCompletionServices;
- _smSyncModelServices = smSyncModelServices;
- }
- #endregion
-
- #region 启动任务下发
-
- #region 前板任务下发
- ///
- /// 前板任务下发
- ///
- ///
- public async Task SendSidePanelPlan()
- {
- // await InitSendSidePanelPlan();//前板任务
- // 设备状态刷新定时器
- System.Timers.Timer timer = new System.Timers.Timer(1000);
- timer.Elapsed += new System.Timers.ElapsedEventHandler(InitSendSidePanelPlan);
- timer.AutoReset = true;
- timer.Enabled = true;
- timer.Start();
-
- await Task.CompletedTask;
- }
- #endregion
-
- #region 后板任务
- public async Task SendBackPanelPlan()
- {
- System.Timers.Timer timer = new System.Timers.Timer(1000);
- timer.Elapsed += new System.Timers.ElapsedEventHandler(InitSendBackPanelPlan);
- timer.AutoReset = true;
- timer.Enabled = true;
- timer.Start();
-
- await Task.CompletedTask;
- }
- #endregion
-
- #region 完成任务执行
- public async Task ExecUpdateComplatePlan()
- {
- System.Timers.Timer timer = new System.Timers.Timer(1000);
- timer.Elapsed += new System.Timers.ElapsedEventHandler(UpdateComplatePlan);
- timer.AutoReset = true;
- timer.Enabled = true;
- timer.Start();
-
- await Task.CompletedTask;
- }
- #endregion
-
- #region 完结任务
- public async Task ExecProcessTheEndTask()
- {
- // 设备状态刷新定时器
- System.Timers.Timer timer = new System.Timers.Timer(1000);
- timer.Elapsed += new System.Timers.ElapsedEventHandler(ProcessTheEndTask);
- timer.AutoReset = true;
- timer.Enabled = true;
- timer.Start();
-
- await Task.CompletedTask;
- }
- #endregion
-
- public Task SheetMetalTasks()
- {
-
- return Task.CompletedTask;
- }
-
- #endregion
-
- #region 计划下达
-
- #region 下发多个计划同步执行
-
- #region 前板任务
- ///
- /// 初始化下发生产计划,获取已拆分的计划进行下发——前板任务
- ///
- public void InitSendSidePanelPlan(object sender, System.Timers.ElapsedEventArgs e)
- {
- var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- if (obj_sidePanel == null) return;
- var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
- if (obj_backPanel == null) return;
- if (sideFlag)
- {
- sideFlag = false;
- try
- {
- List planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Result;
- if (planInfoList == null || planInfoList.Count == 0)
- {
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>未获取到需要下发的前板任务");
- return;
- }
- planInfoList = planInfoList.Where(d => d.PlanAmount > d.SidePanelAmount && (d.ExecuteStatus == 1 || d.ExecuteStatus == 2) && d.PlanType == 2).ToList();
- if (planInfoList == null || planInfoList.Count == 0) return;
- planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList();
- if (planInfoList == null || planInfoList.Count == 0) return;
- var planInfos = planInfoList.Where(d => d.PlanType == 2).ToList();
- if (planInfos != null)
- {
- if (planInfos.Count > 0)
- {
- SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.SidePanelAmount != d.PlanAmount);
- if (planInfo == null) return;
- if (planInfo.PlanType == 2)//如果类型为2,前板计划单独下发
- {
- List binList = GetSideBinStatus(obj_sidePanel);
-
- SmSyncModel smSyncModel = _smSyncModelServices.FirstAsync(d => d.MaterialSpecifications.Equals(planInfo.MaterialSpecificatons) && d.Category == "0").Result;
- if (smSyncModel == null) return;
- Bin bin = binList.SingleOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- if (bin == null) return;
-
- SendPlanTaskToSidPanel(planInfo, obj_sidePanel, smSyncModel.SmProductId.ObjToInt());
-
- //UpdateSidPanelPlanTaskByComplate(planInfo);
- // sideFlag = false;
- }
- if (planInfo.PlanType == 1)
- {
- //联合下发,检测前后板是否都设置了此型号,如果没有执行下一条任务
- List backBinList = GetBackBinStatus(obj_backPanel);
- List sideBinList = GetSideBinStatus(obj_sidePanel);
- if (backBinList != null && sideBinList != null)
- {
- SmSyncModel smSyncModel = _smSyncModelServices.FirstAsync(d => d.MaterialSpecifications.Equals(planInfo.MaterialSpecificatons) && d.Category == "2").Result;
- Bin backBin = backBinList.FirstOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- Bin sideBin = sideBinList.FirstOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- if (backBin == null || sideBin == null)
- {
- planInfos.Remove(planInfo);//移除list中当前的对象,执行下一个计划
-
- Console.WriteLine($"移除数据:{planInfo.ToJson()}");
- //sideFlag = true;
- }
- else
- {
- SendPlanTaskToSidPanel(planInfo, obj_sidePanel, smSyncModel.SmProductId.ObjToInt());
- //UpdateSidPanelPlanTaskByComplate(planInfo);
- // sideFlag = false;
- }
- }
- }
- }
- else
- {
- Console.WriteLine("未获取到需要下发的前板任务");
- }
- }
- else
- {
- Console.WriteLine("未获取到需要下发的前板任务");
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
-
- }
- finally
- {
- sideFlag = true;
- }
- Thread.Sleep(5000);
- }
- }
-
- #endregion
-
- #region 下发前板生产计划
- ///
- /// 下发前板生产计划
- ///
- ///
- ///
- public void SendPlanTaskToSidPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_sidePanel, int SmProductId)
- {
- try
- {
- //Task.Run(() =>
- //{
-
- if (obj_sidePanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
- obj_sidePanel.plc.WriteInt16("D6022", SmProductId.ToString());//产品号
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
- int surplus = planInfo.PlanAmount - planInfo.SidePanelAmount;
- obj_sidePanel.plc.WriteInt16("D6020", surplus.ToString());
- Thread.Sleep(500);
- obj_sidePanel.plc.WriteInt16("D6021", "1");
-
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>下发机头号为:{planInfo.MaterialSpecificatons}");
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】已下发,等待前板设备应答.......");
- RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待前板设备应答.......", "White");
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- bool isTaskFlag = true;
- DateTime startTime = DateTime.Now;
- do
- {
- //判断当前是否有手动下发的任务,有退出当前方法
- isTaskFlag = GetNewTask(planInfo.ObjId);
- if (isTaskFlag)
- {
- break;
- }
-
- int answer = obj_sidePanel.plc.ReadInt16("D6021");
- if (answer == 2)
- {
- obj_sidePanel.plc.WriteInt16("D6021", "0");
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】,收到前板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址", "White");
- startTime = DateTime.Now;
- isFlag = false;
- break;
- }
-
-
- Thread.Sleep(3000);
- } while (isFlag);
-
- if (isTaskFlag) return ;
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus, startTime).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshPlanInfoEvent?.Invoke(planInfo);//刷新计划执行
- }
-
- #endregion
-
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_SidePanel(obj_sidePanel);
- }
- // });
- }
- catch (Exception ex)
- {
- RefreshExecInfoEvent?.Invoke($"前板⽣产计划下发异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 根据前板完成记录更新生产计划
- ///
- /// 根据前板完成记录更新生产计划
- ///
- ///
- private void UpdateSidPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo)
- {
- lock (string.Empty)
- {
- bool isComplate = true;
-
- do
- {
- try
- {
- //等待计划执行完成
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
-
- List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
-
- Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
- RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
- int sumAmount = 0;
-
- if (planInfo.PlanType == 1)
- {
- if (planInfo.PlanAmount == sumSidePanelAmount)
- {
- if (sumSidePanelAmount == sumBackPanelAmount && sumSidePanelAmount != 0 && sumBackPanelAmount != 0)
- {
- sumAmount = sumSidePanelAmount;
- planInfo.ExecuteStatus = 3;
- }
-
- if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumSidePanelAmount;
- }
- if (sumSidePanelAmount > sumBackPanelAmount && sumSidePanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumBackPanelAmount;
- }
- if (sumSidePanelAmount == 0 && sumBackPanelAmount == 0) sumAmount = 0;
-
- isComplate = false;
- }
- else
- {
- if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumSidePanelAmount;
- }
- if (sumSidePanelAmount > sumBackPanelAmount && sumSidePanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumBackPanelAmount;
- }
- if (sumSidePanelAmount == 0 && sumBackPanelAmount == 0) sumAmount = 0;
- }
- }
-
- if (planInfo.PlanType == 2)
- {
- sumAmount = sumSidePanelAmount;
- if (planInfo.PlanAmount - sumAmount == 0)
- {
- planInfo.ExecuteStatus = 3;
- isComplate = false;
- }
- planInfo.CompleteAmount = sumAmount;
- }
-
- planInfo.CompleteAmount = sumAmount;
-
- var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result;
- obj.CompleteAmount = planInfo.CompleteAmount;
- obj.ExecuteStatus = planInfo.ExecuteStatus;
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result;
- if (result)
- {
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshCreatePlanInfoEvent?.Invoke();
- }
- Thread.Sleep(5000);
- }
- catch (Exception ex)
- {
- Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
- }
- } while (isComplate);
-
- if (!isComplate)
- {
- //更新前端展示图表
- //RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- //SheetMetaSendPlanInfoView planInfo = planInfoList.FirstOrDefault(d => d.TaskCode == planCode);
- RefreshPlanInfoEvent?.Invoke(planInfo);//刷新计划执行
- }
- }
-
- }
-
- #endregion
-
- #region 后板任务
- ///
- /// 初始化下发生产计划,获取已拆分的计划进行下发——后板任务
- ///
- public void InitSendBackPanelPlan(object sender, System.Timers.ElapsedEventArgs e)
- {
-
- var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
- if (obj_backPanel == null) return;
- var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- if (obj_sidePanel == null) return;
- if (backFlag)
- {
- backFlag = false;
- try
- {
- var planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Result;
- if (planInfoList == null || planInfoList.Count == 0)
- {
- Console.WriteLine("未获取到需要下发的后板任务");
- Thread.Sleep(3000);
- return;
- }
- planInfoList = planInfoList.Where(d => d.PlanAmount > d.SidePanelAmount).ToList();
- if (planInfoList == null || planInfoList.Count == 0) return;
- planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList();
- if (planInfoList == null || planInfoList.Count == 0) return;
- var planInfos = planInfoList.Where(d => d.PlanType == 3 || d.PlanType == 1).ToList();
- if (planInfos != null)
- {
- if (planInfos.Count > 0)
- {
- SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.BackPanelAmount != d.PlanAmount);
- if (planInfo == null) return;
- if (planInfo.PlanType == 3)//如果为3或者为1 后板计划单独下发
- {
- //获取设置的型号查询对应的型号,下发计划
- List binList = GetBackBinStatus(obj_backPanel);
- SmSyncModel smSyncModel = _smSyncModelServices.FirstAsync(d => d.MaterialSpecifications.Equals(planInfo.MaterialSpecificatons) && d.Category == "1").Result;
- if (smSyncModel == null) return;
- Bin bin = binList.FirstOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- if (bin == null)
- {
- Console.WriteLine($"未查询到钣金设备对计划!当前计划【{planInfo.TaskCode}】");
- // backFlag = true;
- Thread.Sleep(1000);
- return;
- };
-
- SendPlanTaskToBackPanel(planInfo, obj_backPanel, smSyncModel.SmProductId.ObjToInt());
- //UpdateBackPanelPlanTaskByComplate(planInfo);
- //backFlag = false;
- }
- if (planInfo.PlanType == 1)
- {
- //联合下发,检测前后板是否都有此型号,没有执行下一条任务
- List backBinList = GetBackBinStatus(obj_backPanel);
- List sideBinList = GetSideBinStatus(obj_sidePanel);
- if (backBinList != null && sideBinList != null)
- {
- SmSyncModel smSyncModel = _smSyncModelServices.FirstAsync(d => d.MaterialSpecifications.Equals(planInfo.MaterialSpecificatons) && d.Category == "2").Result;
- if (smSyncModel == null)
- {
- planInfos.Remove(planInfo);//连接计划如果没有查询到,移除当前计划执行下一个计划
- Console.WriteLine($"移除数据:{planInfo.ToJson()}");
- //backFlag = true;
- return;
- }
- Bin backBin = backBinList.FirstOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- Bin sideBin = sideBinList.FirstOrDefault(d => d.ProductId.Equals(smSyncModel.SmProductId));
- if (backBin == null || sideBin == null)
- {
- planInfos.Remove(planInfo);
- Console.WriteLine($"移除数据:{planInfo.ToJson()}");
- // backFlag = true;
- }
- else
- {
- SendPlanTaskToBackPanel(planInfo, obj_backPanel, smSyncModel.SmProductId.ObjToInt());
- UpdateBackPanelPlanTaskByComplate(planInfo);
- // backFlag = false;
- }
- }
- else
- {
- // backFlag = false;
- }
- }
-
- }
- else
- {
- Console.WriteLine("未获取到需要下发的后板任务");
- }
- }
- else
- {
- Console.WriteLine("未获取到需要下发的后板任务");
- }
- Thread.Sleep(3000);
- }
- catch (Exception ex)
- {
- logHelper.Error(ex.Message);
- Console.WriteLine(ex.Message);
- }
- finally
- {
- backFlag = true;
- }
- }
-
-
- }
-
- #endregion
-
- #region 下发背板生产计划
- ///
- /// 下发背板生产计划
- ///
- ///
- ///
- public void SendPlanTaskToBackPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_backPanel, int productId)
- {
- try
- {
- //Task.Run(() =>
- //{
- if (obj_backPanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
- obj_backPanel.plc.WriteInt16("D4022", productId.ToString());
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons);
- int surplus = planInfo.PlanAmount - planInfo.CompleteAmount;//剩余计划数量
- obj_backPanel.plc.WriteInt16("D4020", surplus.ToString());
- Thread.Sleep(500);
- obj_backPanel.plc.WriteInt16("D4021", "1");
-
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>下发机头号为:{planInfo.MaterialSpecificatons}");
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>计划【{planInfo.TaskCode}】已下发,等待背板设备应答.......");
- RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待背板设备应答......", "White");
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- bool isTaskFlag = true;
- DateTime startTime = DateTime.Now;
- do
- {
- //判断当前是否有手动下发的任务,有退出当前方法
- isTaskFlag = GetNewTask(planInfo.ObjId);
- if (isTaskFlag)
- {
- break;
- }
-
- int backPalnelAnswer = obj_backPanel.plc.ReadInt16("D4021");
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>应答信号:{backPalnelAnswer}");
- if (backPalnelAnswer == 2)
- {
- obj_backPanel.plc.WriteInt16("D4021", "0");
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>收到背板板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
- startTime = DateTime.Now;
- isFlag = false;
- }
- Thread.Sleep(2000);
- } while (isFlag);
-
- if (isTaskFlag) return;
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus, startTime).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshPlanInfoEvent?.Invoke(planInfo);
- RefreshChatEvent?.Invoke();//刷新图表
- }
-
- #endregion
-
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_BackPanel(obj_backPanel);
- }
- //});
- }
- catch (Exception ex)
- {
- RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 根据后板完成记录更新生产计划
- ///
- /// 根据后板完成记录更新生产计划
- ///
- private void UpdateBackPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo)
- {
- try
- {
- lock (string.Empty)
- {
- bool isComplate = true;
-
- do
- {
- //等待计划执行完成
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
-
- List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
-
- Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
- RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
- int sumAmount = 0;
-
- if (planInfo.PlanType == 1)
- {
- if (planInfo.PlanAmount == sumBackPanelAmount)
- {
- if (sumSidePanelAmount == sumBackPanelAmount && sumSidePanelAmount != 0 && sumBackPanelAmount != 0)
- {
- sumAmount = sumSidePanelAmount;
- planInfo.ExecuteStatus = 3;
- }
- if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumSidePanelAmount;
- }
- if (sumSidePanelAmount > sumBackPanelAmount && sumSidePanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumBackPanelAmount;
- }
- if (sumSidePanelAmount == 0 && sumBackPanelAmount == 0) sumAmount = 0;
- isComplate = false;
-
- }
- else
- {
- if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumSidePanelAmount;
- }
- if (sumSidePanelAmount > sumBackPanelAmount && sumSidePanelAmount == planInfo.PlanAmount)
- {
- sumAmount = sumBackPanelAmount;
- }
- if (sumSidePanelAmount == 0 && sumBackPanelAmount == 0) sumAmount = 0;
- }
- }
-
- if (planInfo.PlanType == 3)
- {
- sumAmount = sumBackPanelAmount;
- if (planInfo.PlanAmount - sumAmount == 0)
- {
- planInfo.ExecuteStatus = 3;
- isComplate = false;
- }
-
- planInfo.CompleteAmount = sumAmount;
- }
-
- var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result;
-
- if (obj.PlanType == 1 && planInfo.ExecuteStatus == 3)
- {
- obj.CompleteAmount = sumAmount;
- obj.EndTime = DateTime.Now;
- }
-
- if (obj.PlanType == 3 && planInfo.ExecuteStatus == 3)
- {
- obj.ExecuteStatus = 3;
- obj.EndTime = DateTime.Now;
- }
-
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result;
- if (result)
- {
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshPlanInfoEvent?.Invoke(planInfo);
- RefreshChatEvent?.Invoke();//刷新图表
- }
-
- Thread.Sleep(5000);
-
- } while (isComplate);
-
- if (!isComplate)
- {
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshPlanInfoEvent?.Invoke(planInfo);
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
- #endregion
-
- #region 下发单个计划逻辑
-
-
- #region 初始化下发生产计划,获取已拆分的计划进行下发
-
-
- ///
- /// 初始化下发生产计划,获取已拆分的计划进行下发
- ///
- public void InitSendPlan()
- {
- Thread.Sleep(5000);
- var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
-
- while (true)
- {
- var planInfos = _executePlanInfoServices.Query(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1 || d.ExecuteStatus == 2);
-
- if (planInfos != null)
- {
- if (planInfos.Count > 0)
- {
- ExecutePlanInfo planInfo = planInfos.First();
- if (planInfo.PlanType == 1) //联合下发
- {
- SendPlanTask(planInfo, obj_sidePanel, obj_backPanel);
-
- UpdatePlanTaskByComplate(planInfo);
-
- }
- else if (planInfo.PlanType == 2)
- {
- SendPlanTask_SidePanel(planInfo, obj_sidePanel);
-
- UpdatePlanTaskByComplate(planInfo);
-
- }
- else if (planInfo.PlanType == 3)
- {
- SendPlanTaskTo_BackPanel(planInfo, obj_backPanel);
-
- UpdatePlanTaskByComplate(planInfo);
- }
- }
- else
- {
- Console.WriteLine("未获取到需要下发的任务");
- }
- }
-
- Thread.Sleep(3000);
- }
- }
-
- #endregion
-
- #region 根据完成记录更新生产计划
- ///
- /// 根据完成记录更新生产计划
- ///
- ///
- private void UpdatePlanTaskByComplate(ExecutePlanInfo planInfo)
- {
- try
- {
- lock (string.Empty)
- {
- bool isComplate = true;
-
- do
- {
- //等待计划执行完成
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- if (sidePanelComplates == null || sidePanelComplates.Count == 0) continue;
- int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
-
- List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
- int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
-
- Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
- RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
- int sumAmount = 0;
-
- if (planInfo.PlanType == 1)
- {
- if (sumSidePanelAmount >= sumBackPanelAmount)
- {
- sumAmount = sumBackPanelAmount;
- }
- else
- {
- sumAmount = sumSidePanelAmount;
- }
- }
- else if (planInfo.PlanType == 2)
- {
- sumAmount = sumSidePanelAmount;
- }
- else
- {
- sumAmount = sumBackPanelAmount;
- }
-
- if (planInfo.PlanAmount - sumAmount == 0)
- {
- planInfo.ExecuteStatus = 3;
- isComplate = false;
- }
-
- planInfo.CompleteAmount = sumAmount;
-
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- Thread.Sleep(5000);
-
- } while (isComplate);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 联合下发
- ///
- /// 联合下发
- ///
- ///
- ///
- ///
- private void SendPlanTask(ExecutePlanInfo planInfo, PlcModel obj_sidePanel, PlcModel obj_backPanel)
- {
- try
- {
- //前板
- Task.Run(() =>
- {
- if (obj_sidePanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
- obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
- obj_sidePanel.plc.WriteInt32("D6021", 1);
-
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
- RefreshExecInfoEvent?.Invoke("等待前板设备应答......", "Red");
- //下发完成后读取PLC应答,应答后复位应答信号
-
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- do
- {
- //开始做计划的时候给我
- if (obj_sidePanel.plc.ReadInt32("D6021") == 2)
- {
- obj_sidePanel.plc.WriteInt32("D6021", 0);
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke("收到前板设备应答信号,复位应答地址", "White");
- isFlag = false;
- }
- Thread.Sleep(2000);
- } while (isFlag);
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- #endregion
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_SidePanel(obj_sidePanel);
- if (!isFlag)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- });
- //背板
- Task.Run(() =>
- {
- if (obj_backPanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_backPanel.plc.WriteString("D4010", "BCD/310NF");
- obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount);
- obj_backPanel.plc.WriteInt32("D4021", 1);
-
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
- RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- do
- {
- if (obj_backPanel.plc.ReadInt32("D4021") == 2)
- {
- obj_backPanel.plc.WriteInt32("D4021", 0);
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址", "White");
- isFlag = false;
- }
- Thread.Sleep(2000);
- } while (isFlag);
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- #endregion
-
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_BackPanel(obj_backPanel);
- if (!isFlag)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- });
- }
- catch (Exception ex)
- {
- Console.WriteLine($"前板⽣产计划下发异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"前板⽣产计划下发异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 下发前板生产计划
- ///
- /// 下发前板生产计划
- ///
- ///
- ///
- public void SendPlanTask_SidePanel(ExecutePlanInfo planInfo, PlcModel obj_sidePanel)
- {
- try
- {
- Task.Run(() =>
- {
- if (obj_sidePanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
- obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
- obj_sidePanel.plc.WriteInt32("D6021", 1);
-
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
- RefreshExecInfoEvent?.Invoke("等待前板设备应答......", "White");
- //下发完成后读取PLC应答,应答后复位应答信号
-
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- do
- {
- if (obj_sidePanel.plc.ReadInt32("D6021") == 2)
- {
- obj_sidePanel.plc.WriteInt32("D6021", 0);
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke("收到前板设备应答信号......", "White");
- isFlag = false;
- }
- Thread.Sleep(2000);
- } while (isFlag);
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshCurrentPlanInfoEvent?.Invoke();
- }
-
- #endregion
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_SidePanel(obj_sidePanel);
- if (!isFlag)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- });
- }
- catch (Exception ex)
- {
- Console.WriteLine($"前板⽣产计划下发异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"前板⽣产计划下发异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 读取前板生产数据
- ///
- /// 读取前板生产数据
- ///
- ///
- public async void ReadDeviceComplate_SidePanel(PlcModel obj)
- {
- bool isFlag = true;
-
- do
- {
- try
- {
-
- //D6030
- //计划编号:D6030-D6039,物料编号:D6040-D6049,计划完成数:D6050,计划下线数:D6051,设备状态:D6052-D6056,生产节拍:D6057-D6058
- byte[] info = obj.plc.Read("D6030", 59);
-
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
-
- //计划编号
- string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
- //物料编号
- string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray());
- //完成数量
- int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
- //下线数量
- int offLineAmount = short.Parse(bytesToHexStr(info.Skip(41).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
- //设备状态
- int deviceStatus = short.Parse(bytesToHexStr(info.Skip(43).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
- //生产节拍
- int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
-
- if (string.IsNullOrEmpty(planCode))
- {
- Thread.Sleep(5000);
- continue;
- }
-
- Console.WriteLine($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
- RefreshExecInfoEvent?.Invoke($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
-
- var planInfo = _executePlanInfoServices.FirstAsync(x => x.TaskCode == planCode).Result;
- if (planInfo == null)
- {
- Thread.Sleep(3000);
- continue;
- }
- if (planInfo.ExecuteStatus !=2)
- {
- isFlag = false;
- break;
- }
- //添加完工记录
- RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
- {
- ProductlineCode = "1001",
- PlanCode = planCode.Substring(0, 16),
- //MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode,
- MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF",
- CompleteAmount = complateAmount,
- OffLineAmount = offLineAmount,
- DeviceStatus = deviceStatus,
- ProductionBeat = productionBeat,
- RecordTime = DateTime.Now,
- IsFlag = 1
- };
-
- //先查询该计划编号下的前一条完工记录,如果不存在本条记录产量为0
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16));
- int lastComplateAmount = 0; //前一条完成记录的计划完成数量
- int sumComplateAmount = 0; //当前计划总产量
- if (sidePanelComplates != null && sidePanelComplates.Count != 0)
- {
- if (sidePanelComplates.Count > 0)
- {
- sidePanelComplates = sidePanelComplates.OrderByDescending(x => x.RecordTime).ToList();
-
- lastComplateAmount = sidePanelComplates.First().CompleteAmount;
- sidePanelComplate.OutPutAmount = complateAmount - lastComplateAmount;
- sumComplateAmount = sidePanelComplates.Sum(x => x.OutPutAmount) + sidePanelComplate.OutPutAmount;
-
- if (sidePanelComplate.OutPutAmount == 0)
- {
- Thread.Sleep(5000);
- continue;
- }
- else
- {
- List planInfos = _executePlanInfoServices.Query(x => x.TaskCode.Equals(planCode.Substring(0, 16)) && x.ExecuteStatus == 2);
- if (planInfos != null)
- {
- if (planInfo.PlanAmount - sumComplateAmount == 0)
- {
- isFlag = false;
- Console.WriteLine($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
- RefreshExecInfoEvent?.Invoke($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
-
- planInfo.CompleteAmount = planInfo.PlanAmount;
- _ = _sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate).Result;
- _ = _executePlanInfoServices.UpdateAsync(planInfo).Result;
-
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- }
- else
- {
- planInfo.CompleteAmount = sumComplateAmount;
- var r =await _executePlanInfoServices.UpdateAsync(planInfo);
- _ = _sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate).Result;
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshCreatePlanInfoEvent?.Invoke();
- //任务没有完成但是已经暂停、退出系统
- if (planInfo.ExecuteStatus==0)
- {
- isFlag = false;
- }
- }
- }
- }
- }
- }
- else
- {
- //如果没有完成记录插入一条默认完成数量为0
- _ = _sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate).Result;
- }
- Thread.Sleep(5000);
- }
- catch (Exception e)
- {
- Console.WriteLine($"读取前板设备完成数据异常:{e.Message}");
- RefreshExecInfoEvent?.Invoke($"读取前板设备完成数据异常:{e.Message}", "Red");
- }
- } while (isFlag);
- }
-
- #endregion
-
- #region 下发背板生产计划
- ///
- /// 下发背板生产计划
- ///
- ///
- ///
- public void SendPlanTaskTo_BackPanel(ExecutePlanInfo planInfo, PlcModel obj_backPanel)
- {
- try
- {
- Task.Run(() =>
- {
- if (obj_backPanel != null)
- {
- //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
- string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
- obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons);
- obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount);
- obj_backPanel.plc.WriteInt32("D4021", 1);
-
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
- RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
- #region PLC反馈信号逻辑处理
- //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
- bool isFlag = true;
- do
- {
-
- if (obj_backPanel.plc.ReadInt32("D4021") == 2)
- {
- obj_backPanel.plc.WriteInt32("D4021", 0);
- Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
- RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
- isFlag = false;
- }
- Thread.Sleep(2000);
- } while (isFlag);
-
- //更新计划状态为2执行中
- planInfo.ExecuteStatus = 2;
- bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
- if (result)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
-
- #endregion
-
- //读取设备进度,完成后再次下发新任务
- ReadDeviceComplate_BackPanel(obj_backPanel);
-
- if (!isFlag)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- });
- }
- catch (Exception ex)
- {
- Console.WriteLine($"读取前板设备完成数据异常:{ex.Message}");
- RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{ex.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 读取背板生产数据
- ///
- /// 读取背板生产数据
- ///
- ///
- public void ReadDeviceComplate_BackPanel(PlcModel obj)
- {
- bool isFlag = true;
- try
- {
- do
- {
- //计划编号:D4030-D4039,物料编号:D4040-D4049,计划完成数:D4050,计划下线数:D4051,设备状态:D4052-D4056,生产节拍:D4057-D4058
- byte[] info = obj.plc.Read("D4030", 59);
-
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
-
- //计划编号
- string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
- //物料编号
- string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray()).Replace("\0", "").Trim();
- //完成数量
- int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
- //下线数量
- int offLineAmount = short.Parse(bytesToHexStr(info.Skip(41).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
- //设备状态
- int deviceStatus = short.Parse(bytesToHexStr(info.Skip(43).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
- //生产节拍
- int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
-
- Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】背板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
- RefreshExecInfoEvent?.Invoke($"当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
-
- if (string.IsNullOrEmpty(planCode))
- {
- Thread.Sleep(5000);
- continue;
- }
- var planInfo = _executePlanInfoServices.FirstAsync(x => x.TaskCode == planCode && x.ExecuteStatus == 2).Result;
- if (planInfo == null)
- {
- Console.WriteLine($"未查询到【{planCode}】运行任务!");
- RefreshExecInfoEvent?.Invoke($"未查询到【{planCode}】计划信息!", "White");
- Thread.Sleep(5000);
- continue;
- }
- //var planInfoStatus = _executePlanInfoServices.FirstAsync(x => x.TaskCode == planCode && x.ExecuteStatus == 3).Result;
- //if (planInfoStatus != null)
- //{
- // break;
- //}
- //添加完工记录
- RecordBackPanelComplate backPanelComplate = new RecordBackPanelComplate()
- {
- ProductlineCode = "1001",
- PlanCode = planCode.Replace("\0", "").Trim(),
- MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode.Replace("\0", "").Trim(),
- //MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF",
- CompleteAmount = complateAmount,//完成数量(计划完成)
- OffLineAmount = offLineAmount,//下线
- DeviceStatus = deviceStatus,
- ProductionBeat = productionBeat,
- RecordTime = DateTime.Now,
- IsFlag = 1
- };
-
- //先查询该计划编号下的前一条完工记录,如果不存在任务,默认创建,记录产量为0
- List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16));
- int lastComplateAmount = 0; //前一条完成记录的计划完成数量
- int sumComplateAmount = 0; //当前计划总产量
- if (backPanelComplates != null && backPanelComplates.Count != 0)
- {
- if (backPanelComplates.Count > 0)
- {
- backPanelComplates = backPanelComplates.OrderByDescending(x => x.RecordTime).ToList();
-
- lastComplateAmount = backPanelComplates.First().CompleteAmount;//最新的完工数量
- backPanelComplate.OutPutAmount = complateAmount - lastComplateAmount;//实际产量
- sumComplateAmount = backPanelComplates.Sum(x => x.OutPutAmount) + backPanelComplate.OutPutAmount; //计划总产量
- if (backPanelComplate.OutPutAmount == 0)
- {
- Thread.Sleep(5000);
- continue;
- }
- else
- {
- if (planInfo != null)
- {
- if (planInfo.PlanAmount - sumComplateAmount == 0)
- {
- isFlag = false;
- Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
- RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
-
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
-
- planInfo.CompleteAmount = planInfo.PlanAmount;
- _backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
-
- _executePlanInfoServices.UpdateAsync(planInfo);
- }
- else
- {
- planInfo.CompleteAmount = sumComplateAmount;
- _executePlanInfoServices.UpdateAsync(planInfo);
- _backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- RefreshCreatePlanInfoEvent?.Invoke();
-
- //任务没有完成但是已经暂停、退出系统
- if (planInfo.ExecuteStatus == 1) break;
-
- }
- }
- }
- if (complateAmount != lastComplateAmount)
- {
- //更新前端展示图表
- RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- RefreshChatEvent?.Invoke();//刷新图表
- }
- }
- }
- else
- {
- //如果没有完成记录插入一条默认完成数量为0
- _backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
- }
- Thread.Sleep(5000);
- } while (isFlag);
-
- //if (!isFlag)
- //{
- // //更新前端展示图表
- // RefreshCreatePlanInfoEvent?.Invoke();//更新界面
- // RefreshChatEvent?.Invoke();//刷新图表
- //}
- }
- catch (Exception e)
- {
- Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
- RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}", "Red");
- }
- }
-
- #endregion
-
- #region 通过物料编号获取工艺编号
- ///
- /// 通过物料编号获取工艺编号
- ///
- ///
- ///
- private string GetProcessNumberBy(string materialCode)
- {
- return System.Guid.NewGuid().ToString("N").Substring(0, 20);
- }
-
- #endregion
-
- public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01"
- {
- string returnStr = "";
- if (bytes != null)
- {
- for (int i = 0; i < iLen; i++)
- {
- returnStr += bytes[i].ToString("X2");
- }
- }
- return returnStr;
- }
- #endregion
-
- #region 更新计划列表数量
- ///
- /// 更新计划列表数量
- ///
- public void UpdateComplatePlan(object sender, System.Timers.ElapsedEventArgs e)
- {
- string stationCode = Appsettings.app("StationInfo", "StationCode");
- string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
-
- if (complatePlanFlag)
- {
- List pPlanInfoList = new List();
- complatePlanFlag = false;
- try
- {
- var planInfoList = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.PlanAmount > d.CompleteAmount).Result;
- if (planInfoList == null || planInfoList.Count == 0) return;
-
- var list = from d in planInfoList
- select new
- {
- d.OrderCode,
- d.CompleteAmount
- };
-
- var grouplist = (from d in list
- group d by d.OrderCode into g
- select new
- {
- OrderCode = g.Key,
- CompleteAmount = g.Sum(d => d.CompleteAmount)
- }).OrderBy(t => t.OrderCode).ToList();
-
- var productPlanInfoList = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.CompleteAmount <= d.PlanAmount).Result;
-
- productPlanInfoList.ForEach(t =>
- {
- // var materialCompletionList = _materialCompletionServices.QueryAsync(d => d.ProductLineCode.Contains(productLineCode) && d.StationName.Equals(stationCode)).Result;
- var obj = grouplist.FirstOrDefault(d => d.OrderCode.Equals(t.OrderCode));
-
- if (obj != null)
- {
- if (obj.CompleteAmount == 1 && t.CompleteAmount == 0)
- {
- t.EndTime = DateTime.Now;
- _sysUserInfoServices.UpdateSapPlan(obj.OrderCode);//第一次执行更新日历表
- }
-
- if (t.PlanAmount == obj.CompleteAmount)
- {
- t.CompleteAmount = obj.CompleteAmount;
- t.EndTime = DateTime.Now;
- }
- if (t.PlanAmount > obj.CompleteAmount)
- {
- t.CompleteAmount = obj.CompleteAmount;
- }
- else
- {
- t.CompleteAmount = t.PlanAmount;
- }
- }
-
- if (pPlanInfoList.Count != 0 && pPlanInfoList != null)
- {
- _ = _productPlanInfoServices.UpdateAsync(t).Result;
- }
-
- });
-
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- finally
- {
- complatePlanFlag = true;
- }
- }
- }
-
- #endregion
-
- #endregion
-
- #region 同步钣金设置型号
-
- ///
- /// 获取所有设置的钣金前板型号
- ///
- ///
- public async Task QuerySidePanelMode()
- {
- while (true)
- {
- Thread.Sleep(50000);
- obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- if (obj_sidePanel == null) { continue; }
- if (obj_sidePanel.plc.IsConnected)
- {
- Console.WriteLine("===============采集前板开始===============");
- RefreshExecInfoEvent?.Invoke($"===============采集前板开始配置开始===============", "White");
- byte[] info = obj_sidePanel.plc.Read("D7000", 3000);
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
- int j = 1;
- string mode = string.Empty;
- List addList = new List();
- List updateList = new List();
- var smSyncModelList = _smSyncModelServices.QueryAsync(d=>d.Category=="0").Result;
-
- for (int i = 1; i <= 600; i++)
- {
- if (i % 2 == 0)
- {
- //设置型号
- mode = Encoding.ASCII.GetString(info.Skip(i * 10).Take(10).ToArray()).Replace("\0", "").Trim();
-
- if (smSyncModelList.Count == 0 || smSyncModelList == null)
- {
- SmSyncModel sm = new SmSyncModel();
- sm.SmProductId = j.ToString();
- sm.SmModel = mode.Trim();
- sm.SyncTime = DateTime.Now;
- sm.CreateTime = DateTime.Now;
- sm.Category = "0";
- addList.Add(sm);
- }
- else
- {
- var obj = smSyncModelList.First(d => d.SmProductId == j.ToString());
- if (obj == null)
- {
- SmSyncModel sm = new SmSyncModel();
- sm.SmProductId = j.ToString();
- sm.SmModel = mode.Trim();
- sm.SyncTime = DateTime.Now;
- sm.Category = "0";
- addList.Add(sm);
- }
- else
- {
- if (string.IsNullOrEmpty(obj.SmModel) && string.IsNullOrEmpty(mode)) continue;
- if (string.IsNullOrEmpty(obj.SmModel) && !string.IsNullOrEmpty(mode))
- {
- obj.SmProductId = j.ToString();
- obj.SmModel = mode.Trim();
- obj.SyncTime = DateTime.Now;
- obj.Category = "0";
- updateList.Add(obj);
- }
- if (!string.IsNullOrEmpty(obj.SmModel) && !string.IsNullOrEmpty(mode) && obj.SmModel!= mode)
- {
- obj.SmProductId = j.ToString();
- obj.SmModel = mode.Trim();
- obj.SyncTime = DateTime.Now;
- obj.Category = "0";
- updateList.Add(obj);
- }
- }
- }
- j++;
- }
- }
- if (addList != null && addList.Count > 0) await _smSyncModelServices.AddAsync(addList);
- if (updateList != null&&updateList.Count > 0) await _smSyncModelServices.UpdateAsync(updateList);
- RefreshExecInfoEvent?.Invoke($"===============采集前板配置结束===============", "White");
- Console.WriteLine("===============采集结束===============");
- }
- }
- }
-
- ///
- /// 获取所有设置的钣金前板型号
- ///
- ///
- public async Task QueryBackPanelMode()
- {
- while (true)
- {
- Thread.Sleep(5000);
- obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
- if (obj_backPanel == null) { continue; }
- if (obj_backPanel.plc.IsConnected)
- {
- RefreshExecInfoEvent?.Invoke($"===============采集后板开始配置===============", "White");
- Console.WriteLine("===============采集后板开始===============");
- byte[] info = obj_backPanel.plc.Read("D7000", 3000);
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
- int j = 1;
- string mode = string.Empty;
- List addList = new List();
- List updateList = new List();
- var smSyncModelList = _smSyncModelServices.QueryAsync(d=>d.Category=="1").Result;
-
- for (int i = 1; i <= 600; i++)
- {
- if (i % 2 == 0)
- {
- //设置型号
- mode = Encoding.ASCII.GetString(info.Skip(i * 10).Take(10).ToArray()).Replace("\0", "").Trim();
-
- if (smSyncModelList.Count == 0 || smSyncModelList == null)
- {
- SmSyncModel sm = new SmSyncModel();
- sm.SmProductId = j.ToString();
- sm.SmModel = mode.Trim();
- sm.SyncTime = DateTime.Now;
- sm.CreateTime = DateTime.Now;
- sm.Category = "1";
- addList.Add(sm);
- }
- else
- {
- var obj = smSyncModelList.First(d => d.SmProductId == j.ToString());
- if (obj == null)
- {
- SmSyncModel sm = new SmSyncModel();
- sm.SmProductId = j.ToString();
- sm.SmModel = mode.Trim();
- sm.SyncTime = DateTime.Now;
- sm.Category = "1";
- addList.Add(sm);
- }
- else
- {
- if (string.IsNullOrEmpty(obj.SmModel) && string.IsNullOrEmpty(mode)) continue;
- if (string.IsNullOrEmpty(obj.SmModel) && !string.IsNullOrEmpty(mode))
- {
- obj.SmProductId = j.ToString();
- obj.SmModel = mode.Trim();
- obj.SyncTime = DateTime.Now;
- obj.Category = "1";
- updateList.Add(obj);
- }
- if (!string.IsNullOrEmpty(obj.SmModel) && !string.IsNullOrEmpty(mode) && obj.SmModel != mode)
- {
- obj.SmProductId = j.ToString();
- obj.SmModel = mode.Trim();
- obj.SyncTime = DateTime.Now;
- obj.Category = "1";
- updateList.Add(obj);
- }
- }
- }
- j++;
- }
- }
- if (addList != null && addList.Count > 0) await _smSyncModelServices.AddAsync(addList);
- if (updateList != null && updateList.Count > 0) await _smSyncModelServices.UpdateAsync(updateList);
- RefreshExecInfoEvent?.Invoke($"===============采集后板配置结束===============", "White");
- Console.WriteLine("===============采集结束===============");
- }
- }
- }
- #endregion
-
- #region 获取后板设置的型号
- ///
- /// 获取后板设置的型号
- ///
- ///
- ///
- public List GetBackBinStatus(PlcModel obj_SidePanel)
- {
- List list = new List();
-
- if (!obj_SidePanel.plc.IsConnected)
- {
- Console.WriteLine("plc为 false");
-
- return null;
- }
- var startb0 = obj_SidePanel.plc.ReadBool("M60");
- if (startb0)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2002").ToString();//读取产品编码
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb0;
- list.Add(bin);
- }
- var startb2 = obj_SidePanel.plc.ReadBool("M61");
- if (startb2)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2026").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb2;
- list.Add(bin);
- }
- var startb4 = obj_SidePanel.plc.ReadBool("M62");
- if (startb4)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2050").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb4;
- list.Add(bin);
- }
- var startb6 = obj_SidePanel.plc.ReadBool("M63");
- if (startb6)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2075").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb6;
- list.Add(bin);
- }
- var startb7 = obj_SidePanel.plc.ReadBool("M64");
- if (startb7)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2098").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb7;
- list.Add(bin);
- }
- var startb8 = obj_SidePanel.plc.ReadBool("M65");
- if (startb8)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D2122").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb8;
- list.Add(bin);
- }
- return list;
-
- }
-
- #endregion
-
- #region 获取前板设置的型号
- ///
- /// 获取前板设置的型号
- ///
- ///
- ///
- public List GetSideBinStatus(PlcModel obj_SidePanel)
- {
- List list = new List();
- var startb0 = obj_SidePanel.plc.ReadBool("M140");
- if (startb0)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D1402").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb0;
- list.Add(bin);
- }
- var startb2 = obj_SidePanel.plc.ReadBool("M141");
- if (startb2)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D1426").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb0;
- list.Add(bin);
- }
- var startb4 = obj_SidePanel.plc.ReadBool("M142");
- if (startb4)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D1450").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb4;
- list.Add(bin);
- }
- var startb6 = obj_SidePanel.plc.ReadBool("M143");
- if (startb6)
- {
- string productId = obj_SidePanel.plc.ReadInt16("D1474").ToString();
- Bin bin = new Bin();
- bin.ProductId = productId;
- bin.Status = startb6;
- list.Add(bin);
- }
- return list;
-
- }
-
- #endregion
-
- #region 前板下线数量
- ///
- /// 前板下线数量
- ///
- public async Task ReadSideBlanking()
- {
- while (true)
- {
- string stationCode = Appsettings.app("StationInfo", "StationCode");
- string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
- Thread.Sleep(5000);
- obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- if (obj_sidePanel.plc.IsConnected)
- {
- byte[] info = obj_sidePanel.plc.Read("D2100", 20);
-
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
- //计划编号
- string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\n", "").Trim();
- var offLineAmount = obj_sidePanel.plc.ReadInt16("D6051");
- RefreshExecInfoEvent?.Invoke($"下线计划号:{planCode}》》》》下线数量:{offLineAmount}", "White");
- Console.WriteLine($"计划号:{planCode}》》》》下线数量:{offLineAmount}");
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == stationCode && x.PlanCode == planCode);
- sidePanelComplates = sidePanelComplates.OrderByDescending(d => d.RecordTime).ToList();
- RecordSidePanelComplate recordSidePanelComplate = sidePanelComplates.First();
- int sumSidePanelAmount = recordSidePanelComplate.OffLineAmount;
- if (recordSidePanelComplate.OffLineAmount < offLineAmount)
- {
- //更新计划数量
- ExecutePlanInfo executePlanInfo = _executePlanInfoServices.FirstAsync(x => x.TaskCode == planCode).Result;
- var productPlanInfoList = _productPlanInfoServices.FirstAsync(d => d.ProductLineCode.Contains(stationCode) && d.PlanCode.Contains(executePlanInfo.ProductPlanCode)).Result;
- productPlanInfoList.CompleteAmount = productPlanInfoList.CompleteAmount + (offLineAmount - recordSidePanelComplate.OffLineAmount);
- await _productPlanInfoServices.UpdateAsync(productPlanInfoList);//更新计划
- }
- }
- }
- }
-
- #endregion
-
- #region 后板下线数量
-
- ///
- /// 后板下线数量
- ///
- public void ReadBackBlanking()
- {
- while (true)
- {
- string stationCode = Appsettings.app("StationInfo", "StationCode");
- string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
- Thread.Sleep(5000);
- obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
- if (obj_sidePanel.plc.IsConnected)
- {
- byte[] info = obj_sidePanel.plc.Read("D2100", 20);
-
- if (info == null)
- {
- Thread.Sleep(1000);
- continue;
- }
- //计划编号
- string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\n", "").Trim();
- var offLineAmount = obj_sidePanel.plc.ReadInt16("D6051");
- RefreshExecInfoEvent?.Invoke($"下线计划号:{planCode}》》》》下线数量:{offLineAmount}", "White");
- Console.WriteLine($"计划号:{planCode}》》》》下线数量:{offLineAmount}");
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == stationCode && x.PlanCode == planCode);
- sidePanelComplates = sidePanelComplates.OrderByDescending(d => d.RecordTime).ToList();
- RecordSidePanelComplate recordSidePanelComplate = sidePanelComplates.First();
- int sumSidePanelAmount = recordSidePanelComplate.OffLineAmount;
- if (recordSidePanelComplate.OffLineAmount < offLineAmount)
- {
- //更新计划数量
- ExecutePlanInfo executePlanInfo = _executePlanInfoServices.FirstAsync(x => x.TaskCode == planCode).Result;
- var productPlanInfoList = _productPlanInfoServices.FirstAsync(d => d.ProductLineCode.Contains(stationCode) && d.PlanCode.Contains(executePlanInfo.ProductPlanCode)).Result;
- productPlanInfoList.CompleteAmount = productPlanInfoList.CompleteAmount + (offLineAmount - recordSidePanelComplate.OffLineAmount);
- _ = _productPlanInfoServices.UpdateAsync(productPlanInfoList).Result;//更新计划
- }
- }
- }
- }
-
- #endregion
-
- #region 处理任务未结束情况
- ///
- /// 处理任务未结束情况 public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
- ///
- ///
- public void ProcessTheEndTask(object sender, System.Timers.ElapsedEventArgs e)
- {
- if (statusFlag)
- {
- statusFlag=false;
- try
- {
- var result = _executePlanInfoServices.QueryAsync(d => d.ExecuteStatus == 2 && d.PlanAmount == d.CompleteAmount).Result;
- if (result == null || result.Count == 0) return;
- List list = new List();
- foreach (var item in result)
- {
- item.ExecuteStatus = 3;
- list.Add(item);
- }
- var back = _executePlanInfoServices.UpdateAsync(list).Result;
- if (back)
- {
- RefreshCurrentPlanInfoEvent?.Invoke();//刷新计划执行
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine( );
- logHelper.Error($"更新钣金计划任务状态异常:{ex.Message}");
- }
- finally
- {
- statusFlag = true;
- }
- }
- }
- #endregion
-
-
- public bool GetNewTask(int Id)
- {
- List planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Result;
- if (planInfoList == null || planInfoList.Count == 0) return false;
- var task= planInfoList.FirstOrDefault(d=>d.ExecuteStatus==2&& d.ObjId!= Id);
- if (task == null) return false;
- else return true;
-
- }
- }
-}
diff --git a/Aucma.Core.SheetMetalTasks/IAucamSheetMetalTaskService.cs b/Aucma.Core.SheetMetalTasks/IAucamSheetMetalTaskService.cs
deleted file mode 100644
index 4862435..0000000
--- a/Aucma.Core.SheetMetalTasks/IAucamSheetMetalTaskService.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-namespace Aucma.Core.SheetMetalTasks
-{
- public interface IAucamSheetMetalTaskService
- {
- ///
- /// 钣金计划任务
- ///
- Task SheetMetalTasks();
-
- Task SendSidePanelPlan();
-
- Task SendBackPanelPlan();
-
- Task ExecUpdateComplatePlan();
-
- Task ExecProcessTheEndTask();
- }
-}
diff --git a/Aucma.Core.SheetMetalTasks/Models/Bin.cs b/Aucma.Core.SheetMetalTasks/Models/Bin.cs
deleted file mode 100644
index 8306fc6..0000000
--- a/Aucma.Core.SheetMetalTasks/Models/Bin.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Aucma.Core.SheetMetalTasks.Models
-{
- ///
- /// 前后板料仓型号
- ///
- public class Bin
- {
- ///
- /// 料仓Id
- ///
- public string? ProductId { get; set; }
- ///
- /// 是否启用
- ///
- public bool Status { get; set; }
- }
-}
diff --git a/dll/Designer.exe b/dll/Designer.exe
deleted file mode 100644
index 3588de2..0000000
Binary files a/dll/Designer.exe and /dev/null differ
diff --git a/dll/FastReport.Bars.dll b/dll/FastReport.Bars.dll
deleted file mode 100644
index 3e9eb6c..0000000
Binary files a/dll/FastReport.Bars.dll and /dev/null differ
diff --git a/dll/FastReport.Editor.dll b/dll/FastReport.Editor.dll
deleted file mode 100644
index 9c727e5..0000000
Binary files a/dll/FastReport.Editor.dll and /dev/null differ
diff --git a/dll/FastReport.dll b/dll/FastReport.dll
deleted file mode 100644
index 6665f27..0000000
Binary files a/dll/FastReport.dll and /dev/null differ
diff --git a/dll/MvCodeReaderCtrl.dll b/dll/MvCodeReaderCtrl.dll
deleted file mode 100644
index acfdf28..0000000
Binary files a/dll/MvCodeReaderCtrl.dll and /dev/null differ
diff --git a/dll/MvCodeReaderSDK.Net.dll b/dll/MvCodeReaderSDK.Net.dll
deleted file mode 100644
index cc1a608..0000000
Binary files a/dll/MvCodeReaderSDK.Net.dll and /dev/null differ