hyingbo
6 天以前 e935889261ef38c8eaef31e54cbfc466d63d2ef4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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.jeecg.modules.mdc.util.DateUtils;
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.*;
 
/**
 * @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(MdcShiftSub mdcShiftSub) {
        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("当前日期已被设备日历引用无法删除");
    }
 
    @Override
    public List<Map<String, String>> initShiftSubList(String shiftId) {
        List<MdcShiftSub> mdcShiftSubs = this.baseMapper.selectList(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftSubStatus, "1").eq(MdcShiftSub::getShiftId, shiftId));
        List<Map<String, String>> result = new ArrayList<>();
        for (MdcShiftSub mdcShiftSub : mdcShiftSubs) {
            Map<String, String> map = new HashMap<>();
            map.put("label", mdcShiftSub.getShiftSubName());
            map.put("value", mdcShiftSub.getId());
            result.add(map);
        }
        return result;
    }
 
 
}