public long CreatezhuanyunCode() { lock (Lockerzhuanyun) //lock 关键字可确保当一个线程位于代码的临界区时,另一个线程不会进入该临界区。 { long lastpack = 0; string date = DateTime.Now.ToString("yyyyMMdd") + "001"; //得到当天第一个包裹号 using (var db = SugarDao.GetInstance(conn)) { busi_transfer send = db.SqlQuery <busi_transfer>("select * from busi_transfer where tran_code=(select MAX(tran_code) from busi_transfer)").FirstOrDefault(); if (send == null)//表为空时 { return(Convert.ToInt64(date)); } if (Convert.ToInt64(send.tran_code) >= Convert.ToInt64(date)) { lastpack = Convert.ToInt64(send.tran_code) + 1; return(lastpack); } else { return(Convert.ToInt64(date)); } } } }
/// <summary> /// 装箱 /// </summary> /// <param name="zhuanyuncode"></param> /// <param name="packgecode"></param> /// <returns></returns> public bool ConfirmPutInBox(string zhuanyuncode, string packgecode) { using (var db = SugarDao.GetInstance(conn)) { try { busi_transfer tran = db.Queryable <busi_transfer>().Where(s => s.tran_code == zhuanyuncode).FirstOrDefault(); if (null == tran) { throw new Exception("转运单号不存在!"); } else { //1.判断包裹是否配货完毕 busi_sendorder send = db.Queryable <busi_sendorder>().Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send) { throw new Exception("不存在此包裹"); } busi_sendorder send2 = db.Queryable <busi_sendorder>().Where(s => s.order_tatus >= 40).Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send2) { throw new Exception("包裹未配货完毕不能装箱"); } busi_sendorder send3 = db.Queryable <busi_sendorder>().Where(s => s.express_id > 0).Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send3) { throw new Exception("请先选择快递再装箱!"); } busi_sendorder send4 = db.Queryable <busi_sendorder>().Where(s => s.tran_id == 0).Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send4) { throw new Exception("包裹已装箱,请先出箱!"); } db.Update <busi_sendorder>(new { tran_id = tran.tran_id, order_tatus = 80 }, it => it.order_code == packgecode);//更新已转运状态 db.Update <busi_custorder>(new { order_status = 80 }, it => it.order_id == send.custorder_id); tran.tran_count++; bool isok2 = db.Update <busi_transfer>(tran);//更新转运单中包裹数量 return(isok2); } } catch (Exception ex) { throw ex; } } }
public bool ConfirmOutofBox(string zhuanyuncode, string packgecode) { using (var db = SugarDao.GetInstance(conn)) { try { busi_transfer tran = db.Queryable <busi_transfer>().Where(s => s.tran_code == zhuanyuncode).FirstOrDefault(); if (null == tran) { throw new Exception("转运单号不存在!"); } else { //1.判断包裹是否配货完毕 busi_sendorder send = db.Queryable <busi_sendorder>().Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send) { throw new Exception("不存在此包裹"); } busi_sendorder send2 = db.Queryable <busi_sendorder>().Where(s => s.order_tatus >= 40).Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send2) { throw new Exception("包裹未配货完毕不能出箱"); } busi_sendorder send3 = db.Queryable <busi_sendorder>().Where(s => s.tran_id > 0).Where(s => s.order_code == packgecode).FirstOrDefault(); if (null == send3) { throw new Exception("包裹未装箱,请先装箱!"); } db.Update <busi_sendorder>(new { tran_id = 0 }, it => it.order_code == packgecode); tran.tran_count--; bool isok2 = db.Update <busi_transfer>(tran);//更新转运单中包裹数量 return(isok2); } } catch (Exception ex) { throw ex; } } }
/// <summary> /// 关联DHL单号和转运单号 /// </summary> /// <param name="dhlcode"></param> /// <param name="zhuanyuncode"></param> /// <returns></returns> public bool AssociateDHLExpressCode(string dhlcode, string zhuanyuncode) { using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { try { busi_transfer tran = db.Queryable <busi_transfer>().Where(s => s.tran_code == zhuanyuncode).FirstOrDefault(); if (null == tran) { throw new Exception("不存在这个转运单号"); } //指定列更新 bool isok = db.Update <busi_transfer>(new { express_code = dhlcode }, it => it.tran_code == zhuanyuncode); //只更新name列 return(isok); } catch (Exception ex) { throw ex; } } }
public bool IsExitZY(string zhuanyuncode) { using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { try { busi_transfer a = db.Queryable <busi_transfer>().Where(s => s.tran_code == zhuanyuncode).FirstOrDefault(); if (null == a) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } } }
/// <summary> /// 判断是否已转运 /// </summary> /// <param name="zhuanyuncode"></param> /// <returns></returns> public bool IszhuanyunCodeing(string zhuanyuncode) { using (var db = SugarDao.GetInstance(conn)) { try { busi_transfer sku = db.Queryable <busi_transfer>().Where(s => s.del_flag == true).Where(s => s.tran_status == 1).Where(s => s.tran_code == zhuanyuncode).FirstOrDefault(); if (sku == null) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } } }
/// <summary> /// 打印转运单 /// </summary> /// <param name="zhuanyuncode"></param> /// <returns></returns> public bool PrintzhuanyunCode(string zhuanyuncode) { using (var db = SugarDao.GetInstance(conn)) { try { busi_transfer inserttran = new busi_transfer(); inserttran.tran_status = 1; inserttran.create_time = DateTime.Now; inserttran.create_user_id = 1; inserttran.del_flag = true; inserttran.remark = ""; inserttran.edit_time = DateTime.Now; inserttran.tran_code = zhuanyuncode; inserttran.tran_count = 0; db.Insert <busi_transfer>(inserttran); busi_printwork insertinfo = new busi_printwork(); insertinfo.p_WorkType = 40; insertinfo.data_1 = zhuanyuncode; insertinfo.data_4 = DateTime.Now.ToString(); insertinfo.p_idPoint = 1; //测试 insertinfo.p_Status = 1; var isok = db.Insert <busi_printwork>(insertinfo).ObjToInt(); if (isok > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } } }