TComplainDealTransferServiceImpl.java 6.63 KB
Newer Older
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 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 169 170 171 172 173 174 175 176 177
package com.zehong.system.service.impl;

import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TComplainDeal;
import com.zehong.system.domain.TComplainDealTransfer;
import com.zehong.system.mapper.TComplainDealMapper;
import com.zehong.system.mapper.TComplainDealTransferMapper;
import com.zehong.system.service.ITComplainDealTransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 燃气投诉处置-转办记录Service业务层处理
 * 
 * @author zehong
 * @date 2024-06-06
 */
@Service
public class TComplainDealTransferServiceImpl implements ITComplainDealTransferService 
{
    @Autowired
    private TComplainDealTransferMapper tComplainDealTransferMapper;

    @Autowired
    private TComplainDealMapper tComplainDealMapper;

    /**
     * 查询燃气投诉处置-转办记录
     * 
     * @param complainDealTransferId 燃气投诉处置-转办记录ID
     * @return 燃气投诉处置-转办记录
     */
    @Override
    public TComplainDealTransfer selectTComplainDealTransferById(Long complainDealTransferId)
    {
        return tComplainDealTransferMapper.selectTComplainDealTransferById(complainDealTransferId);
    }

    /**
     * 查询燃气投诉处置-转办记录列表
     * 
     * @param tComplainDealTransfer 燃气投诉处置-转办记录
     * @return 燃气投诉处置-转办记录
     */
    @Override
    public List<TComplainDealTransfer> selectTComplainDealTransferList(TComplainDealTransfer tComplainDealTransfer)
    {
        return tComplainDealTransferMapper.selectTComplainDealTransferList(tComplainDealTransfer);
    }


    /**
     * 根据 投诉处置id查询 转办记录列表
     * @param complainDealId id
     * @return list
     */
    @Override
    public List<Map<String,Object>> queryComplainDealTransferListByComplainDealId(Long complainDealId) {
        List<TComplainDealTransfer> tComplainDealTransfers = tComplainDealTransferMapper.queryComplainDealTransferListByComplainDealId(complainDealId);

        List<Map<String,Object>> list = new ArrayList<>();
        if (tComplainDealTransfers != null && tComplainDealTransfers.size() > 0) {
            Map<String,Object> item ;
            for (TComplainDealTransfer tComplainDealTransfer : tComplainDealTransfers) {
                item = new HashMap<>();
                String sj = DateUtils.dateTime(tComplainDealTransfer.getCreateTime());
                item.put("sj",sj);

                List<Map<String,String>> dictList = new ArrayList<>();
                Map<String,String> dictListItem = new HashMap<>();
                dictListItem.put("indexCode","enterpriseName");
                dictListItem.put("label","企业名称");
                dictList.add(dictListItem);
                dictListItem = new HashMap<>();
                dictListItem.put("indexCode","assignMan");
                dictListItem.put("label","指派人");
                dictList.add(dictListItem);
                dictListItem = new HashMap<>();
                dictListItem.put("indexCode","reasonConcent");
                dictListItem.put("label","退回原因");
                dictList.add(dictListItem);
                item.put("dictList",dictList);

                List<Map<String,String>> rows = new ArrayList<>();
                Map<String,String> rowsItem = new HashMap<>();
                rowsItem.put("enterpriseName", tComplainDealTransfer.getEnterpriseName());
                rowsItem.put("assignMan", tComplainDealTransfer.getComplainAssignMan());
                rowsItem.put("reasonConcent", tComplainDealTransfer.getReasonConcent());
                rows.add(rowsItem);
                item.put("rows",rows);
                list.add(item);
            }
        }
        return list;
    }

    /**
     * 新增燃气投诉处置-转办记录
     * 
     * @param tComplainDealTransfer 燃气投诉处置-转办记录
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor= Exception.class)
    public AjaxResult insertTComplainDealTransfer(TComplainDealTransfer tComplainDealTransfer)
    {

        if (tComplainDealTransfer.getComplainDealId() == null) {
            return AjaxResult.error("参数丢失!!!");
        }

        //先修改数据的状态 改成4  退回状态,并清理 指派单位,指派人
        TComplainDeal tComplainDeal = new TComplainDeal();
        tComplainDeal.setComplainDealId(tComplainDealTransfer.getComplainDealId());
        tComplainDeal.setComplainStatus("4");
        tComplainDeal.setComplainAssignEnterproseId(null);
        tComplainDeal.setComplainAssignEnterproseName(null);
        tComplainDeal.setComplainAssignMan(null);
        tComplainDeal.setComplainAssignManId(null);
        tComplainDealMapper.clearTComplainDeal(tComplainDeal);

        LoginUser loginUser = SecurityUtils.getLoginUser();

        //用户的部门id就是 企业id
        String deptId = loginUser.getUser().getDeptId();
        tComplainDealTransfer.setEnterpriseId(deptId);

        tComplainDealTransfer.setCreateBy(loginUser.getUsername());
        tComplainDealTransfer.setCreateTime(DateUtils.getNowDate());
        return AjaxResult.success(tComplainDealTransferMapper.insertTComplainDealTransfer(tComplainDealTransfer));
    }

    /**
     * 修改燃气投诉处置-转办记录
     * 
     * @param tComplainDealTransfer 燃气投诉处置-转办记录
     * @return 结果
     */
    @Override
    public int updateTComplainDealTransfer(TComplainDealTransfer tComplainDealTransfer)
    {
        return tComplainDealTransferMapper.updateTComplainDealTransfer(tComplainDealTransfer);
    }

    /**
     * 批量删除燃气投诉处置-转办记录
     * 
     * @param complainDealTransferIds 需要删除的燃气投诉处置-转办记录ID
     * @return 结果
     */
    @Override
    public int deleteTComplainDealTransferByIds(Long[] complainDealTransferIds)
    {
        return tComplainDealTransferMapper.deleteTComplainDealTransferByIds(complainDealTransferIds);
    }

    /**
     * 删除燃气投诉处置-转办记录信息
     * 
     * @param complainDealTransferId 燃气投诉处置-转办记录ID
     * @return 结果
     */
    @Override
    public int deleteTComplainDealTransferById(Long complainDealTransferId)
    {
        return tComplainDealTransferMapper.deleteTComplainDealTransferById(complainDealTransferId);
    }
}