| | |
| | | var req = JsonConvert.DeserializeObject<mesInfo>(res); |
| | | if(req != null) |
| | | { |
| | | var timeCuo = MongoDBSingleton.Instance.FindOne<TimeCuoInfoCom>(Query.EQ("packingMachineNumber", models.machineNo), "TimeCuoInfoCom"); |
| | | if (timeCuo == null) |
| | | if (req.isSuccess) |
| | | { |
| | | MongoDBSingleton.Instance.Insert<TimeCuoInfoCom>(new TimeCuoInfoCom |
| | | var timeCuo = MongoDBSingleton.Instance.FindOne<TimeCuoInfoCom>(Query.EQ("packingMachineNumber", models.machineNo), "TimeCuoInfoCom"); |
| | | if (timeCuo == null) |
| | | { |
| | | isFold = 1, |
| | | packingMachineNumber = models.machineNo, |
| | | needWeight = (int)req.data.FMustQty, |
| | | realWeight = (int)req.data.FMustQty, |
| | | totalWeight = (int)req.data.FMustQty, |
| | | batchNumber = req.data.Flot, |
| | | productModel = req.data.materialSpec, |
| | | bagNumber_1 = req.data.bagNum, |
| | | totalCount = 1, |
| | | timeStamp = req.data.mesCode, |
| | | photoURL = req.data.barCode, |
| | | ProductionDate = req.data.ywDate, |
| | | // ERP变更-照相机新增字段 |
| | | materialCode = req.data.FMaterialNumber, |
| | | materialName = req.data.materialName, |
| | | measurementUnit = req.data.FUnit, |
| | | createOrganization = req.data.FPrdOrgNumber, |
| | | WarehouseCode = req.data.FStockNumber, |
| | | workshopCode = req.data.FWorkShopNumber, |
| | | BusinessDate = req.data.ywDate, |
| | | barcode = req.data.barCode, |
| | | |
| | | employeeID1 = req.data.jycjj, |
| | | |
| | | //变更注释 |
| | | totalNeedWeight = (int)req.data.FMustQty, |
| | | FEntryID_1 = 0, |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | var query = Query.EQ("packingMachineNumber", models.machineNo); |
| | | //变更注释 |
| | | UpdateBuilder update = Update.Set("isFold", 1).Set("packingMachineNumber",models.machineNo).Set("needWeight", (int)req.data.FMustQty) |
| | | .Set("realWeight", (int)req.data.FMustQty).Set("totalWeight", (int)req.data.FMustQty).Set("batchNumber", req.data.Flot) |
| | | .Set("productModel", req.data.materialSpec).Set("bagNumber_1", req.data.bagNum).Set("totalCount", 1).Set("timeStamp", req.data.mesCode) |
| | | .Set("photoURL", req.data.barCode).Set("ProductionDate", req.data.ywDate).Set("materialCode", req.data.FMaterialNumber) |
| | | .Set("materialName", req.data.materialName).Set("measurementUnit", req.data.FUnit) |
| | | .Set("createOrganization", req.data.FPrdOrgNumber).Set("WarehouseCode", req.data.FStockNumber).Set("workshopCode", req.data.FWorkShopNumber) |
| | | .Set("BusinessDate", req.data.ywDate).Set("barcode", req.data.barCode).Set("employeeID1", req.data.jycjj) |
| | | .Set("totalNeedWeight", (int)req.data.FMustQty).Set("FEntryID_1", 0); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoCom>(query, update, UpdateFlags.None); |
| | | } |
| | | |
| | | //生成到接驳平台的任务 |
| | | string traycode = DateTime.Now.ToString("yyyy-MM-dd").Replace("-", ""); |
| | | string timeCuo2 = req.data.mesCode.ToString(); |
| | | var CBInfo = Settings.GetConnectingbitsList().Where(a => a.enable == 1).ToList(); |
| | | if (CBInfo != null) |
| | | { |
| | | AMSHelper.HHAmsExecuteResult amsResult = null; |
| | | foreach (var a in CBInfo) |
| | | { |
| | | if (!string.IsNullOrEmpty(a.locCode)) |
| | | MongoDBSingleton.Instance.Insert<TimeCuoInfoCom>(new TimeCuoInfoCom |
| | | { |
| | | //在中间表中查找点位 |
| | | var CBTable = MongoDBSingleton.Instance.FindOne<ConnectingBits>(Query.EQ("Bit", a.locCode), "ConnectingBits"); |
| | | if (CBTable != null) |
| | | isFold = 1, |
| | | packingMachineNumber = models.machineNo, |
| | | needWeight = (int)req.data.FMustQty, |
| | | realWeight = (int)req.data.FMustQty, |
| | | totalWeight = (int)req.data.FMustQty, |
| | | batchNumber = req.data.Flot, |
| | | productModel = req.data.materialSpec, |
| | | bagNumber_1 = req.data.bagNum, |
| | | totalCount = 1, |
| | | timeStampMES = req.data.mesCode, |
| | | photoURL = req.data.barCode, |
| | | ProductionDate = req.data.ywDate, |
| | | // ERP变更-照相机新增字段 |
| | | materialCode = req.data.FMaterialNumber, |
| | | materialName = req.data.materialName, |
| | | measurementUnit = req.data.FUnit, |
| | | createOrganization = req.data.FPrdOrgNumber, |
| | | WarehouseCode = req.data.FStockNumber, |
| | | workshopCode = req.data.FWorkShopNumber, |
| | | BusinessDate = req.data.ywDate, |
| | | barcode = req.data.barCode, |
| | | |
| | | employeeID1 = req.data.jycjj, |
| | | |
| | | //变更注释 |
| | | totalNeedWeight = (int)req.data.FMustQty, |
| | | FEntryID_1 = 0, |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | var query = Query.EQ("packingMachineNumber", models.machineNo); |
| | | //变更注释 |
| | | UpdateBuilder update = Update.Set("isFold", 1).Set("packingMachineNumber", models.machineNo).Set("needWeight", (int)req.data.FMustQty) |
| | | .Set("realWeight", (int)req.data.FMustQty).Set("totalWeight", (int)req.data.FMustQty).Set("batchNumber", req.data.Flot) |
| | | .Set("productModel", req.data.materialSpec).Set("bagNumber_1", req.data.bagNum).Set("totalCount", 1).Set("timeStampMES", req.data.mesCode) |
| | | .Set("photoURL", req.data.barCode).Set("ProductionDate", req.data.ywDate).Set("materialCode", req.data.FMaterialNumber) |
| | | .Set("materialName", req.data.materialName).Set("measurementUnit", req.data.FUnit) |
| | | .Set("createOrganization", req.data.FPrdOrgNumber).Set("WarehouseCode", req.data.FStockNumber).Set("workshopCode", req.data.FWorkShopNumber) |
| | | .Set("BusinessDate", req.data.ywDate).Set("barcode", req.data.barCode).Set("employeeID1", req.data.jycjj) |
| | | .Set("totalNeedWeight", (int)req.data.FMustQty).Set("FEntryID_1", 0); |
| | | MongoDBSingleton.Instance.Update<TimeCuoInfoCom>(query, update, UpdateFlags.None); |
| | | } |
| | | |
| | | //生成到接驳平台的任务 |
| | | string traycode = DateTime.Now.ToString("yyyy-MM-dd").Replace("-", ""); |
| | | var CBInfo = Settings.GetConnectingbitsList().Where(a => a.enable == 1).ToList(); |
| | | if (CBInfo != null) |
| | | { |
| | | AMSHelper.HHAmsExecuteResult amsResult = null; |
| | | foreach (var a in CBInfo) |
| | | { |
| | | if (!string.IsNullOrEmpty(a.locCode)) |
| | | { |
| | | if (string.IsNullOrEmpty(CBTable.trayCode)) |
| | | //在中间表中查找点位 |
| | | var CBTable = MongoDBSingleton.Instance.FindOne<ConnectingBits>(Query.EQ("Bit", a.locCode), "ConnectingBits"); |
| | | if (CBTable != null) |
| | | { |
| | | if (string.IsNullOrEmpty(CBTable.trayCode)) |
| | | { |
| | | //生成任务,并且将点位写入中间表 |
| | | amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), models.machineNo, a.locCode, "PDA打包下线", 0, traycode); |
| | | if (amsResult.success) |
| | | { |
| | | result.success = true; |
| | | CMMLog.Debug($"PDA打包下线:AMS调用API成功!"); |
| | | MongoDBSingleton.Instance.Update<ConnectingBits>(Query.EQ("Bit", a.locCode), Update.Set("trayCode", traycode).Set("timeCuo", req.data.mesCode), UpdateFlags.None); |
| | | |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"PDA打包下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //生成任务,并且将点位写入中间表 |
| | | amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), models.machineNo, a.locCode, "PDA打包下线", 0, traycode); |
| | |
| | | { |
| | | result.success = true; |
| | | CMMLog.Debug($"PDA打包下线:AMS调用API成功!"); |
| | | MongoDBSingleton.Instance.Update<ConnectingBits>(Query.EQ("Bit", a.locCode), Update.Set("trayCode", traycode).Set("timeCuo", timeCuo2), UpdateFlags.None); |
| | | |
| | | //上报条码表 |
| | | CMMLog.Info($" INSERT INTO T_JY_BARCODESync (FBarCode, FBarCodeRule,FMaterialNumber,FCreateOrgNumber,FLot,FUnit,FQty,FStockNumber,FDept,FBillDate,F_JY_CZZ,FOpStatus) VALUES ('{req.data.barCode}','01','{req.data.materialName}','02','{req.data.Flot}','{req.data.FUnit}','{req.data.FMustQty}','CK020','BM000161','{req.data.ywDate}','{req.data.jycjj}','0')"); |
| | | new SqlHelper<object>().ExecuteSql($" INSERT INTO T_JY_BARCODESync (FBarCode, FBarCodeRule,FMaterialNumber,FCreateOrgNumber,FLot,FUnit,FQty,FStockNumber,FDept,FBillDate,F_JY_CZZ,FOpStatus) VALUES ('{req.data.barCode}','01','{req.data.materialName}','02','{req.data.Flot}','{req.data.FUnit}','{req.data.FMustQty}','CK020','BM000161','{req.data.ywDate}','{req.data.jycjj}','0')", false); |
| | | |
| | | //打包下线任务生成成功,向中间表插入数据 |
| | | MongoDBSingleton.Instance.Insert<ConnectingBits>(new ConnectingBits { Bit = a.locCode, trayCode = traycode, state = "0", timeCuo = req.data.mesCode }); |
| | | |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"PDA打包下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //生成任务,并且将点位写入中间表 |
| | | amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), models.machineNo, a.locCode, "PDA打包下线", 0, traycode); |
| | | if (amsResult.success) |
| | | if (amsResult != null && amsResult.success) |
| | | { |
| | | result.success = true; |
| | | CMMLog.Debug($"PDA打包下线:AMS调用API成功!"); |
| | | //打包下线任务生成成功,向中间表插入数据 |
| | | |
| | | MongoDBSingleton.Instance.Insert<ConnectingBits>(new ConnectingBits { Bit = a.locCode, trayCode = traycode, state = "0", timeCuo = timeCuo2 }); |
| | | |
| | | //上报条码表 |
| | | CMMLog.Info($" INSERT INTO T_JY_BARCODESync (FBarCode, FBarCodeRule,FMaterialNumber,FCreateOrgNumber,FLot,FUnit,FQty,FStockNumber,FDept,FBillDate,F_JY_CZZ,FOpStatus) VALUES ('{req.data.barCode}','01','{req.data.materialName}','02','{req.data.Flot}','{req.data.FUnit}','{req.data.FMustQty}','CK020','BM000161','{req.data.ywDate}','{req.data.jycjj}','0')"); |
| | | CMMLog.Info($"INSERT INTO T_JY_BARCODESync (FBarCode, FBarCodeRule,FMaterialNumber,FCreateOrgNumber,FLot,FUnit,FQty,FStockNumber,FDept,FBillDate,F_JY_CZZ,FOpStatus) VALUES ('{req.data.barCode}','01','{req.data.materialName}','02','{req.data.Flot}','{req.data.FUnit}','{req.data.FMustQty}','CK020','BM000161','{req.data.ywDate}','{req.data.jycjj}','0')"); |
| | | new SqlHelper<object>().ExecuteSql($" INSERT INTO T_JY_BARCODESync (FBarCode, FBarCodeRule,FMaterialNumber,FCreateOrgNumber,FLot,FUnit,FQty,FStockNumber,FDept,FBillDate,F_JY_CZZ,FOpStatus) VALUES ('{req.data.barCode}','01','{req.data.materialName}','02','{req.data.Flot}','{req.data.FUnit}','{req.data.FMustQty}','CK020','BM000161','{req.data.ywDate}','{req.data.jycjj}','0')", false); |
| | | //var plc = Settings.GetPlcInfo().Where(b => b.location == models.machineNo && b.enable == 1).First(); |
| | | //if(plc != null) |
| | | //{ |
| | | // var wirteall01 = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel |
| | | // { |
| | | // addr = plc.writeAddr, |
| | | // host = plc.ip, |
| | | // port = plc.port, |
| | | // data = 4 |
| | | // }); |
| | | //} |
| | | |
| | | break; |
| | | } |
| | | else CMMLog.Debug($"PDA打包下线:AMS调用API失败,开始重新调用!"); |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位点位未配置"); |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位点位未配置"); |
| | | if (amsResult == null || amsResult.success == false) |
| | | { |
| | | result.errMsg = "任务生成失败,接驳位有任务占用"; |
| | | } |
| | | } |
| | | if(amsResult == null || amsResult.success == false) |
| | | { |
| | | result.errMsg = "任务生成失败,接驳位有任务占用"; |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位未配置"); |
| | | } |
| | | else CMMLog.Debug("打包下线口接驳位未配置"); |
| | | else |
| | | { |
| | | result.errMsg = req.msg; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | public int code { get; set; } |
| | | public string msg { get; set; } |
| | | public mesData data { get; set; } |
| | | public bool isSucess { get; set; } |
| | | public bool isSuccess { get; set; } |
| | | } |
| | | |
| | | public class mesData |
| | |
| | | /// <summary> |
| | | /// 唯一码 |
| | | /// </summary> |
| | | public int mesCode { get; set; } |
| | | public string mesCode { get; set; } |
| | | /// <summary> |
| | | /// 完整条码 |
| | | /// </summary> |
| | |
| | | { |
| | | public ObjectId _id { get; set; } |
| | | public string trayCode { get; set; } |
| | | public string isUse { get; set; } = "0"; |
| | | public DateTime createTime { get; set; } |
| | | } |
| | | |