|
|
@@ -1,11 +1,14 @@
|
|
|
package org.jeecg.modules.bus.controller;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.lowagie.text.LargeElement;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.annotation.ApiLogin;
|
|
|
import org.jeecg.com.util.ThirdSessionHolder;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
@@ -15,14 +18,23 @@ import org.jeecg.common.util.TenantContextHolder;
|
|
|
import org.jeecg.config.ApiVersion;
|
|
|
import org.jeecg.config.ApiVersionConstant;
|
|
|
import org.jeecg.config.WebConfig;
|
|
|
-import org.jeecg.modules.business.entity.BusHotel;
|
|
|
-import org.jeecg.modules.business.service.IBusHotelService;
|
|
|
+import org.jeecg.modules.bus.vo.BusServiceRepairCategoryVo;
|
|
|
+import org.jeecg.modules.business.entity.*;
|
|
|
+import org.jeecg.modules.business.service.*;
|
|
|
import org.jeecg.modules.order.entity.CesOrderRepair;
|
|
|
import org.jeecg.modules.order.service.ICesOrderRepairService;
|
|
|
+import org.jeecg.modules.rooms.entity.CesRooms;
|
|
|
+import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
|
|
|
+import org.jeecg.modules.wxuser.entity.MallUserInfo;
|
|
|
+import org.jeecg.modules.wxuser.service.IUserInfoService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* @Description: ces_order_repair
|
|
|
@@ -39,6 +51,20 @@ public class OrderRepairController extends WebConfig {
|
|
|
private ICesOrderRepairService cesOrderRepairService;
|
|
|
@Resource
|
|
|
private IBusHotelService busHotelService;
|
|
|
+ @Resource
|
|
|
+ private IUserInfoService userInfoService;
|
|
|
+ @Resource
|
|
|
+ private IBusRoomsLivingOrderService busRoomsLivingOrderService;
|
|
|
+ @Resource
|
|
|
+ private IBusRoomBookingOrdersService busRoomBookingOrdersService;
|
|
|
+ @Resource
|
|
|
+ private IBusBookingRoomsService busBookingRoomsService;
|
|
|
+ @Resource
|
|
|
+ private CesRoomsServiceImpl cesRoomsService;
|
|
|
+ @Resource
|
|
|
+ private IBusServiceRepairService busServiceRepairService;
|
|
|
+ @Resource
|
|
|
+ private IBusServiceRepairCategoryService busServiceRepairCategoryService;
|
|
|
/**
|
|
|
* 服务维修单分页列表查询
|
|
|
*
|
|
|
@@ -85,7 +111,92 @@ public class OrderRepairController extends WebConfig {
|
|
|
@ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
@PostMapping(value = "/add")
|
|
|
public Result<String> add(@RequestBody CesOrderRepair cesOrderRepair) {
|
|
|
+ String tenantId = TenantContextHolder.getTenantId();
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+ cesOrderRepair.setTenantId(tenantId);
|
|
|
+ cesOrderRepair.setUserId(userId);
|
|
|
+ cesOrderRepair.setType(2);
|
|
|
+ cesOrderRepair.setCreateDate(DateTime.now());
|
|
|
+ cesOrderRepair.setOrderId(randomNumber("WX"));
|
|
|
+ MallUserInfo mallUserInfo = userInfoService.getById(userId);
|
|
|
+ if (mallUserInfo != null) {
|
|
|
+ cesOrderRepair.setUserMobile(mallUserInfo.getMobile());
|
|
|
+ cesOrderRepair.setUserName(mallUserInfo.getNickName());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<BusRoomsLivingOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(BusRoomsLivingOrder::getThirdLoginUserId, userId).last("limit 1");
|
|
|
+ BusRoomsLivingOrder busRoomsLivingOrder = busRoomsLivingOrderService.getOne(lambdaQueryWrapper);
|
|
|
+ if (busRoomsLivingOrder != null && StringUtils.isNotBlank(busRoomsLivingOrder.getBookingOrderId())) {
|
|
|
+ LambdaQueryWrapper<BusBookingRooms> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper1.eq(BusBookingRooms::getBookingOrdersId, busRoomsLivingOrder.getBookingOrderId()).last("limit 1");
|
|
|
+ BusBookingRooms bookingRooms = busBookingRoomsService.getOne(lambdaQueryWrapper1);
|
|
|
+ if (bookingRooms != null) {
|
|
|
+ CesRooms cesRooms = cesRoomsService.getById(bookingRooms.getRoomId());
|
|
|
+ if (cesRooms != null) {
|
|
|
+ cesOrderRepair.setRoomNo(cesRooms.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
cesOrderRepairService.save(cesOrderRepair);
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成16位数字+prefix
|
|
|
+ * @param prefix
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String randomNumber(String prefix) {
|
|
|
+ int first = new Random(10).nextInt(8) + 1;
|
|
|
+ int hashCode = UUID.randomUUID().toString().hashCode();
|
|
|
+ if (hashCode < 0) {
|
|
|
+ hashCode = -hashCode;
|
|
|
+ }
|
|
|
+ return prefix + first + String.format("%015d", hashCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修项目列表
|
|
|
+ * @param hotleId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiLogin
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiOperation(value="维修项目列表", notes="维修项目列表")
|
|
|
+ @GetMapping(value = "/repair-project-list")
|
|
|
+ public Result<List<BusServiceRepair>> getRepairProjectList( @RequestParam(name="hotleId") String hotleId) {
|
|
|
+ LambdaQueryWrapper<BusServiceRepair> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BusServiceRepair::getHotelId, hotleId);
|
|
|
+ queryWrapper.eq(BusServiceRepair::getType, 2);
|
|
|
+ List<BusServiceRepair> list = busServiceRepairService.list(queryWrapper);
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 服务项目列表
|
|
|
+ * @param hotleId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiLogin
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiOperation(value="服务项目列表", notes="服务项目列表")
|
|
|
+ @GetMapping(value = "/service-project-list")
|
|
|
+ public Result<List<BusServiceRepairCategoryVo>> getServiceProjectList(@RequestParam(name="hotleId") String hotleId) {
|
|
|
+ LambdaQueryWrapper<BusServiceRepairCategory> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BusServiceRepairCategory::getHotelId, hotleId);
|
|
|
+ List<BusServiceRepairCategoryVo> voList = new ArrayList<>();
|
|
|
+ List<BusServiceRepairCategory> list = busServiceRepairCategoryService.list(queryWrapper);
|
|
|
+ list.forEach(t -> {
|
|
|
+ BusServiceRepairCategoryVo vo = new BusServiceRepairCategoryVo();
|
|
|
+ vo.setName(t.getName());
|
|
|
+ LambdaQueryWrapper<BusServiceRepair> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper2.eq(BusServiceRepair::getHotelId, hotleId);
|
|
|
+ lambdaQueryWrapper2.eq(BusServiceRepair::getType, 1);
|
|
|
+ lambdaQueryWrapper2.eq(BusServiceRepair::getCategoryId, t.getId());
|
|
|
+ List<BusServiceRepair> busServiceRepairs = busServiceRepairService.list(lambdaQueryWrapper2);
|
|
|
+ vo.setList(busServiceRepairs);
|
|
|
+ voList.add(vo);
|
|
|
+ });
|
|
|
+ return Result.OK(voList);
|
|
|
+ }
|
|
|
}
|