Example #1
0
 /** 提交 */
 @Before(Tx.class)
 public String[] submit(String id, String company_id, String uid, String now, String nowtime) {
   String[] billsnList = new String[2];
   Db.update(
       "update "
           + tableName
           + " set submit_status=1 where id=? and company_id=? and (head_id=? or creater_id=?) ",
       id,
       company_id,
       uid,
       uid);
   StockAllot po = this.findById(id, company_id);
   String to_depot_id = po.getStr("to_depot_id");
   String out_depot_id = po.getStr("out_depot_id");
   billsnList[0] = SnCreater.dao.create("OUTSTOCK", company_id);
   billsnList[1] = SnCreater.dao.create("INSTOCK", company_id);
   // 生成出入库
   StorageBill sb = new StorageBill();
   // 出库单
   sb.set("billsn", billsnList[0]);
   sb.set("type", 2); // 2调拨出库 6调拨入库
   sb.set("depot_id", out_depot_id);
   sb.set("head_id", po.getStr("head_id"));
   sb.set("creater_id", uid);
   sb.set("create_datetime", nowtime);
   sb.set("bill_date", now);
   sb.set("company_id", company_id);
   sb.save();
   String bill_id = sb.getStr("id");
   Db.update(
       "insert into "
           + StorageBillList.tableName
           + " (id,product_id,amount) select '"
           + bill_id
           + "',product_id,amount from "
           + StockAllotList.tableName
           + " a where a.id=?",
       id);
   // 入库单
   sb.set("id", null);
   sb.set("type", 6); // 6调拨入库
   sb.set("depot_id", to_depot_id);
   sb.set("billsn", billsnList[1]);
   sb.save();
   bill_id = sb.getStr("id");
   Db.update(
       "insert into "
           + StorageBillList.tableName
           + " (id,product_id,amount) select '"
           + bill_id
           + "',product_id,amount from "
           + StockAllotList.tableName
           + " a where a.id=?",
       id);
   return billsnList;
 }