| | |
| | | using iWareDataCore.BASE.Entity; |
| | | using iWareCommon.Common.Entity; |
| | | using iWareCommon.Utils; |
| | | using iWareDataCore.BASE.Entity; |
| | | using iWareDataCore.BASE.Service; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Threading; |
| | | using System.Web.Mvc; |
| | | using WebWIPAPI.Models; |
| | | using WebWIPAPI.Properties; |
| | | using WebWIPAPI.Utils; |
| | | |
| | | using LogTextHelper = WebWIPAPI.Utils.LogTextHelper; |
| | | |
| | | namespace WebWIPAPI.Controllers |
| | | { |
| | |
| | | /// <summary> |
| | | /// æä¾åºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="sysCode"></param> |
| | | /// <param name="wareHouseInfo"></param> |
| | | /// <param name="processCardNumber"></param> |
| | | /// <param name="wareHouseId"></param> |
| | | /// <param name="timestamp"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public ActionResult syncMaterialInfo() |
| | |
| | | return Json(responseMessage, JsonRequestBehavior.DenyGet); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导å
¥å
¥åºå |
| | | /// </summary> |
| | | /// <param name="inputmaterials"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public ActionResult importInOrder(List<MaterialViewForMesEntity> importMaterials) |
| | | { |
| | | var responseMessage = new ApiResponse<string>(); |
| | | var msg = ""; |
| | | |
| | | #region ä¸å¡å¤ç |
| | | |
| | | //ç¬¬ä¸æ¥ï¼å
æ°å¢å°ç©æåºç¡è¡¨ |
| | | List<MaterialViewEntity> materials = new List<MaterialViewEntity>(); |
| | | materials = ClassHelper.RotationMapping<List<MaterialViewEntity>, List<MaterialViewForMesEntity>>(importMaterials); |
| | | MaterialViewService.GetInstance().ImportExcelFromMes(materials, out msg); |
| | | |
| | | Thread.Sleep(400);//注æï¼ä¼ç 毫ç§ï¼ç¨äºæ°æ®åºäºå¡æäº¤ |
| | | |
| | | string typeName = "å
¥åº"; |
| | | List<InputMaterialEntity> inputmaterials = new List<InputMaterialEntity>(); |
| | | inputmaterials = ClassHelper.RotationMapping<List<InputMaterialEntity>, List<MaterialViewForMesEntity>>(importMaterials); |
| | | handler_importOutOrder(typeName, inputmaterials, out msg); |
| | | |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "å¼å¸¸:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "æå", |
| | | Data = null, |
| | | }; |
| | | } |
| | | |
| | | //å°å¯¹è±¡è½¬å为jsonæ ¼å¼ |
| | | var responseStr = JsonConvert.SerializeObject(responseMessage); |
| | | LogTextHelper.WriteLine(Resources.LogDir, "WIPAPI:{0},{1}, {2}", "importInOrder", "请æ±åæ°ï¼" + "", "ååºä¿¡æ¯;" + responseStr); |
| | | return Json(responseMessage, JsonRequestBehavior.DenyGet); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 导å
¥åºåºå |
| | | /// </summary> |
| | | /// <param name="inputmaterials"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public ActionResult importOutOrder(List<InputMaterialEntity> inputmaterials) |
| | | { |
| | | var responseMessage = new ApiResponse<string>(); |
| | | var msg = ""; |
| | | |
| | | #region ä¸å¡å¤ç |
| | | |
| | | string typeName = "åºåº"; |
| | | handler_importOutOrder(typeName, inputmaterials, out msg); |
| | | |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "å¼å¸¸:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "æå", |
| | | Data = null, |
| | | }; |
| | | } |
| | | |
| | | //å°å¯¹è±¡è½¬å为jsonæ ¼å¼ |
| | | var responseStr = JsonConvert.SerializeObject(responseMessage); |
| | | LogTextHelper.WriteLine(Resources.LogDir, "WIPAPI:{0},{1}, {2}", "importOutOrder", "请æ±åæ°ï¼" + "", "ååºä¿¡æ¯;" + responseStr); |
| | | return Json(responseMessage, JsonRequestBehavior.DenyGet); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å
Œ
±å¯¼å
¥ å
¥åºåæåºåºå |
| | | /// </summary> |
| | | /// <param name="typeName"></param> |
| | | /// <param name="inputmaterials"></param> |
| | | /// <param name="msg"></param> |
| | | private void handler_importOutOrder(string typeName, List<InputMaterialEntity> inputmaterials, out string msg) |
| | | { |
| | | try |
| | | { |
| | | #region ä¸å¡å¤ç |
| | | |
| | | msg = ""; |
| | | //var inputmaterials = InputMaterialService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Status", "æªçæ" } } }, out msg); |
| | | if (inputmaterials != null && inputmaterials.Count > 0) |
| | | { |
| | | var placeMaterial = PlaceMaterialViewService.GetInstance().QueryByParam(new QueryParam { }, out msg); |
| | | var inoutdetails = InOutListDetailViewService.GetInstance().QueryByParam(new QueryParam { }, out msg); |
| | | List<string> codes = new List<string>(); |
| | | inputmaterials.ForEach(x => codes.Add(x.Code)); |
| | | List<int> ids = new List<int>(); |
| | | var materials = InputMaterialService.GetInstance().GetIds(codes); |
| | | List<InOutListDetailEntity> detail = new List<InOutListDetailEntity>(); |
| | | for (int i = 0; i < materials.Count; i++) |
| | | { |
| | | if (typeName == "å
¥åº") |
| | | { |
| | | |
| | | if (placeMaterial.Select(x => x.MaterialId).Contains(materials[i].id)) |
| | | { |
| | | msg = materials[i].code + "å·²åå¨ç«åºä¸ï¼ä¸è½æ·»å å°å
¥åºåæç»ä¸ï¼"; |
| | | break; |
| | | } |
| | | if (inoutdetails.Select(x => x.MaterialId).Contains(materials[i].id)) |
| | | { |
| | | msg = materials[i].code + "å·²åå¨ä¹åçå
¥åºåæç»ä¸ï¼ä¸è½æ·»å å°å½åå
¥åºåæç»ä¸ï¼"; |
| | | break; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (!placeMaterial.Select(x => x.MaterialId).Contains(materials[i].id)) |
| | | { |
| | | msg = materials[i].code + "ä¸å¨ç«åºä¸ï¼ä¸è½æ·»å å°åºåºåæç»ä¸ï¼"; |
| | | break; |
| | | } |
| | | if (inoutdetails.Select(x => x.MaterialId).Contains(materials[i].id)) |
| | | { |
| | | var inoutdeta = inoutdetails.FirstOrDefault(x => x.MaterialId == materials[i].id); |
| | | if (inoutdeta.TypeName == "åºåº") |
| | | { |
| | | msg = materials[i].name + "å·²åå¨ä¹åçåºåºåæç»ä¸ï¼ä¸è½æ·»å å°å½ååºåºåæç»ä¸ï¼"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | InOutListDetailEntity inoutdetail = new InOutListDetailEntity() |
| | | { |
| | | MaterialId = materials[i].id, |
| | | IsFinish = 0 |
| | | }; |
| | | detail.Add(inoutdetail); |
| | | } |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | { |
| | | return; |
| | | } |
| | | InOutListService.GetInstance().CreateListAndDetial( |
| | | new InOutListEntity |
| | | { |
| | | ListNo = inputmaterials.First().ListNo, |
| | | CreateTime = DateTime.Now, |
| | | TypeName = typeName, |
| | | Status = 0, |
| | | Remark = "", |
| | | InOutListDetail = detail |
| | | }, out msg); |
| | | } |
| | | else |
| | | { |
| | | msg = ("请å
ç¡®ä¿åºå
¥åºåç©ææç»ä¸ä¸ºç©ºï¼"); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Reflection; |
| | | |
| | | namespace iWareCommon.Utils |
| | | { |
| | | public class ClassHelper |
| | | { |
| | | /// <summary> |
| | | /// å®ä½äºè½¬ |
| | | /// </summary> |
| | | /// <typeparam name="T">æ°è½¬æ¢çå®ä½</typeparam> |
| | | /// <typeparam name="S">è¦è½¬æ¢çå®ä½</typeparam> |
| | | /// <param name="s"></param> |
| | | /// <returns></returns> |
| | | public static T RotationMapping<T, S>(S s) |
| | | { |
| | | T target = Activator.CreateInstance<T>(); |
| | | var originalObj = s.GetType(); |
| | | var targetObj = typeof(T); |
| | | foreach (PropertyInfo original in originalObj.GetProperties()) |
| | | { |
| | | foreach (PropertyInfo t in targetObj.GetProperties()) |
| | | { |
| | | if (t.Name == original.Name) |
| | | { |
| | | t.SetValue(target, original.GetValue(s, null), null); |
| | | } |
| | | } |
| | | } |
| | | return target; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | <DependentUpon>Resources.resx</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="Utils\Base64Helper.cs" /> |
| | | <Compile Include="Utils\ClassHelper.cs" /> |
| | | <Compile Include="Utils\DESHelper.cs" /> |
| | | <Compile Include="Utils\EntityPropHelper.cs" /> |
| | | <Compile Include="Utils\FileHelper.cs" /> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using iWareCommon.Common.Entity; |
| | | using iWareCommon.Utils; |
| | | using iWareDataCore.ORM; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | |
| | | namespace iWareDataCore.BASE.Entity |
| | | { |
| | | public class MaterialViewForMesEntity : MaterialViewEntity |
| | | { |
| | | /// 7åºå
¥åºåå· |
| | | /// </summary> |
| | | public string ListNo { get; set; } |
| | | |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 导å
¥ç©æåºç¡æ°æ®ï¼æ¥æºMES ãEditby shaocx,2025-09-17ã |
| | | /// </summary> |
| | | /// <param name="materials"></param> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | public bool ImportExcelFromMes(List<MaterialViewEntity> materials, out string msg) |
| | | { |
| | | using (var dbModel = new DbModelCore()) |
| | | { |
| | | try |
| | | { |
| | | msg = ""; |
| | | if (materials.Count < 1) |
| | | { |
| | | msg = "ç©æè®°å½æ°ä¸º0ï¼è¯·ä¿®æ¹å鿰坼å
¥"; |
| | | return false; |
| | | } |
| | | var types = dbModel.BASEMaterialTypes.Where(x => 1 == 1).ToList(); |
| | | var i = 0; |
| | | var codes = new List<string>(); |
| | | List<MaterialEntity> materlst = new List<MaterialEntity>(); |
| | | var materialSaves = new List<MaterialEntity>(); |
| | | var existMaterialcodes = dbModel.BASEMaterials.Select(x => x.code).ToList(); |
| | | bool b1 = true; |
| | | foreach (MaterialViewEntity m in materials) |
| | | { |
| | | i += 1; |
| | | if (string.IsNullOrEmpty(m.Code)) |
| | | { |
| | | msg = string.Format("å¨ç¬¬{0}è¡ï¼ç©æå·ä¸è½ä¸ºç©ºï¼è¯·ä¿®æ¹å鿰坼å
¥", i + 1); |
| | | b1 = false; |
| | | break; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(m.Wide)) |
| | | { |
| | | msg = string.Format("å¨ç¬¬{0}è¡ï¼å®½ä¸è½ä¸ºç©ºï¼è¯·ä¿®æ¹å鿰坼å
¥", i + 1); |
| | | b1 = false; |
| | | break; |
| | | } |
| | | var type = types.FirstOrDefault(x => x.name == m.TypeName); |
| | | if (type == null) |
| | | { |
| | | m.MaterialType = 5;//å
¶ä» |
| | | } |
| | | else |
| | | { |
| | | m.MaterialType = type.id; |
| | | } |
| | | if (existMaterialcodes.Contains(m.Code)) |
| | | { |
| | | continue; |
| | | } |
| | | codes.Add(m.Code); |
| | | if (string.IsNullOrEmpty(m.Name)) { m.Name = m.Description; } |
| | | if (string.IsNullOrEmpty(m.Version)) { m.Version = "00"; } |
| | | |
| | | MaterialEntity mt = new MaterialEntity() |
| | | { |
| | | ClassificationSociety = m.ClassificationSociety, |
| | | Code = m.Code, |
| | | MaterialNo = m.MaterialNo, |
| | | Cost = m.Cost, |
| | | CuttingType = m.CuttingType, |
| | | Description = m.Description, |
| | | GuaranteePeriod = m.GuaranteePeriod, |
| | | IssueProjectNo = m.IssueProjectNo, |
| | | Length = m.Length, |
| | | SerialNo = m.SerialNo, |
| | | Name = m.Name, |
| | | LaneSeparation = m.Laneseparation, |
| | | MarkingPen = m.MarkingPen, |
| | | PageNo = m.PageNo, |
| | | Status = 1, |
| | | Thick = m.Thick, |
| | | Unit = m.Unit, |
| | | Remark = m.Remark, |
| | | ProcurementProjectNo = m.ProcurementProjectNo, |
| | | TypeId = m.MaterialType, |
| | | Version = m.Version, |
| | | Weight = m.Weight, |
| | | VerticalPosition = m.VerticalPosition, |
| | | Wide = m.Wide |
| | | }; |
| | | materialSaves.Add(mt); |
| | | |
| | | } |
| | | if (!b1) |
| | | { |
| | | return b1; |
| | | } |
| | | var sql = string.Format("INSERT INTO BASEMaterial(status, name, code, materialno, version, typeid, guaranteeperiod, cost, classificationsociety, unit, serialno, description, remark, verticalposition, weight, issueprojectno, procurementprojectno, cuttingtype, pageno, thick, wide, length, markingpen, laneseparation) VALUES"); |
| | | for (var j = 0; j < materialSaves.Count; j++) |
| | | { |
| | | sql += string.Format("({0}, '{1}', '{2}', '{3}', {4}, '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}','{16}' ,'{17}', '{18}', '{19}', '{20}', '{21}','{22}','{23}' ),", |
| | | materialSaves[j].Status, |
| | | StringHelper.RelpaceQuot(materialSaves[j].Name), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Code), |
| | | StringHelper.RelpaceQuot(materialSaves[j].MaterialNo), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Version), |
| | | materialSaves[j].TypeId, |
| | | StringHelper.RelpaceQuot(materialSaves[j].GuaranteePeriod), |
| | | materialSaves[j].Cost, |
| | | StringHelper.RelpaceQuot(materialSaves[j].ClassificationSociety), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Unit), |
| | | StringHelper.RelpaceQuot(materialSaves[j].SerialNo), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Description), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Remark), |
| | | StringHelper.RelpaceQuot(materialSaves[j].VerticalPosition), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Weight), |
| | | StringHelper.RelpaceQuot(materialSaves[j].IssueProjectNo), |
| | | StringHelper.RelpaceQuot(materialSaves[j].ProcurementProjectNo), |
| | | StringHelper.RelpaceQuot(materialSaves[j].CuttingType), |
| | | StringHelper.RelpaceQuot(materialSaves[j].PageNo), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Thick), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Wide), |
| | | StringHelper.RelpaceQuot(materialSaves[j].Length), |
| | | StringHelper.RelpaceQuot(materialSaves[j].MarkingPen), |
| | | StringHelper.RelpaceQuot(materialSaves[j].LaneSeparation)); |
| | | } |
| | | if (sql.EndsWith(",")) |
| | | { |
| | | sql = sql.Substring(0, sql.Length - 1); |
| | | } |
| | | var num = dbModel.Database.ExecuteSqlCommand(sql); |
| | | |
| | | return string.IsNullOrEmpty(msg); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "ImportExcel", ex.Message); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <Compile Include="BASE\Entity\InOutListEntity.cs" /> |
| | | <Compile Include="BASE\Entity\EmptyPlaceViewEntity.cs" /> |
| | | <Compile Include="BASE\Entity\InputMaterialEntity.cs" /> |
| | | <Compile Include="BASE\Entity\MaterialViewForMesEntity.cs" /> |
| | | <Compile Include="BASE\Entity\WebOrderDetailViewEntity.cs" /> |
| | | <Compile Include="BASE\Entity\WebOrderDetailEntity.cs" /> |
| | | <Compile Include="BASE\Entity\MaterialClassEntity.cs" /> |