From 3b3f13a66fe018b1f0abe16db8d194b1927907aa Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Thu, 05 May 2022 10:26:55 +0800 Subject: [PATCH] 20220505 --- zq-erp/src/main/java/com/matrix/system/padApi/action/PadServiceAction.java | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 355 insertions(+), 3 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/padApi/action/PadServiceAction.java b/zq-erp/src/main/java/com/matrix/system/padApi/action/PadServiceAction.java index 0332323..09c808e 100644 --- a/zq-erp/src/main/java/com/matrix/system/padApi/action/PadServiceAction.java +++ b/zq-erp/src/main/java/com/matrix/system/padApi/action/PadServiceAction.java @@ -1,9 +1,15 @@ package com.matrix.system.padApi.action; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.matrix.core.anotations.RemoveRequestToken; +import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; +import com.matrix.core.pojo.VerifyResult; +import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.BusParameterSettings; @@ -19,12 +25,17 @@ import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.service.*; +import com.matrix.system.padApi.dto.PadServiceListDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; import java.util.List; @CrossOrigin(origins = "*") @@ -61,14 +72,66 @@ private SysProjServicesDao sysProjServicesDao; @Autowired BusParameterSettingsDao busParameterSettingsDao; + @Resource + private SysUsersService sysUsersService; + @Resource + private SysWorktimeService sysWorkTimeService; + @Autowired + private SysBeauticianStateDao sysBeauticianStateDao; + @Autowired + private ShoppingGoodsDao shoppingGoodsDao; + @Resource + private SysStoreInfoDao sysStoreInfoDao; + @Resource + private SysWorktimeService worktimeService; + + /** + * 获取用户所有可用的项目和套餐 + * @return + */ + @ApiOperation(value = "获取用户所有可用的项目和套餐", notes = "获取用户所有可用的项目和套餐") + @GetMapping(value = "/getUserProjInfo/{vipId}") + public AjaxResult getUserProjInfo(@PathVariable("vipId")Long vipId) { + AjaxResult result = AjaxResult.buildSuccessInstance("查询成功"); + + SysProjUse queryUse = new SysProjUse(); + queryUse.setVipId(vipId); + queryUse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); + queryUse.setTaocanId(-1L); + queryUse.setStatus(Dictionary.TAOCAN_STATUS_YX); + List<SysProjUse> projList = projUseService.findInPage(queryUse, null); + //切换到套餐查询条件 + queryUse.setTaocanId(null); + queryUse.setType(Dictionary.SHOPPING_GOODS_TYPE_TC); + List<SysProjUse> taoCanList = projUseService.findInPage(queryUse, null); + taoCanList.forEach(item->{ + item.setTaocanProjUse(projUseService.selectTaocanProjUse(item.getId(), queryUse.getStatus())); + item.setProjInfo(shoppingGoodsDao.selectById(item.getProjId())); + }); + result.putInMap("projList", projList); + result.putInMap("taoCanList", taoCanList); + + return result; + } /** * 显示所有服务单列表 */ @ApiOperation(value = "显示所有服务单列表", notes = "显示所有服务单列表") @PostMapping(value = "/showList") - public AjaxResult showList(@RequestBody SysProjServices projService, PaginationVO pageVo) { +// public AjaxResult showList(@RequestBody SysProjServices projService, PaginationVO pageVo) { + public AjaxResult showList(@RequestBody @Validated PadServiceListDto orderListDto) { + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + int offset = (orderListDto.getPageNum() - 1) * orderListDto.getPageSize(); + int limit = orderListDto.getPageSize(); + PaginationVO pageVo = new PaginationVO(); + pageVo.setOffset(offset); + pageVo.setLimit(limit); + if (!DataAuthUtil.hasAllShopAuth()) { + orderListDto.setShopId(user.getShopId()); + } + QueryUtil.setQueryLimitCom(orderListDto); //默认排序 if (StringUtils.isBlank(pageVo.getSort())) { pageVo.setSort("create_time"); @@ -76,18 +139,31 @@ if (StringUtils.isBlank(pageVo.getOrder())) { pageVo.setOrder("desc"); } + + SysProjServices projService = new SysProjServices(); if (!DataAuthUtil.hasAllShopAuth()) { projService.setShopId(getMe().getShopId()); + } + if(ObjectUtil.isNotEmpty(orderListDto.getBeginTime())){ + projService.setBeginTime(orderListDto.getBeginTime()); + } + if(ObjectUtil.isNotEmpty(orderListDto.getClosureTime())){ + projService.setClosureTime(orderListDto.getClosureTime()); + } + if(ObjectUtil.isNotEmpty(orderListDto.getQueryKey())){ + projService.setQueryKey(orderListDto.getQueryKey()); + } + if(StrUtil.isNotEmpty(orderListDto.getState())){ + projService.setState(orderListDto.getState()); } QueryUtil.setQueryLimitCom(projService); List<SysProjServices> dataList = projServicesSerivce.findInPage(projService, pageVo); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, projServicesSerivce.findTotal(projService)); return result; } + /** * 进入预约排班详情 - * - * @author 姜友瑶 */ @ApiOperation(value = "进入预约排班详情", notes = "进入预约排班详情") @PostMapping(value = "/serviceInfo") @@ -146,6 +222,122 @@ result.putInMap("mls", mls); return result; } + + /** + * 获取空闲床位 + */ + @ApiOperation(value = "获取空闲床位", notes = "获取空闲床位") + @PostMapping(value = "/showFreedBed") + public AjaxResult showFreedBed(@RequestBody SysProjServices sysProjServices) { + sysProjServices.setShopId(getMe().getShopId()); + List<SysBedInfo> beds = bedInfoService.findFreeBed(sysProjServices); + return new AjaxResult(AjaxResult.STATUS_SUCCESS, beds, 0); + } + + /** + * 获取美疗师 + */ + @ApiOperation(value = "获取美疗师", notes = "获取美疗师") + @PostMapping(value = "/getPaiBanBeauticianList") + public AjaxResult getPaiBanBeauticianList(@RequestBody SysBeauticianState sysBeauticianState) { + // 根据时间获取一段排班码 + String panBanCodes = DateUtil.dateToString(sysBeauticianState.getBeginTime(),DateUtil.DATE_FORMAT_NO_SPLITE_DD); + // 获取登陆的用户 + SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); + List<SysUsers> staffs=new ArrayList<>(); + if(sysWorkTimeService.isInWorkTime(user.getShopId(),sysBeauticianState.getBeginTime(),sysBeauticianState.getEndTime())){ + staffs= sysUsersService.findByCodeBeaStateShop(user.getShopId(), + sysBeauticianState, panBanCodes); + } + return new AjaxResult(AjaxResult.STATUS_SUCCESS, staffs, 0); + } + + /** + * 获取配料师 + */ + @ApiOperation(value = "获取配料师", notes = "获取配料师") + @GetMapping(value = "/getShopStaffByRoleName") + public AjaxResult getStaffByRoleName() { + return new AjaxResult(AjaxResult.STATUS_SUCCESS, sysUsersService.findByRoleName(true, "配料师")); + } + + /** + * 获取工作时间 + */ + @ApiOperation(value = "获取工作时间", notes = "获取工作时间") + @GetMapping(value = "/getWorkTime") + public AjaxResult getWorkTime() { + Long shopId = getMe().getShopId(); + Date minTime = worktimeService.findMinTime(shopId); + Date maxTime = worktimeService.findMaxTime(shopId); + if (minTime == null || maxTime == null) { + return AjaxResult.buildFailInstance("门店没有班次信息,请先设置门店班次"); + } else { + return AjaxResult.buildSuccessInstance(java.util.Arrays.asList( + DateUtil.dateToString(minTime, "HH:mm"), + DateUtil.dateToString(maxTime, "HH:mm"))); + } + } + + /** + * 新增项目 + */ + @ApiOperation(value = "新增项目", notes = "新增项目") + @PostMapping(value = "/addService") + public AjaxResult servicceAdd(@RequestBody SysProjServices sysProjServices) { + if (CollectionUtils.isEmpty(sysProjServices.getServiceItems())) { + return new AjaxResult(AjaxResult.STATUS_FAIL, "没有选中可消耗的项目"); + } + //检测欠款 + VerifyResult arrearsVerifyResult = sysProjServicesService.checkArrears(sysProjServices); + if (arrearsVerifyResult.isError()) { + return new AjaxResult(AjaxResult.STATUS_FAIL, arrearsVerifyResult.getMsg()); + } + //检测余次 + VerifyResult balanceverifyResult = sysProjServicesService.checkBalance(sysProjServices); + if (balanceverifyResult.isError()) { + return new AjaxResult(AjaxResult.STATUS_FAIL, balanceverifyResult.getMsg()); + } + if (StrUtil.isEmpty(sysProjServices.getState())) { + sysProjServices.setState(Dictionary.SERVICE_STATU_DYY); + } + SysProjServices newSysProjServices = sysProjServicesService.addSysProjServices(sysProjServices); + if (newSysProjServices != null) { + AjaxResult result = AjaxResult.buildSuccessInstance("下单成功!"); + result.putInMap("newSysProjServices", newSysProjServices); + return result; + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "下单失败!"); + } + } + + /** + * 删除服务单项目/套餐 + * @param id + * @return + */ + @ApiOperation(value = "删除服务单项目/套餐", notes = "删除服务单项目/套餐") + @GetMapping(value = "/delServiceOrderItems/{id}") + public AjaxResult delServiceOrderItems(@PathVariable("id")Long id) { + sysProjServicesService.deleteProjServiceItemById(id); + return AjaxResult.buildSuccessInstance("删除成功"); + } + + + /** + * 排班 + */ + @ApiOperation(value = "排班", notes = "排班") + @PostMapping(value = "/servicePaiBan") + public AjaxResult servicePaiBan(@RequestBody SysProjServices projServices, String dataTime) throws GlobleException { + int i = sysProjServicesService.paiban(projServices, dataTime); + if (i > 0) { + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "排班成功"); + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "排班失败"); + } + } + /** * 根据id取消预约 */ @@ -178,5 +370,165 @@ } } + /** + * 开始配料 + */ + @ApiOperation(value = "开始配料", notes = "开始配料") + @GetMapping(value = "/startpl/{id}") + public AjaxResult startpl(@PathVariable("id")Long id) { + // 将服务状态为待配料的更新为配料中 + SysProjServices sysProjServices = projServicesSerivce.findById(id); + List<SysBeauticianState> beauticianStateList = sysBeauticianStateDao.selectBySerIds(sysProjServices.getId()); + List<ShoppingGoods> projInfoList = new ArrayList<>(); + for (SysBeauticianState beauticianState : beauticianStateList) { + ShoppingGoods sysProjInfo = shoppingGoodsDao.selectById(beauticianState.getProjId()); + sysProjInfo.setAssembleGoods(goodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysProjInfo.getId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP)); + projInfoList.add(sysProjInfo); + } + AjaxResult result = AjaxResult.buildSuccessInstance(""); + result.putInMap("serviceId", id); + result.putInMap("projInfoList", projInfoList); + return result; + } + + /** + * 按产品批次显示选择配料 + */ + @ApiOperation(value = "按产品批次显示选择配料", notes = "按产品批次显示选择配料") + @PostMapping(value = "/showCountList") + public AjaxResult showCountList(@RequestBody SysStoreInfo sysStoreInfo, PaginationVO pageVo) { + SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + sysStoreInfo.setShopId(users.getShopId()); + sysStoreInfo.setCompanyId(users.getCompanyId()); + + List<SysStoreInfo> dataList = sysStoreInfoDao.selectCountInPage(sysStoreInfo, pageVo); + AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, sysStoreInfoDao.selectCountTotalRecord(sysStoreInfo)); + return result; + } + + /** + * 配料完成 + */ + @ApiOperation(value = "配料完成", notes = "配料完成") + @PostMapping(value = "/endPl") + @RemoveRequestToken + public AjaxResult endPl(@RequestBody SysProjServices projServices) { + projServicesSerivce.modifyPLProjServices(projServices); + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "配料成功!"); + } + + /** + * 进入划扣页面 + */ + @ApiOperation(value = "进入划扣页面", notes = "进入划扣页面") + @GetMapping(value = "/serviceHkPage/{id}") + public AjaxResult serviceHkPage(@PathVariable("id")Long id) { + // 获取服务单信息 + SysProjServices projServices = sysProjServicesService.findById(id); + + projServices.setVipInfo(sysVipInfoService.findById(projServices.getVipId())); + + //补充服务单扩展信息=============== + List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(id); + projServices.setServiceItems(beauticianStateList); + + SysBedState sysBedState = sysBedStateDao.selectBySerIdAndBedId(projServices.getId(), projServices.getBedId()); + projServices.setBedState(sysBedState); + //补充服务单扩展信息===============END + + // 获取服务单所有信息 + WebUtil.getRequest().setAttribute("obj", projServices); + WebUtil.getRequest().setAttribute("serviceId", id); + + // 准备页面数据 + // 根据岗位名称查询员工 + List<SysUsers> pls = usersService.findByRoleName(true, Dictionary.STAFF_POST_PLS); + pls.addAll(usersService.findByRoleName(true, Dictionary.STAFF_POST_PLZG)); + List<SysUsers> mls = usersService.findByRoleName(true, Dictionary.STAFF_POST_MLS); + WebUtil.getRequest().setAttribute("pls", pls); + WebUtil.getRequest().setAttribute("mls", mls); + SysBedInfo bedInfo = new SysBedInfo(); + bedInfo.setShopId(getMe().getShopId()); + WebUtil.getRequest().setAttribute("cw", bedInfoService.findByModel(bedInfo)); + + + AjaxResult result = AjaxResult.buildSuccessInstance(""); + result.putInMap("obj", projServices); + result.putInMap("serviceId", id); + result.putInMap("cw", bedInfoService.findByModel(bedInfo)); + result.putInMap("pls", pls); + result.putInMap("mls", mls); + return result; + } + + /** + * 设置服务单划扣成功 + */ + @ApiOperation(value = "设置服务单划扣成功", notes = "设置服务单划扣成功") + @GetMapping(value = "/hkService/{id}") + public AjaxResult hkService(@PathVariable("id")Long id) { + SysProjServices services = new SysProjServices(); + services.setId(id); + int i = sysProjServicesService.modifyHKProjServices(services); + if (i > 0) { + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "划扣成功"); + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "划扣失败"); + } + } + + /** + * 编辑排班详情 + */ + @ApiOperation(value = "编辑排班详情", notes = "编辑排班详情") + @GetMapping(value = "/yypb/{id}") + public AjaxResult findProject(@PathVariable("id")Long id) { + // 获取服务单信息 + SysProjServices projServices = sysProjServicesService.findById(id); + // 获取操作的用户 + projServices.setVipInfo(sysVipInfoService.findById(projServices.getVipId())); + + // 设置排班的默认日期 + String dateTime = null; + if (dateTime == null || dateTime.equals("")) { + + SysBedState sysBedState = sysBedStateDao.selectBySerIdAndBedId(projServices.getBedId(), projServices.getId()); + + if (sysBedState != null && sysBedState.getStartTime() != null) { + dateTime = DateUtil.dateToString(sysBedState.getStartTime(), DateUtil.DATE_FORMAT_DD); + } else { + dateTime = DateUtil.dateToString(projServices.getYyTime(), DateUtil.DATE_FORMAT_DD); + } + } + WebUtil.getRequest().setAttribute("dateTime", dateTime); + // 获取服务单所有信息 + WebUtil.getRequest().setAttribute("obj", projServices); + + // 获取服务单对一下的项目信息 + // 准备页面数据 + // 根据岗位名称查询员工 + List<SysUsers> pls = usersService.findByRoleName(true, Dictionary.STAFF_POST_PLS); + pls.addAll(usersService.findByRoleName(true, Dictionary.STAFF_POST_PLZG)); + List<SysUsers> mls = usersService.findByRoleName(true, Dictionary.STAFF_POST_MLS); + WebUtil.getRequest().setAttribute("pls", pls); + WebUtil.getRequest().setAttribute("mls", mls); + + SysBedInfo bedInfo = new SysBedInfo(); + bedInfo.setShopId(getMe().getShopId()); + // 床位 + WebUtil.getRequest().setAttribute("cw", bedInfoService.findByModel(bedInfo)); + + + AjaxResult result = AjaxResult.buildSuccessInstance(""); + result.putInMap("dateTime", dateTime); + result.putInMap("obj", projServices); + result.putInMap("cw", bedInfoService.findByModel(bedInfo)); + result.putInMap("pls", pls); + result.putInMap("mls", mls); + return result; + // 显示当前查询的服务订单的项目信息 +// return "admin/hive/beautySalon/yypb-form"; + } + } -- Gitblit v1.9.1