|
@@ -7,13 +7,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.gis.admin.service.SysRoleService;
|
|
|
+import com.gis.cms.entity.dto.ContactDto;
|
|
|
import com.gis.cms.entity.dto.HotelDto;
|
|
|
import com.gis.cms.entity.dto.HotelPageDto;
|
|
|
import com.gis.cms.entity.dto.RoomDto;
|
|
|
+import com.gis.cms.entity.po.ContactEntity;
|
|
|
import com.gis.cms.entity.po.HotelEntity;
|
|
|
+import com.gis.cms.entity.vo.ContactTypeVo;
|
|
|
+import com.gis.cms.entity.vo.ContactVo;
|
|
|
import com.gis.cms.entity.vo.HotelExcel;
|
|
|
import com.gis.cms.entity.vo.HotelVo;
|
|
|
import com.gis.cms.mapper.HotelMapper;
|
|
|
+import com.gis.cms.service.ContactService;
|
|
|
import com.gis.cms.service.HotelService;
|
|
|
import com.gis.cms.zhengyuan.ZhengYuanService;
|
|
|
import com.gis.common.base.entity.po.LogEntity;
|
|
@@ -32,10 +37,9 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -64,6 +68,9 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
@Autowired
|
|
|
IBaseService baseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ContactService contactService;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -233,7 +240,11 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
|
|
|
@Override
|
|
|
public Result detail(Long id) {
|
|
|
- return Result.success(getById(id));
|
|
|
+ HotelEntity entity = this.getById(id);
|
|
|
+
|
|
|
+ List<ContactVo> contacts = contactService.findByHotelId(id);
|
|
|
+ entity.setContacts(contacts);
|
|
|
+ return Result.success(entity);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -255,12 +266,42 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
+ // 更新联系人
|
|
|
+ this.updateContact(param.getContacts(), id);
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * by owen 2022-07-08
|
|
|
+ * 更新联系人
|
|
|
+ * @param param
|
|
|
+ * @param hotelId
|
|
|
+ */
|
|
|
+ private void updateContact(List<ContactDto> param, Long hotelId){
|
|
|
+ // 先删除、再新添加数据
|
|
|
+ if (param.size() > 0){
|
|
|
+ log.info("需要添加联系人数量: {}", param.size());
|
|
|
+ contactService.delByHotelId(hotelId);
|
|
|
+
|
|
|
+ // 添加数据
|
|
|
+ ArrayList<ContactEntity> list = new ArrayList<>();
|
|
|
+ for (ContactDto dto : param) {
|
|
|
+ ContactEntity entity = new ContactEntity();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
+ entity.setHotelId(hotelId);
|
|
|
+ list.add(entity);
|
|
|
+ }
|
|
|
+ contactService.saveBatch(list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Result exportExcel(){
|
|
|
- List<HotelExcel> rows = baseMapper.getExcelList();
|
|
|
+// List<HotelExcel> rows = baseMapper.getExcelList();
|
|
|
+ List<HotelExcel> rows = getRows();
|
|
|
String filePath = "/excel/" + DateUtils.getDateTime() + ".xlsx";
|
|
|
|
|
|
//LinkedHashMap 中的数据是根据put先后顺序来的,HashMap数据时无序的
|
|
@@ -275,8 +316,17 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
rowTitle.put("usable", "房间可用");
|
|
|
rowTitle.put("touch", "密接人数");
|
|
|
rowTitle.put("touchSecond", "次密人数数");
|
|
|
- rowTitle.put("contact", "联系人");
|
|
|
+// rowTitle.put("contact", "联系人");
|
|
|
rowTitle.put("remark", "备注");
|
|
|
+ rowTitle.put("caseSign", "签约情况");
|
|
|
+ rowTitle.put("caseAccept", "验收情况");
|
|
|
+ rowTitle.put("caseBuild", "三区两通道搭建情况");
|
|
|
+ rowTitle.put("caseSupplies", "物资情况");
|
|
|
+
|
|
|
+
|
|
|
+ rowTitle.putAll(getContactTypeTitle());
|
|
|
+
|
|
|
+
|
|
|
|
|
|
ExcelUtils.createExcel(rows, configConstant.serverBasePath + filePath, rowTitle);
|
|
|
|
|
@@ -288,5 +338,102 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 封装联系人excel Title
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private LinkedHashMap<String, String> getContactTypeTitle(){
|
|
|
+ List<ContactTypeVo> contactTypes = contactService.getContactTypes();
|
|
|
+ // 封装联系人title
|
|
|
+ LinkedHashMap<String, String> rowTitle = new LinkedHashMap<>();
|
|
|
+ for (ContactTypeVo vo : contactTypes) {
|
|
|
+ rowTitle.put("c"+vo.getId(), vo.getName());
|
|
|
+ }
|
|
|
+ return rowTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取酒店行
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<HotelExcel> getRows(){
|
|
|
+
|
|
|
+ // 获取酒店
|
|
|
+ List<HotelExcel> rows = baseMapper.getExcelList();
|
|
|
+
|
|
|
+ // 所以联系人
|
|
|
+ List<ContactEntity> contacts = contactService.list();
|
|
|
+
|
|
|
+ // 根据酒店id分组, 再根据类型类型进行分组
|
|
|
+ Map<Long, Map<Long, List<ContactEntity>>> group = contacts.stream().collect(Collectors.groupingBy(ContactEntity::getHotelId, Collectors.groupingBy(ContactEntity::getContactTypeId)));
|
|
|
+ HashMap<Long, Map<String, String>> resMap = new HashMap<>();
|
|
|
+ for (Map.Entry<Long, Map<Long, List<ContactEntity>>> entry : group.entrySet()) {
|
|
|
+
|
|
|
+ ContactTypeVo vo = null;
|
|
|
+ // 每一个类型,只有一条数据
|
|
|
+ Map<String, String> resGroupType = new HashMap<>();
|
|
|
+ // 联系类型数据合并
|
|
|
+ Map<Long, List<ContactEntity>> value = entry.getValue();
|
|
|
+ for (Map.Entry<Long, List<ContactEntity>> contactMap : value.entrySet()) {
|
|
|
+ List<ContactEntity> contactList = contactMap.getValue();
|
|
|
+ // 封装统一联系类型 的 联系人信息
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ for (ContactEntity entity : contactList) {
|
|
|
+ builder.append(entity.getName()).append(",");
|
|
|
+ builder.append(entity.getPhone()).append(";\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并后的联系人信息
|
|
|
+// vo = new ContactTypeVo();
|
|
|
+// vo.setId(contactMap.getKey());
|
|
|
+// vo.setName(builder.toString());
|
|
|
+ resGroupType.put(contactMap.getKey().toString(), builder.toString());
|
|
|
+ }
|
|
|
+ resMap.put(entry.getKey(), resGroupType);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 将联系人信息添加到酒店详情
|
|
|
+ List<HotelExcel> newRows = new ArrayList<>();
|
|
|
+ for (HotelExcel row : rows) {
|
|
|
+
|
|
|
+ for (Map.Entry<Long, Map<String, String>> entry : resMap.entrySet()) {
|
|
|
+ if (row.getId().equals(entry.getKey())){
|
|
|
+ // 类型人类型
|
|
|
+ Map<String, String> value = entry.getValue();
|
|
|
+// System.out.println("==================" + value.get(1));
|
|
|
+// System.out.println("==================" + value.get(2));
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newRows.add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return newRows;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|