| | |
| | | package com.jilongda.applet.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.applet.model.TLineUp; |
| | | import com.jilongda.applet.service.TLineUpService; |
| | | import com.jilongda.applet.utils.LoginInfoUtil; |
| | | import com.jilongda.applet.vo.TLineUpVO; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.constants.WarehousingConstant; |
| | | import com.jilongda.common.security.JwtTokenUtils; |
| | | import com.jilongda.common.utils.CodeGenerateUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "排号管理") |
| | | @RestController |
| | | @RequestMapping("/t-line-up") |
| | | public class TLineUpController { |
| | | |
| | | @Autowired |
| | | private TLineUpService tLineUpService; |
| | | @Autowired |
| | | private LoginInfoUtil loginInfoUtil; |
| | | |
| | | @ApiOperation(value = "排号管理待验光人数") |
| | | @GetMapping(value = "/getLineUpByStoreId") |
| | | public ApiResult getLineUpByStoreId(@RequestParam Integer storeId) { |
| | | return ApiResult.success(tLineUpService.count(Wrappers.lambdaQuery(TLineUp.class) |
| | | .eq(TLineUp::getStoreId, storeId) |
| | | .eq(TLineUp::getStatus, 1) |
| | | .likeRight(TLineUp::getCreateTime, LocalDate.now()))); |
| | | } |
| | | |
| | | @ApiOperation(value = "添加排号管理") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult add(@Validated @RequestBody TLineUp dto) { |
| | | // 获取当天该门店的排号 |
| | | long count = tLineUpService.count(Wrappers.lambdaQuery(TLineUp.class) |
| | | .likeRight(TLineUp::getCreateTime, LocalDate.now()) |
| | | .eq(TLineUp::getStoreId, dto.getStoreId())); |
| | | dto.setStatus(1); |
| | | dto.setUserId(loginInfoUtil.getUserId()); |
| | | dto.setCode(String.valueOf(count+1)); |
| | | tLineUpService.save(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询当前用户排号信息") |
| | | @GetMapping(value = "/getUserLineUpByStoreId") |
| | | public ApiResult getUserLineUpByStoreId(@RequestParam Integer storeId) { |
| | | long userId = loginInfoUtil.getUserId(); |
| | | List<Integer> list = Arrays.asList(1, 2); |
| | | |
| | | TLineUp lineUp = tLineUpService.getOne(Wrappers.lambdaQuery(TLineUp.class) |
| | | .eq(TLineUp::getUserId, userId) |
| | | .eq(TLineUp::getStoreId, storeId) |
| | | .in(TLineUp::getStatus, list) |
| | | .orderByDesc(TLineUp::getCreateTime) |
| | | .last("LIMIT 1")); |
| | | TLineUpVO tLineUpVO = new TLineUpVO(); |
| | | if (lineUp!=null){ |
| | | BeanUtils.copyProperties(lineUp, tLineUpVO); |
| | | long count = tLineUpService.count(Wrappers.lambdaQuery(TLineUp.class) |
| | | .eq(TLineUp::getStoreId, storeId) |
| | | .eq(TLineUp::getStatus, 1) |
| | | .lt(lineUp!=null,TLineUp::getCode, lineUp.getCode()) |
| | | .likeRight(TLineUp::getCreateTime, LocalDate.now())); |
| | | tLineUpVO.setLinUpCount(count); |
| | | |
| | | }else{ |
| | | long count = tLineUpService.count(Wrappers.lambdaQuery(TLineUp.class) |
| | | .eq(TLineUp::getStoreId, storeId) |
| | | .eq(TLineUp::getStatus, 1) |
| | | .likeRight(TLineUp::getCreateTime, LocalDate.now())); |
| | | tLineUpVO.setLinUpCount(count); |
| | | } |
| | | return ApiResult.success(tLineUpVO); |
| | | } |
| | | @ApiOperation(value = "取消排号") |
| | | @GetMapping(value = "/cancelLineUp") |
| | | public ApiResult cancelLineUp(@RequestParam Integer id) { |
| | | TLineUp lineUp = tLineUpService.getById(id); |
| | | lineUp.setStatus(5); |
| | | tLineUpService.updateById(lineUp); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | } |
| | | |