|
|
@@ -0,0 +1,500 @@
|
|
|
+package org.jeecg.modules.business.controller;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.Time;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import lombok.Data;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
+import org.jeecg.common.util.TokenUtils;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import org.jeecg.modules.business.dto.BusSchemeLayoutDailyPriceDetailDto;
|
|
|
+import org.jeecg.modules.business.dto.BusSchemeLayoutDailyPriceDto;
|
|
|
+import org.jeecg.modules.business.dto.BusSchemeLayoutDailyPriceListDto;
|
|
|
+import org.jeecg.modules.business.entity.BusHousePriceSchemeLayout;
|
|
|
+import org.jeecg.modules.business.entity.BusNightTrial;
|
|
|
+import org.jeecg.modules.business.entity.BusSalesPerson;
|
|
|
+import org.jeecg.modules.business.entity.BusSchemeLayoutDailyPrice;
|
|
|
+import org.jeecg.modules.business.service.IBusHousePriceSchemeLayoutService;
|
|
|
+import org.jeecg.modules.business.service.IBusSchemeLayoutDailyPriceService;
|
|
|
+import org.jeecg.modules.rooms.entity.CesRoomLayout;
|
|
|
+import org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
|
|
|
+import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 房价方案-每日房价表
|
|
|
+ * @Author: jeecg-boot
|
|
|
+ * @Date: 2023-04-08
|
|
|
+ * @Version: V1.0
|
|
|
+ */
|
|
|
+@Api(tags="房价方案-每日房价表")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/business/busSchemeLayoutDailyPrice")
|
|
|
+@Slf4j
|
|
|
+public class BusSchemeLayoutDailyPriceController extends JeecgController<BusSchemeLayoutDailyPrice, IBusSchemeLayoutDailyPriceService> {
|
|
|
+ @Autowired
|
|
|
+ private IBusSchemeLayoutDailyPriceService busSchemeLayoutDailyPriceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBusHousePriceSchemeLayoutService busHousePriceSchemeLayoutService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CesRoomLayoutServiceImpl cesRoomLayoutService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "房价方案-每日房价表-分页列表查询")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-分页列表查询", notes="房价方案-每日房价表-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<IPage<BusSchemeLayoutDailyPrice>> queryPageList(BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<BusSchemeLayoutDailyPrice> queryWrapper = QueryGenerator.initQueryWrapper(busSchemeLayoutDailyPrice, req.getParameterMap());
|
|
|
+ Page<BusSchemeLayoutDailyPrice> page = new Page<BusSchemeLayoutDailyPrice>(pageNo, pageSize);
|
|
|
+ IPage<BusSchemeLayoutDailyPrice> pageList = busSchemeLayoutDailyPriceService.page(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+ public static List<Date> findDates(Date dBegin, Date dEnd)
|
|
|
+ {
|
|
|
+ List lDate = new ArrayList();
|
|
|
+ lDate.add(dBegin);
|
|
|
+ Calendar calBegin = Calendar.getInstance();
|
|
|
+ // 使用给定的 Date 设置此 Calendar 的时间
|
|
|
+ calBegin.setTime(dBegin);
|
|
|
+ Calendar calEnd = Calendar.getInstance();
|
|
|
+ // 使用给定的 Date 设置此 Calendar 的时间
|
|
|
+ calEnd.setTime(dEnd);
|
|
|
+ // 测试此日期是否在指定日期之后
|
|
|
+ while (dEnd.after(calBegin.getTime()))
|
|
|
+ {
|
|
|
+ // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
|
|
+ calBegin.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ lDate.add(calBegin.getTime());
|
|
|
+ }
|
|
|
+ return lDate;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 列表查询
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "每日房价-列表查询")
|
|
|
+ @ApiOperation(value="每日房价-列表查询", notes="每日房价-列表查询")
|
|
|
+ @GetMapping(value = "/queryList")
|
|
|
+ public Result<List<BusSchemeLayoutDailyPrice>> queryList(BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice, HttpServletRequest req) {
|
|
|
+ QueryWrapper<BusSchemeLayoutDailyPrice> queryWrapper = QueryGenerator.initQueryWrapper(busSchemeLayoutDailyPrice, req.getParameterMap());
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ queryWrapper.eq("tenant_id",user.getRelTenantIds());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("del_flag",0);
|
|
|
+ List<BusSchemeLayoutDailyPrice> list = busSchemeLayoutDailyPriceService.list(queryWrapper);
|
|
|
+ //获取从今天开始,两个月时间的数据
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ Date startDate = calendar.getTime();
|
|
|
+ calendar.add(Calendar.MONTH, 2);
|
|
|
+ calendar.add(Calendar.DATE, -1);
|
|
|
+ Date endDate = calendar.getTime();
|
|
|
+
|
|
|
+ List<Date> lDate = findDates(startDate, endDate);
|
|
|
+ String _realDate = req.getParameter("realDate");
|
|
|
+ if (_realDate != null && !_realDate.equals("")){
|
|
|
+ Date realDate = DateUtils.parseDatetime(_realDate);
|
|
|
+ lDate = findDates(realDate, endDate);
|
|
|
+ }
|
|
|
+ List<BusSchemeLayoutDailyPrice> newList = new ArrayList<>();
|
|
|
+ String schemeLayoutId = req.getParameter("schemeLayoutId");
|
|
|
+ BusHousePriceSchemeLayout busHousePriceSchemeLayout = busHousePriceSchemeLayoutService.getById(schemeLayoutId);
|
|
|
+ if (list !=null && list.size() >= 0){
|
|
|
+ lDate.forEach(day->{
|
|
|
+ BusSchemeLayoutDailyPrice dayMoney = new BusSchemeLayoutDailyPrice();
|
|
|
+ dayMoney.setSchemeLayoutId(schemeLayoutId);
|
|
|
+ int flag = 0;
|
|
|
+ for(BusSchemeLayoutDailyPrice s: list){
|
|
|
+ if(format.format(day).equals(format.format(s.getDate()))){
|
|
|
+ flag= 1;
|
|
|
+ dayMoney.setMoney(s.getMoney());
|
|
|
+ dayMoney.setId(s.getId());
|
|
|
+ dayMoney.setDate(s.getDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag == 0){
|
|
|
+ dayMoney.setMoney(busHousePriceSchemeLayout.getMoney());
|
|
|
+ dayMoney.setId("");
|
|
|
+ dayMoney.setDate(day);
|
|
|
+ }
|
|
|
+ newList.add(dayMoney);
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ lDate.forEach(day->{
|
|
|
+ BusSchemeLayoutDailyPrice dayMoney = new BusSchemeLayoutDailyPrice();
|
|
|
+ dayMoney.setSchemeLayoutId(schemeLayoutId);
|
|
|
+ dayMoney.setMoney(busHousePriceSchemeLayout.getMoney());
|
|
|
+ dayMoney.setId("");
|
|
|
+ dayMoney.setDate(day);
|
|
|
+ newList.add(dayMoney);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return Result.OK(newList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表查询
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPriceDto
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "每日房价-列表查询")
|
|
|
+ @ApiOperation(value="每日房价-列表查询", notes="每日房价-列表查询")
|
|
|
+ @GetMapping(value = "/queryListByCond")
|
|
|
+ public Result<BusSchemeLayoutDailyPriceListDto> queryListByCond(BusSchemeLayoutDailyPriceDto busSchemeLayoutDailyPriceDto, HttpServletRequest req) {
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ QueryWrapper<BusHousePriceSchemeLayout> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ queryWrapper1.eq("tenant_id",user.getRelTenantIds());
|
|
|
+ }
|
|
|
+ queryWrapper1.eq("del_flag",0);
|
|
|
+ queryWrapper1.eq("hotel_id",busSchemeLayoutDailyPriceDto.getHotelId());
|
|
|
+ queryWrapper1.eq("scheme_id",busSchemeLayoutDailyPriceDto.getSchemeId());
|
|
|
+ queryWrapper1.eq("layout_id",busSchemeLayoutDailyPriceDto.getLayoutId());
|
|
|
+ BusHousePriceSchemeLayout busHousePriceSchemeLayout = busHousePriceSchemeLayoutService.getOne(queryWrapper1);
|
|
|
+
|
|
|
+ if (busHousePriceSchemeLayout == null){
|
|
|
+ return Result.error("未查询到相关数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ String _startDate = busSchemeLayoutDailyPriceDto.getStartDate()+" 00:00:00";
|
|
|
+ String _endDate = busSchemeLayoutDailyPriceDto.getEndDate()+" 00:00:00";
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date startDate = DateUtils.parseDatetime(_startDate);
|
|
|
+ Date endDate = DateUtils.parseDatetime(_endDate);
|
|
|
+ List<Date> dateList = findDates(startDate, endDate);
|
|
|
+ String schemeLayoutId = busHousePriceSchemeLayout.getId();
|
|
|
+
|
|
|
+ //获取当前所有满足条件的房价
|
|
|
+ QueryWrapper<BusSchemeLayoutDailyPrice> queryWrapper = new QueryWrapper<>();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ queryWrapper.eq("tenant_id",user.getRelTenantIds());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("del_flag",0);
|
|
|
+ queryWrapper.eq("hotel_id",busSchemeLayoutDailyPriceDto.getHotelId());
|
|
|
+ queryWrapper.eq("scheme_layout_id",schemeLayoutId);
|
|
|
+ List<BusSchemeLayoutDailyPrice> list = busSchemeLayoutDailyPriceService.list(queryWrapper);
|
|
|
+
|
|
|
+ BusSchemeLayoutDailyPriceListDto result = new BusSchemeLayoutDailyPriceListDto();
|
|
|
+ result.setLayoutId(busSchemeLayoutDailyPriceDto.getLayoutId());
|
|
|
+ result.setSchemeId(busSchemeLayoutDailyPriceDto.getSchemeId());
|
|
|
+ result.setDepartureTime(busHousePriceSchemeLayout.getDepartureTime());
|
|
|
+ CesRoomLayout layout = cesRoomLayoutService.getById(busHousePriceSchemeLayout.getLayoutId());
|
|
|
+ if (layout != null) {
|
|
|
+ result.setLayoutPrice(layout.getMarketPrice());
|
|
|
+ }
|
|
|
+ result.setLayoutPrice(busHousePriceSchemeLayout.getLayoutPrice());
|
|
|
+ List<BusSchemeLayoutDailyPriceDetailDto> detailDtos = new ArrayList<>();
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ Date curDate = calendar.getTime();
|
|
|
+ if (dateList != null && dateList.size() > 0){
|
|
|
+ dateList.forEach( day -> {
|
|
|
+ BusSchemeLayoutDailyPriceDetailDto detailDto = new BusSchemeLayoutDailyPriceDetailDto();
|
|
|
+ int flag = 0;
|
|
|
+ BigDecimal curMoney = new BigDecimal(0);
|
|
|
+ for(BusSchemeLayoutDailyPrice s: list){
|
|
|
+ if(format.format(day).equals(format.format(s.getDate()))){
|
|
|
+ flag= 1;
|
|
|
+ detailDto.setDate(s.getDate());
|
|
|
+ detailDto.setMoney(s.getMoney());
|
|
|
+ detailDto.setId(s.getId());
|
|
|
+ curMoney=s.getMoney();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag == 0){
|
|
|
+ detailDto.setDate(day);
|
|
|
+ detailDto.setMoney(busHousePriceSchemeLayout.getMoney());
|
|
|
+ detailDto.setId("");
|
|
|
+ curMoney=busHousePriceSchemeLayout.getMoney();
|
|
|
+ }
|
|
|
+ if (format.format(day).equals(format.format(curDate))){
|
|
|
+ result.setDate(day);
|
|
|
+ result.setMoney(curMoney);
|
|
|
+ }
|
|
|
+ detailDtos.add(detailDto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.setList(detailDtos);
|
|
|
+ return Result.OK(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "每日房价-编辑")
|
|
|
+ @ApiOperation(value="每日房价-编辑", notes="每日房价-编辑")
|
|
|
+ @RequestMapping(value = "/editDailyPrice", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<BusSchemeLayoutDailyPrice> editDailyPrice(@RequestBody BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice) {
|
|
|
+ if(busSchemeLayoutDailyPrice.getTenantId() == null || busSchemeLayoutDailyPrice.getTenantId().equals("")){
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ busSchemeLayoutDailyPrice.setTenantId(user.getRelTenantIds());
|
|
|
+ } else {
|
|
|
+ throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (busSchemeLayoutDailyPrice.getId() != null && !busSchemeLayoutDailyPrice.getId().equals("")){
|
|
|
+ BusSchemeLayoutDailyPrice editModel = busSchemeLayoutDailyPriceService.getById(busSchemeLayoutDailyPrice.getId());
|
|
|
+ editModel.setMoney(busSchemeLayoutDailyPrice.getMoney());
|
|
|
+ busSchemeLayoutDailyPriceService.updateById(editModel);
|
|
|
+ return Result.OK(editModel);
|
|
|
+ }else{
|
|
|
+ if(busSchemeLayoutDailyPrice.getTenantId() == null || busSchemeLayoutDailyPrice.getTenantId().equals("")){
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ busSchemeLayoutDailyPrice.setTenantId(user.getRelTenantIds());
|
|
|
+ } else {
|
|
|
+ throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ busSchemeLayoutDailyPrice.setHotelId(busSchemeLayoutDailyPrice.getHotelId());
|
|
|
+ busSchemeLayoutDailyPrice.setSchemeLayoutId(busSchemeLayoutDailyPrice.getSchemeLayoutId());
|
|
|
+ busSchemeLayoutDailyPrice.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ busSchemeLayoutDailyPrice.setMoney(busSchemeLayoutDailyPrice.getMoney());
|
|
|
+ busSchemeLayoutDailyPrice.setDate(busSchemeLayoutDailyPrice.getDate());
|
|
|
+ busSchemeLayoutDailyPriceService.save(busSchemeLayoutDailyPrice);
|
|
|
+ return Result.OK(busSchemeLayoutDailyPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPriceDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "每日房价-批量更新")
|
|
|
+ @ApiOperation(value="每日房价-批量更新", notes="每日房价-批量更新")
|
|
|
+ @RequestMapping(value = "/batchUpdatePrice", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<BusSchemeLayoutDailyPrice> batchUpdatePrice(@RequestBody BusSchemeLayoutDailyPriceDto busSchemeLayoutDailyPriceDto) {
|
|
|
+ if(busSchemeLayoutDailyPriceDto.getTenantId() == null || busSchemeLayoutDailyPriceDto.getTenantId().equals("")){
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+// busSchemeLayoutDailyPriceDto.setTenantId(user.getRelTenantIds());
|
|
|
+ } else {
|
|
|
+ throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String _startDate = busSchemeLayoutDailyPriceDto.getStartDate()+" 00:00:00";
|
|
|
+ String _endDate = busSchemeLayoutDailyPriceDto.getEndDate()+" 00:00:00";
|
|
|
+
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date startDate = DateUtils.parseDatetime(_startDate);
|
|
|
+ Date endDate = DateUtils.parseDatetime(_endDate);
|
|
|
+ List<Date> dateList = findDates(startDate, endDate);
|
|
|
+ String schemeLayoutId = busSchemeLayoutDailyPriceDto.getSchemeLayoutId();
|
|
|
+ BusHousePriceSchemeLayout busHousePriceSchemeLayout = busHousePriceSchemeLayoutService.getById(schemeLayoutId);
|
|
|
+
|
|
|
+ //获取当前所有满足条件的房价
|
|
|
+ QueryWrapper<BusSchemeLayoutDailyPrice> queryWrapper = new QueryWrapper<>();
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
|
|
|
+ queryWrapper.eq("tenant_id",user.getRelTenantIds());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("del_flag",0);
|
|
|
+ queryWrapper.eq("hotel_id",busSchemeLayoutDailyPriceDto.getHotelId());
|
|
|
+ queryWrapper.eq("scheme_layout_id",schemeLayoutId);
|
|
|
+ List<BusSchemeLayoutDailyPrice> list = busSchemeLayoutDailyPriceService.list(queryWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ List<BusSchemeLayoutDailyPrice> newList = new ArrayList<>();
|
|
|
+ if (dateList != null && dateList.size() > 0){
|
|
|
+ dateList.forEach( day -> {
|
|
|
+ BusSchemeLayoutDailyPrice dayMoney = new BusSchemeLayoutDailyPrice();
|
|
|
+ int flag = 0;
|
|
|
+ for(BusSchemeLayoutDailyPrice s: list){
|
|
|
+ if(format.format(day).equals(format.format(s.getDate()))){
|
|
|
+ flag= 1;
|
|
|
+ //修改
|
|
|
+ dayMoney = s;
|
|
|
+ dayMoney.setMoney(busSchemeLayoutDailyPriceDto.getMoney());
|
|
|
+ newList.add(dayMoney);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag == 0){
|
|
|
+ //新增
|
|
|
+ dayMoney.setTenantId(user.getRelTenantIds());
|
|
|
+ dayMoney.setSchemeLayoutId(schemeLayoutId);
|
|
|
+ dayMoney.setHotelId(busSchemeLayoutDailyPriceDto.getHotelId());
|
|
|
+ dayMoney.setSchemeLayoutId(schemeLayoutId);
|
|
|
+ dayMoney.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ dayMoney.setDate(day);
|
|
|
+ dayMoney.setMoney(busSchemeLayoutDailyPriceDto.getMoney());
|
|
|
+ newList.add(dayMoney);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ busSchemeLayoutDailyPriceService.saveOrUpdateBatch(newList);
|
|
|
+ return Result.OK("操作成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "房价方案-每日房价表-添加")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-添加", notes="房价方案-每日房价表-添加")
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:add")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<String> add(@RequestBody BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice) {
|
|
|
+ busSchemeLayoutDailyPriceService.save(busSchemeLayoutDailyPrice);
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "房价方案-每日房价表-编辑")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-编辑", notes="房价方案-每日房价表-编辑")
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:edit")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<String> edit(@RequestBody BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice) {
|
|
|
+ busSchemeLayoutDailyPriceService.updateById(busSchemeLayoutDailyPrice);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "房价方案-每日房价表-通过id删除")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-通过id删除", notes="房价方案-每日房价表-通过id删除")
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:delete")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ busSchemeLayoutDailyPriceService.removeById(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "房价方案-每日房价表-批量删除")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-批量删除", notes="房价方案-每日房价表-批量删除")
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:deleteBatch")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ this.busSchemeLayoutDailyPriceService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "房价方案-每日房价表-通过id查询")
|
|
|
+ @ApiOperation(value="房价方案-每日房价表-通过id查询", notes="房价方案-每日房价表-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<BusSchemeLayoutDailyPrice> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice = busSchemeLayoutDailyPriceService.getById(id);
|
|
|
+ if(busSchemeLayoutDailyPrice==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ return Result.OK(busSchemeLayoutDailyPrice);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param busSchemeLayoutDailyPrice
|
|
|
+ */
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:exportXls")
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, BusSchemeLayoutDailyPrice busSchemeLayoutDailyPrice) {
|
|
|
+ return super.exportXls(request, busSchemeLayoutDailyPrice, BusSchemeLayoutDailyPrice.class, "房价方案-每日房价表");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@RequiresPermissions("business:bus_scheme_layout_daily_price_info:importExcel")
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ return super.importExcel(request, response, BusSchemeLayoutDailyPrice.class);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|