java如何将JSONObject用什么方法转成BigDecimal并将数据传给priceDataTable
public void queryPriceCompareInfo() {
long start = System.currentTimeMillis();
Map < String, Object > params = this.getParameters();
if (params == null) {
return;
}
//询价单id
String askbillid = (String) params.get("askbillid");
logger.info("queryPriceCompareInfo:askbillid:" + askbillid);
@SuppressWarnings("unchecked")
List < Integer > qlist = (List < Integer >) params.get("quotbids");
//重新比价带过来的推荐理由
HashMap < String, String > recommendReasons = new HashMap <>();
if (params.get("recommendReasons") != null) {
recommendReasons = JsonUtils.fromJson(params.get("recommendReasons").toString(), HashMap.class);
}
Long[] quotids = null;
if (qlist != null && qlist.size() > 0) {
String[] qids = qlist.toArray(new String[qlist.size()]);
List < Long > qls = new ArrayList < Long >();
for (String i : qids) {
qls.add(Long.valueOf(i));
}
//报价单ids
quotids = qls.toArray(new Long[qls.size()]);
}
try {
long end7 = doQueryCompareInfoReal(Long.valueOf(askbillid), quotids, recommendReasons);
//做查询数据之后的处理
computeAfterQueryData(params);
assembleDatatable();
long end8 = System.currentTimeMillis();
logger.info("组装datatables耗时(ms):{}", (end8 - end7));
logger.info("queryPriceCompareInfo:结果返回");
long end = System.currentTimeMillis();
logger.info("--------------- 一、性能记录----------------------推荐供应商比价---------------性能记录---------------------- 总耗时(ms):{}", (end - start));
} catch (Exception e) {
ExceptionUtils.marsh(e, com.yonyou.cpu.multi.YcMessageUtils.getMessage("P_DIWORK_YC_CPU-PORTAL_0000057325") /* "查询定标单数据失败" */);
}
}
protected void assembleDatatable() {
askbillHeadDataTable.set(askbillhead1);
askbillHeadDataTable.setSelect(new Integer[]{0});
askbillBodyDataTable.set(askbillbodys1);
askbillBodyDataTable.setTotalPages(1);//songpeng 增加物料规格和型号(根据物料id--product_id查询);产品描述(product_desc)、表体备注(bmemo);
askbillBodyDataTable.setPageIndex(0);
askbillBodyDataTable.setPageSize(1);
priceDataTable.set(compareInfos1);//承兑价,现金价,报价说明,交货期
priceDataTable.setTotalPages(1);
priceDataTable.setPageIndex(0);
priceDataTable.setPageSize(1);
if (talksDataTable != null && quotationOffers1 != null) {
talksDataTable.set(quotationOffers1.toArray(new QuotationOffer[0]));
talksDataTable.setSelect(new Integer[]{0});
}
//本期平均价(含税)
//priceDataTable-rows-data-quotationinfo-key- paymentPrice
Row[] rows1 = priceDataTable.getRows();
for (Row str : rows1) {
Map < String, Field > data = str.getFields();
Field quotationinfo = data.get("quotationinfo");
Object[] value = (Object[]) quotationinfo.getValue();
// HashMap value = (HashMap) quotationinfo.getValue();
// JSONObject key = (JSONObject) value;
for (Object o : value) {
JSONObject key = JSONObject.parseObject(o.toString());
BigDecimal bd = new BigDecimal(String.valueOf(key));
BigDecimal paymentPrice1 = (BigDecimal) key.get("paymentPrice");
BigDecimal a = paymentPrice1;
BigDecimal d2= (BigDecimal) a;
String s1 = String.valueOf(a);
if (s1.contains(".")&&d2!=a){
int i = s1.indexOf(".");
for(int j=i;j<s1.length()-1;j++){
int lastIndex=s1.charAt(s1.length()-1);
int io = s1.lastIndexOf("0");
if (lastIndex==io){
s1=s1.substring(0,s1.length()-1);
}
}
}else {
s1+="0";
}
logger.info("s1:"+s1);
}
}