Commit bed6be97 by huluobin

排班合并 预约更新合并

parent 05ceebb5
......@@ -45,9 +45,6 @@ import com.gogirl.shared.order.serve.command.schedule.*;
import com.gogirl.shared.order.serve.query.dto.IdleTimeDTO;
import com.gogirl.shared.order.serve.query.qry.*;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManagePageQuery;
import com.gogirl.shared.product.query.dto.BaseProduceDTO;
import com.gogirl.shared.product.query.dto.PurchaseSkuDTO;
import com.gogirl.shared.store.query.dto.StoreTechnicianDTO;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -1076,7 +1073,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//服务款式设置
if (scheduleServeCmd.getProduceId() != null) {
BaseProduce baseProduce=baseProduceMapper.selectById(scheduleServeCmd.getProduceId());
BaseProduce baseProduce = baseProduceMapper.selectById(scheduleServeCmd.getProduceId());
scheduleServeCmd.setProduceName(baseProduce.getName());
scheduleServeCmd.setProducePicturePath(baseProduce.getPicturePath());
......@@ -1489,7 +1486,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
if (leisureDiscountConfig == null) {
return 2;
return 3;
}
//
else {
......
package com.gogirl.application.store.store;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gogirl.domain.store.store.StoreClassesTechnician;
import java.util.List;
public interface StoreClassesTechnicianService {
public interface StoreClassesTechnicianService extends IService<StoreClassesTechnician> {
/**
* 查询美甲师排班表
......
package com.gogirl.application.store.store.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.store.store.StoreClassesTechnicianService;
import com.gogirl.domain.store.store.StoreClassesTechnician;
import com.gogirl.infrastructure.mapper.store.StoreClassesTechnicianMapper;
......@@ -15,7 +16,7 @@ import java.util.List;
*/
@Service
@AllArgsConstructor
public class StoreClassesTechnicianServiceImpl implements StoreClassesTechnicianService {
public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesTechnicianMapper, StoreClassesTechnician> implements StoreClassesTechnicianService {
private final StoreClassesTechnicianMapper storeClassesTechnicianMapper;
......
package com.gogirl.domain.store.store;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gogirl.domain.order.serve.ScheduleServe;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.util.Date;
......@@ -16,10 +19,11 @@ import java.util.List;
*/
@ApiModel("每天排班记录")
@TableName("store_classes_technician")
@Builder
@Data
public class StoreClassesTechnician {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("美甲师id 这里是technician_id")
......
package com.gogirl.infrastructure.mapper.store;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.store.store.StoreClassesTechnician;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
......@@ -12,7 +13,7 @@ import java.util.List;
*/
@Repository
public interface StoreClassesTechnicianMapper {
public interface StoreClassesTechnicianMapper extends BaseMapper<StoreClassesTechnician> {
List<StoreClassesTechnician> listClassesTechnician(@Param("scheduleId") Integer scheduleId, @Param("departmentId") Integer departmentId, @Param("days") String days);
......@@ -29,4 +30,7 @@ public interface StoreClassesTechnicianMapper {
List<StoreClassesTechnician> listByDepartmentIdAndDays(@Param("departmentId") Integer departmentId, @Param("days") String days);
StoreClassesTechnician selectOneClassTech(@Param("departmentId") Integer departmentId, @Param("day") Date day, @Param("technicianId") Integer technicianId);
List<Integer> deleteDayClassesIds(@Param("departmentId") Integer departmentId, @Param("day") Date day);
}
......@@ -142,6 +142,7 @@ public class ScheduleManageController {
qry.setServeId(serveId);
qry.setVipLevel(customerBalanceService.getCustomerBalance(currentCustomerId).getLevel());
//todo 会员预约服务
// JsonResult<VipServeDTO> result = vipControllerFeign.query(qry);
// if (result.getData() == null) {
// throw new RRException(1002, "会员才能享受服务");
......@@ -217,8 +218,8 @@ public class ScheduleManageController {
@GetMapping("/technician/schedule/getScheduledServeLeisure")
public JsonResult<Integer> getScheduledServeLeisure(@RequestHeader String token,
@RequestParam Integer scheduleServeId) {
scheduleManageService.getScheduledServeLeisure(scheduleServeId);
return JsonResult.success();
Integer result = scheduleManageService.getScheduledServeLeisure(scheduleServeId);
return JsonResult.success(result);
}
}
......@@ -15,6 +15,7 @@ import com.gogirl.dto.ParmTechnicianClasses;
import com.gogirl.infrastructure.common.annotation.GogirlShop;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.store.StoreClassesTechnicianMapper;
import com.gogirl.infrastructure.mapper.xcx.SysLogMapper;
import io.swagger.annotations.Api;
......@@ -28,10 +29,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = {"11.美甲师排班"}, value = "美甲师排班")
@RestController
......@@ -51,7 +50,8 @@ public class ClassesTechnicianController {
@ApiOperation(value = "美甲师端查询当天店铺排班")
@GetMapping("/technician/classestechnician/queryDayTechnicianClasses")
@GogirlShop
public JsonResult<List<StoreTechnician>> queryDayTechnicianClasses(String token, String dayString) throws ParseException {
public JsonResult<List<StoreTechnician>> queryDayTechnicianClasses(String token,
String dayString) throws ParseException {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken_t(token);
Date day = new SimpleDateFormat("yyyy-MM-dd").parse(dayString);
......@@ -60,33 +60,45 @@ public class ClassesTechnicianController {
//查询店铺下的美甲师
List<StoreTechnician> list = storeTechnicianService.queryDayTechnicianClasses(departmentId, day);
List<StoreClasses> classList = storeClassesService.list(new LambdaQueryWrapper<StoreClasses>().eq(StoreClasses::getDepartmentId, departmentId));
//处理一个对应关系只返回012
Map<Integer, Integer> map = new HashMap<>();
map.put(0, 0);
for (StoreClasses item : classList) {
if (item.getName().equals("早班")) {
map.put(item.getId(), 1);
} else if (item.getName().equals("晚班")) {
map.put(item.getId(), 2);
list.forEach(storeTechnician -> {
StoreClassesTechnician storeClassesTechnician = storeClassesTechnicianMapper.selectOneClassTech(departmentId, day, storeTechnician.getTechnicianId());
if (storeClassesTechnician == null) {
storeClassesTechnician = StoreClassesTechnician.builder()
.userId(storeTechnician.getTechnicianId())
.days(day)
.status(2)
.classes(-1)
.build();
storeTechnician.setClassesTechnician(storeClassesTechnician);
}
//
else if (storeClassesTechnician.getClasses() == 0) {
storeTechnician.setClassesTechnician(storeClassesTechnician);
}
//
else {
StoreClasses storeClasses = storeClassesService.getById(storeClassesTechnician.getClasses());
if (storeClasses.getName().equals("早班")) {
storeClassesTechnician.setClasses(1);
}
//根据map对应关系转换class
for (StoreTechnician item : list) {
item.setId(item.getTechnicianId());
if (item.getClassesTechnician() != null) {
item.getClassesTechnician().setClasses(map.get(item.getClassesTechnician().getClasses()));
if (storeClasses.getName().equals("晚班")) {
storeClassesTechnician.setClasses(2);
}
storeTechnician.setClassesTechnician(storeClassesTechnician);
}
return new JsonResult<>(true, JsonResult.APP_DEFINE_SUC, list);
storeTechnician.setId(storeTechnician.getTechnicianId());
});
list.sort(Comparator.comparing(StoreTechnician::getId));
return JsonResult.success(list);
}
@ApiOperation(value = "美甲师端提交当天店铺排班")
@PostMapping("/technician/classestechnician/updateDayTechnicianClasses")
@GogirlShop
public JsonResult<Object> updateDayTechnicianClasses(@RequestBody ParmTechnicianClasses ParmTechnicianClasses) {
public JsonResult<Object> updateDayTechnicianClasses(@RequestBody ParmTechnicianClasses ParmTechnicianClasses) throws ParseException {
String token = ParmTechnicianClasses.getToken();
......@@ -94,84 +106,54 @@ public class ClassesTechnicianController {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken_t(token);
if (gogirlToken == null) {
return new JsonResult<>(false, "TOKEN_NULL_CODE");
}
if (gogirlToken.getStoreTechnician() == null) {
return new JsonResult<>(false, "找不到美甲师");
}
Date day;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
day = sdf.parse(dayString);
} catch (Exception e) {
return new JsonResult<>(false, "day格式为yyyy-MM-dd");
}
Date day = new SimpleDateFormat("yyyy-MM-dd").parse(dayString);
//店铺id
Integer departmentId = gogirlToken.getStoreTechnician().getDepartmentId();
//查询店铺下的早晚修排班
List<StoreClasses> classList = storeClassesService.list(new LambdaQueryWrapper<StoreClasses>().eq(StoreClasses::getDepartmentId, departmentId));
Map<Integer, Integer> map = new HashMap<>();//处理一个对应关系只返回012
map.put(0, 0);
for (StoreClasses item : classList) {
//早班
if (item.getName().equals("早班")) {
map.put(1, item.getId());
}
//晚班
else if (item.getName().equals("晚班")) {
map.put(2, item.getId());
}
}
List<StoreClassesTechnician> oldVal = storeClassesTechnicianMapper.listByDepartmentIdAndDays(departmentId, ParmTechnicianClasses.getDayString());
List<StoreTechnician> list = ParmTechnicianClasses.getList();
for (int i = 0; i < list.size(); i++) {
StoreTechnician item = list.get(i);
if (item.getId() == null) {
return new JsonResult<>(false, "第" + (i + 1) + "个美甲师id不能为空");
}
if (item.getClassesTechnician() == null) {
return new JsonResult<>(false, "第" + (i + 1) + "个美甲师排班classesTechnician不能为空");
}
//修改早晚班为对应的classid
if (item.getClassesTechnician().getClasses() != null) {
item.getClassesTechnician().setClasses(map.get(item.getClassesTechnician().getClasses()));
}
if (item.getClassesTechnician().getClasses() != null && item.getClassesTechnician().getId() != null) {
storeClassesTechnicianService.updateClassesTechnician(item.getClassesTechnician());
}
//
else if (item.getClassesTechnician().getClasses() != null) {
StoreClassesTechnician storeClassesTechnician = new StoreClassesTechnician();
storeClassesTechnician.setUserId(item.getId());
storeClassesTechnician.setDays(day);
List<StoreClassesTechnician> hasClass = storeClassesTechnicianService.listClassesTechnicianDetailByDays(item.getId(), dayString);
if (hasClass != null && hasClass.size() > 0) {
item.getClassesTechnician().setId(hasClass.get(0).getId());
storeClassesTechnicianService.updateClassesTechnician(item.getClassesTechnician());
}
//
else {
item.getClassesTechnician().setUserId(item.getId());
item.getClassesTechnician().setDays(day);
item.getClassesTechnician().setStatus(2);
storeClassesTechnicianService.insertClassesTechnician(item.getClassesTechnician());
}
}
List<Integer> ids = storeClassesTechnicianMapper.deleteDayClassesIds(departmentId, day);
if (ListUtil.isNotEmpty(ids)) {
storeClassesTechnicianMapper.deleteBatchIds(ids);
}
List<StoreClassesTechnician> storeClassesTechnicianList = ParmTechnicianClasses.getList()
.stream()
.filter(storeTechnician -> storeTechnician.getClassesTechnician().getClasses() != null)
.filter(storeTechnician -> storeTechnician.getClassesTechnician().getClasses() > -1)
.map(storeTechnician -> {
LambdaQueryWrapper<StoreClasses> wrapper = new LambdaQueryWrapper<>();
Integer classes = storeTechnician.getClassesTechnician().getClasses();
if (classes == 0) {
wrapper.eq(StoreClasses::getName, "休息");
} else if (classes == 1) {
wrapper.eq(StoreClasses::getName, "早班");
wrapper.eq(StoreClasses::getDepartmentId, departmentId);
} else if (classes == 2) {
wrapper.eq(StoreClasses::getName, "晚班");
wrapper.eq(StoreClasses::getDepartmentId, departmentId);
}
StoreClasses storeClasses = storeClassesService.getOne(wrapper);
StoreClassesTechnician storeClassesTechnician = StoreClassesTechnician.builder()
.classes(storeClasses.getId())
.status(2)
.days(day)
.userId(storeTechnician.getId())
.build();
if (storeClasses.getName().equals("休息")) {
storeClassesTechnician.setClasses(0);
}
return storeClassesTechnician;
})
.collect(Collectors.toList());
storeClassesTechnicianService.saveBatch(storeClassesTechnicianList);
List<StoreClassesTechnician> newVal = storeClassesTechnicianMapper.listByDepartmentIdAndDays(departmentId, ParmTechnicianClasses.getDayString());
SysLog sysLog = SysLog.builder()
.createDate(new Date())
.createUser(gogirlToken.getStoreTechnician().getTechnicianId())
.createUserName(gogirlToken.getStoreTechnician().getName())
.oldVal(JsonUtilByFsJson.beanToJson(oldVal))
.newVal(JsonUtilByFsJson.beanToJson(newVal))
.oldVal(JsonUtilByFsJson.beanToJson(ids))
.newVal(JsonUtilByFsJson.beanToJson(storeClassesTechnicianList))
.tableName("store_classes")
.field("")
.build();
......@@ -185,18 +167,13 @@ public class ClassesTechnicianController {
@ApiOperation(value = "美甲师端查询当月排班排班")
@GetMapping("/technician/classestechnician/queryMonthClasses")
public JsonResult<List<StoreClassesTechnician>> queryMonthClasses(String token, Integer technicianId, String month) {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken_t(token);
if (gogirlToken == null) {
return new JsonResult<>(false, "TOKEN_NULL_CODE");
}
if (gogirlToken.getStoreTechnician() == null) {
return new JsonResult<>(false, "找不到美甲师");
}
Integer departmentId = gogirlToken.getStoreTechnician().getDepartmentId();
List<StoreClasses> classList = storeClassesService.list(new LambdaQueryWrapper<StoreClasses>().eq(StoreClasses::getDepartmentId, departmentId));
Map<Integer, Integer> map = new HashMap<Integer, Integer>();//处理一个对应关系只返回012
map.put(0, 0);
for (int i = 0; i < classList.size(); i++) {
......@@ -216,4 +193,5 @@ public class ClassesTechnicianController {
return new JsonResult<>(true, JsonResult.APP_DEFINE_SUC, lists);
}
}
......@@ -139,6 +139,24 @@
and t2.department_id = #{departmentId}
</select>
<select id="selectOneClassTech" resultType="com.gogirl.domain.store.store.StoreClassesTechnician">
SELECT *
from store_classes_technician t1
LEFT JOIN store_classes t2 on t1.classes = t2.id
where (t1.days = #{day} and t2.department_id = #{departmentId} and t1.user_id = #{technicianId})
or (t1.classes = 0 and t1.user_id = #{technicianId} and t1.days = #{day})
order by classes desc
limit 1
</select>
<select id="deleteDayClassesIds" resultType="java.lang.Integer">
SELECT t1.id
FROM store_classes_technician t1
LEFT JOIN store_classes t2 ON t1.classes = t2.id
WHERE (t1.days = #{day} AND t2.department_id = #{departmentId})
OR (t1.classes = 0 AND t1.days = #{day})
</select>
<update id="updateClassesTechnician" parameterType="com.gogirl.domain.store.store.StoreClassesTechnician">
update store_classes_technician
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment