Commit d4682615 by liushuangwu

Merge remote-tracking branch 'origin/master'

2 parents 9c5afbc1 d6a79552
package com.pipihelper.project.controller;
import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultGenerator;
import com.pipihelper.project.rostering.model.DateRuleModel;
import com.pipihelper.project.rostering.model.RosteringModel;
import com.pipihelper.project.rostering.model.ShiftRuleModel;
import com.pipihelper.project.rostering.model.StaffRuleModel;
import com.pipihelper.project.rostering.service.RosteringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description:
* @author: zsw
* @create: 2022-10-15 20:01
**/
@RestController
@RequestMapping("/api/v1/rostering")
public class RosteringController {
@Autowired
private RosteringService rosteringService;
@PostMapping(value = "gen")
public Result genRostering(@RequestParam("month") int month,
@RequestParam("shiftRuleModel") String shiftRuleModelStr,
@RequestParam("staffRuleModel") String staffRuleModelStr,
@RequestParam("dateRuleModel") String dateRuleModelStr) {
List<ShiftRuleModel> shiftRuleModels = JSONObject.parseArray(shiftRuleModelStr, ShiftRuleModel.class);
List<StaffRuleModel> staffRuleModels = JSONObject.parseArray(staffRuleModelStr, StaffRuleModel.class);
List<DateRuleModel> dateRuleModels = JSONObject.parseArray(dateRuleModelStr, DateRuleModel.class);
return ResultGenerator.genSuccessResult(rosteringService.gen(month, shiftRuleModels, staffRuleModels, dateRuleModels));
}
}
package com.pipihelper.project.feishu.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
import com.pipihelper.project.feishu.service.massage.MassageService;
import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter;
import com.pipihelper.project.utils.CacheUtil;
import jdk.nashorn.internal.ir.CatchNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -108,7 +106,7 @@ public class FeiShuEventController {
// 都需要返回 不能点击的卡片json
if ("revice".equals(actionTypeSecond)) {
// 接受按摩
String fileName = String.format("/templates/massage-singel-msg-card-end.json.json");
String fileName = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName, "感谢支持");
} else if ("giveUp".equals(actionTypeSecond)) {
......@@ -116,11 +114,11 @@ public class FeiShuEventController {
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId());
String fileName = String.format("/templates/massage-msg-card-rob.json.json");
String fileName = String.format("/templates/massage-msg-card-rob.json");
String msgCardContent = String.format(massageMsgCardSerivce.getInteractiveCardStr(fileName), feiShuMsgCardEventDTO.getOpen_id());
feiShuMsgDTO.setContent(msgCardContent);
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json");
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "遗憾放弃");
} else if ("wait".equals(actionTypeSecond)) {
......@@ -131,7 +129,7 @@ public class FeiShuEventController {
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat();
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json");
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "已为你推迟到最后");
} else if ("rob".equals(actionTypeSecond)) {
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
......@@ -144,14 +142,14 @@ public class FeiShuEventController {
Pain oldPain = painService.findByOpenId(endUserId);
oldPain.setStatus(2);
painService.update(oldPain);
List<Pain> painList = painService.findBackIndex(oldPain.getIndex(), 1);
List<Pain> painList = painService.findBackIndex(oldPain.getPindex(), 1);
if (CollectionUtil.isNotEmpty(painList)) {
Pain noticePain = CollectionUtil.getFirst(painList);
noticePain.setStatus(1);
painService.update(noticePain);
massageService.updateSingleMassageMsgCardWhenBegin(noticePain.getMessageId());
}
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json");
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "欢迎下次光临~");
}
default:
......@@ -170,7 +168,7 @@ public class FeiShuEventController {
feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()});
feiShuApiService.joinChatList(feiShuChatDTO);
//ToDo 更新大群和按摩群的大卡片,异步
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json.json.json");
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json");
return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~");
}
......@@ -237,7 +235,7 @@ public class FeiShuEventController {
pain.setStatus(0);
pain.setFloor(Optional.ofNullable(it.getFloor()).orElse(14));
int increment = i.getAndIncrement();
pain.setIndex(increment);
pain.setPindex(increment);
pain.setName(it.getName());
String departMentName = departmentMap.getOrDefault(it.getDepartmentId(), new FeiShuDepartmentDTO()).getName();
pain.setDepartMentName(departMentName);
......
......@@ -8,7 +8,7 @@ import java.util.Date;
public class Pain {
private Integer id;
private String openId;
private Integer index;
private Integer pindex;
private String name;
private Integer status;
private Date startTime;
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.feishu.bo.PushPainBO;
import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.entity.ChatMessage;
import com.pipihelper.project.feishu.entity.Pain;
import com.pipihelper.project.feishu.service.ChatMessageService;
import com.pipihelper.project.feishu.service.FeiShuApiService;
......@@ -76,7 +77,14 @@ public class MassageService {
feiShuMsgDTO.setContent(content);
feiShuMsgDTO.setReceiveId(chatId);
log.info(feiShuMsgDTO.toString());
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
JSONObject rep = feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
String messageId = rep.getJSONObject("data").getString("message_id");
ChatMessage chatMessage = new ChatMessage();
chatMessage.setChatId(chatId);
chatMessage.setMessageId(messageId);
chatMessage.setType(1);
chatMessageService.create(chatMessage);
}
......@@ -96,10 +104,10 @@ public class MassageService {
for(Pain pain:pains){
List<String> user = new ArrayList<>();
//构建给大群发送的名单
user.add(pain.getIndex().toString());
user.add(pain.getPindex().toString());
user.add(pain.getName());
user.add(pain.getDepartMentName());
user.add(pain.getTimeRange());
user.add("15:00-18:00");
user.add("");
pushUser.add(user);
}
......
package com.pipihelper.project.interceptor;
import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
* 白名单拦截器,用于控制允许访问的请求
*
* @author zlikun
* @date 2021/10/21 14:39
*/
@Slf4j
@Component
@Aspect
public class ResponseAop {
//这里改成自己项目的控制层路径
@Pointcut("execution(public * com.pipihelper.project.controller..*(..))")
public void httpResponse() {
}
//环切
@Around("httpResponse()")
public Result handlerController(ProceedingJoinPoint proceedingJoinPoint) {
Result result = new Result();
try {
//获取方法的执行结果
Object proceed = proceedingJoinPoint.proceed();
//如果方法的执行结果是Result,则将该对象直接返回
if (proceed instanceof Result) {
result = (Result) proceed;
} else {
//否则,就要封装到Result的data中
result.setData(proceed);
}
} catch (Throwable throwable) {
//如果出现了异常,调用异常处理方法将错误信息封装到Result中并返回
result = handlerException(throwable);
}
return result;
}
//异常处理
private Result handlerException(Throwable throwable) {
Result result = new Result();
//这里需要注意,返回枚举类中的枚举在写的时候应该和异常的名称相对应,以便动态的获取异常代码和异常信息,我这边是统一返回500,msg存报的异常
//获取异常名称的方法
String errorName = throwable.toString();
errorName = errorName.substring(errorName.lastIndexOf(".") + 1);
result.setMessage(errorName);
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
return result;
}
}
......@@ -19,8 +19,14 @@ public class DateRuleModel {
*/
private Date date;
/**
* 班次名称
*/
private String shift;
/**
* 次数
*/
private Integer times;
}
......@@ -3,6 +3,7 @@ package com.pipihelper.project.rostering.model;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description:
......@@ -20,7 +21,7 @@ public class RosteringModel {
/**
* 班次
*/
private String shift;
private List<String> shift;
/**
* 时间
......
package com.pipihelper.project.rostering.model;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
......@@ -27,16 +24,6 @@ public class ShiftRuleModel {
private Integer everyDay;
/**
* 班次前允许
*/
private List<String> frontAllow;
/**
* 班次前不允许
*/
private List<String> frontDenied;
/**
* 班次后允许
*/
private List<String> backAllow;
......@@ -55,23 +42,13 @@ public class ShiftRuleModel {
/**
* 班次最大次数后指定班次
*/
private String maxContinuityFollow;
private List<String> maxContinuityFollow;
//{"backAllow":["早班"],"backDenied":["晚班"],"everyDay":5,"frontAllow":["早班"],"frontDenied":["晚班"],"maxContinuity":5,"maxContinuityFollow":"休息","name":"早班"}
public static void main(String[] args) {
ShiftRuleModel shiftRuleModel = new ShiftRuleModel();
shiftRuleModel.setName("早班");
shiftRuleModel.setEveryDay(5);
shiftRuleModel.setFrontAllow(Lists.newArrayList("早班"));
shiftRuleModel.setFrontDenied(Lists.newArrayList("晚班"));
shiftRuleModel.setBackAllow(Lists.newArrayList("早班"));
shiftRuleModel.setBackDenied(Lists.newArrayList("晚班"));
/**
* 是否休息
*/
private boolean isRest;
shiftRuleModel.setMaxContinuity(5);
shiftRuleModel.setMaxContinuityFollow("休息");
String s = JSONObject.toJSONString(shiftRuleModel);
System.out.println(s);
}
//{"backAllow":["早班"],"backDenied":["晚班"],"everyDay":5,"frontAllow":["早班"],"frontDenied":["晚班"],"maxContinuity":5,"maxContinuityFollow":"休息","name":"早班"}
}
......@@ -3,8 +3,10 @@ package com.pipihelper.project.rostering.model;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
/**
......@@ -54,31 +56,5 @@ public class StaffRuleModel {
private Date date;
}
//{"fixedShift":{"date":"2022-10-14 00:00:00","shift":"AAAA"},"maxTimes":{"shift":"AAA","times":5},"minTimes":{"shift":"AAA","times":5},"name":"xxxx"}
public static void main(String[] args) {
StaffRuleModel staffRuleModel = new StaffRuleModel();
staffRuleModel.setName("xxxx");
Threshold maxTimes = new Threshold();
maxTimes.setShift("AAA");
maxTimes.setTimes(5);
Threshold minTimes = new Threshold();
minTimes.setShift("AAA");
minTimes.setTimes(5);
Threshold fixedShift = new Threshold();
fixedShift.setDate(DateUtil.parse("2022-10-14 00:00:00"));
fixedShift.setShift("AAAA");
staffRuleModel.setMaxTimes(maxTimes);
staffRuleModel.setMinTimes(minTimes);
staffRuleModel.setFixedShift(fixedShift);
String s = JSONObject.toJSONString(staffRuleModel, SerializerFeature.WriteDateUseDateFormat);
System.out.println(s);
}
}
......@@ -16,15 +16,14 @@ public interface RosteringService {
/**
* 生成班次
* @param staffs 人员
* @param shifts 班次
*
* @param month
* @param shiftRuleModels 班次规则
* @param staffRuleModels 原因规则
* @param dateRuleModels 时间规则
* @return
*/
List<RosteringModel> gen(List<String> staffs,
List<String> shifts,
List<RosteringModel> gen(int month,
List<ShiftRuleModel> shiftRuleModels,
List<StaffRuleModel> staffRuleModels,
List<DateRuleModel> dateRuleModels);
......
package com.pipihelper.project.rostering.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.google.common.collect.Lists;
import com.pipihelper.project.rostering.model.DateRuleModel;
import com.pipihelper.project.rostering.model.RosteringModel;
import com.pipihelper.project.rostering.model.ShiftRuleModel;
import com.pipihelper.project.rostering.model.StaffRuleModel;
import com.pipihelper.project.rostering.service.RosteringService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @description:
......@@ -18,38 +33,178 @@ import java.util.List;
public class RosteringServiceImpl implements RosteringService {
@Override
public List<RosteringModel> gen(List<String> staffs,
List<String> shifts,
public List<RosteringModel> gen(int month,
List<ShiftRuleModel> shiftRuleModels,
List<StaffRuleModel> staffRuleModels,
List<DateRuleModel> dateRuleModels) {
//校验
verify(staffs, shifts, shiftRuleModels, staffRuleModels);
int daysOfMonth = getDaysOfNextMonth(month);
Map<String, StaffRuleModel> staffRuleModelMap = staffRuleModels.stream().collect(Collectors.toMap(StaffRuleModel::getName, Function.identity()));
//记录用户当次排版已经排了多少次
Map<String, List<ShiftRuleModel>> staffMap = new HashMap<>();
for (int i = 0; i < daysOfMonth; i++) {
int currentDay = i + 1;
return null;
staffRuleModels.forEach(e -> {
List<ShiftRuleModel> currentShifts = Optional.ofNullable(staffMap.get(e.getName())).orElse(Lists.newArrayList());
//指定日期班次
StaffRuleModel.Threshold fixedShift = e.getFixedShift();
boolean isFixed = Optional.ofNullable(fixedShift).map(StaffRuleModel.Threshold::getDate).filter(fixedDate -> DateUtil.dayOfMonth(fixedDate) == currentDay).isPresent();
ShiftRuleModel shiftRuleModel = null;
if (isFixed) {
shiftRuleModel = shiftRuleModels.stream().filter(shift -> ObjectUtil.equal(shift.getName(), fixedShift.getShift())).findFirst().orElse(null);
}
if (shiftRuleModel == null) {
shiftRuleModel = getByShiftRule(shiftRuleModels, currentShifts, e);
}
private void verify(List<String> staffs,
List<String> shifts,
List<ShiftRuleModel> shiftRuleModels,
List<StaffRuleModel> staffRuleModels) {
//判断是否已经达到了最大次数
StaffRuleModel.Threshold maxTimes = e.getMaxTimes();
if (maxTimes != null && maxTimes.getTimes() != null && StringUtils.isNotBlank(maxTimes.getShift())) {
String shift = maxTimes.getShift();
int count = (int) currentShifts.stream().filter(result -> ObjectUtil.equal(result.getName(), shift)).count();
count = ObjectUtil.equal(shiftRuleModel.getName(), shift) ? count + 1 : count;
if (count > maxTimes.getTimes()) {
shiftRuleModel = getRandom(shiftRuleModels.stream().filter(ignore -> ObjectUtil.notEqual(ignore.getName(), shift)).collect(Collectors.toList()));
}
}
//添加到map中
currentShifts.add(shiftRuleModel);
staffMap.putIfAbsent(e.getName(), currentShifts);
});
}
if (shiftRuleModels.stream().noneMatch(e -> shifts.contains(e.getName()))) {
throw new RuntimeException("班次配置不合法");
List<RosteringModel> result = new ArrayList<>();
staffRuleModels.forEach(e -> {
List<String> shifts = Optional.ofNullable(staffMap.get(e.getName())).orElse(Lists.newArrayList())
.stream().map(ShiftRuleModel::getName).collect(Collectors.toList());
StaffRuleModel.Threshold minTimes = e.getMinTimes();
if (minTimes != null && minTimes.getTimes() != null && StringUtils.isNotBlank(minTimes.getShift())) {
int count = (int) shifts.stream().filter(shift -> ObjectUtil.equal(shift, minTimes.getShift())).count();
int diff = minTimes.getTimes() - count;
if (diff > 0) {
int index = 0;
for (int i = 0; i < diff; i++) {
index = getRandomInt(shifts.size() - 1, index);
shifts.set(index, minTimes.getShift());
}
}
}
if (staffRuleModels.stream().noneMatch(e -> staffs.contains(e.getName()))) {
throw new RuntimeException("员工配置不合法");
RosteringModel rosteringModel = new RosteringModel();
rosteringModel.setName(e.getName());
rosteringModel.setShift(shifts);
result.add(rosteringModel);
});
return result;
}
/**
* 获取某个月的天数
*
* @return
*/
private int getDaysOfNextMonth(int month) {
Calendar calendar = Calendar.getInstance();
//获得当前日期往后推1个月 amount 为设置的月份值 +为往后推 +号可以省略 -为往前推
calendar.add(Calendar.MONTH, +1);
//获得下一个月是多少年
int year = calendar.get(Calendar.YEAR);
calendar.set(year, month, 0);
//获得下一个月有多少天
return calendar.get(Calendar.DAY_OF_MONTH);
}
/**
* 根据班次规则获取
*
* @param shiftRuleModels
* @param currentShifts
* @return
*/
private ShiftRuleModel getByShiftRule(List<ShiftRuleModel> shiftRuleModels, List<ShiftRuleModel> currentShifts, StaffRuleModel staffRuleModel) {
//随机获取,当前排班为null 则代表是第一次排班
if (CollectionUtil.isEmpty(currentShifts)) {
return getRandom(shiftRuleModels.stream().filter(e -> BooleanUtil.isFalse(e.isRest())).collect(Collectors.toList()));
}
//获取最后一次分配的班次
int size = currentShifts.size();
ShiftRuleModel lastShift = currentShifts.get(size - 1);
//获取最后一次分配的班次的连续次数
int currentShiftTimes = 0;
for (int i = size - 1; i >= 0; i--) {
ShiftRuleModel currentShift = currentShifts.get(i);
if (ObjectUtil.equal(lastShift.getName(), currentShift.getName())) {
currentShiftTimes++;
} else {
break;
}
}
//根据次数获取
ShiftRuleModel result = getByTimes(shiftRuleModels, lastShift, currentShiftTimes);
if (result == null) {
//证明没有设置连续班,首先判断允许班次是否为空,不为空则从允许班次中随机获取一个班次
List<String> backAllow = lastShift.getBackAllow();
if (CollectionUtil.isNotEmpty(backAllow)) {
result = getRandom(shiftRuleModels.stream().filter(e -> backAllow.contains(e.getName())).collect(Collectors.toList()));
}
//证明没有设置连续班,首先判断不允许允许班次是否为空,不为空则排除不允许班次随机获取班次
List<String> backDenied = lastShift.getBackDenied();
if (CollectionUtil.isNotEmpty(backDenied)) {
result = getRandom(shiftRuleModels.stream().filter(e -> !backDenied.contains(e.getName())).collect(Collectors.toList()));
}
}
if (result == null) {
result = getRandom(shiftRuleModels);
}
//是否有休息并且
if (BooleanUtil.isFalse(result.isRest()) && BooleanUtil.isFalse(lastShift.isRest())) {
result = shiftRuleModels.stream()
.filter(e -> ObjectUtil.equal(e.getName(), lastShift.getName()))
.findFirst().orElse(null);
}
return result;
}
private ShiftRuleModel getByTimes(List<ShiftRuleModel> shiftRuleModels, ShiftRuleModel lastShift, Integer currentShiftTimes) {
//当前班次的次数小于最大连续次数,则返回同样班次
Integer maxContinuity = lastShift.getMaxContinuity();
if (maxContinuity == null) {
return null;
}
if (currentShiftTimes < maxContinuity) {
return lastShift;
}
List<String> maxContinuityFollows = lastShift.getMaxContinuityFollow();
return shiftRuleModels.stream().filter(e -> maxContinuityFollows.contains(e.getName())).findFirst().orElse(null);
}
private ShiftRuleModel getRandom(List<ShiftRuleModel> shiftRuleModels) {
return shiftRuleModels.get(RandomUtil.randomInt(0, shiftRuleModels.size()));
}
private int getRandomInt(int size, int index) {
int i = RandomUtil.randomInt(0, size);
if (i == index) {
return getRandomInt(size, index);
}
return i;
}
}
......@@ -12,7 +12,7 @@
<result column="message_id" property="messageId"/>
<result column="name" property="name"/>
<result column="depart_ment_name" property="departMentName"/>
<result column="index" property="index"/>
<result column="pindex" property="pindex"/>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
......@@ -20,7 +20,8 @@
</resultMap>-->
<sql id="Base_Column_List">
id,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name
id
,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name,`pindex`
</sql>
<select id="findById" parameterType="java.lang.Integer" resultMap="PainResultMap">
......@@ -37,9 +38,9 @@
<include refid="Base_Column_List"/>
from t_pain
<where>
index >= #{index}
pindex >= #{pindex}
and status = 0
order by index asc
order by pindex asc
limit #{limit}
</where>
</select>
......@@ -50,7 +51,7 @@
from t_pain
<where>
status = 0
order by index asc
order by pindex asc
limit #{limit}
</where>
</select>
......@@ -65,7 +66,9 @@
</select>
<delete id="deleteAllByFloor">
delete from t_pain where floor = #{floor}
delete
from t_pain
where floor = #{floor}
</delete>
<select id="findByIndex" parameterType="java.lang.String" resultMap="PainResultMap">
......@@ -73,7 +76,7 @@
<include refid="Base_Column_List"/>
from t_pain
<where>
index = #{index}
pindex = #{pindex}
</where>
</select>
......@@ -92,12 +95,12 @@
<insert id="create" useGeneratedKeys="true" keyProperty="id"
parameterType="com.pipihelper.project.feishu.entity.Pain">
insert into t_pain (open_id, start_time, end_time, status, floor,message_id,name,depart_ment_name)
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId},#{name},#{departMentName})
insert into t_pain (open_id, start_time, end_time, status, floor, message_id, name, depart_ment_name, pindex)
values (#{openId}, #{startTime}, #{endTime}, #{status}, #{floor}, #{messageId}, #{name}, #{departMentName},#{pindex})
</insert>
<update id="waitPain" parameterType="com.pipihelper.project.feishu.entity.Pain">
UPDATE t_pain set `index` = ((SELECT selected_value FROM (SELECT MAX(`index`) AS selected_value FROM t_pain) AS
UPDATE t_pain set pindex = ((SELECT selected_value FROM (SELECT MAX(pindex) AS selected_value FROM t_pain) AS
sub_selected_value) + 1)
<where>
open_id = #{openId}
......@@ -133,6 +136,9 @@
<if test="departMentName != null">
depart_ment_name = #{departMentName},
</if>
<if test="pindex != null">
pindex = #{pindex},
</if>
</set>
<where>
id = #{id}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!