public void dgchNew(HttpContext context) { context.Response.ContentType = "application/json"; StringBuilder sb = new StringBuilder(); string ldNO = context.Request["ldNO"].ToString(); string mechineID = context.Request["mechineID"].ToString(); string memberID = context.Request["memberID"].ToString(); string productID = context.Request["productID"].ToString(); string type = context.Request["type"].ToString(); string code = context.Request["code"].ToString(); string money = context.Request["money"].ToString(); log("ldNO=" + ldNO + ";mechineID=" + mechineID + ";memberID=" + memberID + ";productID=" + productID + ";type=" + type + ";code=" + code + ";money=" + money, "订购出货信息.txt"); Util.asm_ld_change(mechineID, productID, ldNO, 1, "2", -1); //库存变动记录 //此处料道库存增加 Util.update_reduceLDKC(mechineID, ldNO); Util.update_KCDetail(mechineID, productID); sb.Append(GetJson("cmd", "ch")); //11111 //111{} sb.Append(GetJson("ldNO", ldNO)); sb.Append(GetJson("memberID", memberID)); sb.Append(GetJson("type", type)); sb.Append(GetJson("productID", productID)); sb.Append(GetJson("mechineID", mechineID)); sb.Append(GetJson("code", code)); sb.Append(GetJson("money", money)); log("sb=" + sb, "订购出货信息.txt"); StringBuilder sbCH = new StringBuilder(); sbCH = sb; sbCH.Append(GetJson("createTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); sbCH.Append(GetJson("CHStatus", "")); log("mechineIDCHString", "接收到的指令.txt"); string mechineIDCHString = RedisUtil.getMechineChString(mechineID); //出货指令缓存 JObject mechineIDCHObj = JObject.Parse(mechineIDCHString); mechineIDCHObj["CH" + memberID + code] = ReturnJson(context, sbCH); RedisHelper.SetRedisModel <string>("CH" + mechineID, mechineIDCHObj.ToString()); //出货指令缓存 log("mechineIDCHString=" + mechineIDCHString, "接收到的指令.txt"); string _mechineInfo = RedisUtil.getMechine(mechineID); JArray _mechineJArray = RedisUtil.DeserializeObject(_mechineInfo); if (_mechineJArray != null) { log("_mechineJArray != null", "测试chnew.txt"); string status = _mechineJArray[0]["zt"].ToString(); string netStatus = _mechineJArray[0]["netStatus"].ToString(); log("status=" + status + "netStatus=" + netStatus + "is=" + (webSocket.CONNECT_POOL.ContainsKey(mechineID) ? 1 : 0), "测试chnew.txt"); if (status == "2" && netStatus == "0" && webSocket.CONNECT_POOL.ContainsKey(mechineID)) { log("进入", "测试chnew.txt"); BlockModel msgmodel = new BlockModel(); msgmodel.ID = mechineID; msgmodel.MsgId = Util.GetTimeStamp(); msgmodel.cmd = "ch"; msgmodel.SendMsg = ReturnJson(context, sb); msgmodel = JiQi.sendMessageToAndroidWaitReturn(msgmodel); if (msgmodel.Status == 0) { context.Response.Write("{\"code\":\"200\",\"msg\":\"发送成功\"}"); return; } else { context.Response.Write("{\"code\":\"500\",\"msg\":\"失败\"}"); } } } context.Response.Write("{\"code\":\"500\",\"msg\":\"机器不在线\"}"); return; }
//调整出货指令,等待返回值的 public void chNew(HttpContext context) { //库存变动记录 //sendMessageToAndroidWaitReturn //11ldNO=24;mechineID=68;billno=157412726502334876;payType=3;productID=424;money=0.01 type=2 context.Response.ContentType = "application/json"; StringBuilder sb = new StringBuilder(); string ldNO = context.Request["ldNO"].ToString(); //料道 string mechineID = context.Request["mechineID"].ToString(); //机器号 string billno = context.Request["billno"].ToString(); //交易号 string payType = context.Request["payType"].ToString(); string productID = context.Request["productID"].ToString(); //产品编号 string money = context.Request["money"].ToString(); //支付金额 string type = context.Request["type"].ToString(); log("ldNO=" + ldNO + ";mechineID=" + mechineID + ";billno=" + billno + ";payType=" + payType + ";productID=" + productID + ";money=" + money, "接收到的指令.txt"); //此处出货之前需要 //1、料道变动记录(减) //2、预减料道库存 //3、预减库存detail Util.asm_ld_change(mechineID, productID, ldNO, 1, "2", -1); //库存变动记录 //此处料道库存增加 Util.update_reduceLDKC(mechineID, ldNO); Util.update_KCDetail(mechineID, productID); sb.Append(GetJson("cmd", "ch")); sb.Append(GetJson("code", "200")); sb.Append(GetJson("ldNO", ldNO)); sb.Append(GetJson("billno", billno)); sb.Append(GetJson("payType", payType)); sb.Append(GetJson("productID", productID)); sb.Append(GetJson("money", money)); sb.Append(GetJson("type", type)); StringBuilder sbCH = new StringBuilder(); sbCH = sb; sbCH.Append(GetJson("createTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); sbCH.Append(GetJson("CHStatus", "")); log("mechineIDCHString", "接收到的指令.txt"); string mechineIDCHString = RedisUtil.getMechineChString(mechineID); //出货指令缓存 JObject mechineIDCHObj = JObject.Parse(mechineIDCHString); mechineIDCHObj["CH" + billno] = ReturnJson(context, sbCH); RedisHelper.SetRedisModel <string>("CH" + mechineID, mechineIDCHObj.ToString()); //出货指令缓存 log("mechineIDCHString=" + mechineIDCHString, "接收到的指令.txt"); string _mechineInfo = RedisUtil.getMechine(mechineID); JArray _mechineJArray = RedisUtil.DeserializeObject(_mechineInfo); if (_mechineJArray != null) { log("_mechineJArray != null", "测试chnew.txt"); string status = _mechineJArray[0]["zt"].ToString(); string netStatus = _mechineJArray[0]["netStatus"].ToString(); log("status=" + status + "netStatus=" + netStatus + "is=" + (webSocket.CONNECT_POOL.ContainsKey(mechineID)?1:0), "测试chnew.txt"); if (status == "2" && netStatus == "0" && webSocket.CONNECT_POOL.ContainsKey(mechineID)) { log("进入", "测试chnew.txt"); BlockModel msgmodel = new BlockModel(); msgmodel.ID = mechineID; msgmodel.MsgId = Util.GetTimeStamp(); msgmodel.cmd = "ch"; msgmodel.SendMsg = ReturnJson(context, sb); log("开始循环", "测试chnew.txt"); for (int i = 0; i < 3; i++) { msgmodel = JiQi.sendMessageToAndroidWaitReturn(msgmodel); log("i=" + i + ";msgmodel.status=" + msgmodel.Status + ";msgmodel.samtype=" + msgmodel.samtype, "测试chnew.txt"); if (msgmodel.Status == 0) { context.Response.Write("{\"code\":\"200\",\"msg\":\"发送成功\"}"); return; } } } } context.Response.Write("{\"code\":\"500\",\"msg\":\"机器不在线\"}"); return; }