TTroubleStandingBookServiceImpl.java 5.12 KB
Newer Older
1 2 3 4
package com.zehong.system.service.impl;

import java.util.List;
import java.util.Map;
5
import java.util.stream.Collectors;
6

7
import com.zehong.common.core.domain.entity.SysRole;
8
import com.zehong.common.utils.DateUtils;
9
import com.zehong.common.utils.SecurityUtils;
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
import com.zehong.system.domain.Statistics;
import com.zehong.system.domain.form.TTroubleStandingBookForm;
import com.zehong.system.domain.vo.TTroubleStandingBookVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TTroubleStandingBookMapper;
import com.zehong.system.domain.TTroubleStandingBook;
import com.zehong.system.service.ITTroubleStandingBookService;

/**
 * 事故台账Service业务层处理
 *
 * @author zehong
 * @date 2022-02-09
 */
@Service
public class TTroubleStandingBookServiceImpl implements ITTroubleStandingBookService
{
    @Autowired
    private TTroubleStandingBookMapper tTroubleStandingBookMapper;

    /**
     * 查询事故台账
     *
     * @param troubleId 事故台账ID
     * @return 事故台账
     */
    @Override
    public TTroubleStandingBook selectTTroubleStandingBookById(Long troubleId)
    {
        return tTroubleStandingBookMapper.selectTTroubleStandingBookById(troubleId);
    }

    /**
     * 查询事故台账列表
     *
     * @param tTroubleStandingBook 事故台账
     * @return 事故台账
     */
    @Override
    public List<TTroubleStandingBook> selectTTroubleStandingBookList(TTroubleStandingBookForm tTroubleStandingBook)
    {
52 53 54 55
        // 20240725 调整 政府和企业都可以录,企业看自己,政府看所有
        if (isEnterprise() && tTroubleStandingBook != null) {
            tTroubleStandingBook.setEnterpriseId(SecurityUtils.getLoginUser().getUser().getDeptId());
        }
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
        return tTroubleStandingBookMapper.selectTTroubleStandingBookList(tTroubleStandingBook);
    }

    /**
     * 事故台账统计
     *
     * @return 事故台账统计
     */
    @Override
    public TTroubleStandingBookVo selectTTroubleStandingBookStatistic()
    {
        return tTroubleStandingBookMapper.selectTTroubleStandingBookStatistic();
    }

    /**
     * 新增事故台账
     *
     * @param tTroubleStandingBook 事故台账
     * @return 结果
     */
    @Override
    public int insertTTroubleStandingBook(TTroubleStandingBook tTroubleStandingBook)
    {
        tTroubleStandingBook.setCreateTime(DateUtils.getNowDate());
        return tTroubleStandingBookMapper.insertTTroubleStandingBook(tTroubleStandingBook);
    }

    /**
     * 修改事故台账
     *
     * @param tTroubleStandingBook 事故台账
     * @return 结果
     */
    @Override
    public int updateTTroubleStandingBook(TTroubleStandingBook tTroubleStandingBook)
    {
        // 是否人员伤亡:2否,受伤人数和死亡人数改为0
        if(tTroubleStandingBook.getIsCasualties().equals("2")){
            tTroubleStandingBook.setInjuryNum(0);
            tTroubleStandingBook.setDeathNum(0);
        }
        tTroubleStandingBook.setUpdateTime(DateUtils.getNowDate());
        return tTroubleStandingBookMapper.updateTTroubleStandingBook(tTroubleStandingBook);
    }

    /**
     * 批量删除事故台账
     *
     * @param troubleIds 需要删除的事故台账ID
     * @return 结果
     */
    @Override
    public int deleteTTroubleStandingBookByIds(Long[] troubleIds)
    {
        return tTroubleStandingBookMapper.deleteTTroubleStandingBookByIds(troubleIds);
    }

    /**
     * 删除事故台账信息
     *
     * @param troubleId 事故台账ID
     * @return 结果
     */
    @Override
    public int deleteTTroubleStandingBookById(Long troubleId)
    {
        return tTroubleStandingBookMapper.deleteTTroubleStandingBookById(troubleId);
    }

    /**
     * 查询统计信息
     * @param sevenDate
     * @return
     */
    @Override
    public List<Statistics> accidentLedger(List<String> sevenDate) {
        return tTroubleStandingBookMapper.accidentLedger(sevenDate);
    }
    /**
     * 统计数量
     * @param
     * @return
     */
    @Override
    public List<Map<String,Object>> selectTrobleCountByMonth(){
        return tTroubleStandingBookMapper.selectTrobleCountByMonth();
    }
    /**
     * 统计每年事故数量
     * @return
     */
    @Override
    public List<Map<String,Object>> selectTrobleCountByYear(){
        return tTroubleStandingBookMapper.selectTrobleCountByYear();
    }
    /**
     * 统计乡镇事故数量
     * @return
     */
    @Override
    public List<Map<String,Object>> selectTrobleRanking(){
        return tTroubleStandingBookMapper.selectTrobleRanking();
    }
    /**
     * 根据事故原因统计数量
     * @return
     */
    @Override
    public List<Map<String,Object>> selectTrobleReason(){
        return tTroubleStandingBookMapper.selectTrobleReason();
    }


169 170 171 172 173 174 175 176 177
    /**
     * 判断是否为企业
     * @return
     */
    private boolean isEnterprise(){
        List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
        List<String> roleKeys = roles.stream().map(item -> item.getRoleKey()).collect(Collectors.toList());
        return roleKeys.contains("qy");
    }
178
}