liusheng
2024-03-06 c92523467edf0306bad25f141faa5fcb56da8806
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
package com.smartor.service.impl;
 
import com.google.gson.Gson;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DtoConversionUtils;
import com.smartor.domain.*;
import com.smartor.mapper.IvrTaskcallMapper;
import com.smartor.mapper.PatTaskRelevanceMapper;
import com.smartor.service.IIvrTaskcallService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
/**
 * 单一任务(随访)Service业务层处理
 *
 * @author ruoyi
 * @date 2024-02-02
 */
@Slf4j
@Service
public class IvrTaskcallServiceImpl implements IIvrTaskcallService {
    @Autowired
    private IvrTaskcallMapper ivrTaskcallMapper;
 
    @Autowired
    private PatTaskRelevanceMapper patTaskRelevanceMapper;
 
    /**
     * 查询单一任务(随访)
     *
     * @param id 单一任务(随访)主键
     * @return 单一任务(随访)
     */
    @Override
    public IvrTaskcall selectIvrTaskcallById(Long id) {
        return ivrTaskcallMapper.selectIvrTaskcallById(id);
    }
 
    /**
     * 查询单一任务(随访)列表
     *
     * @param ivrTaskcall 单一任务(随访)
     * @return 单一任务(随访)
     */
    @Override
    public List<IvrTaskcall> selectIvrTaskcallList(IvrTaskcall ivrTaskcall) {
        return ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall);
    }
 
    /**
     * 新增单一任务(随访)
     *
     * @param ivrTaskcall 单一任务(随访)
     * @return 结果
     */
    @Override
    public int insertIvrTaskcall(IvrTaskcall ivrTaskcall) {
        ivrTaskcall.setCreateTime(DateUtils.getNowDate());
        return ivrTaskcallMapper.insertIvrTaskcall(ivrTaskcall);
    }
 
    /**
     * 修改单一任务(随访)
     *
     * @param ivrTaskcall 单一任务(随访)
     * @return 结果
     */
    @Override
    public int updateIvrTaskcall(IvrTaskcall ivrTaskcall) {
        ivrTaskcall.setUpdateTime(DateUtils.getNowDate());
        return ivrTaskcallMapper.updateIvrTaskcall(ivrTaskcall);
    }
 
    /**
     * 批量删除单一任务(随访)
     *
     * @param ids 需要删除的单一任务(随访)主键
     * @return 结果
     */
    @Override
    public int deleteIvrTaskcallByIds(Long[] ids) {
        Integer i = 0;
        for (Long id : ids) {
            i = ivrTaskcallMapper.deleteIvrTaskcallById(id);
        }
        return i;
    }
 
    /**
     * 单一任务
     *
     * @param ivrTaskcallVO 单一任务
     * @return 结果
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertOrUpdateTask(IvrTaskcallVO ivrTaskcallVO) {
        if (ObjectUtils.isEmpty(ivrTaskcallVO)) {
            log.info("宣教任务入参为空,请检查入参");
            throw new BaseException("宣教任务入参为空,请检查入参");
        }
        Integer integer = 0;
        if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 1) {
            //新增
            if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getPatTaskRelevances())) {
                for (PatTaskRelevance patTaskRelevance : ivrTaskcallVO.getPatTaskRelevances()) {
                    //将任务信息新增到宣教任务表中
                    IvrTaskcall ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskcall.class);
                    ivrTaskcall.setSendname(patTaskRelevance.getName());
                    ivrTaskcall.setAge(patTaskRelevance.getAge());
                    ivrTaskcall.setSfzh(patTaskRelevance.getSfzh());
                    ivrTaskcall.setPhone(patTaskRelevance.getPhone());
                    ivrTaskcall.setAddr(patTaskRelevance.getAddr());
                    ivrTaskcall.setCreateTime(DateUtils.getNowDate());
                    ivrTaskcall.setTextParam(new Gson().toJson(ivrTaskcallVO.getTextParam()));
                    ivrTaskcallMapper.insertIvrTaskcall(ivrTaskcall);
                    integer = ivrTaskcall.getId().intValue();
                }
            }
 
        } else if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 2) {
            if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getPatTaskRelevances())) {
                for (PatTaskRelevance patTaskRelevance : ivrTaskcallVO.getPatTaskRelevances()) {
                    IvrTaskcall ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskcall.class);
                    ivrTaskcall.setSendname(patTaskRelevance.getName());
                    ivrTaskcall.setAge(patTaskRelevance.getAge());
                    ivrTaskcall.setSfzh(patTaskRelevance.getSfzh());
                    ivrTaskcall.setPhone(patTaskRelevance.getPhone());
                    ivrTaskcall.setAddr(patTaskRelevance.getAddr());
                    ivrTaskcall.setCreateTime(DateUtils.getNowDate());
                    ivrTaskcall.setTextParam(new Gson().toJson(ivrTaskcallVO.getTextParam()));
 
                    ivrTaskcallMapper.updateIvrTaskcall(ivrTaskcall);
                    integer = ivrTaskcall.getId().intValue();
                }
            }
 
        } else if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 3) {
            ivrTaskcallMapper.deleteIvrTaskcallById(ivrTaskcallVO.getId());
 
            integer = ivrTaskcallVO.getId().intValue();
        }
        return integer;
    }
 
}