Administrator
2024-01-30 bc45a4a5a9b40e934317644c691ec5117e802859
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
package com.dy.pipIrrSell.clientCard;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voSe.VoCardInfo;
import com.dy.pipIrrGlobal.voSe.VoCards;
import com.dy.pipIrrSell.clientCard.qo.QoCards;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.*;
 
/**
 * @author ZhuBaoMin
 * @date 2023/12/7 9:18
 * @LastEditTime 2023/12/7 9:18
 * @Description
 */
 
@Slf4j
@Service
public class ClientCardSv {
    @Autowired
    private SeClientCardMapper seClientCardMapper;
 
    /**
     * 添加农户水卡记录
     * @param po
     * @return
     */
    public Long add(SeClientCard po) {
        seClientCardMapper.insert(po);
        return po.getId();
    }
 
    /**
     * 依据水卡地址获取水卡编号(12月19日废弃)
     * @param cardAddr
     * @return
     */
    public Long getCardIdByAddr(String cardAddr) {
        return seClientCardMapper.getCardIdByAddr(cardAddr);
    }
 
    /**
     * 根据水卡编号获取水卡表主键(12月19日添加后废弃)
     * @param cardNum 16位水卡编号
     * @return 水卡表主键
     */
    public Long getCardIdByNum(String cardNum) {
        return seClientCardMapper.getCardIdByNum(cardNum);
    }
 
    /**
     * 根据水卡编号获取水卡表主键及农户编号
     * @param cardNum
     * @return
     */
    public Map getCardIdAndClientNum(String cardNum) {
        return seClientCardMapper.getCardIdAndClientNum(cardNum);
    }
    /**
     * 根据水卡编号(主键)修改农户卡信息
     * @param po
     * @return
     */
    public Integer UpdateClientCard(SeClientCard po) {
        return seClientCardMapper.updateByPrimaryKeySelective(po);
    }
 
    /**
     * 根据农户主键获取水卡列表
     * @param clientId
     * @return
     */
    public List<VoCardInfo> getCardInfoByClientId(Long clientId){
        List<VoCardInfo> list = Optional.ofNullable(seClientCardMapper.getCardInfoByClientId(clientId)).orElse(new ArrayList<>());
        if(list.size() > 0) {
            return list;
        }else {
            return new ArrayList<>();
        }
    }
 
    /**
     * 根据水卡编号获取操作记录及余额
     * @param cardNum
     * @return
     */
    public Map getOperateRecordsAndMoney(Long cardNum) {
        List<Map<String, Object>> list = Optional.ofNullable(seClientCardMapper.getOperateRecordsByCardNum(cardNum)).orElse(new ArrayList<>());
        Float mondy = Optional.ofNullable(seClientCardMapper.getMoneyByCardNum(cardNum)).orElse(0f);
        Float amount = Optional.ofNullable(seClientCardMapper.sumRechargeByCardNum(cardNum)).orElse(0f);
 
        Map map = new HashMap();
        map.put("mondy", mondy);
        map.put("amount", amount);
        map.put("list", list);
        return map;
    }
 
    /**
     * 根据水卡编号获取卡片状态
     * @param cardNum
     * @return
     */
    public String getCardStateByCardNum(Long cardNum) {
        String stateName = Optional.ofNullable(seClientCardMapper.getCardStateByCardNum(cardNum)).orElse("");
        return stateName;
    }
 
    /**
     * 根据指定条件获取水卡列表,应用程序使用
     * @param queryVo
     * @return
     */
    public QueryResultVo<List<VoCards>> getCards(QoCards queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ;
        Long itemTotal = seClientCardMapper.getCardsCount(params);
 
        QueryResultVo<List<VoCards>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = queryVo.pageSize ;
        rsVo.pageCurr = queryVo.pageCurr ;
 
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = seClientCardMapper.getCards(params);
 
        return rsVo ;
    }
}