|
|
@@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.happy.Model.House;
|
|
|
import com.happy.Model.HousePrice;
|
|
|
import com.happy.Until.DateUtil;
|
|
|
+import com.happy.Until.Excel.toExcel;
|
|
|
import com.happy.Until.Func;
|
|
|
+import com.happy.Until.ResponseUtil;
|
|
|
+import com.happy.Until.UUIDUtil;
|
|
|
import com.happy.dao.HouseDao;
|
|
|
import com.happy.dao.HousePriceDao;
|
|
|
import com.happy.dto.HousePriceDto;
|
|
|
@@ -12,6 +15,8 @@ import com.happy.dto.IPage;
|
|
|
import com.happy.service.HousePriceService;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.struts2.ServletActionContext;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -31,12 +36,11 @@ public class HousePriceServiceImpl implements HousePriceService {
|
|
|
List<HousePrice> housePriceList = new ArrayList<>();
|
|
|
Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
priceList.forEach(item -> {
|
|
|
- item.setCreateId("");
|
|
|
item.setCreateDate(now);
|
|
|
item.setStatus(1);
|
|
|
dateList.forEach(date -> {
|
|
|
HousePrice housePrice = new HousePrice();
|
|
|
- org.springframework.beans.BeanUtils.copyProperties(item, housePrice);
|
|
|
+ BeanUtils.copyProperties(item, housePrice);
|
|
|
housePrice.setId(Func.newGuid());
|
|
|
housePrice.setSetDate(date);
|
|
|
housePriceList.add(housePrice);
|
|
|
@@ -50,7 +54,6 @@ public class HousePriceServiceImpl implements HousePriceService {
|
|
|
public void modifyPrice(HousePriceDto housePriceDto) {
|
|
|
Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
housePriceDto.setId(Func.newGuid());
|
|
|
- housePriceDto.setCreateId("");
|
|
|
housePriceDto.setCreateDate(now);
|
|
|
housePriceDto.setStatus(1);
|
|
|
housePriceDao.insertBatch(Collections.singletonList(housePriceDto));
|
|
|
@@ -75,7 +78,7 @@ public class HousePriceServiceImpl implements HousePriceService {
|
|
|
|
|
|
List<Date> dateListBetween = DateUtil.getDateListBetween(startDate, endDate);
|
|
|
pageList.forEach(item -> {
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
|
|
jsonObject.put("id", item.getHouseId());
|
|
|
jsonObject.put("houseName", item.getHouseName());
|
|
|
dateListBetween.forEach(date -> jsonObject.put(DateUtil.parseDateToStr(date, DateUtil.Time_Formatter_Day), getPrice(date, item, housePriceDtoList)));
|
|
|
@@ -114,6 +117,45 @@ public class HousePriceServiceImpl implements HousePriceService {
|
|
|
return houseDao.queryList(sqlx);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportHistory(HousePriceDto housePriceDto) {
|
|
|
+ if (StringUtils.isBlank(housePriceDto.getManagerId())) return;
|
|
|
+ List<HousePriceDto> list = housePriceDao.queryListThree(housePriceDto, null, null);
|
|
|
+ if (list.isEmpty()) return;
|
|
|
+ // List<Vector<Object>> vectorsList = new ArrayList<>();
|
|
|
+ List<Vector> vectorsList = new ArrayList<>();
|
|
|
+ list.forEach(housePrice -> {
|
|
|
+ Vector columnValue = new Vector<>();
|
|
|
+ columnValue.add(housePrice.getHouseName());
|
|
|
+ columnValue.add(housePrice.getSetDate());
|
|
|
+ columnValue.add(housePrice.getPrice());
|
|
|
+ columnValue.add(housePrice.getOperationName());
|
|
|
+ columnValue.add(housePrice.getOperationTime());
|
|
|
+ vectorsList.add(columnValue);
|
|
|
+ });
|
|
|
+ // 项目路径地址
|
|
|
+ String path = ServletActionContext.getRequest().getSession().getServletContext()
|
|
|
+ .getRealPath("/download/");// File.separator
|
|
|
+ Vector<String> columnName = new Vector<>();
|
|
|
+ columnName.add("房型");
|
|
|
+ columnName.add("价格日期");
|
|
|
+ columnName.add("修改后价格");
|
|
|
+ columnName.add("操作人");
|
|
|
+ columnName.add("操作时间");
|
|
|
+ String filePathName = "改价记录" + UUIDUtil.generateID() + "Report.xls";
|
|
|
+
|
|
|
+ // 导出文件
|
|
|
+ new toExcel().book(vectorsList, path + filePathName,
|
|
|
+ "sheet1", columnName);
|
|
|
+ String url = "https://chtech.ncjti.edu.cn/hotelReservation/mhotel";
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("downurl", url + "/download/" + filePathName);
|
|
|
+ result.put("code", 200);
|
|
|
+ result.put("message", "导出成功");
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
+ result.toString());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取房型指定日期的价格
|
|
|
*
|