stuts批量导入

本文介绍了如何下载货代填写的价格模板,并执行导入报价信息的步骤,包括验证和批量导入月度询盘报价,以及处理可能出现的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


	//下载 货代填写价格  模板
	public void doDownloadHuoDaiPrice(){
		try {
			hyMonthInquiryList = new ArrayList<HyMonthInquiryFO>();
			//设置货代编码
			queryData.setGoodsAgentCode(super.getUserContext().getOrgaId());
			DboList hyMonthInquirysBj = getHyMonthInquiryBO().getHyMonthInquirysNotBj(super.getQueryContext());
			for(int i=0; i<hyMonthInquirysBj.size(); i++){
				HyMonthInquiry tmpHyMonthInquiry = (HyMonthInquiry) hyMonthInquirysBj.get(i);
				tmpHyMonthInquiry.setLocalLanguage(super.getLanguage());
				HyMonthInquiryFO tmpHyMonthInquiryFo = new HyMonthInquiryFO();

				BeanUtils.copy(tmpHyMonthInquiry, tmpHyMonthInquiryFo);
				codeToName(tmpHyMonthInquiryFo,tmpHyMonthInquiry);

			}
			String EXL = "HY_MONTH_INQUIRY_PRICE";
			ExcelGeneralOperate ex = new ExcelGeneralOperate();
			String fileName = ex.doGeneralExportValue(hyMonthInquirysBj, EXL);

			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String ly_time = sdf.format(new java.util.Date());
			String filePath = SystemConfigs.GENDMS_FILE_PATH + "/" + SystemConfigs.TEMP_FILE_DIR + "/" + fileName;
			fileName = "未报价的月度询盘信息(" + ly_time + ").xls";

			OdDownloadLog downLog = this.getOdDownloadLogBO().createLog(fileName, fileName, filePath,"",fileName);
			super.outSuccess(downLog.getId());
		}catch (Exception e) {
			e.printStackTrace();
			super.outFailure(e.getMessage());
		}
	}


//导入报价信息
	public void importHyMonthInquiryInfo(){
		UserTransaction transaction = TransactionFactory.getInstance().createTransaction();
		try{
			transaction.begin();
			String path = SystemConfigs.GENDMS_FILE_PATH + File.separatorChar + SystemConfigs.TEMP_FILE_DIR + File.separatorChar + UUIDHexGenerator.getInstance().generate()+".xls";
			FileHelper.copyFile(file, path);
				List<ImportExcelErrorFO> errorList = this.getHyMonthInquiryBO().importHyMonthInquiryInfo(path,super.getQueryContext());
			if(errorList.size()>0){
				transaction.rollback();
				//返回错误提示
				StringBuffer s = new StringBuffer(JSONArray.fromObject(errorList).toString());
				outJsonStringForUpload("{success:false, data:" + s.toString() + "}");
			}else{
				transaction.commit();
				super.outSuccessHtml("成功");
			}
		} catch (Exception e) {
			transaction.rollback();
			e.printStackTrace();
			LogHome.getLog().error(e.getMessage(),e);
			super.outFailureForUploadReplace(e.getMessage());
		}
	}




//导入月度询盘报价
	public List<ImportExcelErrorFO> importHyMonthInquiryInfo(String path, IBoQueryContext queryContext) throws Exception {
		DboList list = new DboList();
		InputStream inStream = null;
		long userId = StringHelper.getUserSession().getId();
		List<ImportExcelErrorFO> errorList = new ArrayList<ImportExcelErrorFO>();
		try {
			inStream = new FileInputStream(path);
			HSSFWorkbook wb = new HSSFWorkbook(inStream);
			HSSFSheet sheet = wb.getSheetAt(0);
			errorList = this.validationHyMonthInquiryItem(sheet, list,queryContext);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			if (inStream != null) {
				inStream.close();
			}
		}

		if (errorList.size()==0){
			//如果没有错误批量导入
			try {
				for (int i = 0, count = list.size(); i < count; i++) {
					HyMonthInquiryItem item = (HyMonthInquiryItem) list.get(i);
					super.composeCreator(item, userId);
					String id = item.getId();
					DboList hyShipTypeList = this.getHyMonthInquiryDAO().queryShipType(id);
					for (int b=0;b<hyShipTypeList.size();b++ ) {
						GenericDO shipType =  hyShipTypeList.get(b);
						if (shipType.getAttrString("SHIP_TYPE").equals("集装箱")) {
							item.setBillingUnit("/柜");
						} else {
							item.setBillingUnit("/立方米");
						}
					}
					super.updateObject(item);
				}
			} catch (Exception e) {
				e.printStackTrace();
				//数据库执行异常
				ImportExcelErrorFO error = new ImportExcelErrorFO();
				error.setErrorMsg(e.getMessage());
				errorList.add(error);
			}

		}
		return errorList;
	}
	private List<ImportExcelErrorFO> validationHyMonthInquiryItem(HSSFSheet sheet, DboList list,IBoQueryContext queryContext) throws Exception {
		HSSFRow row = null;
		int rowNum = ExcelUtil.countRows(sheet);
		int currentRow = 1;
		List<ImportExcelErrorFO> errorList = new ArrayList<ImportExcelErrorFO>();
		String temp = "";
		HSSFRow testRow = sheet.getRow(currentRow);
		if (testRow != null) {
		} else {
			ImportExcelErrorFO error = new ImportExcelErrorFO();
			error.setErrorMsg("模板中无数据");
			errorList.add(error);
			return errorList;
		}

		for (int i = currentRow; i <= rowNum; i++, currentRow++) {
			row = sheet.getRow(currentRow);
			if (row == null) {
				continue;
			}
			HyMonthInquiryItem hyMonthInquiryItem = new HyMonthInquiryItem();
			StringBuffer errorString = new StringBuffer();
			ImportExcelErrorFO excelError = new ImportExcelErrorFO();
			excelError.setRowNum("第" + (currentRow + 1) + "行");

			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(0), i, (	short) 0) + "", "");
			String hyGoodsAgentNametemp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(1), i, (	short) 1) + "", "");
			String batchNo = temp;
			if (!"".equals(temp)) {
				//根据批次号 货代名称判断是否已经报价
				DboList hyMonthInquiryList = this.getHyMonthInquiryDAO().queryhyMonthInquiryById(queryContext, temp, hyGoodsAgentNametemp);
					GenericDO tmpHyMonthInquiry =  hyMonthInquiryList.get(0);
					if (tmpHyMonthInquiry.getAttrString("QUOTATION")!= null) {
						errorString.append("导入失败![报价信息已存在]");
				}
			}
			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(5), i, (short) 5) + "", "");
			if (!"".equals(temp)) {
				try {
					hyMonthInquiryItem.setVoyageMin(temp);
				} catch (Exception e) {
					errorString.append("第" + (6) + "列 最小航程不能为空 ;");
				}
			}

			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(6), i, (short) 6) + "", "");
			if (!"".equals(temp)) {
				hyMonthInquiryItem.setVoyageMax(temp);
			} else {
				errorString.append("第" + (7) + "列 最大航程不能为空  ;");
			}


			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(7), i, (short) 7) + "", "");
			if (!"".equals(temp) && !temp.equals("0") && Double.valueOf(temp)>0) {
				hyMonthInquiryItem.setQuotation(Double.valueOf(temp));
			} else {
				errorString.append("第" + (8) + "列 货代报价不能为空或者为0,批次号["+batchNo+"];");
			}

			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(8), i, (short) 8) + "", "");
			if (!"".equals(temp)) {
				hyMonthInquiryItem.setShippingSample(temp);
			}

			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(9), i, (short) 9) + "", "");
			if (!"".equals(temp)) {
				hyMonthInquiryItem.setHdNote(temp);
			}

			temp = StringTools.getString(ExcelUtil.getCellValue(row.getCell(10), i, (short) 10) + "", "");
			if (!"".equals(temp)) {
				hyMonthInquiryItem.setId(temp);
			}


			if(errorString.length() != 0){
				excelError.setErrorMsg(errorString.toString());
				errorList.add(excelError);
			}
			else{
				list.add(hyMonthInquiryItem);
			}
		}

		return errorList;
	}
本资源为Qt绘图基础,世界坐标系转换为逻辑坐标系。世界坐标系原点在视图左上角,本例子通过世界坐标转换,将坐标原点定位在视图中央,Y轴向上,X轴向右,并绘制坐标轴,基于逻辑坐标系下的绘图,可将转换关系函数取消生效,对比世界坐标系下的绘图。 重写PainterEvent函数: void QtPixPainter::paintEvent(QPaintEvent* event) { QPainter painter(this); // 反走样 painter.setRenderHint(QPainter::Antialiasing, true); //物理坐标系与逻辑坐标系的转换,如果不转换,下面的绘图都是在世界坐标系下 setWorldTransform(painter); // 其他一些绘制矩形,多边形的例子,经过上面转换,都是在逻辑坐标系下 drawRectScale(painter); //draw_shearRect(painter); //利用rotate()函数进行比例变换,实现缩放效果 //draw_rotate_act(painter); //draw_by_save_restore(painter); //transform_draw_SinX(painter); transform_draw(painter); local_drawConvexPolygon(painter); } // 将世界坐标(原点左上角)转换为逻辑坐标(原点在屏幕中间) QPointF QtPixPainter::mapToScene(const QPointF& point) { QTransform transMatrix = _transform.inverted(); //翻转矩阵? return transMatrix.map(point); //将点piont映射到transMatrix定义的坐标系中来 } // 将鼠标的逻辑位置返回并以标签形式展示 void QtPixPainter::mouseMoveEvent(QMouseEvent* event) { QString msg; QPointF mouse_po = mapToScene(event->pos()); //总是返回屏幕物理坐标系 double x = mouse_po.x(); // 总是返回屏幕物理坐标系 double y = mouse_po.y(); QString str = "(" + QString::number(x) + "," + QString::number(y) + ")"; //qDebug()<<"world x = "<pos().x()<<",world y = "<pos().y(); m_mouse_lable->setText(str); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值