package org.jeecg.modules.mdc.service.impl;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.google.gson.JsonObject;
|
import org.apache.commons.lang.StringUtils;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.modules.mdc.entity.MdcShift;
|
import org.jeecg.modules.mdc.entity.MdcShiftSub;
|
import org.jeecg.modules.mdc.mapper.MdcShiftSubMapper;
|
import org.jeecg.modules.mdc.service.IMdcShiftSubService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Description: 班次表(次表)
|
* @Author: Sake
|
* @Date: 2023-04-03 16:54
|
*/
|
@Service
|
public class MdcShiftSubServiceImpl extends ServiceImpl<MdcShiftSubMapper, MdcShiftSub> implements IMdcShiftSubService {
|
|
@Override
|
public Boolean selectMdcShiftSub(String id) {
|
List<MdcShiftSub> mdcShiftList = this.list(new LambdaQueryWrapper<MdcShiftSub>()
|
.eq(MdcShiftSub::getShiftId, id));
|
//子表有数据则返回true
|
if (mdcShiftList == null || mdcShiftList.isEmpty()) {
|
return true;
|
}
|
return false;
|
}
|
|
@Override
|
public IPage<MdcShiftSub> queryPageList(String shiftId, Page page) {
|
LambdaQueryWrapper<MdcShiftSub> wrapper =new LambdaQueryWrapper<>();
|
wrapper.eq(MdcShiftSub::getShiftId,shiftId);
|
return baseMapper.selectPage(page,wrapper);
|
}
|
|
@Override
|
public MdcShiftSub addMdcShiftSub(JSONObject jsonbject) {
|
MdcShiftSub mdcShiftSub = jsonbject.toJavaObject(MdcShiftSub.class);
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
|
String startDate = simpleDateFormat.format(jsonbject.getDate("startDate"));
|
mdcShiftSub.setStartDate(startDate);
|
String endDate = simpleDateFormat.format(jsonbject.getDate("endDate"));
|
mdcShiftSub.setEndDate(endDate);
|
if (jsonbject.getDate("sleepStartDate") != null) {
|
String sleepStartDate = simpleDateFormat.format(jsonbject.getDate("sleepStartDate"));
|
mdcShiftSub.setSleepStartDate(sleepStartDate);
|
}
|
if (jsonbject.getDate("sleepEndDate") != null) {
|
String sleepEndDate = simpleDateFormat.format(jsonbject.getDate("sleepEndDate"));
|
mdcShiftSub.setSleepEndDate(sleepEndDate);
|
}
|
this.save(mdcShiftSub);
|
return mdcShiftSub;
|
}
|
|
@Override
|
public Boolean editMdcShiftSub(MdcShiftSub mdcShiftSub) {
|
return this.updateById(mdcShiftSub);
|
}
|
|
@Override
|
public Boolean updateSubStatusById(JSONObject jsonObject) {
|
String id = jsonObject.getString("id");
|
String status = jsonObject.getString("status");
|
MdcShiftSub mdcShiftSub = this.getById(id);
|
mdcShiftSub.setShiftSubStatus(status);
|
return this.updateById(mdcShiftSub);
|
}
|
|
@Override
|
public Result deleteMdcShiftSub(String id) {
|
//TODO 删除前判断设备日历表是否没有引用当前数据
|
Boolean flag = true;
|
if (flag){
|
boolean flags = this.removeById(id);
|
return flags ? Result.OK("删除成功") : Result.error("没有此数据");
|
}
|
return Result.error("当前日期已被设备日历引用无法删除");
|
}
|
|
|
}
|