Commit 03976617 by 284718418@qq.com

假期统调

parent 897656d1
......@@ -3,8 +3,10 @@ package cn.timer.api.bean.kqmk;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
......@@ -15,6 +17,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author LAL 2020-05-09
*/
......@@ -67,4 +71,9 @@ public class KqglAssoLeaveBalance extends Model<KqglAssoLeaveBalance> {
@ApiModelProperty(value = "是否为系统自动 0:否;1:是", example = "101")
private Integer isAutomatic;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "假期统调用户ID")
private List<Integer> userIds;
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
......@@ -984,6 +985,65 @@ public class TimeCardController {
}
/**
* 假期统调
*/
@PostMapping(value = "/leave_balance_all")
@ApiOperation(value = "假期统调", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> LeaveBalanceAll(@CurrentUser UserBean userBean,@RequestBody KqglAssoLeaveBalance balance) {
balance.setModifyUserid(userBean.getEmpNum());
balance.setModifyTimer(new Date().getTime());
balance.setOrgCode(userBean.getOrgCode());
String balanceDays = "0";
if(balance.getModifyAction() == 1) {//增加
balanceDays = "+" + balance.getBalanceDays();
}else {
balanceDays = "-" + balance.getBalanceDays();
}
balance.setBalanceDays(balanceDays);
if(!CollectionUtils.isEmpty(balance.getUserIds())){
for (Integer userId :balance.getUserIds()) {
KqglAssoLeaveBalance balan = kqglassoleavebalancemapper.selectOne(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getUserid, userId)
.orderByDesc(KqglAssoLeaveBalance :: getModifyNumber).last("LIMIT 1"));
if(balan != null) {
balance.setModifyNumber(balan.getModifyNumber()+1);
}else {
balance.setModifyNumber(1);
}
balance.setUserid(userId);
//添加成功
if(balance.insert()) {
//查询员工假期余额表中所对应的假期id
KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, balance.getLeaveRulesId())
.eq(KqglAssoLeaveEmployeeBalance::getUserid, userId).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, userBean.getOrgCode()));
//获取最后得到的最终余额
double balance_days = kqglassoleavebalancemapper.Sumbalancedays(userId, userBean.getOrgCode(),balance.getLeaveRulesId());
if(emba != null && balance_days > 0) {
if(emba.getBalanceDays() != -1) {//确认为限制余额的
//修改最终的余额数
KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(balance_days).build().updateById();
}
}else{
if(emba.getBalanceDays() != -1) {//确认为限制余额的
//修改最终的余额数
KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(0).build().updateById();
}
}
}
}
}
return ResultUtil.success("操作成功!") ;
}
/**
* 根据考勤余额id获取信息 ||大于“0”为有数字限制 ||为“-1”时为无数字限制
*/
@GetMapping(value="/hqleavebalance/{id}")
......
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