java110
2021-10-13 5c8ea097a69d7a3b46d39a1b6908d999398c415d
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 com.java110.fee.listener.tempCarFeeConfig;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener;
import com.java110.entity.center.Business;
import com.java110.fee.dao.ITempCarFeeConfigServiceDao;
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 AbstractTempCarFeeConfigBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
    private static Logger logger = LoggerFactory.getLogger(AbstractTempCarFeeConfigBusinessServiceDataFlowListener.class);
 
 
    /**
     * 获取 DAO工具类
     *
     * @return
     */
    public abstract ITempCarFeeConfigServiceDao getTempCarFeeConfigServiceDaoImpl();
 
    /**
     * 刷新 businessTempCarFeeConfigInfo 数据
     * 主要将 数据库 中字段和 接口传递字段建立关系
     *
     * @param businessTempCarFeeConfigInfo
     */
    protected void flushBusinessTempCarFeeConfigInfo(Map businessTempCarFeeConfigInfo, String statusCd) {
        businessTempCarFeeConfigInfo.put("newBId", businessTempCarFeeConfigInfo.get("b_id"));
        businessTempCarFeeConfigInfo.put("carType", businessTempCarFeeConfigInfo.get("car_type"));
        businessTempCarFeeConfigInfo.put("operate", businessTempCarFeeConfigInfo.get("operate"));
        businessTempCarFeeConfigInfo.put("configId", businessTempCarFeeConfigInfo.get("config_id"));
        businessTempCarFeeConfigInfo.put("feeName", businessTempCarFeeConfigInfo.get("fee_name"));
        businessTempCarFeeConfigInfo.put("paId", businessTempCarFeeConfigInfo.get("pa_id"));
        businessTempCarFeeConfigInfo.put("areaNum", businessTempCarFeeConfigInfo.get("area_num"));
        businessTempCarFeeConfigInfo.put("startTime", businessTempCarFeeConfigInfo.get("start_time"));
        businessTempCarFeeConfigInfo.put("endTime", businessTempCarFeeConfigInfo.get("end_time"));
        businessTempCarFeeConfigInfo.put("ruleId", businessTempCarFeeConfigInfo.get("rule_id"));
        businessTempCarFeeConfigInfo.put("communityId", businessTempCarFeeConfigInfo.get("community_id"));
        businessTempCarFeeConfigInfo.put("feeConfigId", businessTempCarFeeConfigInfo.get("fee_config_id"));
        businessTempCarFeeConfigInfo.remove("bId");
        businessTempCarFeeConfigInfo.put("statusCd", statusCd);
    }
 
 
    /**
     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
     *
     * @param businessTempCarFeeConfig 临时车收费标准信息
     */
    protected void autoSaveDelBusinessTempCarFeeConfig(Business business, JSONObject businessTempCarFeeConfig) {
//自动插入DEL
        Map info = new HashMap();
        info.put("configId", businessTempCarFeeConfig.getString("configId"));
        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
        List<Map> currentTempCarFeeConfigInfos = getTempCarFeeConfigServiceDaoImpl().getTempCarFeeConfigInfo(info);
        if (currentTempCarFeeConfigInfos == null || currentTempCarFeeConfigInfos.size() != 1) {
            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
        }
 
        Map currentTempCarFeeConfigInfo = currentTempCarFeeConfigInfos.get(0);
 
        currentTempCarFeeConfigInfo.put("bId", business.getbId());
 
        currentTempCarFeeConfigInfo.put("carType", currentTempCarFeeConfigInfo.get("car_type"));
        currentTempCarFeeConfigInfo.put("operate", currentTempCarFeeConfigInfo.get("operate"));
        currentTempCarFeeConfigInfo.put("configId", currentTempCarFeeConfigInfo.get("config_id"));
        currentTempCarFeeConfigInfo.put("feeName", currentTempCarFeeConfigInfo.get("fee_name"));
        currentTempCarFeeConfigInfo.put("paId", currentTempCarFeeConfigInfo.get("pa_id"));
        currentTempCarFeeConfigInfo.put("areaNum", currentTempCarFeeConfigInfo.get("area_num"));
        currentTempCarFeeConfigInfo.put("startTime", currentTempCarFeeConfigInfo.get("start_time"));
        currentTempCarFeeConfigInfo.put("endTime", currentTempCarFeeConfigInfo.get("end_time"));
        currentTempCarFeeConfigInfo.put("ruleId", currentTempCarFeeConfigInfo.get("rule_id"));
        currentTempCarFeeConfigInfo.put("communityId", currentTempCarFeeConfigInfo.get("community_id"));
        currentTempCarFeeConfigInfo.put("feeConfigId", currentTempCarFeeConfigInfo.get("fee_config_id"));
 
 
        currentTempCarFeeConfigInfo.put("operate", StatusConstant.OPERATE_DEL);
        getTempCarFeeConfigServiceDaoImpl().saveBusinessTempCarFeeConfigInfo(currentTempCarFeeConfigInfo);
        for (Object key : currentTempCarFeeConfigInfo.keySet()) {
            if (businessTempCarFeeConfig.get(key) == null) {
                businessTempCarFeeConfig.put(key.toString(), currentTempCarFeeConfigInfo.get(key));
            }
        }
    }
 
 
}