|
|
@@ -87,7 +87,7 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
//时根据包装线及执行顺序给 PLC 传输下一条的工单信息,更新标识位为 0,
|
|
|
if (updateFlag > 0)
|
|
|
{
|
|
|
- DataRow dr = GetForms();
|
|
|
+ DataRow dr = GetForms(formID);
|
|
|
//传输数据
|
|
|
if (dr != null)
|
|
|
{
|
|
|
@@ -99,17 +99,22 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
PlcWriteRepeat<short>(PLC.dbGoodsCode, Convert.ToInt16(dr["GOODSCODE"].ToString()));//产品型号 1000.12
|
|
|
PlcWriteRepeat<string>(PLC.dbGoodsCodes, dr["GOODSCODES"].ToString());//产品型号 1000.18
|
|
|
}
|
|
|
- result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbFormID + " = " + s7.Read<int>(PLC.dbFormID) + ";" + PLC.dbStackNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbStackNum) + ";" + PLC.dbGoodsType + " = " + s7.Read<short>(PLC.dbGoodsType)+ ";" + PLC.dbGoodsCode +
|
|
|
- " = " + s7.Read<short>(PLC.dbGoodsCode) + ";"+ PLC.dbPlateType + " = " + s7.Read<short>(PLC.dbPlateType) +";" + PLC.dbPlateNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbPlateNum) + ";" + PLC.dbGoodsCodes + " = " + s7.Read<string>(PLC.dbGoodsCodes, 14))));
|
|
|
+ result.Add(new JObject(new JProperty("PLC读出(核对)",
|
|
|
+ "FormID["+ PLC.dbFormID + "] =" + s7.Read<int>(PLC.dbFormID) +
|
|
|
+ ";StackNum[" + PLC.dbStackNum + "] = " + s7.Read<short>(PLC.dbStackNum) +
|
|
|
+ ";GoodsType[" + PLC.dbGoodsType + "] = " + s7.Read<short>(PLC.dbGoodsType) +
|
|
|
+ ";PlateType[" + PLC.dbPlateType + "] = " + s7.Read<short>(PLC.dbPlateType) +
|
|
|
+ ";PlateNum[" + PLC.dbPlateNum + "] = " + s7.Read<short>(PLC.dbPlateNum) +
|
|
|
+ ";GoodsCode[" + PLC.dbGoodsCode + "] = " + s7.Read<short>(PLC.dbGoodsCode) +
|
|
|
+ ";GoodsCodes[" + PLC.dbGoodsCodes + "] = " + s7.Read<string>(PLC.dbGoodsCodes, 14)
|
|
|
+ )));
|
|
|
//========================================
|
|
|
context.Response.Write(new JsonResult(JsonStatus.success) { rows = result }.ToJson());
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DataRow dr = GetForms();
|
|
|
+ DataRow dr = GetForms(formID);
|
|
|
//传输数据
|
|
|
if (dr != null)
|
|
|
{
|
|
|
@@ -121,17 +126,22 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
PlcWriteRepeat<short>(PLC.dbGoodsCode, Convert.ToInt16(dr["GOODSCODE"].ToString()));//产品型号 1000.12
|
|
|
PlcWriteRepeat<string>(PLC.dbGoodsCodes, dr["GOODSCODES"].ToString());//产品型号 1000.18
|
|
|
}
|
|
|
- result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbFormID + " = " + s7.Read<int>(PLC.dbFormID) + ";" + PLC.dbStackNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbStackNum) + ";" + PLC.dbGoodsType + " = " + s7.Read<short>(PLC.dbGoodsType)+ ";" + PLC.dbGoodsCode +
|
|
|
- " = " + s7.Read<short>(PLC.dbGoodsCode) + ";"+ PLC.dbPlateType + " = " + s7.Read<short>(PLC.dbPlateType) +";" + PLC.dbPlateNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbPlateNum) + ";" + PLC.dbGoodsCodes + " = " + s7.Read<string>(PLC.dbGoodsCodes, 14))));
|
|
|
+ result.Add(new JObject(new JProperty("PLC读出(核对)",
|
|
|
+ "FormID["+ PLC.dbFormID + "] =" + s7.Read<int>(PLC.dbFormID) +
|
|
|
+ ";StackNum[" + PLC.dbStackNum + "] = " + s7.Read<short>(PLC.dbStackNum) +
|
|
|
+ ";GoodsType[" + PLC.dbGoodsType + "] = " + s7.Read<short>(PLC.dbGoodsType) +
|
|
|
+ ";PlateType[" + PLC.dbPlateType + "] = " + s7.Read<short>(PLC.dbPlateType) +
|
|
|
+ ";PlateNum[" + PLC.dbPlateNum + "] = " + s7.Read<short>(PLC.dbPlateNum) +
|
|
|
+ ";GoodsCode[" + PLC.dbGoodsCode + "] = " + s7.Read<short>(PLC.dbGoodsCode) +
|
|
|
+ ";GoodsCodes[" + PLC.dbGoodsCodes + "] = " + s7.Read<string>(PLC.dbGoodsCodes, 14)
|
|
|
+ )));
|
|
|
//========================================
|
|
|
context.Response.Write(new JsonResult(JsonStatus.success) { rows = result }.ToJson());
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DataRow dr = GetForms();
|
|
|
+ DataRow dr = GetForms(0);
|
|
|
//传输数据
|
|
|
if (dr != null)
|
|
|
{
|
|
|
@@ -143,10 +153,15 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
PlcWriteRepeat<short>(PLC.dbGoodsCode, Convert.ToInt16(dr["GOODSCODE"].ToString()));//产品型号 1000.12
|
|
|
PlcWriteRepeat<string>(PLC.dbGoodsCodes, dr["GOODSCODES"].ToString());//产品型号 1000.18
|
|
|
}
|
|
|
- result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbFormID + " = " + s7.Read<int>(PLC.dbFormID) + ";" + PLC.dbStackNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbStackNum) + ";" + PLC.dbGoodsType + " = " + s7.Read<short>(PLC.dbGoodsType)+ ";" + PLC.dbGoodsCode +
|
|
|
- " = " + s7.Read<short>(PLC.dbGoodsCode) + ";"+ PLC.dbPlateType + " = " + s7.Read<short>(PLC.dbPlateType) +";" + PLC.dbPlateNum +
|
|
|
- " = " + s7.Read<short>(PLC.dbPlateNum) + ";" + PLC.dbGoodsCodes + " = " + s7.Read<string>(PLC.dbGoodsCodes, 14))));
|
|
|
+ result.Add(new JObject(new JProperty("PLC读出(核对)",
|
|
|
+ "FormID["+ PLC.dbFormID + "] =" + s7.Read<int>(PLC.dbFormID) +
|
|
|
+ ";StackNum[" + PLC.dbStackNum + "] = " + s7.Read<short>(PLC.dbStackNum) +
|
|
|
+ ";GoodsType[" + PLC.dbGoodsType + "] = " + s7.Read<short>(PLC.dbGoodsType) +
|
|
|
+ ";PlateType[" + PLC.dbPlateType + "] = " + s7.Read<short>(PLC.dbPlateType) +
|
|
|
+ ";PlateNum[" + PLC.dbPlateNum + "] = " + s7.Read<short>(PLC.dbPlateNum) +
|
|
|
+ ";GoodsCode[" + PLC.dbGoodsCode + "] = " + s7.Read<short>(PLC.dbGoodsCode) +
|
|
|
+ ";GoodsCodes[" + PLC.dbGoodsCodes + "] = " + s7.Read<string>(PLC.dbGoodsCodes, 14)
|
|
|
+ )));
|
|
|
//========================================
|
|
|
context.Response.Write(new JsonResult(JsonStatus.success) { rows = result }.ToJson());
|
|
|
//包装工单 ID错误
|
|
|
@@ -156,7 +171,7 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
}
|
|
|
PlcClose();
|
|
|
}
|
|
|
- context.Response.Write(new JsonResult(resultFlag ? JsonStatus.success : JsonStatus.error) { rows = result }.ToJson());
|
|
|
+ context.Response.Write(System.Environment.NewLine + (new JsonResult(resultFlag ? JsonStatus.success : JsonStatus.error) { rows = result }.ToJson()));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -165,7 +180,7 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
{
|
|
|
if (!resultFlag) return -1;
|
|
|
try
|
|
|
- {
|
|
|
+ {
|
|
|
int read = Convert.ToInt16(s7.Read<short>(PLC.dbStatus));
|
|
|
result.Add(new JObject(new JProperty("PLC读取(读取标识:OK)", PLC.dbStatus + " = " + read.ToString())));
|
|
|
return read;
|
|
|
@@ -254,13 +269,47 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
}
|
|
|
|
|
|
|
|
|
- public DataRow GetForms()
|
|
|
+ public DataRow GetForms(int formid)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
using (IDataAccess conn = DataAccess.Create())
|
|
|
{
|
|
|
- DataTable dt = conn.ExecuteDatatable(@"
|
|
|
+ string sql = null;
|
|
|
+ if (formid > 0)
|
|
|
+ {
|
|
|
+ sql = @"
|
|
|
+ SELECT
|
|
|
+ pf.packingformid FORMID,
|
|
|
+ g.SEATCOVERCODE GOODSCODE,
|
|
|
+ pf.materialcode,
|
|
|
+ d1.dictionaryvalue STACKNUM,
|
|
|
+ CASE WHEN G.GOODSTYPEID = 18 THEN 1
|
|
|
+ WHEN G.GOODSTYPEID = 3 THEN 2
|
|
|
+ ELSE 3 END GOODSTYPE,
|
|
|
+ CASE WHEN d.dictionaryvalue = '铁托' THEN 1
|
|
|
+ WHEN d.dictionaryvalue = '胶托' THEN 2 ELSE 3 END PLATETYPE,
|
|
|
+ pf.PLATENUM,
|
|
|
+ g.GOODSCODE GOODSCODES
|
|
|
+ FROM
|
|
|
+ TP_MST_PACKINGFORM pf
|
|
|
+ left join tp_mst_goods g on g.goodsid = pf.goodsid
|
|
|
+ left join tp_mst_datadictionary d on pf.platetype = d.dictionaryid and d.dictionarytype = 'TPC031'
|
|
|
+ left join tp_mst_datadictionary d1 on pf.stacknum = d1.dictionaryid and d1.dictionarytype = 'TPC032'
|
|
|
+ left join V_GOODS_MATERIALCODE gg ON gg.GOODSID = pf.GOODSID AND gg.MATERIALCODE = pf.MATERIALCODE
|
|
|
+ WHERE pf.packingformid = "+formid+@"
|
|
|
+ ORDER BY PF.CREATETIME ,PF.ORDERNO
|
|
|
+ ";
|
|
|
+
|
|
|
+ /*and pf.packingline = '2'
|
|
|
+ and pf.sycnflag = 0
|
|
|
+ and pf.stacknum is not null
|
|
|
+ and pf.platetype is not null
|
|
|
+ and (pf.logoid not in(0,65) or (pf.logoid = 0 and gg.logoid <>65) )*/
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql = @"
|
|
|
SELECT
|
|
|
pf.packingformid FORMID,
|
|
|
g.SEATCOVERCODE GOODSCODE,
|
|
|
@@ -286,8 +335,10 @@ public class autoPackingForm6157 : IHttpHandler
|
|
|
and pf.platetype is not null
|
|
|
and (pf.logoid not in(0,65) or (pf.logoid = 0 and gg.logoid <>65) )
|
|
|
ORDER BY PF.CREATETIME ,PF.ORDERNO
|
|
|
- "
|
|
|
- );
|
|
|
+ ";
|
|
|
+ }
|
|
|
+ DataTable dt = conn.ExecuteDatatable(sql);
|
|
|
+
|
|
|
if(dt.Rows.Count > 0 )
|
|
|
{
|
|
|
JObject obj = new JObject();
|