|
@@ -1,6 +1,8 @@
|
|
|
package com.gis.cms.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -30,6 +32,7 @@ import com.gis.common.util.DateUtils;
|
|
|
import com.gis.common.util.ExcelUtils;
|
|
|
import com.gis.common.util.Result;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.junit.Test;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -297,7 +300,8 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
@Override
|
|
|
public Result exportExcel(){
|
|
|
// List<HotelExcel> rows = baseMapper.getExcelList();
|
|
|
- List<HotelExcel> rows = getRows();
|
|
|
+// List<HotelExcel> rows = getRows();
|
|
|
+ List<JSONObject> rows = getRows_2();
|
|
|
String filePath = "/excel/" + DateUtils.getDateTime() + ".xlsx";
|
|
|
|
|
|
//LinkedHashMap 中的数据是根据put先后顺序来的,HashMap数据时无序的
|
|
@@ -312,12 +316,11 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
rowTitle.put("usable", "房间可用");
|
|
|
rowTitle.put("touch", "密接人数");
|
|
|
rowTitle.put("touchSecond", "次密人数数");
|
|
|
- rowTitle.put("remark", "备注");
|
|
|
rowTitle.put("caseSign", "签约情况");
|
|
|
rowTitle.put("caseAccept", "验收情况");
|
|
|
rowTitle.put("caseBuild", "三区两通道搭建情况");
|
|
|
rowTitle.put("caseSupplies", "物资情况");
|
|
|
-
|
|
|
+ rowTitle.put("remark", "备注");
|
|
|
|
|
|
rowTitle.putAll(getContactTypeTitle());
|
|
|
|
|
@@ -342,17 +345,19 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
// 封装联系人title
|
|
|
LinkedHashMap<String, String> rowTitle = new LinkedHashMap<>();
|
|
|
for (ContactTypeVo vo : contactTypes) {
|
|
|
- rowTitle.put("c"+vo.getId(), vo.getName());
|
|
|
+ rowTitle.put(vo.getId().toString(), vo.getName());
|
|
|
}
|
|
|
return rowTitle;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取酒店行
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<HotelExcel> getRows(){
|
|
|
+ private List<JSONObject> getRows_2(){
|
|
|
|
|
|
// 获取酒店
|
|
|
List<HotelExcel> rows = baseMapper.getExcelList();
|
|
@@ -375,15 +380,15 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
// 封装统一联系类型 的 联系人信息
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
for (ContactEntity entity : contactList) {
|
|
|
- if (StrUtil.isNotBlank(entity.getName())){
|
|
|
- builder.append(entity.getName());
|
|
|
- }
|
|
|
- if (StrUtil.isNotBlank(entity.getPhone())){
|
|
|
- if (StrUtil.isNotBlank(builder)){
|
|
|
- builder.append(",");
|
|
|
- }
|
|
|
- builder.append(entity.getPhone()).append(";\r\n");
|
|
|
- }
|
|
|
+ if (StrUtil.isNotBlank(entity.getName())){
|
|
|
+ builder.append(entity.getName());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(entity.getPhone())){
|
|
|
+ if (StrUtil.isNotBlank(builder)){
|
|
|
+ builder.append(",");
|
|
|
+ }
|
|
|
+ builder.append(entity.getPhone()).append(";\r\n ");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 合并后的联系人信息
|
|
@@ -394,41 +399,46 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
|
|
|
|
|
|
// 将联系人信息添加到酒店详情
|
|
|
- List<HotelExcel> newRows = new ArrayList<>();
|
|
|
+ List<JSONObject> newRows = new ArrayList<>();
|
|
|
for (HotelExcel row : rows) {
|
|
|
+ // 转json
|
|
|
+// row.setCaseAccept();
|
|
|
+// row.setCaseBuild();
|
|
|
+// row.setCaseSign();
|
|
|
+// row.setCaseSupplies();
|
|
|
+ JSONObject rowJson = (JSONObject)JSONObject.toJSON(row);
|
|
|
|
|
|
for (Map.Entry<Long, Map<String, String>> entry : resMap.entrySet()) {
|
|
|
if (row.getId().equals(entry.getKey())){
|
|
|
// 类型人类型
|
|
|
Map<String, String> value = entry.getValue();
|
|
|
- row.setC1(value.get("1"));
|
|
|
- row.setC2(value.get("2"));
|
|
|
- row.setC3(value.get("3"));
|
|
|
- row.setC4(value.get("4"));
|
|
|
- row.setC5(value.get("5"));
|
|
|
- row.setC6(value.get("6"));
|
|
|
- row.setC7(value.get("7"));
|
|
|
- row.setC8(value.get("8"));
|
|
|
- row.setC9(value.get("9"));
|
|
|
- row.setC10(value.get("10"));
|
|
|
- row.setC11(value.get("11"));
|
|
|
- row.setC12(value.get("12"));
|
|
|
- row.setC13(value.get("13"));
|
|
|
- row.setC14(value.get("14"));
|
|
|
- row.setC15(value.get("15"));
|
|
|
- row.setC16(value.get("16"));
|
|
|
+ // 添加字段
|
|
|
+ for (Map.Entry<String, String> typeKey : value.entrySet()) {
|
|
|
+ rowJson.put(typeKey.getKey(), typeKey.getValue());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- newRows.add(row);
|
|
|
+ newRows.add(rowJson);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- return newRows;
|
|
|
+ return newRows;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ @Test
|
|
|
+ public void test(){
|
|
|
+ HotelExcel excel = new HotelExcel();
|
|
|
+ excel.setName("小明");
|
|
|
|
|
|
+ JSONObject jsonObject = (JSONObject)JSONObject.toJSON(excel);
|
|
|
|
|
|
+ System.out.println(jsonObject);
|
|
|
}
|
|
|
|
|
|
|