zenglf
2023-09-28 f84d9e69907cb678150eaa6393fd74cf042fcca4
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcShiftServiceImpl.java
@@ -12,7 +12,9 @@
import org.jeecg.modules.mdc.mapper.MdcShiftMapper;
import org.jeecg.modules.mdc.service.IMdcShiftService;
import org.jeecg.modules.mdc.service.IMdcShiftSubService;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -32,14 +34,11 @@
    @Resource
    private IMdcShiftSubService mdcShiftSubService;
    @Resource
    private MdcShiftMapper mdcShiftMapper;
    @Override
    public IPage<MdcShift> queryPageList(Page page, MdcShift mdcShift) {
        LambdaQueryWrapper<MdcShift> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //判断前端返回的值中shiftName是否不为空,不为空则将shiftName添加到模糊查询中
        if(StringUtils.isNotBlank(mdcShift.getShiftName())){
        if (StringUtils.isNotBlank(mdcShift.getShiftName())) {
            lambdaQueryWrapper.like(MdcShift::getShiftName, mdcShift.getShiftName());
        }
        return this.page(page, lambdaQueryWrapper);
@@ -48,12 +47,13 @@
    @Override
    public Boolean addShift(MdcShift mdcShift) {
        //状态默认为启用
        if (StringUtils.isEmpty(mdcShift.getShiftStatus())){
        if (StringUtils.isEmpty(mdcShift.getShiftStatus())) {
            mdcShift.setShiftStatus("1");
        }
        mdcShift.setDefaultShift("false");
        List<MdcShift> mdcShifts = listMdcName(mdcShift);
        //查询有重复数据返回false
        if (null != mdcShifts && !mdcShifts.isEmpty()){
        if (null != mdcShifts && !mdcShifts.isEmpty()) {
            return false;
        }
        return this.save(mdcShift);
@@ -82,8 +82,8 @@
    public Result<MdcShift> deleteShift(String id) {
        //返回true未查到数据
        Boolean flag = mdcShiftSubService.selectMdcShiftSub(id);
        if (flag){
            if (removeById(id)){
        if (flag) {
            if (removeById(id)) {
                return Result.OK("删除成功");
            }
            return Result.error("数据库无该数据,无法删除");
@@ -103,4 +103,22 @@
        }
        return result;
    }
    /**
     * 设置默认班制
     *
     * @param id
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean changeDefaultShift(String id) {
        MdcShift mdcShift = this.baseMapper.selectOne(new LambdaQueryWrapper<MdcShift>().eq(MdcShift::getDefaultShift, "true"));
        mdcShift.setDefaultShift("false");
        this.baseMapper.updateById(mdcShift);
        MdcShift defaultShift = this.baseMapper.selectById(id);
        defaultShift.setDefaultShift("true");
        this.baseMapper.updateById(defaultShift);
        return true;
    }
}