TOrderFeedbackServiceImpl.java 6.89 KB
Newer Older
1 2
package com.zehong.system.service.impl;

3
import java.util.HashMap;
4
import java.util.List;
5
import java.util.Map;
王晓倩's avatar
王晓倩 committed
6

7
import com.zehong.common.utils.DateUtils;
王晓倩's avatar
王晓倩 committed
8 9
import com.zehong.system.domain.*;
import com.zehong.system.mapper.*;
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.service.ITOrderFeedbackService;

/**
 * 工单反馈信息Service业务层处理
 * 
 * @author zehong
 * @date 2021-07-19
 */
@Service
public class TOrderFeedbackServiceImpl implements ITOrderFeedbackService 
{
    @Autowired
    private TOrderFeedbackMapper tOrderFeedbackMapper;
王晓倩's avatar
王晓倩 committed
25 26 27 28 29
    @Autowired
    private TWorkOrderMapper tWorkOrderMapper;
    @Autowired
    private TInspectionDataMapper tInspectionDataMapper;
    @Autowired
30 31
    private TInspectionPlanMapper tInspectionPlanMapper;
    @Autowired
王晓倩's avatar
王晓倩 committed
32 33 34
    private THiddenTroubleMapper tHiddenTroubleMapper;
    @Autowired
    private TDeviceAlarmMapper tDeviceAlarmMapper;
35 36 37 38
    @Autowired
    private TPipeMapper tPipeMapper;
    @Autowired
    private TDeviceInfoMapper tDeviceInfoMapper;
39 40 41 42 43 44 45 46

    /**
     * 查询工单反馈信息
     * 
     * @param feedbackId 工单反馈信息ID
     * @return 工单反馈信息
     */
    @Override
47
    public TOrderFeedback selectTOrderFeedbackById(int feedbackId)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    {
        return tOrderFeedbackMapper.selectTOrderFeedbackById(feedbackId);
    }

    /**
     * 查询工单反馈信息列表
     * 
     * @param tOrderFeedback 工单反馈信息
     * @return 工单反馈信息
     */
    @Override
    public List<TOrderFeedback> selectTOrderFeedbackList(TOrderFeedback tOrderFeedback)
    {
        return tOrderFeedbackMapper.selectTOrderFeedbackList(tOrderFeedback);
    }

    /**
     * 新增工单反馈信息
     * 
     * @param tOrderFeedback 工单反馈信息
     * @return 结果
     */
    @Override
71
    public int insertTOrderFeedback(TOrderFeedback tOrderFeedback) throws Exception
72
    {
王晓倩's avatar
王晓倩 committed
73 74 75 76 77
        if("2".equals(tOrderFeedback.getIsHiddenDanger())){
            tOrderFeedback.setDealStatus("1");
        }
        tOrderFeedback.setFeedbackTime(DateUtils.getNowDate());

王晓倩's avatar
王晓倩 committed
78
        String dealStatus = tOrderFeedback.getDealStatus();
79
        String isHiddenDanger = tOrderFeedback.getIsHiddenDanger();
王晓倩's avatar
王晓倩 committed
80 81 82 83 84 85

        // 根据工单类型和源id修改源数据状态
        TWorkOrder order = tWorkOrderMapper.selectTWorkOrderById(tOrderFeedback.getOrderId());
        String orderType = order.getOrderType();

        if("1".equals(orderType)){
86 87
            TInspectionPlan tInspectionPlan = tInspectionPlanMapper.selectTInspectionPlanById(order.getResourceId());
            Integer planId = tInspectionPlan.getPlanId();
88
            Integer deviceId = tOrderFeedback.getDeviceId();
89 90

            TInspectionData data = tInspectionDataMapper.selectTInspectionDataByDeviceId(planId, deviceId);
王晓倩's avatar
王晓倩 committed
91
            data.setDealStatus(dealStatus);
92 93
            data.setIsHiddenDanger(isHiddenDanger);
            data.setUpdateTime(DateUtils.getNowDate());
94 95 96

            tOrderFeedback.setDeviceType(data.getDeviceType());

王晓倩's avatar
王晓倩 committed
97 98
            tInspectionDataMapper.updateTInspectionData(data);

99
            if("0".equals(data.getDeviceType())){
100
                TPipe pipe = tPipeMapper.selectTPipeById(deviceId);
101 102 103
                pipe.setInspectionTime(DateUtils.getNowDate());
                tPipeMapper.updateTPipe(pipe);
            } else {
104
                TDeviceInfo device = tDeviceInfoMapper.selectTDeviceInfoById(deviceId);
105 106 107
                device.setInspectionTime(DateUtils.getNowDate());
                tDeviceInfoMapper.updateTDeviceInfo(device);
            }
王晓倩's avatar
王晓倩 committed
108 109 110
        } else if("2".equals(orderType)) {
            THiddenTrouble trouble = tHiddenTroubleMapper.selectTHiddenTroubleById(order.getResourceId());
            trouble.setDealStatus(dealStatus);
111
            trouble.setUpdateTime(DateUtils.getNowDate());
112

113
            tOrderFeedback.setDeviceId(trouble.getDeviceId());
114 115
            tOrderFeedback.setDeviceType(trouble.getDeviceType());

王晓倩's avatar
王晓倩 committed
116 117
            tHiddenTroubleMapper.updateTHiddenTrouble(trouble);

王晓倩's avatar
王晓倩 committed
118 119 120 121 122 123 124 125 126
            if("0".equals(trouble.getDeviceType())){
                TPipe pipe = tPipeMapper.selectTPipeById(trouble.getDeviceId());
                pipe.setInspectionTime(DateUtils.getNowDate());
                tPipeMapper.updateTPipe(pipe);
            } else {
                TDeviceInfo device = tDeviceInfoMapper.selectTDeviceInfoById(trouble.getDeviceId());
                device.setInspectionTime(DateUtils.getNowDate());
                tDeviceInfoMapper.updateTDeviceInfo(device);
            }
127
        } else if("3".equals(orderType)) {
王晓倩's avatar
王晓倩 committed
128 129
            TDeviceAlarm alarm = tDeviceAlarmMapper.selectTDeviceAlarmById(order.getResourceId());
            alarm.setDealStatus(dealStatus);
130
            alarm.setUpdateTime(DateUtils.getNowDate());
131

132
            tOrderFeedback.setDeviceId(alarm.getDeviceId());
133 134
            tOrderFeedback.setDeviceType(alarm.getDeviceType());

王晓倩's avatar
王晓倩 committed
135
            tDeviceAlarmMapper.updateTDeviceAlarm(alarm);
王晓倩's avatar
王晓倩 committed
136 137 138 139 140 141 142 143 144 145

            if("0".equals(alarm.getDeviceType())){
                TPipe pipe = tPipeMapper.selectTPipeById(alarm.getDeviceId());
                pipe.setInspectionTime(DateUtils.getNowDate());
                tPipeMapper.updateTPipe(pipe);
            } else {
                TDeviceInfo device = tDeviceInfoMapper.selectTDeviceInfoById(alarm.getDeviceId());
                device.setInspectionTime(DateUtils.getNowDate());
                tDeviceInfoMapper.updateTDeviceInfo(device);
            }
王晓倩's avatar
王晓倩 committed
146
        }
147

148 149 150
        // 如果工单状态是已接收,修改状态为已反馈
        if("1".equals(order.getOrderStatus())){
            order.setOrderStatus("2");
王晓倩's avatar
王晓倩 committed
151
            tWorkOrderMapper.updateTWorkOrder(order);
152
        }
王晓倩's avatar
王晓倩 committed
153

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
        return tOrderFeedbackMapper.insertTOrderFeedback(tOrderFeedback);
    }

    /**
     * 修改工单反馈信息
     * 
     * @param tOrderFeedback 工单反馈信息
     * @return 结果
     */
    @Override
    public int updateTOrderFeedback(TOrderFeedback tOrderFeedback)
    {
        return tOrderFeedbackMapper.updateTOrderFeedback(tOrderFeedback);
    }

    /**
     * 批量删除工单反馈信息
     * 
     * @param feedbackIds 需要删除的工单反馈信息ID
     * @return 结果
     */
    @Override
176
    public int deleteTOrderFeedbackByIds(int[] feedbackIds)
177 178 179 180 181 182 183 184 185 186 187
    {
        return tOrderFeedbackMapper.deleteTOrderFeedbackByIds(feedbackIds);
    }

    /**
     * 删除工单反馈信息信息
     * 
     * @param feedbackId 工单反馈信息ID
     * @return 结果
     */
    @Override
188
    public int deleteTOrderFeedbackById(int feedbackId)
189 190 191
    {
        return tOrderFeedbackMapper.deleteTOrderFeedbackById(feedbackId);
    }
jianqian's avatar
jianqian committed
192 193 194 195 196 197 198 199 200 201 202

    /**
     * 工单的反馈信息列表
     * @param orderId
     * @return
     */
    @Override
    public List<TOrderFeedback> selectTOrderFeedbackByOrderId(String orderId){
        List<TOrderFeedback> orderFeedbackList = tOrderFeedbackMapper.selectTOrderFeedbackByOrderId(orderId);
        return orderFeedbackList;
    }
203
}