| | |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IPackInfoService; |
| | | <<<<<<< HEAD |
| | | ======= |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | |
| | | >>>>>>> main |
| | | |
| | | namespace WIDESEAWCS_PackInfoService |
| | | { |
| | | public class PackaxisService : ServiceBase<Dt_Packaxis, IPackaxisRepository>, IPackaxisService |
| | | { |
| | | <<<<<<< HEAD |
| | | public PackaxisService(IPackaxisRepository BaseDal) : base(BaseDal) |
| | | { |
| | | ======= |
| | | private readonly IPackTypeRepository _packTypeRepository; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | public PackaxisService(IPackaxisRepository BaseDal, IPackTypeRepository packTypeRepository, IStationMangerRepository stationMangerRepository) : base(BaseDal) |
| | | { |
| | | _packTypeRepository = packTypeRepository; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | >>>>>>> main |
| | | } |
| | | public override WebResponseContent Import(List<IFormFile> files) |
| | | { |
| | |
| | | using (ImportExcelHelper excelHelper = new ImportExcelHelper(fullPath)) |
| | | { |
| | | dtExcel = excelHelper.ExcelToDataTable(); |
| | | <<<<<<< HEAD |
| | | |
| | | ======= |
| | | |
| | | >>>>>>> main |
| | | } |
| | | List<Dt_Packaxis> addAxis = new List<Dt_Packaxis>(); |
| | | List<Dt_Packaxis> updateAxis = new List<Dt_Packaxis>(); |
| | |
| | | string AxisZCount = row["AxisZCount"]?.ToString() ?? string.Empty; |
| | | string AxisZSpacing = row["AxisZSpacing"]?.ToString() ?? string.Empty; |
| | | var axis = BaseDal.QueryFirst(x => x.DeviceCode == DeviceCode && x.StationCode == StationCode && x.PackType == PackType); |
| | | <<<<<<< HEAD |
| | | if(axis == null) |
| | | ======= |
| | | if (axis == null) |
| | | >>>>>>> main |
| | | { |
| | | Dt_Packaxis packaxis = new Dt_Packaxis() |
| | | { |
| | |
| | | |
| | | return content; |
| | | } |
| | | <<<<<<< HEAD |
| | | ======= |
| | | /// <summary> |
| | | /// æ·»å åæ æ°æ® |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public override WebResponseContent AddData(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string json = JsonConvert.SerializeObject(saveModel.MainData); |
| | | Dt_Packaxis dt_Pack = JsonConvert.DeserializeObject<Dt_Packaxis>(json); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == dt_Pack.StationCode && x.StackerCraneCode == dt_Pack.DeviceCode); |
| | | Dt_PackType packTyp = _packTypeRepository.QueryFirst(x => x.Id == dt_Pack.PackType); |
| | | |
| | | int w = 1200;//è¿ä¸ªæ¯ç åæç宽1.2ç±³ |
| | | int h = 1500;//æççé«åº¦éé«1.5ç±³ |
| | | int AxisXCountMax = w / packTyp.PackLength;//Xåæ æå¤æ¾ç åæ°é |
| | | int AxisYCountMax = w / packTyp.PackWidth;//Yåæ æå¤æ¾ç åæ°é |
| | | int AxisZCountMax = h / packTyp.PackHeight;//Zåæ æå¤æ¾ç åæ°é |
| | | |
| | | |
| | | if (dt_Pack.AxisXCount <= 0 || dt_Pack.AxisXCount > AxisXCountMax || dt_Pack.AxisYCount <= 0 || dt_Pack.AxisYCount > AxisYCountMax || dt_Pack.AxisZCount <= 0 || dt_Pack.AxisZCount > AxisZCountMax) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æ·»å 失败ï¼è¯·è¾å
¥Xåæ ç 忰大äº0ä¸å°äº{AxisXCountMax + 1}ä¸Yåæ ç 忰大äº0ä¸å°äº{AxisYCountMax + 1}ä¸Zåæ ç 忰大äº0ä¸å°äº{AxisZCountMax + 1}"); |
| | | } |
| | | |
| | | if (stationManger.IsNullOrEmpty()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æ·»å 失败ï¼è¯¥ç åæºå¨è¾é线工ä½ééï¼"); |
| | | } |
| | | |
| | | Dt_Packaxis packaxis = BaseDal.QueryFirst(x => x.DeviceCode == dt_Pack.DeviceCode && x.StationCode == dt_Pack.StationCode && x.PackType == dt_Pack.PackType); |
| | | |
| | | |
| | | |
| | | if (packaxis.IsNullOrEmpty()) |
| | | { |
| | | |
| | | saveModel.MainData["PackNum"] = dt_Pack.AxisXCount * dt_Pack.AxisYCount * dt_Pack.AxisZCount; |
| | | |
| | | return base.AddData(saveModel); |
| | | } |
| | | return WebResponseContent.Instance.Error($"æ·»å 失败,该ç ååæ æ°æ®å·²åå¨!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | return content; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// ä¿®æ¹åæ æ°æ® |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public override WebResponseContent UpdateData(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string json = JsonConvert.SerializeObject(saveModel.MainData); |
| | | Dt_Packaxis dt_Pack = JsonConvert.DeserializeObject<Dt_Packaxis>(json); |
| | | |
| | | Dt_PackType packTyp = _packTypeRepository.QueryFirst(x => x.Id == dt_Pack.PackType); |
| | | |
| | | int w = 1200;//è¿ä¸ªæ¯ç åæç宽1.2ç±³ |
| | | int h = 1500;//æççé«åº¦éé«1.5ç±³ |
| | | int AxisXCountMax = w / packTyp.PackLength;//Xåæ æå¤æ¾ç åæ°é |
| | | int AxisYCountMax = w / packTyp.PackWidth;//Yåæ æå¤æ¾ç åæ°é |
| | | int AxisZCountMax = h / packTyp.PackHeight;//Zåæ æå¤æ¾ç åæ°é |
| | | |
| | | |
| | | if (dt_Pack.AxisXCount <= 0 || dt_Pack.AxisXCount > AxisXCountMax || dt_Pack.AxisYCount <= 0 || dt_Pack.AxisYCount > AxisYCountMax || dt_Pack.AxisZCount <= 0 || dt_Pack.AxisZCount > AxisZCountMax) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä¿®æ¹å¤±è´¥ï¼è¯·è¾å
¥Xåæ ç 忰大äº0ä¸å°äº{AxisXCountMax + 1}ä¸Yåæ ç 忰大äº0ä¸å°äº{AxisYCountMax + 1}ä¸Zåæ ç 忰大äº0ä¸å°äº{AxisZCountMax + 1}"); |
| | | } |
| | | |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == dt_Pack.StationCode && x.StackerCraneCode == dt_Pack.DeviceCode); |
| | | if (stationManger.IsNullOrEmpty()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä¿®æ¹å¤±è´¥ï¼è¯¥ç åæºå¨è¾é线工ä½ééï¼"); |
| | | } |
| | | Dt_Packaxis packaxis = BaseDal.QueryFirst(x => x.Id != dt_Pack.Id && x.DeviceCode == dt_Pack.DeviceCode && x.StationCode == dt_Pack.StationCode && x.PackType == dt_Pack.PackType); |
| | | if (packaxis.IsNullOrEmpty()) |
| | | { |
| | | |
| | | saveModel.MainData["PackNum"] = dt_Pack.AxisXCount * dt_Pack.AxisYCount * dt_Pack.AxisZCount; |
| | | |
| | | return base.UpdateData(saveModel); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.Error($"ä¿®æ¹å¤±è´¥,该ç ååæ æ°æ®å·²åå¨!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | return content; |
| | | |
| | | } |
| | | >>>>>>> main |
| | | } |
| | | } |