using Model;
|
using Model.生产管理;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers
|
{
|
//生产任务单Controller
|
//数据库主表Sc_ICMOBillMain
|
//数据库子表Sc_ICMOBillSub
|
public class Sc_ICMOBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
#region 生产任务单 保存/编辑功能
|
[Route("Sc_ICMOBill/ICMOBillEdit")]
|
[HttpPost]
|
public object ICMOBillEdit([FromBody] JObject sMainSub)
|
{
|
try
|
{
|
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;
|
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
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 OperationType = int.Parse(sArray[2].ToString()); // 数据类型 1添加 3修改
|
string user = sArray[3].ToString();
|
|
try
|
{
|
if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
msg2 = "[" + msg2.ToString() + "]";
|
List<ClsSc_ICMOBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillMain>>(msg2);
|
|
long HInterID = mainList[0].HInterID;//递入type得到的单据ID
|
string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
|
long HPRDORGID = mainList[0].HPRDORGID;//组织
|
DateTime HDate = mainList[0].HDate;//日期
|
string HRemark = mainList[0].HRemark;//备注
|
string HSeOrderBillNo = mainList[0].HSeOrderBillNo;//销售订单号
|
long HSeOrderInterID = mainList[0].HSeOrderInterID;//销售订主id
|
long HSeOrderEntryID = mainList[0].HSeOrderEntryID;//销售订子id
|
long HEmpID = mainList[0].HEmpID;//业务员
|
long HCusID = mainList[0].HCusID;//客户
|
long HCenterID = mainList[0].HCenterID;//工作中心
|
double? HPlanQty = mainList[0].HPlanQty == null ? 0 : mainList[0].HPlanQty;//计划数量
|
string HMaker = user;//制单人
|
|
long HISENTRUST = mainList[0].HISENTRUST == null ? 0 : mainList[0].HISENTRUST;//组织受托加工
|
long HISREWORK = mainList[0].HISREWORK == null ? 0 : mainList[0].HISREWORK;//是否返工
|
|
ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_ICMOBillList");
|
|
if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
|
{
|
//主表
|
oCN.RunProc(@"Insert Into Sc_ICMOBillMain
|
(HBillType,HInterID,HBillNo,HDate,HPRDORGID
|
,HYear,HPeriod,HRemark,HMaker,HMakeDate
|
,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
|
,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate,HISENTRUST,HISREWORK)
|
values('3710'," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
|
",'" + HSeOrderBillNo + "'," + HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID +
|
"," + HCenterID + "," + HPlanQty + ",0,0,0,0,'',''" + "," + HISENTRUST + "," + HISREWORK + ") ");
|
}
|
else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
|
{ //修改
|
oCN.RunProc("update Sc_ICMOBillMain set " +
|
"HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
|
", HSeOrderBillNo='" + HSeOrderBillNo + "', HSeOrderInterID=" + HSeOrderInterID + ", HSeOrderEntryID=" + HSeOrderEntryID + ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + "" +
|
", HCenterID=" + HCenterID + ", HPlanQty=" + HPlanQty + " where HInterID=" + HInterID);
|
|
//删除子表
|
oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "'");
|
}
|
//保存子表
|
objJsonResult = AddBillSub(msg3, HInterID, OperationType);
|
|
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, long HInterID, int OperationType)
|
{
|
List<ClsSc_ICMOBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillSub>>(msg3);
|
|
string HINSTOCKTYPE = DetailColl[0].HINSTOCKTYPE == null ? "''" : DetailColl[0].HINSTOCKTYPE; //入库类型,
|
long HCHECKPRODUCT = DetailColl[0].HCHECKPRODUCT == null ? 0 : DetailColl[0].HCHECKPRODUCT; //产品检验,
|
string HQAIP = DetailColl[0].HQAIP == null ? "''" : DetailColl[0].HQAIP; //紧急放行,
|
long HISBACKFLUSH = DetailColl[0].HISBACKFLUSH == null ? 0 : DetailColl[0].HISBACKFLUSH; //倒冲领料,
|
string HREQSRC = DetailColl[0].HREQSRC == null ? "''" : DetailColl[0].HREQSRC; //需求来源,
|
double HSTOCKINQUASELAUXQTY = DetailColl[0].HSTOCKINQUASELAUXQTY == null ? 0 : DetailColl[0].HSTOCKINQUASELAUXQTY; //合格品入库选单数量,
|
long HSeOrderEntrySEQ = DetailColl[0].HSeOrderEntrySEQ == null ? 0 : DetailColl[0].HSeOrderEntrySEQ; //销售订单行号,
|
string HPROJECTNO = DetailColl[0].HPROJECTNO == null ? "''" : DetailColl[0].HPROJECTNO; //项目编号,
|
long HPRODUCTTYPE = DetailColl[0].HPRODUCTTYPE == null ? 0 : DetailColl[0].HPRODUCTTYPE; //产品类型,
|
long HCOSTRATE = DetailColl[0].HCOSTRATE == null ? 0 : DetailColl[0].HCOSTRATE; // 权重,
|
long HBASEUNITID = DetailColl[0].HBASEUNITID == null ? 0 : DetailColl[0].HBASEUNITID; //基本计量单位,
|
|
int i = 0;
|
foreach (ClsSc_ICMOBillSub oSub in DetailColl)
|
{
|
i++;
|
if (oSub.HQty <= 0 || oSub.HQty == null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "第" + i + "行,数量不能为0或者小于0";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HMaterID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "第" + i + "行,物料不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//if (oSub.HSourceID == 0)
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "第" + i + "行,生产资源不能为空";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
if (oSub.HDeptID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "第" + i + "行,生产车间不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HUnitID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "第" + i + "行,计量单位不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.RunProc($@"Insert into Sc_ICMOBillSub
|
(HInterID,HENTRYID,HQty
|
,HPlanBeginDate,HPlanEndDate
|
,HBeginDate,HEndDate
|
,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
|
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
|
,HINSTOCKTYPE,HCHECKPRODUCT,HQAIP,HISBACKFLUSH,HREQSRC,HSTOCKINQUASELAUXQTY,HSeOrderEntrySEQ,HPROJECTNO,HPRODUCTTYPE,HCOSTRATE,HBASEUNITID)
|
values({HInterID},{i},{(oSub.HQty == null ? 0 : oSub.HQty)}
|
,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
|
,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
|
,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
|
,0,0,'','',0,0,{HINSTOCKTYPE},{HCHECKPRODUCT},{HQAIP},{HISBACKFLUSH},{HREQSRC},{HSTOCKINQUASELAUXQTY},{HSeOrderEntrySEQ},{HPROJECTNO},{HPRODUCTTYPE},{HCOSTRATE},{HBASEUNITID})");
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
|
[Route("Sc_ICMOBill/ICMOBillSaveApi")]
|
[HttpPost]
|
public object ICMOBillSaveApi([FromBody] JObject sMainSub)
|
{
|
try
|
{
|
//LogService.Write(sMainSub.ToString());
|
var model = sMainSub["model"].ToString();
|
var entry = sMainSub["model"]["HENTRY"].ToString();
|
var _model = sMainSub["model"]["HPPBOMMAINENTRY"].ToString();
|
var _entry = sMainSub["model"]["HPPBOMSUBENTRY"].ToString();
|
model = "[" + model.ToString() + "]";
|
List<ClsSc_ICMOBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillMain>>(model);
|
List<ClsSc_ICMOBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillSub>>(entry);
|
List<ClsSc_PPBomBillMain> _mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_PPBomBillMain>>(_model);
|
List<ClsSc_PPBomBillSub> _subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_PPBomBillSub>>(_entry);
|
string sql = string.Empty;
|
oCN.BeginTran();
|
sql = $"delete Sc_ICMOBillMain where HinterID = {mainList[0].HInterID}";
|
oCN.RunProc(sql);
|
sql = $"delete Sc_ICMOBillSub where HinterID = {mainList[0].HInterID}";
|
oCN.RunProc(sql);
|
//主表
|
oCN.RunProc(@"Insert Into Sc_ICMOBillMain
|
(HBillType,HInterID,HBillNo,HDate,HPRDORGID
|
,HYear,HPeriod,HRemark,HMaker,HMakeDate
|
,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
|
,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate,HBillStatus)
|
values('3710'," + mainList[0].HInterID + ",'" + mainList[0].HBillNo + "','" + mainList[0].HDate + "'," + mainList[0].HPRDORGID +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + mainList[0].HRemark + "','" + mainList[0].HMaker + "',getdate()" +
|
",'" + mainList[0].HSeOrderBillNo + "'," + mainList[0].HSeOrderInterID + "," + mainList[0].HSeOrderEntryID + "," + mainList[0].HEmpID + "," + mainList[0].HCusID +
|
"," + mainList[0].HCenterID + "," + mainList[0].HPlanQty + ",0,0,0,0,'','',2) ");
|
//保存主表
|
foreach (var oSub in subList)
|
{
|
oCN.RunProc($@"Insert into Sc_ICMOBillSub
|
(HInterID,HENTRYID,HQty
|
,HPlanBeginDate,HPlanEndDate
|
,HBeginDate,HEndDate
|
,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
|
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
|
values({oSub.HInterID},{oSub.HEntryID},{(oSub.HQty == null ? 0 : oSub.HQty)}
|
,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
|
,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
|
,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},4
|
,0,0,'','',0,0)");
|
}
|
|
foreach (var _item in _mainList)
|
{
|
//生产用料清单
|
sql = $"delete Sc_PPBomBillMain where HinterID = {_item.HInterID}";
|
oCN.RunProc(sql);
|
sql = $"delete Sc_PPBomBillSub where HinterID = {_item.HInterID}";
|
oCN.RunProc(sql);
|
//主表
|
oCN.RunProc(@"Insert Into Sc_PPBomBillMain
|
(HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus,HICMOInterID
|
,HICMOEntryID,HMaterID,HUnitID,HQty,HDeptID,HMaker,HMakeDate,HChecker,HCheckDate
|
,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HPRDORGID,HENTRUSTORGID,HPARENTOWNERID
|
,HPARENTOWNERTYPEID,HERPInterID,HERPBillType,HSeOrderEntrySEQ,HICMOEntrySEQ,HREQSRC)
|
values(" + _item.HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 3720 + "','" +
|
_item.HBillSubType + "','" + _item.HDate + "','" + _item.HBillNo + "','" + _item.HBillStatus + "'," + _item.HICMOInterID +
|
"," + _item.HICMOEntryID + ",'" + _item.HMaterID + "'," + _item.HUnitID + "," + _item.HQty + "," + _item.HDeptID +
|
",'" + _item.HMaker + "','" + _item.HMakeDate + "','" + _item.HChecker + "','" + _item.HCheckDate + "','" + _item.HSeOrderBillNo + "'," + _item.HSeOrderInterID + "," + _item.HSeOrderEntryID + "," + _item.HPRDORGID + "," + _item.HENTRUSTORGID + "," + _item.HPARENTOWNERID + ",'" +
|
_item.HPARENTOWNERTYPEID + "'," + _item.HERPInterID + ",'" + _item.HERPBillType + "'," + _item.HSeOrderEntrySEQ + "," + _item.HICMOEntrySEQ + ",'" + _item.HREQSRC + "')");
|
}
|
foreach (var oSub in _subList)
|
{
|
oCN.RunProc($@"Insert into Sc_PPBomBillSub
|
(HInterID,HEntryID,HMaterID,HMaterNumber,HUnitID,HUnitNumber,HSPID,HQty,HQtyMust,HWHID,HRemark
|
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HICMOInterID,HICMOEntryID,HICMOBillNo
|
,HCHILDSUPPLYORGID,HSUPPLYORGID,HENTRUSTPICKORGID,HSRCTRANSORGID,HGROUPBYOWNERID,HOWNERID,HOWNERTYPEID
|
,HRelationQty,HMoveStockQty,HAuxPropID,HBatchNO,HMTONo,HQtyScrap,HERPInterID,HERPEntryID
|
,HBackRelationQty,HNumerator,HDenominator,HBASEUNITID,HProcessID,HICMOENTRYSEQ,HPROJECTNO
|
,HOPERID,HSEQ,HSTOCKSTATUSID,HLOT,HOPTQUEUE,HRESERVETYPE,HSelPickedQty,HSELPRCDRETURNQTY,HProcName)
|
values('{oSub.HInterID}','{oSub.HEntryID}','{oSub.HMaterID}','{oSub.HMaterNumber}','{oSub.HUnitID}','{oSub.HUnitNumber}','{oSub.HSPID}','{oSub.HQty}'
|
,'{oSub.HQtyMust}','{oSub.HWHID}','{oSub.HRemark}','{oSub.HSourceInterID}','{oSub.HSourceEntryID}','{oSub.HSourceBillNo}','{oSub.HSourceBillType}','{oSub.HICMOInterID}','{oSub.HICMOEntryID}','{oSub.HICMOBillNo}','{oSub.HCHILDSUPPLYORGID}','{oSub.HSUPPLYORGID}','{oSub.HENTRUSTPICKORGID}','{oSub.HSRCTRANSORGID}','{oSub.HGROUPBYOWNERID}','{oSub.HOWNERID}','{oSub.HOWNERTYPEID}','{oSub.HRelationQty}','{oSub.HMoveStockQty}','{oSub.HAuxPropID}','{oSub.HBatchNO}','{oSub.HMTONo}','{Convert.ToDecimal(oSub.HQtyScrap)}','{oSub.HERPInterID}','{oSub.HERPEntryID}','{oSub.HBackRelationQty}','{oSub.HNumerator}','{oSub.HDenominator}','{oSub.HBASEUNITID}','{oSub.HProcessID}','{oSub.HICMOENTRYSEQ}','{oSub.HPROJECTNO}','{oSub.HOPERID}','{oSub.HSEQ}','{oSub.HSTOCKSTATUSID}','{oSub.HLOT}','{oSub.HOPTQUEUE}','{oSub.HRESERVETYPE}','{oSub.HSelPickedQty}','{oSub.HSELPRCDRETURNQTY}','{oSub.HProcName}')");
|
}
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据保存成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
|
}
|
catch (Exception e)
|
{
|
LogService.Write(e.Message.ToString());
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
}
|
|
|
#region 生产任务单(无列表) 保存/编辑功能
|
[Route("Sc_ICMOBill/ICMOBillEdit_NoTable")]
|
[HttpPost]
|
public object ICMOBillEdit_NoTable([FromBody] JObject sMainSub)
|
{
|
try
|
{
|
var _value = sMainSub["sMainSub"].ToString();
|
string msg1 = _value.ToString();
|
oCN.BeginTran();
|
//保存主表
|
objJsonResult = AddBillMain_NoTable(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;
|
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
public json AddBillMain_NoTable(string msg1)
|
{
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString(); //主表数据
|
int OperationType = int.Parse(sArray[1].ToString()); // 数据类型 1添加 3修改
|
string user = sArray[2].ToString();
|
|
try
|
{
|
if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var msg3 = msg2.ToString();
|
msg2 = "[" + msg2.ToString() + "]";
|
List<ClsSc_ICMOBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillMain>>(msg2);
|
|
long HInterID = mainList[0].HInterID;//递入type得到的单据ID
|
string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
|
long HPRDORGID = mainList[0].HPRDORGID;//组织
|
DateTime HDate = mainList[0].HDate;//日期
|
string HRemark = mainList[0].HRemark;//备注
|
string HSeOrderBillNo = mainList[0].HSeOrderBillNo;//销售订单号
|
long HSeOrderInterID = mainList[0].HSeOrderInterID;//销售订主id
|
long HSeOrderEntryID = mainList[0].HSeOrderEntryID;//销售订子id
|
long HEmpID = mainList[0].HEmpID;//业务员
|
long HCusID = mainList[0].HCusID;//客户
|
long HCenterID = mainList[0].HCenterID;//工作中心
|
long HBomID = mainList[0].HBomID;//bom
|
//double? HPlanQty = mainList[0].HPlanQty == null ? 0 : mainList[0].HPlanQty;//计划数量
|
string HMaker = user;//制单人
|
|
ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_ICMOBillList");
|
|
if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
|
{
|
//主表
|
oCN.RunProc(@"Insert Into Sc_ICMOBillMain
|
(HBillType,HInterID,HBillNo,HDate,HPRDORGID
|
,HYear,HPeriod,HRemark,HMaker,HMakeDate
|
,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
|
,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate)
|
values('3710'," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
|
",'" + HSeOrderBillNo + "'," + HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID +
|
"," + HCenterID + ",0,0,0,0," + HBomID + ",'','') ");
|
}
|
else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
|
{ //修改
|
oCN.RunProc("update Sc_ICMOBillMain set " +
|
"HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
|
", HSeOrderBillNo='" + HSeOrderBillNo + "', HSeOrderInterID=" + HSeOrderInterID + ", HSeOrderEntryID=" + HSeOrderEntryID + ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + "" +
|
", HCenterID=" + HCenterID + ",HBomID=" + HBomID + " where HInterID=" + HInterID);
|
|
//删除子表
|
oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "'");
|
}
|
//保存子表
|
objJsonResult = AddBillSub_NoTable(msg3, HInterID, OperationType);
|
|
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_NoTable(string msg3, long HInterID, int OperationType)
|
{
|
ClsSc_ICMOBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ICMOBillSub>(msg3);
|
if (oSub.HQty <= 0 || oSub.HQty == null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "数量不能为0或者小于0";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HMaterID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "物料不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HDeptID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "生产车间不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HUnitID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "计量单位不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oSub.HBomID == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "BOM不能为空";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.RunProc($@"Insert into Sc_ICMOBillSub
|
(HInterID,HENTRYID,HQty
|
,HPlanBeginDate,HPlanEndDate
|
,HBeginDate,HEndDate
|
,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
|
,HBomID,HEntryCusID
|
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
|
values({HInterID},1,{(oSub.HQty == null ? 0 : oSub.HQty)}
|
,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
|
,'{(oSub.HBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HBeginDate.ToString())}','{(oSub.HEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HEndDate.ToString())}'
|
,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
|
,{oSub.HBomID} ,{oSub.HCusID}
|
,0,0,'','',0,0)");
|
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 生产任务单删除功能
|
[Route("Sc_ICMOBill/DeltetSc_ICMOReportBill")]
|
[HttpGet]
|
public object DeltetSc_ICMOReportBill(string HInterID, string user)
|
{
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Drop", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (string.IsNullOrWhiteSpace(HInterID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
oCN.BeginTran();//开始事务
|
ds = oCN.RunProcReturn("select * from Sc_ICMOBillMain where HInterID=" + HInterID, "Sc_ICMOBillMain");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有数据,无法删除!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
oCN.RunProc("delete from Sc_ICMOBillMain where HInterID=" + HInterID);
|
oCN.RunProc("delete from Sc_ICMOBillSub where HInterID=" + HInterID);
|
oCN.Commit();//提交事务
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "* 数据删除成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 生产任务单获取车间
|
[Route("Sc_ICMOBill/GetHDeptList")]
|
[HttpGet]
|
public object GetHDeptList()
|
{
|
try
|
{
|
DataSet oDs = new DataSet();
|
//==========
|
oDs = oCN.RunProcReturn("select HItemID,HName from Gy_Department", "Gy_Department");
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取成功!";
|
objJsonResult.data = oDs.Tables[0];
|
return objJsonResult; ;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 墙咔装箱单回车事件
|
[Route("Sc_ICMOBill/QK_PackingBillByXSBill")]
|
[HttpGet]
|
public object QK_PackingBillByXSBill(string HBillNo)
|
{
|
try
|
{
|
//string sql = string.Format(@"select a.HInterID,a.HBillNo,b.HEntryID,b.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName, b.HUnitID,u.HName HUnitName,b.HQty HPlanQty,b.HQty HSPlanQty,
|
// a.HCusID, c.HName HCusName,a.HEmpID,e.HName HEmpName,b.HDeptID,d.HName HDeptName,a.HPlanEndDate,0 HMinQty,0 HTotalQty,0 HSpsQty,a.HSeOrderBillNo,a.HRemark
|
// from Sc_ICMOBillMain a
|
// left join Sc_ICMOBillSub b on a.HInterID=b.HInterID
|
// left join Gy_Material m on b.HMaterID=m.HItemID
|
// left join Gy_Unit u on b.HUnitID=u.HItemID
|
// left join Gy_Customer c on a.HCusID=c.HItemID
|
// left join Gy_Employee e on a.HEmpID=e.HItemID
|
// left join Gy_Department d on a.HDeptID=d.HItemID
|
// where b.HInterID=(select HICMOInterID from Sc_PPBomBillMain where HBillNo='" + HBillNo + "')");
|
string sql = string.Format(@"select a.HInterID,a.HBillNo,b.HMaterID,b.HEntryID, m.HNumber HMaterNumber, m.HName HMaterName, b.HUnitID,u.HName HUnitName,b.HQty HPlanQty,b.HQty HSPlanQty,a.HCusID, c.HName HCusName,
|
a.HEmpID,e.HName HEmpName,b.HDeptID,d.HName HDeptName,a.HPlanEndDate,0 HMinQty,0 HTotalQty,0 HSpsQty,a.HSeOrderBillNo,a.HRemark,
|
fo.FBILLNO FBillNo,fo.F_ZZZZ_TEXT7 FLXName,fo.FRECEIVEADDRESS FInAddress,fmn.FNAME FMaterName,fo1.F_ZZZZ_TEXT FBZFS,fu.FDATAVALUE FHX,
|
fu1.FDATAVALUE FQK,fo1.F_ZZZZ_WBBZ1 FWBBZ
|
from Sc_ICMOBillMain a
|
left join Sc_ICMOBillSub b on a.HInterID=b.HInterID
|
left join Gy_Material m on b.HMaterID=m.HItemID
|
left join Gy_Unit u on b.HUnitID=u.HItemID
|
left join Gy_Customer c on a.HCusID=c.HItemID
|
left join Gy_Employee e on a.HEmpID=e.HItemID
|
left join Gy_Department d on a.HDeptID=d.HItemID
|
left join AIS20200908101915zs..T_PRD_MOENTRY f1 on b.HERPEntryID=f1.FENTRYID
|
left join AIS20200908101915zs..T_SAL_ORDERENTRY fo1 on f1.FSaleOrderEntryId=fo1.FENTRYID
|
left join AIS20200908101915zs..T_SAL_ORDER fo on fo1.FID=fo.FID
|
left join AIS20200908101915zs..T_BD_MATERIAL fm1 on fo1.FSUBMATERIALNUMBER=fm1.FMATERIALID
|
left join AIS20200908101915zs..T_BD_MATERIAL_L fmn on fo1.FSUBMATERIALNUMBER=fmn.FMATERIALID
|
LEFT JOIN AIS20200908101915zs..T_BAS_ASSISTANTDATAENTRY_L fu1 on fo1.F_ZZZZ_ASSISTANT1=fu1.FENTRYID
|
LEFT JOIN AIS20200908101915zs..T_BAS_ASSISTANTDATAENTRY_L fu on fo1.F_ZZZZ_ASSISTANT2=fu.FENTRYID
|
where b.HInterID=(select HICMOInterID from Sc_PPBomBillMain where HBillNo='" + HBillNo + "')");
|
|
ds = oCN.RunProcReturn(sql, "Sc_ICMOBillMain");
|
if (ds.Tables[0].Rows.Count != 0 || ds != null)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "暂无对应的销售明细!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "获取失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 墙咔装箱单整箱生成
|
[Route("Sc_ICMOBill/QK_PackingBillSavePack")]
|
[HttpPost]
|
public object QK_PackingBillSavePack([FromBody] JObject msg)
|
{
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();//表格数据
|
string msg3 = sArray[1].ToString();//登录人
|
string msg5 = sArray[2].ToString();//登录组织
|
string msg6 = sArray[3].ToString();//标记
|
string msg7 = sArray[4].ToString();//当前用料清单
|
|
ListModels oListModels = new ListModels();
|
DataSet ds = new DataSet();
|
ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + msg5, "Xt_ORGANIZATIONS");
|
string OrgNum = ds.Tables[0].Rows[0]["HNumber"].ToString();//组织代码
|
DataSet d = oCN.RunProcReturn("select HRemark from Sc_PPBomBillMain where HBillNo='" + msg7 + "'", "Sc_ICMOBillMain");//查找该用料清单上次生成的箱号(HRemark存放箱号)
|
DataSet Ds1 = new DataSet();
|
try
|
{
|
//表体数据
|
//按 },{来拆分数组 //去掉【和】
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
//msg2 = msg2.Replace("'", "’");
|
List<Models.ClsQK_PackingBill> ls = new List<Models.ClsQK_PackingBill>();
|
ls = oListModels.getObjectByJson_QK_PackingBill(msg2);
|
|
|
//获取年月日并拼接成字符串
|
string year = DateTime.Now.Year.ToString();
|
string month = DateTime.Now.Month.ToString();
|
string day = DateTime.Now.Day.ToString();
|
string nowDate = year + month + day;
|
//string materid = "";
|
//long sum = 0;
|
//if (msg4 == "ZZ")
|
//{
|
string FID = "";
|
int LSH;
|
string LSH2;
|
string TM = "";
|
int XH = Convert.ToInt32(d.Tables[0].Rows[0]["HRemark"].ToString() == "" ? 0 : Convert.ToInt32(d.Tables[0].Rows[0]["HRemark"].ToString()));
|
|
foreach (Models.ClsQK_PackingBill oItemSub in ls)
|
{
|
//根据生成条数生成相应数量条码
|
for (int i = 0; i < oItemSub.HTotalQty; i++)
|
{
|
long HInterID = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
|
string sTMNumber = OrgNum + oItemSub.HMaterNumber + nowDate;
|
Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < 6)
|
{
|
LSH2 = "0" + LSH2;
|
}
|
TM = sTMNumber + LSH2;
|
|
if (msg6 == "ZZ")
|
{
|
XH = XH + 1;
|
}
|
else if (msg6 == "PZ" && ls.IndexOf(oItemSub) == 0)
|
{
|
XH = XH + 1;
|
}
|
|
//获取内码
|
oCN.RunProc("insert into Gy_BarCodeBill (HEntryID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
|
",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
|
",HGiveAwayFlag " +
|
",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
|
") values (" + i
|
+ ",'" + TM + "','唯一条码'," + oItemSub.HMaterID.ToString() + "," + oItemSub.HUnitID.ToString() + "," + oItemSub.HMinQty.ToString()
|
+ ",'',0,0,'" + msg3 + "',getdate(),0," + oItemSub.HMinQty.ToString()
|
+ ", " + oItemSub.HInterID.ToString() + "," + oItemSub.HEntryID.ToString() + ",'" + oItemSub.HBillNo + "','3710',''"
|
+ ",1,1," + oItemSub.HDeptID.ToString() + ",0,0,'" + XH + "'"
|
+ ", " + oItemSub.HCusID.ToString() + ",'',getdate(),'',getdate()"
|
+ ", " + msg5.ToString() + "," + OrgNum.ToString() + ",'" + oItemSub.HSeOrderBillNo.ToString() + "'," + HInterID.ToString()
|
+ ",0"
|
+ ",'" + oItemSub.HMaterName + "','','',0,'','')");
|
|
oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
|
|
}
|
oCN.RunProc("update Sc_ICMOBillSub set HQty=" + oItemSub.HSpsQty + " where HEntryID=" + oItemSub.HEntryID);
|
oCN.RunProc("update Sc_PPBomBillMain set HRemark=" + XH + " where HBillNo='" + msg7 + "'");
|
DataSet Dsn = oCN.RunProcReturn("select top " + oItemSub.HTotalQty + " HItemID from Gy_BarCodeBill order by HItemID desc", "Gy_BarCodeBill"); //获取最大流水号
|
for (int i = 0; i < oItemSub.HTotalQty; i++)
|
{
|
FID = FID + Dsn.Tables[0].Rows[i][0] + ",";
|
}
|
}
|
objJsonResult.code = FID;
|
objJsonResult.count = 1;
|
objJsonResult.Message = "整装生成成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
//}
|
//else
|
//{
|
// var HInterID = DBUtility.ClsPub.CreateBillID("3783", ref DBUtility.ClsPub.sExeReturnInfo);
|
// var HBillNo = DBUtility.ClsPub.CreateBillCode("3783", ref DBUtility.ClsPub.sExeReturnInfo, true);
|
// oCN.BeginTran();
|
// foreach (Models.ClsQK_PackingBill oItemSub in ls)
|
// {
|
// sum += oItemSub.HMinQty;
|
// materid = oItemSub.HMaterNumber;
|
// //获取内码
|
// long HInterID2 = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
|
// //生成唯一条码 条码前缀 = 组织代码 + 物料代码 + 年 + 月 + 日
|
// string sTMNumber = OrgNum + oItemSub.HMaterNumber + nowDate;
|
// Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
// LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//唯一码
|
// //插入条码档案
|
// oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
// ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
// ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
// ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
// ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
|
// ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
|
// ",HGiveAwayFlag " +
|
// ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
|
// ") values ("
|
// + "'" + LSH + "','唯一条码'," + oItemSub.HMaterID.ToString() + "," + oItemSub.HUnitID.ToString() + "," + oItemSub.HMinQty.ToString()
|
// + ",'',0,0,'" + msg3 + "',getdate(),0," + oItemSub.HMinQty.ToString()
|
// + ", " + oItemSub.HInterID.ToString() + "," + oItemSub.HInterID.ToString() + ",'" + oItemSub.HBillNo + "','3710',''"
|
// + ",1,1," + oItemSub.HDeptID.ToString() + ",0,0,''"
|
// + ", " + oItemSub.HCusID.ToString() + ",'',getdate(),'',getdate()"
|
// + ", " + msg5.ToString() + "," + OrgNum.ToString() + ",''," + HInterID2.ToString()
|
// + ",0"
|
// + ",'" + oItemSub.HMaterName + "','','',0,'','')");
|
// //插入组托单子表
|
// string sql = string.Format(@"insert into Sc_PackUnionBillSub(HInterID,HEntryID,HCloseMan,HCloseType,HRemark,
|
// HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,
|
// HRelationQty,HRelationMoney,HMaterID,HUnitID,HQty,HSourceID,HEquipID,HGroupID,HWorkerID,
|
// HScanDate,HBarCode,HBarCode_Pack)
|
// values(" + HInterID + ",'','',0,'自动绑定'," + oItemSub.HInterID + ",'','" + oItemSub.HBillNo + "','3710'," +
|
// "0,0," + oItemSub.HMaterID + "," + oItemSub.HUnitID + "," + oItemSub.HPlanQty + ", 0,0,0,0," +
|
// "getdate(),'" + LSH + "','" + HBillNo + "')");
|
// //更改生产订单的数量
|
// string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=" + oItemSub.HSpsQty + " where HInterID=" + oItemSub.HInterID);
|
|
// oCN.RunProc(sql);
|
// oCN.RunProc(sql1);
|
// }
|
// //生成组托单主表
|
// string sql2 = string.Format(@"Insert Sc_PackUnionBillMain(HYear,HPeriod,HBillType,HInterID,HDate,HBillNo,HBillStatus,HCheckItemNowID,HCheckItemNextID,
|
// HRemark,HBacker,HChecker,HMaker,HMakeDate,HUpDater,HCloseMan,HCloseType,HDeleteMan,HICMOInterID,HICMOBillNo,
|
// HBarCode_Pack,HMaterID,HUnitID,HWeight,HMWeight,HPWeight,
|
// HProdOrgID,HDeptID,HEmpID,HSNum,HPackNum,HBarCode_Cus,HBatchNo,HBillSubType)
|
// values('2022',1,'3783'," + HInterID + ",getdate(),'" + HBillNo + "',1,0,0," +
|
// "'自动绑定','','', '" + msg3 + "',getdate(),'','',0,'',0,0,'" +
|
// HBillNo + "',0,0,0,0,0," +
|
// "0,0,0,0,0,'','','')");
|
// oCN.RunProc(sql2);
|
// //再次生成唯一码
|
// //获取内码
|
// long HInterID3 = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
|
// //生成唯一条码 条码前缀 = 组织代码 + 物料代码 + 年 + 月 + 日
|
// string sTMNumber1 = OrgNum + materid + nowDate;
|
// Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber1 + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
// int LSH1 = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//唯一码
|
// string sql3 = string.Format(@"insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
// ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
// ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
// ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
// ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
|
// ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
|
// ",HGiveAwayFlag " +
|
// ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
|
// ") values ("
|
// + "'" + LSH1 + "','唯一条码','" + materid.ToString() + "',0," + sum.ToString()
|
// + ",'',0,0,'" + msg3 + "',getdate(),0," + sum.ToString()
|
// + ", 0,0,'" + HBillNo + "','3710','',"
|
// + sum.ToString() + "," + HInterID.ToString() + ",0,0,0,''"
|
// + ",0,'',getdate(),'',getdate()"
|
// + ", " + msg5.ToString() + "," + OrgNum.ToString() + ",''," + HInterID3.ToString()
|
// + ",0"
|
// + ",'','','',0,'','')");
|
|
// oCN.RunProc(sql3);
|
// oCN.Commit();
|
// objJsonResult.code = "1";
|
// objJsonResult.count = 1;
|
// objJsonResult.Message = "拼装生成成功";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "获取失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
# region[墙咔装箱点击主表带出从表]
|
[Route("Sc_ICMOBillController/QK_GetPackingBillListByMainID")]
|
[HttpGet]
|
public object QK_GetPackingBillListByMainID(string HInterID)
|
{
|
|
DataSet ds;
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
//获取保养项目编辑数据
|
string sql = string.Format(@"select a.HInterID hmainid,a.HBarCode,a.HBillType,a.HBarCodeType,
|
a.HMaterID,m.HName HMaterName,a.HUnitID,u.HName HUnitName,
|
a.HEmpID,e.HName HEmpName,a.HDeptID,d.HItemID HDeptName,P.HBarCode_Pack,
|
a.HMakeDate 制单日期,a.HMaker 制单人
|
from Gy_BarCodeBill a
|
left join Gy_Material m on a.HMaterID=m.HItemID
|
left join Gy_Unit u on a.HUnitID=u.HItemID
|
left join Gy_Employee e on a.HEmpID=e.HItemID
|
left join Gy_Department d on a.HDeptID=d.HItemID
|
left join Sc_PackUnionBillMain p on a.HSourceInterID=p.HInterID
|
where a.HBarCode in(select HBarCode from Sc_PackUnionBillSub where HInterID=
|
(select HBarcodeNo from Gy_BarCodeBill where HItemID='" + HInterID + "'))");
|
ds = oCN.RunProcReturn(sql, "Sc_PackUnionBillSub");
|
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取信息成功!";
|
objJsonResult.data = ds.Tables[0];
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region[墙咔装箱列表]
|
/// <summary>
|
/// 墙咔装箱列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("Sc_ICMOBillController/QK_GetPackingBillList")]
|
[HttpGet]
|
public object QK_GetPackingBillList(string sWhere)
|
{
|
try
|
{
|
|
ds = QK_GetPackingBillList_s(sWhere);
|
|
//if (ds.Tables[0].Rows.Count != 0 || ds != null)
|
//{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
//}
|
//else
|
//{
|
//objJsonResult.code = "0";
|
//objJsonResult.count = 0;
|
//objJsonResult.Message = "无数据";
|
//objJsonResult.data = null;
|
//return objJsonResult;
|
//}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#region sql语句
|
|
|
public static DataSet QK_GetPackingBillList_s(string sWhere)
|
{
|
;
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_QK_PackedBillList order by 制单日期 desc", "h_v_QK_PackedBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_QK_PackedBillList where HBarCodeType='唯一条码' ";
|
string sql = sql1 + sWhere + " order by 制单日期 desc";
|
return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_QK_PackedBillList");
|
|
}
|
//return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainBillList ", "h_v_Sc_MouldMaintainBillList");
|
}
|
#endregion
|
|
#endregion
|
|
#region[墙咔装箱列表-删除]
|
/// <summary>
|
/// 墙咔装箱列表-删除
|
/// </summary>
|
/// <param name="HInterID">条码档案主表主ID(唯一)</param>
|
/// <param name="Flag">标识</param>
|
/// <returns></returns>
|
[Route("Sc_ICMOBillController/DeleteQK_GetPackingBillList")]
|
[HttpGet]
|
public object DeleteQK_GetPackingBillList(string HInterID, string Flag)
|
{
|
try
|
{
|
oCN.BeginTran();
|
if (Flag == "0")
|
{
|
DataSet ds = new DataSet();
|
ds = oCN.RunProcReturn("select * from Gy_BarCodeBill where HItemID=" + HInterID, "Gy_BarCodeBill");
|
DataRow dr = ds.Tables[0].Rows[0];
|
string sql = string.Format(@"delete from Gy_BarCodeBill where HItemID=" + HInterID);
|
string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=HQty+" + dr["HQty"] + " where HEntryID=(select HSourceEntryID from Gy_BarCodeBill where HItemID=" + HInterID + ")");
|
oCN.RunProc(sql1);
|
oCN.RunProc(sql);
|
}
|
else
|
{
|
//通过条码id找到托条码,通过托条码找到组托单子表中的唯一码
|
string sql2 = "select HBarCode from Sc_PackUnionBillSub where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=" + HInterID + ")";
|
//string sql2 = "select HBarCode from Sc_PackUnionBillSub where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=3250)";
|
DataSet ds1 = oCN.RunProcReturn(sql2, "Sc_PackUnionBillSub");
|
DataTable dt = ds1.Tables[0];
|
//遍历找到的唯一码删除条码档案里的相关数据,同时通过唯一码的源单找到生产订单更改生产订单的数量
|
if (dt.Rows.Count > 0)
|
{
|
foreach (DataRow dr in dt.Rows)
|
{
|
DataSet ds = new DataSet();
|
ds = oCN.RunProcReturn("select * from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "'", "Gy_BarCodeBill");
|
DataRow dr1 = ds.Tables[0].Rows[0];
|
|
string sql = string.Format(@"delete from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "'");
|
string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=HQty+" + dr1["HQty"] + " where HEntryID=(select HSourceEntryID from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "')");
|
oCN.RunProc(sql1);
|
oCN.RunProc(sql);
|
}
|
}
|
|
//遍历完后删除通过条码id找到托条码,通过托条码找到组托单子表的数据,以及主表数据
|
string sql3 = string.Format(@"delect from Sc_PackUnionBillSub where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=" + HInterID);
|
string sql4 = string.Format(@"delect from Sc_PackUnionBillMain where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=" + HInterID);
|
//删除最大的合成的唯一码
|
string sql5 = string.Format(@"delete from Gy_BarCodeBill where HItemID=" + HInterID);
|
oCN.RunProc(sql3);
|
oCN.RunProc(sql4);
|
oCN.RunProc(sql5);
|
}
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "删除成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
|
}
|
catch (Exception ex)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除失败" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
}
|
}
|