| | |
| | | using iWareCommon.Common.Entity; |
| | | using AutoMapper; |
| | | using iWareCommon.Common.Entity; |
| | | using iWareCommon.Utils; |
| | | using iWareDataCore.BASE.Entity; |
| | | using iWareDataCore.BASE.Service; |
| | |
| | | using System.Web.Mvc; |
| | | using WebWIPAPI.Models; |
| | | using WebWIPAPI.Properties; |
| | | using WebWIPAPI.Utils; |
| | | using LogTextHelper = WebWIPAPI.Utils.LogTextHelper; |
| | | |
| | | namespace WebWIPAPI.Controllers |
| | |
| | | public ActionResult syncMaterialInfo() |
| | | { |
| | | var responseMessage = new ApiResponse<List<PlaceMaterialViewEntity>>(); |
| | | var msg = ""; |
| | | var datalist = PlaceMaterialViewService.GetInstance().GetPlacePreview(out msg); |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | try |
| | | { |
| | | var msg = ""; |
| | | var datalist = PlaceMaterialViewService.GetInstance().GetPlacePreview(out msg); |
| | | datalist = datalist.Where(x => !string.IsNullOrEmpty(x.MaterialCode)).ToList(); |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | { |
| | | responseMessage = new ApiResponse<List<PlaceMaterialViewEntity>>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "获取异常:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<List<PlaceMaterialViewEntity>>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "成功", |
| | | Data = datalist, |
| | | }; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | responseMessage = new ApiResponse<List<PlaceMaterialViewEntity>>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "异常:" + msg, |
| | | Message = "异常:" + ex.Message, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<List<PlaceMaterialViewEntity>>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "成功", |
| | | Data = datalist, |
| | | }; |
| | | } |
| | | |
| | | //将对象转化为json格式 |
| | | var responseStr = JsonConvert.SerializeObject(responseMessage); |
| | | LogTextHelper.WriteLine(Resources.LogDir, "WIPAPI:{0},{1}, {2}", "syncMaterialInfo", "请求参数:" + "", "响应信息;" + responseStr); |
| | |
| | | var responseMessage = new ApiResponse<string>(); |
| | | var msg = ""; |
| | | |
| | | #region 业务处理 |
| | | try |
| | | { |
| | | #region 验证 |
| | | if (importMaterials?.Count() == 0) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "数据条数为0", |
| | | Data = null, |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importInOrder", ""); |
| | | } |
| | | if (importMaterials.Select(x => x.ListNo).Distinct().Count() != 1) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "本次请求单号必须为同一值", |
| | | Data = null, |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importInOrder", ""); |
| | | } |
| | | #endregion |
| | | |
| | | //第一步:先新增到物料基础表 |
| | | List<MaterialViewEntity> materials = new List<MaterialViewEntity>(); |
| | | materials = ClassHelper.RotationMapping<List<MaterialViewEntity>, List<MaterialViewForMesEntity>>(importMaterials); |
| | | MaterialViewService.GetInstance().ImportExcelFromMes(materials, out msg); |
| | | #region 业务处理 |
| | | |
| | | Thread.Sleep(400);//注意:休眠毫秒,用于数据库事务提交 |
| | | //第一步:先新增到物料基础表 |
| | | List<MaterialViewEntity> materials = new List<MaterialViewEntity>(); |
| | | |
| | | string typeName = "入库"; |
| | | List<InputMaterialEntity> inputmaterials = new List<InputMaterialEntity>(); |
| | | inputmaterials = ClassHelper.RotationMapping<List<InputMaterialEntity>, List<MaterialViewForMesEntity>>(importMaterials); |
| | | handler_importOutOrder(typeName, inputmaterials, out msg); |
| | | materials = ClassHelper.RotationMapping_Json<List<MaterialViewEntity>, List<MaterialViewForMesEntity>>(importMaterials); |
| | | |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | MaterialViewService.GetInstance().ImportExcelFromMes(materials, out msg); |
| | | if (!string.IsNullOrEmpty(msg)) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "新增到物料基础表异常:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(400);//注意:休眠毫秒,用于数据库事务提交 |
| | | |
| | | string typeName = "入库"; |
| | | List<InputMaterialEntity> inputmaterials = new List<InputMaterialEntity>(); |
| | | inputmaterials = ClassHelper.RotationMapping_Json<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, |
| | | }; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "异常:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "成功", |
| | | Message = "异常:" + ex.Message, |
| | | Data = null, |
| | | }; |
| | | } |
| | | |
| | | //将对象转化为json格式 |
| | | var responseStr = JsonConvert.SerializeObject(responseMessage); |
| | | LogTextHelper.WriteLine(Resources.LogDir, "WIPAPI:{0},{1}, {2}", "importInOrder", "请求参数:" + "", "响应信息;" + responseStr); |
| | | return Json(responseMessage, JsonRequestBehavior.DenyGet); |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importInOrder", ""); |
| | | } |
| | | |
| | | |
| | | ///// <summary> |
| | | ///// 导入出库单-版本1 |
| | | ///// </summary> |
| | | ///// <param name="inputmaterials"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost] |
| | | //public ActionResult importOutOrder(List<InputMaterialEntity> inputmaterials) |
| | | //{ |
| | | // var responseMessage = new ApiResponse<string>(); |
| | | // try |
| | | // { |
| | | // var msg = ""; |
| | | |
| | | // #region 验证 |
| | | // if (inputmaterials?.Count() == 0) |
| | | // { |
| | | // responseMessage = new ApiResponse<string>() |
| | | // { |
| | | // Code = 500, |
| | | // Success = false, |
| | | // Message = "数据条数为0", |
| | | // Data = null, |
| | | // }; |
| | | // return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | // } |
| | | // if (inputmaterials.Select(x => x.ListNo).Distinct().Count() != 1) |
| | | // { |
| | | // responseMessage = new ApiResponse<string>() |
| | | // { |
| | | // Code = 500, |
| | | // Success = false, |
| | | // Message = "本次请求单号必须为同一值", |
| | | // Data = null, |
| | | // }; |
| | | // return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | // } |
| | | // #endregion |
| | | |
| | | // #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, |
| | | // }; |
| | | // } |
| | | |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // responseMessage = new ApiResponse<string>() |
| | | // { |
| | | // Code = 500, |
| | | // Success = false, |
| | | // Message = "异常:" + ex.Message, |
| | | // Data = null, |
| | | // }; |
| | | // } |
| | | |
| | | // return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | //} |
| | | |
| | | |
| | | /// <summary> |
| | | /// 导入出库单 |
| | | /// 导入出库单-版本2 |
| | | /// </summary> |
| | | /// <param name="inputmaterials"></param> |
| | | /// <returns></returns> |
| | |
| | | public ActionResult importOutOrder(List<InputMaterialEntity> inputmaterials) |
| | | { |
| | | var responseMessage = new ApiResponse<string>(); |
| | | var msg = ""; |
| | | try |
| | | { |
| | | var msg = ""; |
| | | |
| | | #region 业务处理 |
| | | #region 验证 |
| | | if (inputmaterials?.Count() == 0) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "数据条数为0", |
| | | Data = null, |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | if (inputmaterials.Select(x => x.ListNo).Distinct().Count() != 1) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "本次请求单号必须为同一值", |
| | | Data = null, |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | #endregion |
| | | |
| | | string typeName = "出库"; |
| | | handler_importOutOrder(typeName, inputmaterials, out msg); |
| | | #region 业务处理 |
| | | |
| | | #endregion |
| | | string typeName = "出库"; |
| | | handler_importOutOrder(typeName, inputmaterials, out msg); |
| | | |
| | | if (!string.IsNullOrEmpty(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, |
| | | }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "异常:" + msg, |
| | | Data = null, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | { |
| | | Code = 200, |
| | | Success = true, |
| | | Message = "成功", |
| | | Message = "异常:" + ex.Message, |
| | | Data = null, |
| | | }; |
| | | } |
| | | |
| | | //将对象转化为json格式 |
| | | var responseStr = JsonConvert.SerializeObject(responseMessage); |
| | | LogTextHelper.WriteLine(Resources.LogDir, "WIPAPI:{0},{1}, {2}", "importOutOrder", "请求参数:" + "", "响应信息;" + responseStr); |
| | | return Json(responseMessage, JsonRequestBehavior.DenyGet); |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 公共导入 入库单或出库单 |
| | |
| | | List<int> ids = new List<int>(); |
| | | var materials = InputMaterialService.GetInstance().GetIds(codes); |
| | | List<InOutListDetailEntity> detail = new List<InOutListDetailEntity>(); |
| | | if (materials?.Count == 0) |
| | | { |
| | | msg = ("物料明细查询为空!"); |
| | | return; |
| | | } |
| | | for (int i = 0; i < materials.Count; i++) |
| | | { |
| | | if (typeName == "入库") |