public boolean updateBoxsAndParentBox(final String[] boxNos,final Integer woId,final Integer userID,final int maxQty,final int actQty,final int perQty,final String parentBoxNo,final String chidBoxType) {
boolean flag=Db.tx(new IAtom() {
@Override
public boolean run() throws SQLException {
for(String boxNo:boxNos) {
Record record = new Record();
record.set("BOX_NO", boxNo);
record.set("WO_ID", woId);
record.set("UPDATED_BY", userID);
record.set("UPDATED_TIME", new Date());
record.set("PARENT_BOX_NO",parentBoxNo);
if(!Db.use("mes").update("t_sp_box_no","BOX_NO,WO_ID",record))
return false;
}
for(String boxNo:boxNos) {
boolean flag=false;
Record record = new Record();
record.set("WO_ID", woId);
record.set("UPDATED_BY", userID);
record.set("UPDATED_TIME", new Date());
switch (chidBoxType.charAt(0)) {
case 'S':
record.set("SMALLBOXNO",boxNo);
record.set("MIDDLEBOXNO",parentBoxNo);
flag=Db.use("mes").update("member_card","SmallBoxNo_",record);
break;
case 'M':
record.set("MIDDLEBOXNO",boxNo);
record.set("LARGEBOXNO",parentBoxNo);
flag=Db.use("mes").update("member_card","MiddleBoxNo",record);
break;
}
if(!flag)/*回滚*/
return flag;
}
Record parentBox=new Record();
parentBox.set("BOX_No",parentBoxNo);
parentBox.set("WO_ID", woId);
parentBox.set("UPDATED_BY", userID);
parentBox.set("UPDATED_TIME", new Date());
if((actQty+perQty)==maxQty) {
parentBox.set("ISFULL_FLAG",1);
parentBox.set("PACK_DATE",new Date());
}
parentBox.set("ACT_BOX_PER_QTY",perQty+actQty);
if(!Db.use("mes").update("t_sp_box_no","BOX_NO,WO_ID",parentBox))/*回滚*/
return false;
else
return true;
}
});
return flag;
}