New file |
| | |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers.SCGL |
| | | { |
| | | public class Sc_WorkBillSortBillController : ApiController |
| | | { |
| | | private json objJsonResult = new json(); |
| | | public DataSet ds = new DataSet(); |
| | | public WebServer webserver = new WebServer(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | Sc_WorkBillSortBillMain omdelMian = new Sc_WorkBillSortBillMain(); |
| | | List<Sc_WorkBillSortBillSub> omodelsub = new List<Sc_WorkBillSortBillSub>(); |
| | | |
| | | #region 日计划工单 列表 |
| | | [Route("Sc_WorkBillSortBill/Sc_WorkBillSortBillList")] |
| | | [HttpGet] |
| | | public object Sc_WorkBillSortBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Sc_WorkBillSortBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_JIT_Sc_WorkBillSortBillList"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 日计划工单 添加/修改 |
| | | [Route("Sc_WorkBillSortBill/AddWorkBillSortBillList")] |
| | | [HttpPost] |
| | | public object AddWorkBillSortBillList([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //保存主表 |
| | | objJsonResult = AddBillMain(msg1); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "新增单据成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | public json AddBillMain(string msg1) |
| | | { |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | |
| | | int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id |
| | | int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改 |
| | | string user = sArray[4].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("JIT_ComplementGoodBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(msg2); |
| | | string BillType = "4610"; |
| | | |
| | | |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //主表 |
| | | oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType" + |
| | | ",HBillSubType,HDate,HBillStatus,HMaker,HMakeDate" + |
| | | ", HRemark, HPrintQty, HDeptID, HSeOrderBillNo, HSourceQty" + |
| | | ", HInStockQty, HMaterID, HMaterName, HMaterModel, HGroupID" + |
| | | ", HWorkShopID, HRelationQty, HUnitID, HWorkerID, HSourceID" + |
| | | ", HBeginWorkTimes, HInStockOwnerTypeID, HSplitRelationQty, HOrderLev, HWorkQty" + |
| | | ", HSplitPlanQty, HOwnerTypeID, HPlanBeginDate, HPlanEndDate, HICMOBillNo" + |
| | | ", HOwnerID, HBatchNo, HYX, HProdTimes, HEntrustORGID" + |
| | | ", HPlanQty, HPreparatDate, HOrderNeedQty, HOrderCommitDate, HCompleteQty" + |
| | | ", HSeOrderBillQty, HICMOInterID, HKTQ, HStockInORGID, HDayPlanSumQty" + |
| | | ", HSourceBillNo, HICMOEntryID, HMainInterID, HProdORGID, HLeftPlanQty" + |
| | | ", HEmpID, HInStockOwnerID, HICMOEntrySEQ, HICMOBillType, HCloseCount" + |
| | | ", HOrderType, HSplitQty, HSourceStockInQty, HPriority, HLocked, HHangUp)" + |
| | | $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}', {DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}'" + |
| | | $", '{BillType}','{omdelMian.HDate}',1, '{omdelMian.HMaker}',GETDATE()," + |
| | | $"'{omdelMian.HRemark}',{(omdelMian.HPrintQty==null?0: omdelMian.HPrintQty)},{omdelMian.HDeptID}, '{omdelMian.HSeOrderBillNo}', {(omdelMian.HSourceQty==null?0:omdelMian.HSourceQty)}" + |
| | | $",{(omdelMian.HInStockQty == null ? 0: omdelMian.HInStockQty)},{omdelMian.HMaterID}, '{omdelMian.HMaterName}', '{omdelMian.HMaterModel}', {omdelMian.HGroupID}" + |
| | | $", {omdelMian.HWorkShopID}, {(omdelMian.HRelationQty == null ? 0: omdelMian.HRelationQty)},{omdelMian.HUnitID},{omdelMian.HWorkerID},{omdelMian.HSourceID}" + |
| | | $", {(omdelMian.HBeginWorkTimes == null ? 0: omdelMian.HBeginWorkTimes)}, '{omdelMian.HInStockOwnerTypeID}', {(omdelMian.HSplitRelationQty == null ? 0:omdelMian.HSplitRelationQty)}, '{omdelMian.HOrderLev}', {(omdelMian.HWorkQty == null ? 0:omdelMian.HWorkQty)}" + |
| | | $", {(omdelMian.HSplitPlanQty == null ? 0: omdelMian.HSplitPlanQty)}, '{omdelMian.HOwnerTypeID}', '{omdelMian.HPlanBeginDate}','{omdelMian.HPlanEndDate}', '{omdelMian.HICMOBillNo}'" + |
| | | $", {omdelMian.HOwnerID}, '{omdelMian.HBatchNo}', {(omdelMian.HYX == null ? 0: omdelMian.HYX)}, {(omdelMian.HProdTimes == null ? 0: omdelMian.HProdTimes)}, {omdelMian.HEntrustORGID}" + |
| | | $", {(omdelMian.HPlanQty == null ? 0: omdelMian.HPlanQty)},'{omdelMian.HPreparatDate}', {(omdelMian.HOrderNeedQty == null ? 0: omdelMian.HOrderNeedQty)},'{omdelMian.HOrderCommitDate}', {(omdelMian.HCompleteQty == null ? 0: omdelMian.HCompleteQty)}" + |
| | | $", {(omdelMian.HSeOrderBillQty == null ? 0: omdelMian.HSeOrderBillQty)},{(omdelMian.HICMOInterID == null ? 0: omdelMian.HICMOInterID)},{(omdelMian.HKTQ == null ? 0: omdelMian.HKTQ)},{(omdelMian.HStockInORGID == null ? 0: omdelMian.HStockInORGID)},{(omdelMian.HDayPlanSumQty == null ? 0: omdelMian.HDayPlanSumQty)}," + |
| | | $"'{omdelMian.HSourceBillNo}', {(omdelMian.HICMOEntryID == null ? 0: omdelMian.HICMOEntryID)}, {(omdelMian.HMainInterID == null ? 0: omdelMian.HMainInterID)},{omdelMian.HProdORGID},{(omdelMian.HLeftPlanQty == null ? 0: omdelMian.HLeftPlanQty)}" + |
| | | $", {(omdelMian.HEmpID == null ? 0: omdelMian.HEmpID)},{omdelMian.HInStockOwnerID},{(omdelMian.HICMOEntrySEQ == null ? 0: omdelMian.HICMOEntrySEQ)}, '{omdelMian.HICMOBillType}', {(omdelMian.HCloseCount == null ? 0: omdelMian.HCloseCount)}" + |
| | | $", '{omdelMian.HOrderType}', {(omdelMian.HSplitQty == null ? 0: omdelMian.HSplitQty)}, {(omdelMian.HSourceStockInQty == null ? 0: omdelMian.HSourceStockInQty)}, {(omdelMian.HPriority == null ? 0: omdelMian.HPriority)}, '{(omdelMian.HLocked == true ? 1 : 0)}', '{(omdelMian.HHangUp == true ? 1 : 0)}')"); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //修改 |
| | | oCN.RunProc("UpDate Gy_WorkWarehouseBillMain set " + |
| | | " HOrgId='" + omdelMian.HPRDORGID + "'" + |
| | | ",HUpDater='" + omdelMian.HMaker + "'" + |
| | | ",HUpDateDate='" + DateTime.Now + "'" + |
| | | " where HInterID=" + omdelMian.HInterID.ToString()); |
| | | |
| | | //删除子表 |
| | | oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | } |
| | | //保存子表 |
| | | objJsonResult = AddBillSub(msg3, hentryid); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json AddBillSub(string msg3, int hentryid) |
| | | { |
| | | omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Sc_WorkBillSortBillSub>>(msg3); |
| | | int i = 1; |
| | | //插入子表 |
| | | foreach (Models.Sc_WorkBillSortBillSub oSub in omodelsub) |
| | | { |
| | | oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HEntryID,HRemark,HMasterDate,HQty" + |
| | | ", HRptFinishQty, HTimes, HUseTimes, HBTimes, HETimes" + |
| | | ", HDateSub, HCloseMan, HEntryCloseDate, HCloseTypeSub, HColumn" + |
| | | ", HLockedSub, HComplete, HStatusTag, HIsHandModify)" + |
| | | $"values({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid)}, '{oSub.HRemark}', '{oSub.HMasterDate}', {(oSub.HQty == null ? 0: oSub.HQty)}" + |
| | | $", {(oSub.HRptFinishQty == null ? 0: oSub.HRptFinishQty)}, {(oSub.HTimes == null ? 0: oSub.HTimes)}, {(oSub.HUseTimes == null ? 0: oSub.HUseTimes)}, '{oSub.HBTimes}', '{oSub.HETimes}'" + |
| | | $", '{oSub.HDateSub}', '{oSub.HCloseMan}', '{oSub.HEntryCloseDate}', {(oSub.HCloseTypeSub == true ? 1 : 0)}, '{oSub.HColumn}'" + |
| | | $", '{(oSub.HLockedSub == true ? 1 : 0)}', '{oSub.HComplete}', '{(oSub.HStatusTag == true ? 1 : 0)}', '{(oSub.HIsHandModify == true ? 1 : 0)}')"); |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 日计划工单 删除 |
| | | [Route("Sc_WorkBillSortBill/DelWorkBillSortBillList")] |
| | | [HttpGet] |
| | | public object DelWorkBillSortBillList(string HInterID, string HEntryID, string User) |
| | | { |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Sc_WorkBillSortBill_Drop", 1, false, User)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Sc_WorkBillSortBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Sc_WorkBillSortBillList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["单据状态"].ToString() != "1") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "当前单据不能删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran();//开启事务 |
| | | |
| | | if (ds.Tables[0].Rows.Count == 1) |
| | | { |
| | | oCN.RunProc($"delete from Sc_WorkBillSortBillMain where HInterID={HInterID}"); |
| | | } |
| | | oCN.RunProc($"delete from Sc_WorkBillSortBillSub where HInterID={HInterID} and HEntryID={HEntryID}"); |
| | | |
| | | oCN.Commit();//结束事务 |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "当前单据不存在,无法删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack();//回滚事务 |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 日计划工单 关闭 |
| | | [Route("Sc_WorkBillSortBill/CloseWorkBillSortBillList")] |
| | | [HttpGet] |
| | | public object CloseWorkBillSortBillList(string HInterID, string User) |
| | | { |
| | | try |
| | | { |
| | | //关闭权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Sc_WorkBillSortBill_Close", 1, false, User)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Sc_WorkBillSortBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Sc_WorkBillSortBillList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["单据状态"].ToString() == "2") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "当前单据正在审核,不能关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran();//开启事务 |
| | | |
| | | oCN.RunProc($"update Sc_WorkBillSortBillMain set HBillStatus=3,HCloseMan='{User}',HCloseDate=getdate() where HInterID={HInterID}"); |
| | | |
| | | oCN.Commit();//结束事务 |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "关闭成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "当前单据不存在,无法关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack();//回滚事务 |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |