更新代码以使用SqlSugarScope替代SqlSugarClient,并添加生产产线属性
| | |
| | | <template> |
| | | <el-row> |
| | | <el-col :span="3"> |
| | | |
| | | <device-stacker v-for="stacker in Stackers" :key="stacker.deviceName" :Stacker="stacker"></device-stacker> |
| | | </el-col> |
| | | <el-col :span="21"> |
| | | <device-line v-for="device in devices" :key="device.deviceName" :device="device" /> |
| | | </el-col> |
| | | </el-row> |
| | | <div> |
| | | <div> |
| | | <div class="Stackerbox"> |
| | | <div class="card"> |
| | | <div class="card-header"> |
| | | <div> |
| | | <div class="card-body Stacker"> |
| | | {{ StackerOne.deviceName }} |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="card-body"> |
| | | <ul class="list-group"> |
| | | <li class="list-group-item list-group-item-secondary"> |
| | | 任务号:{{ StackerOne.data.currentTaskNum || '暂无任务号' }} |
| | | </li> |
| | | <li :class="getStatusClass(StackerOne.data.stackerCraneAutoStatusDes)"> |
| | | 工作模式:{{ StackerOne.data.stackerCraneAutoStatusDes }} |
| | | </li> |
| | | <li :class="getStatusClass(StackerOne.data.stackerCraneStatusDes)"> |
| | | 设备状态:{{ StackerOne.data.stackerCraneStatusDes }} |
| | | </li> |
| | | <li :class="getStatusClass(StackerOne.data.stackerCraneWorkStatusDes)"> |
| | | 工作状态:{{ StackerOne.data.stackerCraneWorkStatusDes }} |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <device-line v-for="device in devices" :key="device.deviceName" :device="device" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, reactive, toRefs } from "vue"; |
| | | import eventBus from "@/uitils/eventBus"; |
| | | import DeviceLine from "@/components/DeviceLine.vue"; |
| | | import DeviceStacker from "@/components/DeviceStacker.vue"; |
| | | |
| | | // 堆垛机 |
| | | const Stackers = reactive([]); |
| | | const StackerOne = reactive({ |
| | | deviceName: "", |
| | | data: { |
| | | } |
| | | }); |
| | | |
| | | // 设备列表(修改重复设备名称) |
| | | const devices = reactive([]); |
| | | const devices = reactive([ |
| | | { deviceName: "陈化出库输送线", data: { command: {}, commandWrite: {}, writeInteractiveSignal: [] } }, |
| | | { deviceName: "陈化入库输送线", data: { command: {}, commandWrite: {}, writeInteractiveSignal: [] } }, |
| | | // { deviceName: "堆垛机1", data: { command: {}, commandWrite: {}, writeInteractiveSignal: [] } }, |
| | | // Add all devices similarly... |
| | | ]); |
| | | |
| | | const intToBitArrayFromBinaryString = (num, numBits) => { |
| | | let binaryString = num.toString(2).padStart(numBits, '0'); |
| | | return Array.from({ length: numBits }, (_, index) => binaryString[index] === '1'); |
| | | // 获取状态类名(优化状态判断) |
| | | const getStatusClass = (status) => { |
| | | if (status === '正常' || status === '自动' || status === '待机') { |
| | | return 'list-group-item list-group-item-success'; |
| | | } |
| | | if (status === '故障' || status === '停机') { |
| | | return 'list-group-item list-group-item-danger'; |
| | | } |
| | | return 'list-group-item list-group-item-warning'; // 默认警告状态 |
| | | }; |
| | | |
| | | // 监听设备数据变化 |
| | | onMounted(() => { |
| | | eventBus.on('locationData', eventData => { |
| | | console.log(eventData) |
| | | if (eventData.deviceName === "陈化入库输送线"||eventData.deviceName === "陈化入库输送线") { |
| | | |
| | | if (devices.length <= 0) { |
| | | devices.push({ deviceName: eventData.deviceName, data: eventData.data, childDeviceCode: eventData.childDeviceCode }); |
| | | } |
| | | else { |
| | | const device = devices.find(c => c.childDeviceCode == eventData.childDeviceCode) |
| | | if (device) { |
| | | const number = eventData.data.commandWrite.writeInteractiveSignal; |
| | | const writeInteractiveSignal = intToBitArrayFromBinaryString(number, 8) |
| | | eventData.data.writeInteractiveSignal = writeInteractiveSignal; |
| | | device.data = eventData.data |
| | | } |
| | | else { |
| | | const number = eventData.data.commandWrite.writeInteractiveSignal; |
| | | const writeInteractiveSignal = intToBitArrayFromBinaryString(number, 8) |
| | | eventData.data.writeInteractiveSignal = writeInteractiveSignal; |
| | | devices.push({ deviceName: eventData.deviceName, data: eventData.data, childDeviceCode: eventData.childDeviceCode }); |
| | | } |
| | | } |
| | | const device = devices.find(d => d.deviceName === eventData.deviceName); |
| | | if (device) { |
| | | // 使用扩展运算符更新对象属性,保持响应性 |
| | | device.data = { ...device.data, ...eventData.data }; |
| | | } |
| | | }); |
| | | eventBus.on('stackerData', eventData => { |
| | | if (eventData.deviceName == "陈化1号堆垛机"||eventData.deviceName == "陈化2号堆垛机") { |
| | | if (Stackers.length == 0) { |
| | | Stackers.push({ deviceName: eventData.deviceName, data: eventData.data }); |
| | | } |
| | | else { |
| | | const Stacker = Stackers.find(c => c.deviceName == eventData.deviceName); |
| | | if (Stacker) { |
| | | Stacker.data = eventData.data |
| | | } |
| | | else { |
| | | Stackers.push({ deviceName: eventData.deviceName, data: eventData.data }); |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | </script> |
| | | <style scoped> |
| | |
| | | public class RepositoryBase<TEntity> : IRepository<TEntity> where TEntity : class, new() |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly SqlSugarClient _dbBase; |
| | | private readonly SqlSugarScope _dbBase; |
| | | |
| | | private ISqlSugarClient _db |
| | | { |
| | |
| | | /// <returns>查询结果</returns> |
| | | public virtual TEntity QureyDataById(object id) |
| | | { |
| | | return _db.Queryable<TEntity>().In(id).Single(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(id).Single(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>查询结果集合</returns> |
| | | public virtual List<TEntity> QureyDataByIds(object[] lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>查询结果集合</returns> |
| | | public virtual List<TEntity> QureyDataByIds(List<object> lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>影响行数</returns> |
| | | public virtual int AddData(TEntity entity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(entity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(entity); |
| | | return insert.ExecuteReturnIdentity(); |
| | | } |
| | | |
| | |
| | | /// <returns>影响行数</returns> |
| | | public virtual int AddData(List<TEntity> listEntity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(listEntity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(listEntity); |
| | | return insert.ExecuteCommand(); |
| | | } |
| | | |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteDataById(object id) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(id).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(id).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteDataByIds(object[] ids) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(ids).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteData(TEntity entity) |
| | | { |
| | | return _db.Deleteable(entity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable(entity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteData(List<TEntity> listEntity) |
| | | { |
| | | return _db.Deleteable(listEntity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable(listEntity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(TEntity entity) |
| | | { |
| | | return _db.Updateable(entity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Updateable(entity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(List<TEntity> listEntity) |
| | | { |
| | | return _db.Updateable(listEntity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Updateable(listEntity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(TEntity entity, List<string> lstColumns, List<string>? lstIgnoreColumns = null) |
| | | { |
| | | IUpdateable<TEntity> update = _db.Updateable(entity); |
| | | IUpdateable<TEntity> update = _db.CopyNew().Updateable(entity); |
| | | |
| | | if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData() |
| | | { |
| | | return _db.Queryable<TEntity>().ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | } |
| | | |
| | | public virtual TEntity QueryFirst(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).First(); |
| | | } |
| | | |
| | | public virtual TResult QueryFirst<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).First(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TResult> QueryData<TResult>(Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().Select(expression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().Select(expression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TResult> QueryData<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields = "") |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression).ToPageList(pageIndex, pageSize); |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).ToPageList(pageIndex, pageSize); |
| | | } |
| | | |
| | |
| | | public virtual PageGridData<TEntity> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | var list = _db.Queryable<TEntity>() |
| | | var list = _db.CopyNew().Queryable<TEntity>() |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | | .ToPageList(pageIndex, pageSize, ref totalCount); |
| | |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | int totalCount = 0; |
| | | List<TEntity> list = _db.Queryable<TEntity>() |
| | | List<TEntity> list = _db.CopyNew().Queryable<TEntity>() |
| | | .OrderBy(orderByModels) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | | .ToPageList(pageIndex, pageSize, ref totalCount); |
| | |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | int totalCount = 0; |
| | | List<TEntity> list = _db.Queryable<TEntity>() |
| | | List<TEntity> list = _db.CopyNew().Queryable<TEntity>() |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToPageList(pageIndex, pageSize, ref totalCount); |
| | | |
| | | return new PageGridData<TEntity>(totalCount, list); |
| | |
| | | Expression<Func<T,T2, bool>> whereExpressionT1, |
| | | Expression<Func<TResult, bool>> whereExpression) |
| | | { |
| | | List<TResult> list = _db.Queryable(joinExpression).WhereIF(whereExpressionT1 != null, whereExpressionT1) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression).WhereIF(whereExpressionT1 != null, whereExpressionT1) |
| | | .Select(selectExpression) |
| | | .WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return list; |
| | |
| | | public virtual PageGridData<TResult> QueryTabsPage<T1, T2, TResult>(Expression<Func<T1, T2, object[]>> joinExpression, Expression<Func<T1, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | List<TResult> list = _db.Queryable(joinExpression) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression) |
| | | .Select(selectExpression) |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | |
| | | public virtual PageGridData<TResult> QueryTabsPage<T1, T2, TResult>(Expression<Func<T1, T2, object[]>> joinExpression, Expression<Func<T1, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression, Expression<Func<T1, object>> groupExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | List<TResult> list = _db.Queryable(joinExpression).GroupBy(groupExpression) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression).GroupBy(groupExpression) |
| | | .Select(selectExpression) |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | |
| | | |
| | | public Task<TEntity> QureyDataByIdAsync(object id) |
| | | { |
| | | return _db.Queryable<TEntity>().In(id).SingleAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(id).SingleAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QureyDataByIdsAsync(object[] lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QureyDataByIdsAsync(List<object> lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | } |
| | | |
| | | public Task<int> AddDataAsync(TEntity entity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(entity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(entity); |
| | | return insert.ExecuteReturnIdentityAsync(); |
| | | } |
| | | |
| | | public Task<int> AddDataAsync(List<TEntity> listEntity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(listEntity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(listEntity); |
| | | return insert.ExecuteReturnIdentityAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataByIdAsync(object id) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(id).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(id).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataByIdsAsync(object[] ids) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataAsync(TEntity entity) |
| | | { |
| | | return _db.Deleteable(entity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable(entity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataAsync(List<TEntity> listEntity) |
| | | { |
| | | return _db.Deleteable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(TEntity entity) |
| | | { |
| | | return _db.Updateable(entity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Updateable(entity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(List<TEntity> listEntity) |
| | | { |
| | | return _db.Updateable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Updateable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(TEntity entity, List<string> lstColumns, List<string>? lstIgnoreColumns = null) |
| | | { |
| | | IUpdateable<TEntity> update = _db.Updateable(entity); |
| | | IUpdateable<TEntity> update = _db.CopyNew().Updateable(entity); |
| | | |
| | | if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) |
| | | { |
| | |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync() |
| | | { |
| | | return _db.Queryable<TEntity>().ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).FirstAsync(); |
| | | } |
| | | |
| | | public Task<TResult> QueryFirstAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).FirstAsync(); |
| | | } |
| | | |
| | | public TResult QueryFirst<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).First(); |
| | | } |
| | | |
| | | public Task<TResult> QueryFirstAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).FirstAsync(); |
| | | } |
| | | |
| | | public TEntity QueryFirst(Expression<Func<TEntity, bool>> whereExpression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).First(); |
| | | } |
| | | |
| | | public Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> whereExpression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).FirstAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryDataAsync<TResult>(Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().Select(expression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().Select(expression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryDataAsync<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataBySqlAsync(string sql, SugarParameter[]? parameters = null) |
| | |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression).ToPageListAsync(pageIndex, pageSize); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).ToPageListAsync(pageIndex, pageSize); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryTabsAsync<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable(joinExpression) |
| | | return _db.CopyNew().Queryable(joinExpression) |
| | | .Select(selectExpression) |
| | | .WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |
| | |
| | | { |
| | | public interface IUnitOfWorkManage |
| | | { |
| | | SqlSugarClient GetDbClient(); |
| | | SqlSugarScope GetDbClient(); |
| | | int TranCount { get; } |
| | | |
| | | UnitOfWork CreateUnitOfWork(); |
| | |
| | | /// 获取DB,保证唯一性 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public SqlSugarClient GetDbClient() |
| | | public SqlSugarScope GetDbClient() |
| | | { |
| | | // 必须要as,后边会用到切换数据库操作 |
| | | return _sqlSugarClient as SqlSugarClient; |
| | | return _sqlSugarClient as SqlSugarScope; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | List<TDetail> list = detailDics.DicToIEnumerable<TDetail>(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | int id = BaseDal.Db.Insertable(entity).ExecuteReturnIdentity(); |
| | | |
| | |
| | | |
| | | BaseDal.Db.Insertable(list).ExecuteCommand(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | |
| | | object mainId = typeof(TEntity).GetPropertyValue(entity, typeof(TEntity).GetKeyName()); |
| | | if (mainId != null) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | if (dynamicDelKeys.Count > 0) |
| | | BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{detailType.GetKeyName()} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange(); |
| | |
| | | |
| | | BaseDal.Db.Insertable(addRows).ExecuteCommand(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | |
| | | { |
| | | dynamicDelKeys.Add(keys[i]); |
| | | } |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | if (dynamicDelKeys.Count > 0) |
| | | BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{name} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange(); |
| | | |
| | | BaseDal.DeleteDataByIds(keys); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | |
| | | |
| | | public static List<MutiDBOperate> MutiInitConn() |
| | | { |
| | | SqlSugarClient sqlSugarClient = new SqlSugarClient(new ConnectionConfig |
| | | SqlSugarScope sqlSugarClient = new SqlSugarScope(new ConnectionConfig |
| | | { |
| | | ConfigId = MainDb.CurrentDbConnId, |
| | | ConnectionString = AppSettings.app(MainDb.ConnectionString).DecryptDES(AppSecret.DB), |
| | |
| | | |
| | | // 默认添加主数据库连接 |
| | | //MainDb.CurrentDbConnId = AppSettings.app(new string[] { "MainDB" }); |
| | | |
| | | services.AddHttpContextAccessor(); |
| | | // SqlSugarScope是线程安全,可使用单例注入 |
| | | // 参考:https://www.donet5.com/Home/Doc?typeId=1181 |
| | | services.AddScoped<ISqlSugarClient>(o => |
| | | services.AddSingleton<ISqlSugarClient>(o => |
| | | { |
| | | var memoryCache = o.GetRequiredService<IMemoryCache>(); |
| | | |
| | |
| | | //}); |
| | | #endregion |
| | | |
| | | SqlSugarClient sqlSugarClient = new SqlSugarClient(listConfig, db => |
| | | SqlSugarScope sqlSugarClient = new SqlSugarScope(listConfig, db => |
| | | { |
| | | db.Aop.DataExecuting = SqlSugarAop.DataExecuting; |
| | | }); |
| | |
| | | |
| | | if (queueTable.Rows.Count == 0) { continue; } |
| | | |
| | | SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig() |
| | | SqlSugarScope sugarClient = new SqlSugarScope(new ConnectionConfig() |
| | | { |
| | | ConnectionString = DBContext.GetMainConnectionDb().Connection, |
| | | IsAutoCloseConnection = true, |
| | |
| | | private static string _connectionString = connectObject.Connection; |
| | | private static DbType _dbType = (DbType)connectObject.DbType; |
| | | public static string ConnId = connectObject.ConnId; |
| | | private SqlSugarClient _db; |
| | | private SqlSugarScope _db; |
| | | |
| | | /// <summary> |
| | | /// 连接字符串 |
| | |
| | | /// <summary> |
| | | /// 数据连接对象 |
| | | /// </summary> |
| | | public SqlSugarClient Db |
| | | public SqlSugarScope Db |
| | | { |
| | | get { return _db; } |
| | | private set { _db = value; } |
| | |
| | | if (string.IsNullOrEmpty(_connectionString)) |
| | | throw new ArgumentNullException("数据库连接字符串为空"); |
| | | |
| | | _db = sqlSugarClient as SqlSugarClient; |
| | | _db = sqlSugarClient as SqlSugarScope; |
| | | //_db.Aop.DataExecuting = SqlSugarAop.DataExecuting; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="config">config</param> |
| | | /// <returns>返回值</returns> |
| | | public static SqlSugarClient GetCustomDB(ConnectionConfig config) |
| | | public static SqlSugarScope GetCustomDB(ConnectionConfig config) |
| | | { |
| | | return new SqlSugarClient(config); |
| | | return new SqlSugarScope(config); |
| | | } |
| | | /// <summary> |
| | | /// 功能描述:获取一个自定义的数据库处理对象 |
| | | /// </summary> |
| | | /// <param name="sugarClient">sugarClient</param> |
| | | /// <returns>返回值</returns> |
| | | public static SimpleClient<T> GetCustomEntityDB<T>(SqlSugarClient sugarClient) where T : class, new() |
| | | { |
| | | return new SimpleClient<T>(sugarClient); |
| | | } |
| | | //public static SqlSugarScope<T> GetCustomEntityDB<T>(SqlSugarScope sugarClient) where T : class, new() |
| | | //{ |
| | | // return new SqlSugarScope<T>(sugarClient); |
| | | //} |
| | | /// <summary> |
| | | /// 功能描述:获取一个自定义的数据库处理对象 |
| | | /// </summary> |
| | | /// <param name="config">config</param> |
| | | /// <returns>返回值</returns> |
| | | public static SimpleClient<T> GetCustomEntityDB<T>(ConnectionConfig config) where T : class, new() |
| | | { |
| | | SqlSugarClient sugarClient = GetCustomDB(config); |
| | | return GetCustomEntityDB<T>(sugarClient); |
| | | } |
| | | //public static SimpleClient<T> GetCustomEntityDB<T>(ConnectionConfig config) where T : class, new() |
| | | //{ |
| | | // SqlSugarScope sugarClient = GetCustomDB(config); |
| | | // return GetCustomEntityDB<T>(sugarClient); |
| | | //} |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | Dt_Task QueryStackerCraneOutTask(string deviceNo, string currentAddress = ""); |
| | | |
| | | /// <summary> |
| | | /// 根据设备编号、排除的任务、当前地址按照优先级以及创建时间排序查询任务池出库类型的新增的任务 |
| | | /// </summary> |
| | | /// <param name="deviceNo">设备编号</param> |
| | | /// <param name="excludedTaskId">排除的任务</param> |
| | | /// <param name="currentAddress">当前地址</param> |
| | | /// <returns>返回任务实体对象,可能为null</returns> |
| | | List<Dt_Task> QueryAllOutboundTasks(string deviceNo, string currentAddress = ""); |
| | | |
| | | /// <summary> |
| | | /// 根据设备编号、当前地址按照优先级以及创建时间排序查询任务池出库类型的新增的任务 |
| | | /// </summary> |
| | | /// <param name="deviceNo">设备编号</param> |
| | |
| | | #endregion |
| | | |
| | | //传入反射出来的执行程序集 |
| | | //IJobDetail jobDetail = JobBuilder.Create(jobType) |
| | | // .WithIdentity(tasksQz.Id.ToString(), tasksQz.JobGroup) |
| | | // .Build(); |
| | | //jobDetail.JobDataMap.Add("JobParams", tasksQz.JobParams); |
| | | |
| | | IJobDetail job = new JobDetailImpl(tasksQz.Id.ToString(), tasksQz.JobGroup, jobType); |
| | | job.JobDataMap.Add("JobParams", tasksQz.JobParams); |
| | | |
| | |
| | | |
| | | // 告诉Quartz使用我们的触发器来安排作业 |
| | | await _scheduler.Result.ScheduleJob(job, trigger); |
| | | //await _scheduler.Result.ScheduleJob(jobDetail, trigger); |
| | | |
| | | result = WebResponseContent.Instance.OK(string.Format(QuartzJobInfoMessage.JobAddSuccess, tasksQz.Name)); |
| | | return result; |
| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using Quartz.Impl.Matchers; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using Quartz.Impl; |
| | | using System.Collections.Specialized; |
| | | |
| | | namespace WIDESEAWCS_QuartzJob.Service |
| | | { |
| | |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | public DispatchInfoService(IDispatchInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IDeviceInfoRepository deviceInfoRepository) : base(BaseDal) |
| | | private readonly ISchedulerCenter _schedulerCenter; |
| | | public DispatchInfoService(IDispatchInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IDeviceInfoRepository deviceInfoRepository, ISchedulerCenter schedulerCenter) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | _schedulerCenter = schedulerCenter; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | DeviceType = b.DeviceType |
| | | }).ToList(); |
| | | } |
| | | |
| | | public async Task<WebResponseContent> GetDispatchInfosAsync() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | NameValueCollection collection = new NameValueCollection |
| | | { |
| | | { "quartz.serializer.type", "binary" }, |
| | | }; |
| | | StdSchedulerFactory factory = new StdSchedulerFactory(collection); |
| | | IScheduler scheduler = await factory.GetScheduler(); |
| | | var jobKeys = await scheduler.GetJobKeys(GroupMatcher<JobKey>.AnyGroup()); |
| | | foreach (var jobKey in jobKeys) |
| | | { |
| | | // 在这里处理每个JobKey |
| | | IJobDetail jobDetail = await scheduler.GetJobDetail(jobKey); |
| | | if (jobDetail != null) |
| | | { |
| | | // 可以获取Job的描述信息 |
| | | string jobDescription = jobDetail.Description; |
| | | // 以及Job的数据映射(JobDataMap) |
| | | JobDataMap jobDataMap = jobDetail.JobDataMap; |
| | | } |
| | | } |
| | | |
| | | var triggerKeys = await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.AnyGroup()); |
| | | foreach (var triggerKey in triggerKeys) |
| | | { |
| | | // 在这里处理每个TriggerKey |
| | | ITrigger trigger = await scheduler.GetTrigger(triggerKey); |
| | | if (trigger != null) |
| | | { |
| | | // 获取下一次触发时间(如果有) |
| | | DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc(); |
| | | // 获取上次触发时间(如果有) |
| | | DateTimeOffset? previousFireTime = trigger.GetPreviousFireTimeUtc(); |
| | | // 获取触发类型(如SimpleTrigger、CronTrigger) |
| | | string triggerType = trigger.GetType().Name; |
| | | // 对于CronTrigger,还可以获取Cron表达式(如果是) |
| | | //if (trigger is CronTrigger cronTrigger) |
| | | //{ |
| | | // string cronExpression = cronTrigger.CronExpressionString; |
| | | //} |
| | | if (!previousFireTime.HasValue && nextFireTime.HasValue) |
| | | { |
| | | Console.WriteLine($"Job处于等待触发状态,Trigger名称: {triggerKey.Name}"); |
| | | } |
| | | } |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | |
| | | /// </summary> |
| | | /// <returns>返回定时器Job与对应的设备信息DTO集合。</returns> |
| | | List<DispatchInfoDTO> QueryDispatchInfos(); |
| | | |
| | | Task<WebResponseContent> GetDispatchInfosAsync(); |
| | | } |
| | | } |
| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseController; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | |
| | | [ApiController] |
| | | public class DispatchInfoController : ApiBaseController<IDispatchInfoService, Dt_DispatchInfo> |
| | | { |
| | | public DispatchInfoController(IDispatchInfoService service) : base(service) |
| | | private readonly IDispatchInfoService _dispatchInfoService; |
| | | public DispatchInfoController(IDispatchInfoService service, IDispatchInfoService dispatchInfoService) : base(service) |
| | | { |
| | | _dispatchInfoService = dispatchInfoService; |
| | | } |
| | | |
| | | [HttpGet("GetDispatchInfosAsync"),AllowAnonymous] |
| | | public Task<WebResponseContent> GetDispatchInfosAsync() |
| | | { |
| | | return _dispatchInfoService.GetDispatchInfosAsync(); |
| | | } |
| | | } |
| | | } |
| | |
| | | task.Creater = "WMS"; |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.RoadWay, item.TargetAddress); |
| | | if (routers.Count > 0) |
| | | if (task.TargetAddress == "002-021-001") |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.OutNew; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | else |
| | | { |
| | | routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.RoadWay, item.TargetAddress); |
| | | if (routers.Count > 0) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | task.TaskState = (int)TaskOutStatusEnum.OutNew; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | else |
| | | { |
| | | routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); |
| | | if (routers.Count > 0) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); |
| | | if (routers.Count > 0) |
| | | if (task.SourceAddress == "1359-4") |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.InNew; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | else |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); |
| | | if (routers.Count > 0) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.InNew; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | } |
| | | } |
| | | tasks.Add(task); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据设备编号、排除的任务、当前地址按照优先级以及创建时间排序查询任务池出库类型的新增的所有任务 |
| | | /// </summary> |
| | | /// <param name="deviceNo">设备编号</param> |
| | | /// <param name="excludedTaskId">排除的任务</param> |
| | | /// <param name="currentAddress">当前地址</param> |
| | | /// <returns>返回任务实体对象,可能为null</returns> |
| | | public List<Dt_Task> QueryAllOutboundTasks(string deviceNo, string currentAddress = "") |
| | | { |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryData(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew, TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryData(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据设备编号、当前地址按照优先级以及创建时间排序查询任务池出库类型的新增的任务 |
| | | /// </summary> |
| | | /// <param name="deviceNo">设备编号</param> |
| | |
| | | _noticeService = noticeService; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | public async Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | string jobName = context.JobDetail.Key.Name; |
| | | if (MemoryLockManager.TryAcquireLock(jobName)) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | try |
| | | { |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | ProcessDeviceAsync(conveyorLine, childDeviceCode); |
| | | } |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList(); |
| | | await Task.WhenAll(tasks); |
| | | |
| | | List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | foreach (var station in stationManagers) |
| | | { |
| | | if (station.stationType == 11) |
| | | List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | foreach (var station in stationManagers) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | if (station.stationType == 11) |
| | | { |
| | | var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[0] == true) |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | { |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】空托盘请求扫码入库"); |
| | | NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); |
| | | } |
| | | else |
| | | { |
| | | ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | private void ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | { |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | { |
| | | //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | return; |
| | | } |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | command, |
| | | commandWrite |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | |
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | | if (deviceProtocolDetails != null) |
| | | { |
| | | foreach (var item in deviceProtocolDetails) |
| | | { |
| | | var outDeviceCodes = _routerService.QueryOutDeviceCodes(conveyorLine.DeviceCode); |
| | | if (structs[item.ProtocalDetailValue.ObjToInt()] == true) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | var numRead = item.ProtocalDetailValue.ObjToInt(); |
| | | var numWrite = item.ProtocalDetailValue.ObjToInt() + 1; |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】【{childDeviceCode}】【{numRead.ToString()}】位输送线读取信号:【{structs[item.ProtocalDetailValue.ObjToInt()]}】 【{numWrite}】位WCS写入信号:【{structs[item.ProtocalDetailValue.ObjToInt() + 1]}】"); |
| | | if (structs[item.ProtocalDetailValue.ObjToInt() + 1] != structs[item.ProtocalDetailValue.ObjToInt()]) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | |
| | | //DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | //string[] x = devicePro.DeviceProAddress.Split('.'); |
| | | //x[x.Length - 1] = (item.ProtocalDetailValue.ObjToInt() + 1).ToString(); |
| | | //string DeviceProAddress = string.Join(".", x); |
| | | //var writeRead = conveyorLine.Communicator.Read<bool>(DeviceProAddress); |
| | | //if (writeRead) |
| | | //{ |
| | | // conveyorLine.Communicator.Write(DeviceProAddress, false); |
| | | // //ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | //} |
| | | } |
| | | } |
| | | } |
| | | |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | | { |
| | | if (command.InteractiveSignal != 2) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (platform.Location != null && platform.Location != "") |
| | | { |
| | | var strings = platform.Location.Split(',').ToList(); |
| | | foreach (var ite in strings) |
| | | { |
| | | //int index = strings.FindIndex(p => p == ite); |
| | | ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite); |
| | | if (command1.InteractiveSignal != 2) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[0] == true) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | //int count = strings.Count - index; |
| | | int count = strings.Count; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】空托盘请求扫码入库"); |
| | | NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); |
| | | } |
| | | else |
| | | { |
| | | ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | } |
| | | finally |
| | | { |
| | | MemoryLockManager.ReleaseLock(jobName); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]【{jobName}】任务已被锁定,无法处理"); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | private Task ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | { |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos != null && tokenInfos.Any()) |
| | | { |
| | | var userTokenIds = tokenInfos.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | command, |
| | | commandWrite |
| | | }; |
| | | _noticeService.LineData(userIds.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); |
| | | } |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | var writeInteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | var structs = BitConverter.GetBytes(writeInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | | if (deviceProtocolDetails != null) |
| | | { |
| | | foreach (var item in deviceProtocolDetails) |
| | | { |
| | | int itemValue = item.ProtocalDetailValue.ObjToInt(); |
| | | if (structs[itemValue] == true) |
| | | { |
| | | var numRead = itemValue; |
| | | var numWrite = itemValue + 1; |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】【{childDeviceCode}】【{numRead.ToString()}】位输送线读取信号:【{structs[itemValue]}】 【{numWrite}】位WCS写入信号:【{structs[itemValue + 1]}】"); |
| | | if (structs[itemValue + 1] != structs[itemValue]) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, itemValue }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, itemValue, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null && !string.IsNullOrEmpty(platform.Location)) |
| | | { |
| | | var strings = platform.Location.Split(',').ToList(); |
| | | foreach (var ite in strings) |
| | | { |
| | | ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite); |
| | | if (command1.InteractiveSignal != 2) |
| | | { |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | int count = strings.Count; |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | }; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #region |
| | | //var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | |
| | | //List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | | //if (deviceProtocolDetails != null) |
| | | //{ |
| | | // foreach (var item in deviceProtocolDetails) |
| | | // { |
| | | // if (structs[item.ProtocalDetailValue.ObjToInt()] == true) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | // if (method != null) |
| | | // { |
| | | // var numRead = item.ProtocalDetailValue.ObjToInt(); |
| | | // var numWrite = item.ProtocalDetailValue.ObjToInt() + 1; |
| | | // ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】【{childDeviceCode}】【{numRead.ToString()}】位输送线读取信号:【{structs[item.ProtocalDetailValue.ObjToInt()]}】 【{numWrite}】位WCS写入信号:【{structs[item.ProtocalDetailValue.ObjToInt() + 1]}】"); |
| | | // if (structs[item.ProtocalDetailValue.ObjToInt() + 1] != structs[item.ProtocalDetailValue.ObjToInt()]) |
| | | // { |
| | | // command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() }); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | //Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | //if (platform != null) |
| | | //{ |
| | | // if (command.InteractiveSignal != 2) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | // if (method != null) |
| | | // { |
| | | // command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1; |
| | | // method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // if (platform.Location != null && platform.Location != "") |
| | | // { |
| | | // var strings = platform.Location.Split(',').ToList(); |
| | | // foreach (var ite in strings) |
| | | // { |
| | | // //int index = strings.FindIndex(p => p == ite); |
| | | // ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite); |
| | | // if (command1.InteractiveSignal != 2) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | // if (method != null) |
| | | // { |
| | | // command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // //int count = strings.Count - index; |
| | | // int count = strings.Count; |
| | | // method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | #endregion |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | #region 入库 |
| | |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | | if (command.Barcode == task.PalletCode) |
| | | if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress) |
| | | { |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成,下一目标地址【等待分配货位】"); |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | |
| | | { |
| | | if (task.NextAddress.Contains("JZ")) |
| | | { |
| | | command.Barcode = task.PalletCode; |
| | | command.TaskNum = task.TaskNum; |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{task.TargetAddress}】"); |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{task.TargetAddress}】"); |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | } |
| | |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | task.NextAddress = next; |
| | | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(是胖),下一目标地址【{taskCommand.TargetAddress}】"); |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{taskCommand.TargetAddress}】"); |
| | | |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | |
| | | |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Microsoft.CodeAnalysis; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using SqlSugar; |
| | |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; |
| | | using Platform = WIDESEAWCS_Model.Models.Platform; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <param name="index">线体当前bool读取偏移地址</param> |
| | | public async void EmptyTrayReturn(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int index, Platform platform) |
| | | public async void EmptyTrayReturn(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int index, WIDESEAWCS_Model.Models.Platform platform) |
| | | { |
| | | try |
| | | { |
| | |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray; |
| | | else |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.Outbound; |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform.Stacker); |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform.Stacker, platform); |
| | | } |
| | | catch (Exception) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 检查任务并创建新任务 |
| | | /// </summary> |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, List<string> roadways = null) |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, Platform platform) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count < index) |
| | |
| | | } |
| | | var wmsIpAddress = wmsBase + requestTrayOutTask; |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = roadWay, roadways = roadways }.ToJsonString()); |
| | | |
| | | List<string> strings = platform.Location.Split(',').ToList(); |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = roadWay, AreaCdoes = strings, platform.ProductionLine }.ToJsonString()); |
| | | //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString()); |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | |
| | | if (IsStationValid(station)) |
| | | { |
| | | var hasPallet = ReadPalletStatus(station); // 获取托盘状态 |
| | | if (hasPallet == 0) // 如果没有托盘 |
| | | if (hasPallet == 16) // 如果没有托盘 |
| | | { |
| | | palletCount++; |
| | | } |
| | |
| | | private int ReadPalletStatus(Dt_StationManager station) |
| | | { |
| | | var commonConveyorLine_GW = Storage.Devices.FirstOrDefault(device => device.DeviceCode == station.stationPLC) as CommonConveyorLine_GW; |
| | | return Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.HasPallet, station.stationChildCode)); |
| | | return Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.InteractiveSignal, station.stationChildCode)); |
| | | } |
| | | } |
| | | } |
| | |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Caches; |
| | |
| | | else |
| | | return; |
| | | } |
| | | |
| | | |
| | | _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | if (commonStackerCrane.DeviceCode.Contains("CH") && task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | } |
| | | if(task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "1359-4") |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "002-021-001") |
| | | { |
| | | var TASKHTY = task.Adapt<Dt_Task_Hty>(); |
| | | _taskRepository.DeleteData(task); |
| | |
| | | private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | Dt_Task task; |
| | | //var taskRun = _taskRepository.QueryFirst(x => x.Roadway == commonStackerCrane.DeviceCode && (x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting)); |
| | | //if (taskRun != null) { return null; } |
| | | if (commonStackerCrane.LastTaskType == null) |
| | | { |
| | | task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); |
| | | } |
| | | else |
| | | { |
| | | if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | var lastTaskTypeGroup = commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup(); |
| | | if (lastTaskTypeGroup == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | if (task == null) |
| | |
| | | |
| | | if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | if (OutTaskStationIsOccupied(task) != null) |
| | | // 检查当前出库任务站台是否允许放货 |
| | | var occupiedStation = OutTaskStationIsOccupied(task); |
| | | if (occupiedStation == null) |
| | | { |
| | | // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务 |
| | | ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货"); |
| | | task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId); |
| | | } |
| | | else |
| | | { |
| | | return task; |
| | | } |
| | | //else |
| | | //{ |
| | | // List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList(); |
| | | // List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes); |
| | | // foreach (var item in tasks) |
| | | // { |
| | | // if (OutTaskStationIsOccupied(task) != null) |
| | | // { |
| | | // return task; |
| | | // } |
| | | // } |
| | | // task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | //} |
| | | } |
| | | else if (task == null) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查找其他出库任务的辅助方法(排除指定任务ID的任务) |
| | | /// </summary> |
| | | /// <param name="deviceCode">设备代码</param> |
| | | /// <param name="excludedTaskId">要排除的任务ID</param> |
| | | /// <returns></returns> |
| | | private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId) |
| | | { |
| | | // 先获取所有符合条件(排除指定任务ID)的出库任务列表 |
| | | var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode); |
| | | var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList(); |
| | | |
| | | if (availableTasks == null || availableTasks.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | // 遍历可用任务列表,检查任务站台是否允许放货,找到第一个允许放货的任务就返回 |
| | | foreach (var candidateTask in availableTasks) |
| | | { |
| | | var occupiedStation = OutTaskStationIsOccupied(candidateTask); |
| | | if (occupiedStation != null) |
| | | { |
| | | return candidateTask; |
| | | } |
| | | ConsoleHelper.WriteErrorLine($"任务号:【{occupiedStation.TaskNum}】出库地址:【{occupiedStation.NextAddress}】不允许放货"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务实体转换成命令Model |
| | | /// </summary> |
| | |
| | | public string Roadways { get; set; } |
| | | |
| | | public int area { get; set; } |
| | | public string ProductionLine { get; set; } |
| | | } |
| | | |
| | | public class RequestOutTaskDto |
| | |
| | | public string Position { get; set; } |
| | | public int Tag { get; set; } |
| | | public string AreaCdoe { get; set; } |
| | | public List<string> AreaCdoes { get; set; } |
| | | public string ProductionLine { get; set; } |
| | | } |
| | |
| | | /// <param name="areaCode">区域编码</param> |
| | | /// <param name="roadways">巷道列表</param> |
| | | /// <returns>返回结果集</returns> |
| | | Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, string productionLine); |
| | | Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, List<string> areaCodes, string productionLine); |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "备注")] |
| | | public string Remark { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 生产产线 |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "生产产线")] |
| | | public string ProductionLine { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 当前工序 |
| | | /// </summary> |
| | |
| | | { |
| | | public dt_needBarcodeService(IDt_needBarcodeRepository BaseDal) : base(BaseDal) |
| | | { |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | using Mapster; |
| | | using AngleSharp.Io; |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_Core.Const; |
| | |
| | | //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() |
| | | // .FirstAsync(x => x.EquipmentName == task.Roadway); |
| | | //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); |
| | | if (!task.Roadway.Contains("FR")) //非分容库区均上报MOM出入站 |
| | | if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") //非分容库区与当前工序是OCVB均上报MOM出入站 |
| | | { |
| | | var agingOutputDto = MapToAgingOutputDto(stock); |
| | | content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); |
| | |
| | | } |
| | | else |
| | | { |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); |
| | | if (station.stationPLC == "1017") |
| | | area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation)); |
| | | else |
| | | area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId); |
| | | //var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); |
| | | //if (station.stationPLC == "1017") |
| | | // area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation)); |
| | | //else |
| | | // area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId); |
| | | //if (area == null) |
| | | // throw new Exception("未找到对应区域信息"); |
| | | |
| | | if (boxing.ProcessCode == "OCV1") |
| | | area = _areaInfoRepository.QueryFirst(x => x.AreaID == 6); |
| | | |
| | | else if (boxing.ProcessCode == "OCVB") |
| | | area = _areaInfoRepository.QueryFirst(x => x.AreaID == 7); |
| | | |
| | | if (area == null) |
| | | throw new Exception("未找到对应区域信息"); |
| | | } |
| | |
| | | Remark = boxing.BoxingInfoDetails.Count().ToString(), |
| | | }; |
| | | |
| | | // 处理请求参数 |
| | | AgingInputDto agingInputDto = new AgingInputDto() |
| | | if (boxing.ProcessCode != "OCVB") |
| | | { |
| | | SerialNos = boxing.BoxingInfoDetails |
| | | .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo }) |
| | | .ToList(), |
| | | TrayBarcode = task.PalletCode, |
| | | OpFlag = 1, |
| | | EquipmentCode = area.Spare2, |
| | | Software = area.Spare3 |
| | | }; |
| | | // 处理请求参数 |
| | | AgingInputDto agingInputDto = new AgingInputDto() |
| | | { |
| | | SerialNos = boxing.BoxingInfoDetails |
| | | .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo }) |
| | | .ToList(), |
| | | TrayBarcode = task.PalletCode, |
| | | OpFlag = 1, |
| | | EquipmentCode = area.Spare2, |
| | | Software = area.Spare3 |
| | | }; |
| | | |
| | | var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; |
| | | var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()); |
| | | if (respone.ProductionLine == null || respone.ParameterInfos == null || respone.SpecialParameterDuration.IsNullOrEmpty()) |
| | | { |
| | | throw new Exception("MOM数据返回错误"); |
| | | var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; |
| | | var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()); |
| | | |
| | | bool isFull = false; |
| | | if (!task.Roadway.Contains("FR")) |
| | | { |
| | | isFull = respone.SpecialParameterDuration.IsNullOrEmpty(); |
| | | } |
| | | if (respone.ProductionLine == null || respone.ParameterInfos == null) |
| | | { |
| | | throw new Exception("MOM数据返回错误"); |
| | | } |
| | | stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; |
| | | stock.SpecialParameterDuration = respone.SpecialParameterDuration; |
| | | //2024年11月16日:新增字段计算应出库时间 |
| | | stock.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration)); |
| | | stock.ProductionLine = respone.ProductionLine; |
| | | stock.ParameterInfos = respone.ParameterInfos.ToJsonString(); |
| | | stock.StockStatus = 1; |
| | | } |
| | | stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; |
| | | stock.SpecialParameterDuration = respone.SpecialParameterDuration; |
| | | //2024年11月16日:新增字段计算应出库时间 |
| | | stock.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration)); |
| | | stock.ProductionLine = respone.ProductionLine; |
| | | stock.ParameterInfos = respone.ParameterInfos.ToJsonString(); |
| | | stock.StockStatus = 1; |
| | | else |
| | | { |
| | | stock.OutboundTime = DateTime.Now; |
| | | stock.StockStatus = 1; |
| | | stock.ProductionLine = boxing.ProductionLine; |
| | | } |
| | | |
| | | // 记录日志 |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "入库任务完成", $"货位地址:{task.TargetAddress},修改后货位数据:{locationInf}"); |
| | |
| | | PalletCode = palletCode, |
| | | IsFull = true, |
| | | ProcessCode = result.ProcessCode, |
| | | ProductionLine = result.ProductionLine, |
| | | BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail |
| | | { |
| | | SerialNumber = serialNoObj.SerialNo, |
| | |
| | | /// <param name="areaCode">区域编码</param> |
| | | /// <param name="roadways">巷道编码集合</param> |
| | | /// <returns>返回结果集</returns> |
| | | public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, string productionLine) |
| | | public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, List<string> areaCodes, string productionLine) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | // 根据托盘类型查询库存信息 |
| | | DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound |
| | | ? QueryStockInfoForRealTrayAsync(areaCode, productionLine).Result |
| | | : QueryStockInfoForEmptyTrayAsync(areaCode).Result; |
| | | ? areaCodes == null ? await QueryStockInfoForRealTrayAsync(areaCode, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine) |
| | | : await QueryStockInfoForEmptyTrayAsync(areaCode); |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | |
| | | .Includes(x => x.LocationInfo) // 预加载LocationInfo |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | | .FirstAsync(); // 获取第一个元素 |
| | | |
| | | //var firstOrDefault = result.FirstOrDefault(x => roadways.Contains(x.LocationInfo.RoadwayNo)); // 查找第一个匹配的元素 |
| | | //var firstOrDefault = result[0]; // 查找第一个匹配的元素 |
| | | //return firstOrDefault; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询实盘库存信息 |
| | | /// </summary> |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayCWAsync(List<string> areaCodes, string productionLine) |
| | | { |
| | | var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == "CWSC1"); |
| | | |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Includes(x => x.LocationInfo) // 预加载LocationInfo |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | |
| | | { |
| | | if (stockInfo.LocationInfo.RoadwayNo == "JZSC1") |
| | | { |
| | | task = CreateTask(stockInfo, "1359-4", taskType); |
| | | task = CreateTask(stockInfo, "002-021-001", taskType); |
| | | } |
| | | } |
| | | //var taskId = await BaseDal.AddDataAsync(task); |
| | |
| | | |
| | | #endregion 指定任务出库 |
| | | |
| | | #region 静置异常口入库 |
| | | |
| | | #endregion |
| | | |
| | | #endregion 外部接口方法 |
| | | |
| | | #region 内部调用方法 |
| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Common.CustomModels; |
| | | |
| | | //using WIDESEA_Common.CustomModels; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO.MOM; |
| | |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | // 判断需不需要去包装,不需要就去常温三 |
| | | var stationManagers = _stationManagerRepository.QueryData(x => x.stationPLC == "1018" && x.stationArea == "Cache"); |
| | | var station = stationManagers.Select(x => x.stationChildCode).ToList(); |
| | | var stationManagers = _stationManagerRepository.QueryData(x => x.stationPLC == "1018" && x.stationArea == "Cache" && x.productLine == input.ProductionLine); |
| | | |
| | | // 获取WCSip地址相关配置 |
| | | var wcsIpAddrss = GetWCSIpAddress(); |
| | | if (wcsIpAddrss == null) |
| | | { |
| | | throw new InvalidOperationException("WCS IP 未配置"); |
| | | } |
| | | //var station = stationManagers.Select(x => x.stationChildCode).ToList(); |
| | | |
| | | var abc = HttpHelper.PostAsync(wcsIpAddrss, station.ToJsonString()).Result; |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(abc); |
| | | if (content.Data.ObjToInt() > 0) |
| | | //// 获取WCSip地址相关配置 |
| | | //var wcsIpAddrss = GetWCSIpAddress(); |
| | | //if (wcsIpAddrss == null) |
| | | //{ |
| | | // throw new InvalidOperationException("WCS IP 未配置"); |
| | | //} |
| | | |
| | | //var abc = HttpHelper.PostAsync(wcsIpAddrss, station.ToJsonString()).Result; |
| | | //content = JsonConvert.DeserializeObject<WebResponseContent>(abc); |
| | | //var num = content.Data.ObjToInt(); |
| | | |
| | | |
| | | // TODO 判断在途数量 |
| | | var count = BaseDal.QueryData(x => x.TargetAddress == stationManagers[0].Roadway).Count; |
| | | if (count <= 10) |
| | | { |
| | | // 送至包装 |
| | | List<string> strings = stationManagers.Where(x => x.stationType == 0).Select(x => x.Roadway).ToList(); |
| | |
| | | [HttpPost, AllowAnonymous, Route("RequestTrayOutTaskAsync")] |
| | | public async Task<WebResponseContent> RequestTrayOutTaskAsync([FromBody] RequestOutTaskDto request) |
| | | { |
| | | return await Service.RequestTrayOutTaskAsync(request.Position, request.Tag, request.AreaCdoe, request.ProductionLine); |
| | | return await Service.RequestTrayOutTaskAsync(request.Position, request.Tag, request.AreaCdoe, request.AreaCdoes, request.ProductionLine); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="input">请求数据</param> |
| | | /// <returns></returns> |
| | | [HttpPost, AllowAnonymous, Route("EmergencyTask")] |
| | | public WebResponseContent EmergencyTask([FromBody] object input) |
| | | { |
| | | return Service.EmergencyTask(input); |
| | | } |
| | | //[HttpPost, AllowAnonymous, Route("EmergencyTask")] |
| | | //public WebResponseContent EmergencyTask([FromBody] object input) |
| | | //{ |
| | | // //return Service.EmergencyTask(input); |
| | | //} |
| | | } |