I. Storage: The essence is to save the library file in the cat code instock indate to the Code table and update the inventory table in stock the total number of cat corresponding quantity!
Code table: ID code cat instock indate outdate stock table: ID Cat Quantity
0.
<div id= "Drop-zone" > Drag and Drop <br/>S1001-xxx.csv<br/> file here </div><div id= "FileInfo" ></ Div><table data-bind= "Foreach:racks" class= "sortable" > <tbody data-bind= "foreach:plates" > <tr da Ta-bind= "foreach: $data" > <td> <span class= "Plate-label" data-bind= "Text:label" ></spa n> <div class= "Plate-code" data-bind= "Text:code, css: {' plate-no-tube ': ' no tube ' = = Code, ' Plate-no-rea d ': ' No Read ' = = code} ' ></div> <div class= "Plate-cat" data-bind= "Text:cat" ></div> </td> </tr> </tbody></table><div> <button id= "Instockbutton" type= "button" Disab LED data-bind= "Click:instock" > Inbound </button></div>//passed the cat and codes Model.prototype.inStock via Ajax = function () {var codes, I, J, Len, LEN1, plate, platerow, racks, ref; codes = []; Racks = Ko.mapping.toJS (this.racks); if (racks.length) {ref = Racks[0].plates; for (i = 0, len = ref.length; i < Len; i++) {platerow = Ref[i]; for (j = 0, len1 = platerow.length; J < Len1; J + +) {plate = Platerow[j]; if (Plate.code.match (/^\d+$/)) {Codes.push (Plate.code); }}} return $.postjson (' doinstock.jhtml ', {cat:this.cat, codes:codes}). Done ((func tion (_this) {return function (JSON) {if (json.error) {return alert (json.error); } else {return alert (' upload succeeded '); } }; }) (this)); } };
1.action.xml
<action name= "In-stock" class= "codelibaction" method= "Instock" > <result name= "Success" >/web-inf/ jsp/backoffice/codelib/in-stock.jsp</result> <interceptor-ref name= "Defaultstack"/> < Interceptor-ref name= "Permission"/> </action> <action name= "Doinstock" class= "Codelibaction" method= "Doinstock"/>
2. Action
Public String Instock () { return SUCCESS; } @SuppressWarnings ("unchecked") public String Doinstock () { map<string, object> result = new hashmap< > (); try { map<string, object> Map = Readjson (); String cat = (string) map.get ("Cat"); list<string> codes = (list<string>) map.get ("Codes"); Codelibservice.savenewstockcodes (cat, codes); } catch (Exception e) { e.printstacktrace (); Result.put ("Error", E.getmessage ()); } Writejson (result); return null; }
3.daoImpl
private void Updatestockquantity () {Dao.flush ();//The front crud and other operations are brushed into the database, otherwise the data cannot be queried, because of the reason for the transaction. Dao.executesql ("Insert Selleck_cl_stock (CAT) SELECT DISTINCT c.cat from Selleck_cl_stock_code C where NOT exists (SELECT * From Selleck_cl_stock s where S.cat=c.cat) "); Dao.executesql ("Update selleck_cl_stock s Set quantity = (select count (*) from Selleck_cl_stock_code C where C.cat=s.cat a nd instock=1) "); } @Override public void Savenewstockcodes (String cat, list<string> codes) throws Exception {List<co delibstockcodedto> stockcodelist = new arraylist<> (Codes.size ()); Date today = new Date (); Codes.foreach (code-, {codelibstockcodedto codelibstockcode = new Codelibstockcodedto (); Codelibstockcode.setcat (CAT); Codelibstockcode.setcode (code); Codelibstockcode.setinstock (1); Codelibstockcode.setindate (today); Stockcodelist.add (Codelibstockcode); }); Dao.save (stockcodelist); Updatestockquantity (); }
Second: Save the Order (one is the save of the new Order, one is the edited save), read some fields of the table in Excel saved to the Codeliborder order table and the plate drug hole table,
When you click the Create button to create a new order: The new order must first require that the order number no in the big contract SELLECK_ORDR exist!
Codeliborder table: ID no Memo boardfile plate table: ID Codeliborderid rack Plate row col Cat code where rack or Derno cat can be obtained by file name, which is transmitted by the foreground.
1. Save and upload the file to the specified directory for the next download.
Public String Ordersave () { if (Stringutils.isblank (Order.getmemo ())) { throw new runtimeexception ("Please fill in remarks"); } String root = Servletactioncontext.getservletcontext (). Getrealpath ("/"); Codelibservice.save (Order, Excel, Excelfilename, root, ForceUpdate = = 1); return SUCCESS; }
The first case is saved after editing. First edit and save, by clicking on the ID of the column that the order is in to go to the database query there is no record, if there is a record to see if the status of the order is NULL, if NULL is set to working
Public String Orderedit () { order = Codelibservice.findcodeliborderbyid (Order.getid ()). Orelseget ( codeliborderdto::new); if (order.getstatus () = = null) { order.setstatus ("working"); } return SUCCESS; }
Serviceimpl saved business logic, this time only executes the first three lines of code, the following code will not be executed!
@Override public void Save (codeliborderdto order, file file, string filename, String uploadroot, Boolean Resetstock ) {Dao.save (order); if (resetstock) {resetstockoutdata (order); } if (file = null) {String Savepath = uploadroot + "newpath/downloads/codelib/"; char[] chars = Filename.trim (). ToCharArray (); for (int i = 0; i < chars.length; i++) {char c = chars[i]; if (C < '-' | | c > ' z ') {chars[i] = '-'; }} filename = new String (chars); Order.setboardfile (filename); Dao.save (order); try {files.createdirectories (new File (Savepath). Topath ()); } catch (Exception e) {throw new RuntimeException (e); } Savepath + = Order.getid (). toString () + "-" + filename; Try (outputstream out = new FileOutputStream (Savepath); InputStream in = new FileInputStream (file)} {ioutils.copy (in, out); } catch (Exception e) {throw new RuntimeException (e); } list<codeliborderplatedto> platesfromexcel = getorderplatesfromexcel (file, order); list<codeliborderplatedto> plates = getplates (order); if (! Isplatesmatch (Platesfromexcel, plates)) {if (! Plates.isempty () &&! Resetstock) { throw new RuntimeException ("The library table does not match the current data, please select" Empty the out-of-stock data "); } dao.delete (plates); Dao.save (Platesfromexcel); } } }
Span style= "color: #000080; Font-weight:bold; " > < Span style= "color: #0000ff; Font-weight:bold; " >
Selleck--codelib