wuxw
2021-04-23 fdf45f690fa4eca9191aa0fb6abf077e7b36ce06
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
package com.java110.community.listener.repair;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.community.dao.IRepairServiceDao;
import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener;
import com.java110.entity.center.Business;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.constant.StatusConstant;
import com.java110.utils.exception.ListenerExecuteException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 报修信息 服务侦听 父类
 * Created by wuxw on 2018/7/4.
 */
public abstract class AbstractRepairBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
    private static Logger logger = LoggerFactory.getLogger(AbstractRepairBusinessServiceDataFlowListener.class);
 
 
    /**
     * 获取 DAO工具类
     *
     * @return
     */
    public abstract IRepairServiceDao getRepairServiceDaoImpl();
 
    /**
     * 刷新 businessRepairInfo 数据
     * 主要将 数据库 中字段和 接口传递字段建立关系
     *
     * @param businessRepairInfo
     */
    protected void flushBusinessRepairInfo(Map businessRepairInfo, String statusCd) {
        businessRepairInfo.put("newBId", businessRepairInfo.get("b_id"));
        businessRepairInfo.put("operate", businessRepairInfo.get("operate"));
        businessRepairInfo.put("repairName", businessRepairInfo.get("repair_name"));
        businessRepairInfo.put("appointmentTime", businessRepairInfo.get("appointment_time"));
        businessRepairInfo.put("repairType", businessRepairInfo.get("repair_type"));
        businessRepairInfo.put("context", businessRepairInfo.get("context"));
        businessRepairInfo.put("repairId", businessRepairInfo.get("repair_id"));
        businessRepairInfo.put("tel", businessRepairInfo.get("tel"));
        businessRepairInfo.put("state", businessRepairInfo.get("state"));
        businessRepairInfo.put("communityId", businessRepairInfo.get("community_id"));
        businessRepairInfo.put("repairObjType", businessRepairInfo.get("repair_obj_type"));
        businessRepairInfo.put("repairObjId", businessRepairInfo.get("repair_obj_id"));
        businessRepairInfo.put("repairObjName", businessRepairInfo.get("repair_obj_name"));
        businessRepairInfo.put("repairChannel", businessRepairInfo.get("repair_channel"));
        businessRepairInfo.put("maintenanceType", businessRepairInfo.get("maintenance_type"));
        businessRepairInfo.put("repairMaterials", businessRepairInfo.get("repair_materials"));
        businessRepairInfo.put("repairFee", businessRepairInfo.get("repair_fee"));
        businessRepairInfo.remove("bId");
        businessRepairInfo.put("statusCd", statusCd);
    }
 
 
    /**
     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
     *
     * @param businessRepair 报修信息信息
     */
    protected void autoSaveDelBusinessRepair(Business business, JSONObject businessRepair) {
//自动插入DEL
        Map info = new HashMap();
        info.put("repairId", businessRepair.getString("repairId"));
        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
        List<Map> currentRepairInfos = getRepairServiceDaoImpl().getRepairInfo(info);
        if (currentRepairInfos == null || currentRepairInfos.size() != 1) {
            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
        }
 
        Map currentRepairInfo = currentRepairInfos.get(0);
 
        currentRepairInfo.put("bId", business.getbId());
 
        currentRepairInfo.put("operate", currentRepairInfo.get("operate"));
        currentRepairInfo.put("repairName", currentRepairInfo.get("repair_name"));
        currentRepairInfo.put("appointmentTime", currentRepairInfo.get("appointment_time"));
        currentRepairInfo.put("repairType", currentRepairInfo.get("repair_type"));
        currentRepairInfo.put("context", currentRepairInfo.get("context"));
        currentRepairInfo.put("repairId", currentRepairInfo.get("repair_id"));
        currentRepairInfo.put("tel", currentRepairInfo.get("tel"));
        currentRepairInfo.put("state", currentRepairInfo.get("state"));
        currentRepairInfo.put("communityId", currentRepairInfo.get("community_id"));
        currentRepairInfo.put("repairObjType", currentRepairInfo.get("repair_obj_type"));
        currentRepairInfo.put("repairObjId", currentRepairInfo.get("repair_obj_id"));
        currentRepairInfo.put("repairObjName", currentRepairInfo.get("repair_obj_name"));
        currentRepairInfo.put("repairChannel", currentRepairInfo.get("repair_channel"));
        currentRepairInfo.put("maintenanceType", currentRepairInfo.get("maintenance_type"));
        currentRepairInfo.put("repairMaterials", currentRepairInfo.get("repair_materials"));
        currentRepairInfo.put("repairFee", currentRepairInfo.get("repair_fee"));
        currentRepairInfo.put("operate", StatusConstant.OPERATE_DEL);
        getRepairServiceDaoImpl().saveBusinessRepairInfo(currentRepairInfo);
 
        for (Object key : currentRepairInfo.keySet()) {
            if (businessRepair.get(key) == null) {
                businessRepair.put(key.toString(), currentRepairInfo.get(key));
            }
        }
    }
 
 
}