def _process_pac(self): wb = YRWorkbook(self.filename) names = wb.get_sheet_names() for name in names: wb.pin_sheet_by_name(name) self.logger.debug(name) nrows = wb.get_nrows() for ind in xrange(self.START_ROW,nrows): pn = wb.get_cell_value(self.PN_COL + str(ind)) pcs = wb.get_cell_value(self.PCS_COL + str(ind)) nw = wb.get_cell_value(self.NW_COL + str(ind)) gw = wb.get_cell_value(self.GW_COL + str(ind)) end_tag = wb.get_cell_value(self.END_TAG_COL + str(ind)).lower() pcs = int(pcs) nw = float(nw) gw = float(gw) #print type(pcs) if pcs <= 0 or nw <= 0 or gw <= 0: utils.ABT(u"ERROR: PAC 中,这条记录(pn=%s,pcs=%d,nw=%f,gw=%f)存在错误" %(pn,pcs,nw,gw)) if not end_tag.find(self.END_STR): self._get_plt(wb,self.PLT_COL+str(ind)) break self.logger.debug("%s, %d, %f, %f, %s", pn, pcs, nw, gw,end_tag) if not self.data.has_key(pn): self.data[pn] = {self.PCS: 0, self.NW:0.0, self.GW:0.0} self.data[pn][self.PCS] += pcs self.data[pn][self.NW] += nw self.data[pn][self.GW] += gw
def _process_tpi(self): try: wb = YRWorkbook(self.filename) except IOError : utils.ABT(u"处理文件 %s 出错" % self.filename) names = wb.get_sheet_names() for name in names: times = 0 #ind = self.START_ROW wb.pin_sheet_by_name(name) nrows = wb.get_nrows() self.logger.debug(name) self._get_hawb(wb.get_cell_value(self.HAWB_POS)) for ind in xrange(self.START_ROW, nrows): pn = wb.get_cell_value(self.PN_COL+str(ind)) qty = wb.get_cell_value(self.QTY_COL+str(ind)) uprice =wb.get_cell_value(self.UNIT_PRICE_COL+str(ind)) extend = wb.get_cell_value(self.EXTENDED_COL+str(ind)) extend_type = wb.get_cell_type(self.EXTENDED_COL+str(ind)) if extend == self.END_STR: break if extend == "": times += 1 continue if times >= MAX_TIMES: break #ok, then clear timer times = 0 if not self.data.has_key(pn): self.data[pn] = [0,0] if uprice[0] != "$": self.logger.debug("pn=%s, unit_price=%s, pty=%s",pn, uprice, qty) self.logger.warn("Unit_Price Error, unit price shuold start with $") continue if int(qty) <= 0: utils.ABT(u"ERROR: TPI 中, 这条记录(pn=%s,qty=%s,unit_price=%s) 有错误" %(pn,qty,uprice)) self.data[pn][0] = max(self.data[pn][0],float(uprice[1:])) self.data[pn][1] += int(qty) self.logger.debug("pn=%s, unit_price=%f, pty=%d",pn, float(uprice[1:]), int(qty))