优化导出excel的功能,解决数字展示的问题
This commit is contained in:
@@ -513,28 +513,28 @@ public class MaterialService {
|
||||
}
|
||||
String[] names = StringUtil.listToStringArray(nameList);
|
||||
String title = "商品信息";
|
||||
List<String[]> objects = new ArrayList<>();
|
||||
List<Object[]> objects = new ArrayList<>();
|
||||
if (null != dataList) {
|
||||
for (MaterialVo4Unit m : dataList) {
|
||||
String[] objs = new String[names.length];
|
||||
Object[] objs = new Object[names.length];
|
||||
objs[0] = m.getName();
|
||||
objs[1] = m.getStandard();
|
||||
objs[2] = m.getModel();
|
||||
objs[3] = m.getColor();
|
||||
objs[4] = m.getBrand();
|
||||
objs[5] = m.getCategoryName();
|
||||
objs[6] = m.getWeight() == null ? "" : m.getWeight().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[7] = m.getExpiryNum() == null ? "" : m.getExpiryNum().toString();
|
||||
objs[6] = m.getWeight() == null ? "" : m.getWeight().setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
objs[7] = m.getExpiryNum() == null ? "" : m.getExpiryNum();
|
||||
objs[8] = m.getCommodityUnit();
|
||||
objs[9] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getCommodityUnit();
|
||||
objs[10] = m.getmBarCode();
|
||||
objs[11] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getBarCode();
|
||||
objs[12] = m.getRatio() == null ? "" : m.getRatio().toString();
|
||||
objs[12] = m.getRatio() == null ? "" : m.getRatio();
|
||||
objs[13] = m.getSku();
|
||||
objs[14] = m.getPurchaseDecimal() == null ? "" : m.getPurchaseDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[15] = m.getCommodityDecimal() == null ? "" : m.getCommodityDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[16] = m.getWholesaleDecimal() == null ? "" : m.getWholesaleDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[17] = m.getLowDecimal() == null ? "" : m.getLowDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[14] = m.getPurchaseDecimal() == null ? "" : m.getPurchaseDecimal().setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
objs[15] = m.getCommodityDecimal() == null ? "" : m.getCommodityDecimal().setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
objs[16] = m.getWholesaleDecimal() == null ? "" : m.getWholesaleDecimal().setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
objs[17] = m.getLowDecimal() == null ? "" : m.getLowDecimal().setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
objs[18] = m.getEnabled() ? "1" : "0";
|
||||
objs[19] = m.getEnableSerialNumber();
|
||||
objs[20] = m.getEnableBatchNumber();
|
||||
@@ -548,7 +548,7 @@ public class MaterialService {
|
||||
int i = 27;
|
||||
for(Depot depot: depotList) {
|
||||
BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
|
||||
objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[i] = number == null ? BigDecimal.ZERO : number.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
i++;
|
||||
}
|
||||
objects.add(objs);
|
||||
|
||||
@@ -559,10 +559,10 @@ public class SupplierService {
|
||||
//会员
|
||||
String[] names = {"会员卡号*", "联系人", "手机号码", "联系电话", "电子邮箱", "备注", "排序", "状态*"};
|
||||
String title = "信息内容";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
List<Object[]> objects = new ArrayList<>();
|
||||
if (null != dataList) {
|
||||
for (Supplier s : dataList) {
|
||||
String[] objs = new String[names.length];
|
||||
Object[] objs = new Object[names.length];
|
||||
objs[0] = s.getSupplier();
|
||||
objs[1] = s.getContacts();
|
||||
objs[2] = s.getTelephone();
|
||||
@@ -588,10 +588,10 @@ public class SupplierService {
|
||||
String[] names = {"名称*", "联系人", "手机号码", "联系电话", "电子邮箱", "传真", beginNeedStr,
|
||||
"纳税人识别号", "税率(%)", "开户行", "账号", "地址", "备注", "排序", "状态*"};
|
||||
String title = "信息内容";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
List<Object[]> objects = new ArrayList<>();
|
||||
if (null != dataList) {
|
||||
for (Supplier s : dataList) {
|
||||
String[] objs = new String[names.length];
|
||||
Object[] objs = new Object[names.length];
|
||||
objs[0] = s.getSupplier();
|
||||
objs[1] = s.getContacts();
|
||||
objs[2] = s.getTelephone();
|
||||
@@ -599,12 +599,12 @@ public class SupplierService {
|
||||
objs[4] = s.getEmail();
|
||||
objs[5] = s.getFax();
|
||||
if(("客户").equals(s.getType())) {
|
||||
objs[6] = s.getBeginNeedGet() == null? "" : s.getBeginNeedGet().setScale(2,BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[6] = s.getBeginNeedGet() == null? "" : s.getBeginNeedGet().setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
} else if(("供应商").equals(s.getType())) {
|
||||
objs[6] = s.getBeginNeedPay() == null? "" : s.getBeginNeedPay().setScale(2,BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[6] = s.getBeginNeedPay() == null? "" : s.getBeginNeedPay().setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
objs[7] = s.getTaxNum();
|
||||
objs[8] = s.getTaxRate() == null? "" : s.getTaxRate().setScale(2,BigDecimal.ROUND_HALF_UP).toString();
|
||||
objs[8] = s.getTaxRate() == null? "" : s.getTaxRate().setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
objs[9] = s.getBankName();
|
||||
objs[10] = s.getAccountNumber();
|
||||
objs[11] = s.getAddress();
|
||||
|
||||
@@ -648,14 +648,14 @@ public class SystemConfigService {
|
||||
public void exportExcelByParam(String title, String head, String tip, JSONArray arr, HttpServletResponse response) throws Exception {
|
||||
List<String> nameList = StringUtil.strToStringList(head);
|
||||
String[] names = StringUtil.listToStringArray(nameList);
|
||||
List<String[]> objects = new ArrayList<>();
|
||||
List<Object[]> objects = new ArrayList<>();
|
||||
if (null != arr) {
|
||||
for (Object object: arr) {
|
||||
List<Object> list = (List<Object>) object;
|
||||
String[] objs = new String[names.length];
|
||||
Object[] objs = new Object[names.length];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if(null != list.get(i)) {
|
||||
objs[i] = list.get(i).toString();
|
||||
objs[i] = list.get(i);
|
||||
}
|
||||
}
|
||||
objects.add(objs);
|
||||
|
||||
Reference in New Issue
Block a user