| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.optometrist.authority.model.SecUser; |
| | | import com.jilongda.optometrist.authority.service.SecUserService; |
| | | import com.jilongda.optometrist.model.*; |
| | | import com.jilongda.optometrist.query.TOptometristQuery; |
| | | import com.jilongda.optometrist.query.TOptometryQuery; |
| | | import com.jilongda.optometrist.query.TicketQuery; |
| | | import com.jilongda.optometrist.service.*; |
| | | import com.jilongda.optometrist.utils.LoginInfoUtil; |
| | | import com.jilongda.optometrist.vo.TAddOptometryVO; |
| | | import com.jilongda.optometrist.vo.TLineUpDetailVO; |
| | | import com.jilongda.optometrist.vo.TOptometristVO; |
| | | import com.jilongda.optometrist.vo.TOptometryDetailVO; |
| | | import com.jilongda.optometrist.vo.*; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | 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.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private TOrderService orderService; |
| | | @Autowired |
| | | private TOptometryDetailService optometryDetailService; |
| | | @ApiOperation(value = "获取验光单分页列表",tags = "验光单") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TOptometryVO>> pageList(@RequestBody TOptometryQuery query) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (StringUtils.hasLength(query.getTime())){ |
| | | startTime = query.getTime()+" 00:00:00"; |
| | | endTime = query.getTime()+" 23:59:59"; |
| | | } |
| | | query.setStartTime(startTime); |
| | | query.setEndTime(endTime); |
| | | PageInfo<TOptometryVO> tOptometryVOPageInfo = optometristService.pageList(query); |
| | | return ApiResult.success(tOptometryVOPageInfo); |
| | | } |
| | | @ApiOperation(value = "验光记录详情") |
| | | @GetMapping(value = "/detail") |
| | | public ApiResult<TDetailVO> detail(Integer id) { |
| | | TOptometry one = optometryService.getById(id); |
| | | TAppUser byId = appUserService.getById(one.getUserId()); |
| | | TDetailVO tDetailVO = new TDetailVO(); |
| | | tDetailVO.setName(byId.getName()); |
| | | tDetailVO.setPhone(byId.getPhone()); |
| | | tDetailVO.setAvatar(byId.getAvatar()); |
| | | tDetailVO.setRealName(one.getRealName()); |
| | | tDetailVO.setAge(one.getAge()); |
| | | tDetailVO.setGender(one.getGender()); |
| | | // 查询消费次数,验光次数 |
| | | long l = optometryService.count(Wrappers.<TOptometry>lambdaQuery() |
| | | .eq(TOptometry::getUserId, byId.getId()) |
| | | .eq(TOptometry::getStatus,3)); |
| | | tDetailVO.setOptometryCount((int) l); |
| | | long count = orderService.count(Wrappers.<TOrder>lambdaQuery() |
| | | .eq(TOrder::getUserId, byId.getId())); |
| | | tDetailVO.setSaleCount((int) count); |
| | | TOptometrist byId1 = optometristService.getById(one.getOptometristId()); |
| | | tDetailVO.setOptometristName(byId1.getName()); |
| | | TStore byId2 = storeService.getById(one.getStoreId()); |
| | | tDetailVO.setStoreName(byId2.getName()); |
| | | List<TOptometryDetail> list = optometryDetailService.lambdaQuery().eq(TOptometryDetail::getOptometryId, one.getId()).list(); |
| | | tDetailVO.setOptometryDetailVOS(list); |
| | | tDetailVO.setCreateTime(one.getCreateTime()); |
| | | return ApiResult.success(tDetailVO); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // LocalDateTime now = LocalDateTime.now(); |
| | | // // 获取凌晨00:00:00和23:59:59 |
| | | // LocalDateTime startTime = now.withHour(0).withMinute(0).withSecond(0); |
| | | // LocalDateTime endTime = now.withHour(23).withMinute(59).withSecond(59); |
| | | // System.err.println(startTime); |
| | | // System.err.println(endTime); |
| | | } |
| | | @ApiOperation(value = "首页") |
| | | @PostMapping(value = "/index") |
| | | public ApiResult<TOptometristVO> index() { |
| | | TOptometristVO tOptometristVO = new TOptometristVO(); |
| | | |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | SecUser byId = secUserService.getById(userId); |
| | | TStore byId1 = storeService.getById(byId.getStoreId()); |
| | | tOptometristVO.setStoreName(byId1.getName()); |
| | | int size = optometryService.lambdaQuery().eq(TOptometry::getOptometristId, userId) |
| | | Integer userId = loginInfoUtil.getUserId(); |
| | | TOptometrist optometrist = optometristService.getById(userId); |
| | | TStore store = storeService.getById(optometrist.getStoreId()); |
| | | tOptometristVO.setStoreName(store.getName()); |
| | | tOptometristVO.setName(optometrist.getName()); |
| | | tOptometristVO.setPhone(optometrist.getPhone()); |
| | | LocalDateTime nowTime = LocalDateTime.now(); |
| | | // 获取凌晨00:00:00和23:59:59 |
| | | LocalDateTime startTime = nowTime.withHour(0).withMinute(0).withSecond(0); |
| | | LocalDateTime endTime = nowTime.withHour(23).withMinute(59).withSecond(59); |
| | | int size = optometryService.lambdaQuery().eq(TOptometry::getStoreId, optometrist.getId()) |
| | | .between(TOptometry::getCreateTime, startTime, endTime) |
| | | .eq(TOptometry::getStatus, 3).list().size(); |
| | | tOptometristVO.setOptometryCount(size); |
| | | // 查询今日的排号列表 |
| | | List<TLineUp> list = tLineUpService.lambdaQuery().eq(TLineUp::getStoreId, byId.getStoreId()) |
| | | List<TLineUp> list = tLineUpService.lambdaQuery().eq(TLineUp::getStoreId, optometrist.getStoreId()) |
| | | .ne(TLineUp::getStatus, 3) |
| | | .ne(TLineUp::getStatus, 5).list(); |
| | | .ne(TLineUp::getStatus, 5) |
| | | .orderByAsc(TLineUp::getCode) |
| | | .list(); |
| | | for (TLineUp tLineUp : list) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime createTime = tLineUp.getCreateTime(); |
| | |
| | | @ApiOperation(value = "开始验光") |
| | | @GetMapping(value = "/startOptometry") |
| | | public ApiResult startOptometry(Integer id) { |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | Integer userId = loginInfoUtil.getUserId(); |
| | | List<TLineUp> list = tLineUpService.lambdaQuery().eq(TLineUp::getStatus, 2) |
| | | .eq(TLineUp::getOptometristId, userId).list(); |
| | | if (!list.isEmpty())return ApiResult.failed("当前还有未结束的验光单"); |
| | | if (!list.isEmpty()){ |
| | | return ApiResult.failed("当前还有未结束的验光单"); |
| | | } |
| | | TLineUp lineUp = tLineUpService.getById(id); |
| | | // 获取今天凌晨00:00:00和今日23:59:59 |
| | | Date start = new Date(); |
| | | start.setHours(0); |
| | | start.setMinutes(0); |
| | | start.setSeconds(0); |
| | | Date end = new Date(); |
| | | end.setHours(23); |
| | | end.setMinutes(59); |
| | | end.setSeconds(59); |
| | | List<TLineUp> lineUps = tLineUpService.lambdaQuery().eq(TLineUp::getStoreId, lineUp.getStoreId()) |
| | | .between(TLineUp::getCreateTime, start, end).list(); |
| | | for (TLineUp up : lineUps) { |
| | | if (Integer.parseInt(up.getCode())<Integer.parseInt(lineUp.getCode())){ |
| | | up.setStatus(4); |
| | | } |
| | | } |
| | | tLineUpService.updateBatchById(lineUps); |
| | | lineUp.setStatus(2); |
| | | lineUp.setOptometristId(userId); |
| | | tLineUpService.updateById(lineUp); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "取消排号") |
| | | @GetMapping(value = "/cancelLineUp") |
| | | public ApiResult cancelLineUp(Integer id) { |
| | | TLineUp lineUp = tLineUpService.getById(id); |
| | | lineUp.setStatus(5); |
| | | tLineUpService.updateById(lineUp); |
| | | TOptometry one = optometryService.lambdaQuery().eq(TOptometry::getLineUpId, lineUp.getId()).one(); |
| | | if (one!=null){ |
| | | one.setStatus(5); |
| | | optometryService.updateById(one); |
| | | } |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "填写验光信息完成") |
| | |
| | | if (byId1!=null){ |
| | | tOptometry.setPhone(byId1.getPhone()); |
| | | } |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | SecUser byId2 = secUserService.getById(userId); |
| | | tOptometry.setLineUpId(dto.getId()); |
| | | Integer userId = loginInfoUtil.getUserId(); |
| | | TOptometrist byId2 = optometristService.getById(userId); |
| | | tOptometry.setRealName(byId.getUserName()); |
| | | tOptometry.setOptometristId(userId.intValue()); |
| | | tOptometry.setLineUpId(dto.getId()); |
| | | tOptometry.setOptometristId(userId); |
| | | tOptometry.setStoreId(byId2.getStoreId()); |
| | | tOptometry.setStatus(3); |
| | | optometryService.save(tOptometry); |
| | | List<TOptometryDetail> tOptometryDetails = new ArrayList<>(); |
| | | |
| | |
| | | tOptometryDetail.setBallMirror(optometryDetailVO.getBallMirror()); |
| | | tOptometryDetail.setColumnMirror(optometryDetailVO.getColumnMirror()); |
| | | tOptometryDetail.setAxis(optometryDetailVO.getAxis()); |
| | | tOptometryDetail.setAdd(optometryDetailVO.getAdd()); |
| | | tOptometryDetail.setAddS(optometryDetailVO.getAddS()); |
| | | tOptometryDetail.setPupilHeight(optometryDetailVO.getPupilHeight()); |
| | | tOptometryDetail.setPupilDistance(optometryDetailVO.getPupilDistance()); |
| | | tOptometryDetail.setCorrect(optometryDetailVO.getCorrect()); |
| | |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "验光师编辑") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update(@RequestBody TOptometrist dto) { |
| | | optometristService.updateById(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "验光师上下架") |
| | | @GetMapping(value = "/upAndDown") |
| | | public ApiResult<Boolean> upAndDown(@RequestParam Integer id, |
| | | @RequestParam Integer status) { |
| | | return ApiResult.success(optometristService.upAndDown(id,status)); |
| | | } |
| | | } |
| | | |