| | |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using WebAPI.Service; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class Sc_ProcessMangementController : ApiController |
| | |
| | | List<WebAPI.Models.Sc_ProcessPlanViewModel> ls = new List<WebAPI.Models.Sc_ProcessPlanViewModel>(); |
| | | ls = oListModels.getObjectByJson_SendWorkSub(msg3); |
| | | int i = 0; |
| | | Model.ClsSc_ProcessSendWorkSub sendworksub = new Model.ClsSc_ProcessSendWorkSub(); |
| | | List<Model.ClsSc_ProcessSendWorkSub> lss = new List<Model.ClsSc_ProcessSendWorkSub>(); |
| | | foreach (WebAPI.Models.Sc_ProcessPlanViewModel oItemSub in ls) |
| | | { |
| | | |
| | | //foreach (var item in collection) |
| | | //{ |
| | | |
| | | //} |
| | | //i++; |
| | | //if (oItemSub.HQty <= 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "保存失败!第" + i.ToString() + "行数量不大于0无法保存!"; |
| | | // objJsonResult.data = 1; |
| | | // return objJsonResult; |
| | | //} |
| | | //if (oItemSub.HQty > oItemSub.HRelationQty) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "保存失败!第" + i.ToString() + "行数量不能大于未关联数量!"; |
| | | // objJsonResult.data = 1; |
| | | // return objJsonResult; |
| | | //} |
| | | i++; |
| | | Model.ClsSc_ProcessSendWorkSub sendworksub = new Model.ClsSc_ProcessSendWorkSub(); |
| | | sendworksub.HProcID = oItemSub.hprocid.Value;//--工序ID |
| | | sendworksub.HProcPlanBillNo = oItemSub.工序计划单号; //--工序计划单号 |
| | | sendworksub.HProcPlanEntryID = oItemSub.hsubid.Value; //--工序计划单子ID |
| | | sendworksub.HProcPlanInterID = oItemSub.hmainid.Value; //--工序计划单ID |
| | | sendworksub.HICMOInterID = oItemSub.hicmointerid.Value; //--任务单ID |
| | | sendworksub.HICMOBillNo = oItemSub.任务单号; //--任务单号 |
| | | sendworksub.HSeOrderBillNo = oItemSub.销售订单号; //--销售订单号 |
| | | sendworksub.HSeOrderEntryID = oItemSub.销售订单子ID.Value; //--销售子ID |
| | | sendworksub.HSeOrderInterID = oItemSub.销售订单主ID.Value; //--销售订单主ID |
| | | sendworksub.HPlanTimes = (float)oItemSub.计划加工时间; //--计划工时 |
| | | sendworksub.HPlanEndDate = oItemSub.计划完工日期.Value; //--计划完工日期 |
| | | sendworksub.HPlanBeginDate = oItemSub.计划开工日期.Value; //--计划开工日期 |
| | | sendworksub.HQty = (double)oItemSub.计划数量; //--派工数量 |
| | | sendworksub.HWorkerNumber = oItemSub.操作员代码; //--操作工代码 |
| | | sendworksub.HWorkerID = oItemSub.HWorkerID.Value; //--操作工ID |
| | | sendworksub.HGroupNumber = oItemSub.班组代码; //班组代码 |
| | | sendworksub.HGroupID = oItemSub.HGroupID.Value; //--班组ID |
| | | sendworksub.HSourceNumber = oItemSub.生产资源; //--生产资源代码 |
| | | //--生产资源ID |
| | | sendworksub.HProcNumber = oItemSub.工序代码; //--工序代码 |
| | | sendworksub.HRemark = oItemSub.表体备注; //--备注 |
| | | |
| | | if (oItemSub.计划数量 <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!第" + i.ToString() + "行数量不大于0无法保存!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (Convert.ToInt32( sendworksub.HQty) > Convert.ToInt32( oItemSub.计划数量)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!第" + i.ToString() + "行派工数量不能大于计划单数量!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //if (DBUtility.ClsPub.isStrNull(oItemSub.HBatChNo) == "") |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | //oItemSub.HEntryID = i; |
| | | //oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); |
| | | //oItemSub.HRemark = ""; |
| | | //oItemSub.HCloseMan = ""; |
| | | //oItemSub.HCloseType = false; |
| | | //Sendwork.DetailColl.Add(oItemSub); |
| | | sendworksub.HEntryID = i; |
| | | sendworksub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); |
| | | sendworksub.HRemark = ""; |
| | | sendworksub.HCloseMan = ""; |
| | | sendworksub.HCloseType = false; |
| | | sendworksub.HSourceBillType = oItemSub.HBillType; |
| | | lss.Add(sendworksub);//先把数据存放到派工单子表集合里 |
| | | |
| | | |
| | | |
| | | } |
| | | if (lss.Count > 0) |
| | | { |
| | | //然后再循环保存到派工单子表的集合里 |
| | | foreach (Model.ClsSc_ProcessSendWorkSub Itemsendwork in lss) |
| | | { |
| | | Sendwork.DetailColl.Add(Itemsendwork); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!lss集合小于0"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //保存 |
| | | //保存完毕后处理 |
| | |
| | | return GetObjectJson(ds); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PDA工序汇报单保存 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveProcessReport")] |
| | | [HttpPost] |
| | | public object SaveProcessReport([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | DAL.ClsSc_ProcessReport ReportModel = new DAL.ClsSc_ProcessReport(); |
| | | List<WebAPI.Models.Sc_ProcessReportViewModel> ls = new List<WebAPI.Models.Sc_ProcessReportViewModel>(); |
| | | ls = oListModels.getObjectByJson_Report(msg1); |
| | | int i = 0; |
| | | Model.ClsSc_ProcessReportMain ReportMain = new Model.ClsSc_ProcessReportMain(); |
| | | Model.ClsSc_ProcessReportSub ReportSub = new Model.ClsSc_ProcessReportSub(); |
| | | foreach (Models.Sc_ProcessReportViewModel ItemView in ls) |
| | | { |
| | | i++; |
| | | //工序汇报单主表保存 |
| | | ReportMain.HBillType = "3714"; |
| | | ReportMain.HBillNo = ItemView.HBillNo; |
| | | ReportMain.HMakeDate=DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | ReportMain.HYear=DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | ReportMain.HDate = DateTime.Now; |
| | | ReportMain.HInterID = ItemView.HInterID; |
| | | ReportMain.HMaker = ItemView.HEmp; |
| | | ReportMain.HCloseType = false; |
| | | ReportMain.HPlanQty = (double)ItemView.HQty; |
| | | //保存到汇报单主表 |
| | | ReportModel.omodel = ReportMain; |
| | | |
| | | |
| | | ReportSub.HEmpID = (long)ItemView.HEmpID; |
| | | ReportSub.HICMOBillNo = ItemView.HICMOBillNo; |
| | | ReportSub.HICMOInterID = (long)ItemView.HICMOInterID; |
| | | ReportSub.HEntryID = i; |
| | | ReportSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); |
| | | ReportSub.HRemark = ""; |
| | | ReportSub.HCloseMan = ""; |
| | | ReportSub.HCloseType = false; |
| | | ReportSub.HSourceBillType = "3712"; |
| | | ReportSub.HQty = (double)ItemView.HQty; |
| | | //保存到汇报单子表 |
| | | ReportModel.DetailColl.Add(ReportSub); |
| | | } |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult; |
| | | if (ReportModel.omodel.HInterID == 0) |
| | | { |
| | | // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | bResult = ReportModel.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | bResult = ReportModel.ModifyBill(ReportModel.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 派工单号获取信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Sc_ProcessMangement/getHbarCodeDetail")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetHbarCodeDetail(string sBillBarCode) |
| | | { |
| | | var model = LuBaoSevice.GetHbarCodeDetail(sBillBarCode); |
| | | return model; |
| | | } |
| | | |
| | | /// <summary> |
| | | ///工序号获得信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Sc_ProcessMangement/getProcDetail")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo) |
| | | { |
| | | var model = LuBaoSevice.GetProcDetail(sBillNo, sProcNo); |
| | | return model; |
| | | } |
| | | |
| | | |
| | | // |
| | | } |