Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu
| | |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json |
| | | /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json |
| | | /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/CodeChunks.db |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/CodeChunks.db-shm |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/CodeChunks.db-wal |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/SemanticSymbols.db |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/SemanticSymbols.db-shm |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.31.40377/SemanticSymbols.db-wal |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/publish/win-x64/WIDESEAWCS_Server.csproj.nuget.g.targets |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/WIDESEAWCS_Server.csproj.EntityFrameworkCore.targets |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Properties/PublishProfiles/FolderProfile.pubxml |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/CodeChunks.db |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/CodeChunks.db-shm |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/CodeChunks.db-wal |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db-shm |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db-wal |
| | |
| | | <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> |
| | | </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 devices = reactive([]); |
| | | |
| | | const intToBitArrayFromBinaryString = (num, numBits) => { |
| | | let binaryString = num.toString(2).padStart(numBits, '0'); |
| | | return Array.from({ length: numBits }, (_, index) => binaryString[index] === '1'); |
| | | }; |
| | | |
| | | // çå¬è®¾å¤æ°æ®åå |
| | | 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 }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | 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> |
| | | .Stackerbox { |
| | | width: 220px; |
| | | float: left; |
| | | } |
| | | |
| | | .Linebox { |
| | | width: 500px; |
| | | float: left; |
| | | } |
| | | |
| | | .box1 { |
| | | float: left; |
| | | } |
| | | |
| | | .card-body { |
| | | text-align: center; |
| | | border-radius: 6%; |
| | | } |
| | | |
| | | .Stacker { |
| | | background-color: burlywood; |
| | | } |
| | | |
| | | .lis { |
| | | float: left; |
| | | width: 233px; |
| | | } |
| | | </style> |
| | | <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> |
| | | </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 devices = reactive([]); |
| | | |
| | | const intToBitArrayFromBinaryString = (num, numBits) => { |
| | | let binaryString = num.toString(2).padStart(numBits, '0'); |
| | | return Array.from({ length: numBits }, (_, index) => binaryString[index] === '1'); |
| | | }; |
| | | |
| | | // çå¬è®¾å¤æ°æ®åå |
| | | 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 }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | 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> |
| | | .Stackerbox { |
| | | width: 220px; |
| | | float: left; |
| | | } |
| | | |
| | | .Linebox { |
| | | width: 500px; |
| | | float: left; |
| | | } |
| | | |
| | | .box1 { |
| | | float: left; |
| | | } |
| | | |
| | | .card-body { |
| | | text-align: center; |
| | | border-radius: 6%; |
| | | } |
| | | |
| | | .Stacker { |
| | | background-color: burlywood; |
| | | } |
| | | |
| | | .lis { |
| | | float: left; |
| | | width: 233px; |
| | | } |
| | | </style> |
| | |
| | | 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); |
| | | //} |
| | | } |