forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-08 261d715822e5464334ea1bffc60a5f86e371d8f7
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
package cn.huge.module.cases.service;
 
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.cases.domain.dto.CaseFlowDTO;
import cn.huge.module.cases.domain.dto.TabButtonDTO;
import cn.huge.module.cases.domain.dto.TabButtonInfoDTO;
import cn.huge.module.client.api.impl.CustClientImpl;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.cases.dao.mapper.CaseTaskMapper;
import cn.huge.module.cases.domain.po.CaseTask;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.mediate.constant.CaseBaseConsts;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.PostConstruct;
import java.util.*;
 
/**
 * @title: 纠纷任务表业务逻辑处理
 * @Description 纠纷任务表业务逻辑处理
 * @company hugeinfo
 * @author liyj
 * @Time 2024-09-06 15:50:06
 * @version 1.0.0
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CaseTaskService extends ServiceImpl<CaseTaskMapper, CaseTask>{
 
    @Autowired
    private CaseTaskMapper mapper;
 
    @Autowired
    private UtilsClientImpl utilsClient;
 
    @Autowired
    private CustClientImpl custClient;
 
    @Autowired
    private CaseSuperviseService superviseService;
 
    /**
    * 更新对象
    * @param entity 对象
    */
    public void updateCaseTask(CaseTask entity){
        try{
            mapper.updateCaseTask(entity);
        }catch (Exception e){
            log.error("[CaseTaskService.updateCaseTask]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.updateCaseTask", e);
        }
    }
 
    /**
    * 条件更新对象
    * @param entity 对象
    * @param terms 条件
    */
    public void updateCaseTaskTerms(CaseTask entity, Map<String, Object> terms){
        try{
            mapper.updateCaseTaskTerms(entity, terms);
        }catch (Exception e){
            log.error("[CaseTaskService.updateCaseTaskTerms]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.updateCaseTaskTerms", e);
        }
    }
 
    /**
    * 根据编号物理删除
    * @param id 查询条件集合
    */
    public void deleteCaseTask(String id){
        try{
            mapper.deleteCaseTask(id);
        }catch (Exception e){
            log.error("[CaseTaskService.deleteCaseTask]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.deleteCaseTask", e);
        }
    }
 
    /**
    * 按条件查询
    * @param terms 条件
    * @return List
    */
    public List<CaseTask> listTerms(Map<String, Object> terms){
        return mapper.listTerms(terms);
    }
 
    /**
    * 按条件统计
    * @param terms 条件
    * @return long
    */
    public long countTerms(Map<String, Object> terms){
        return mapper.countTerms(terms);
    }
 
    /**
    * 按条件分页查询
    * @param page 分页对象
    * @param terms 条件
    * @return Page
    */
    public Page<CaseTask> pageQuery(PageRequest page, Map<String, Object> terms){
        long total = mapper.countTerms(terms);
        List<CaseTask> content = mapper.pageTerms(page, terms);
        return new PageImpl<CaseTask>(content, page, total);
    }
 
    /**
    * 新增或更新对象
    * @param caseTask 实体对象
    */
    public void saveCaseTask(CaseTask caseTask){
        try{
            Date nowDate = DateUtils.getNowDate();
            // 判断是否新增
            if (IdUtils.checkNewId(caseTask.getId())){
                caseTask.setId(utilsClient.getNewTimeId());
                caseTask.setCreateTime(nowDate);
            }
            caseTask.setUpdateTime(nowDate);
            this.saveOrUpdate(caseTask);
        }catch (Exception e){
            log.error("[CaseTaskService.saveCaseTask]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.saveCaseTask", e);
        }
    }
 
    /**
     * web端-任务出来页面-初始化tab和按钮
     * @param caseTaskId
     * @return
     */
    public TabButtonDTO webGetTabButton(String caseTaskId, String userId){
        try{
            // 临时给前端联调数据
            TabButtonDTO tabButtonDTO = new TabButtonDTO();
            List<TabButtonInfoDTO> tabList = new LinkedList<>();
            TabButtonInfoDTO sxxq = new TabButtonInfoDTO();
            sxxq.setId("sxxq");
            sxxq.setName("事项详情");
            tabList.add(sxxq);
 
            TabButtonInfoDTO dslxq = new TabButtonInfoDTO();
            dslxq.setId("dslxq");
            dslxq.setName("详情");
            tabList.add(dslxq);
 
            TabButtonInfoDTO sxbl = new TabButtonInfoDTO();
            sxbl.setId("sxbl");
            sxbl.setName("事项办理");
            tabList.add(sxbl);
 
            TabButtonInfoDTO sqjl = new TabButtonInfoDTO();
            sqjl.setId("sqjl");
            sqjl.setName("申请记录");
            tabList.add(sqjl);
 
            TabButtonInfoDTO htsh = new TabButtonInfoDTO();
            htsh.setId("htsh");
            htsh.setName("回退审核");
            tabList.add(htsh);
 
            TabButtonInfoDTO sbsh = new TabButtonInfoDTO();
            sbsh.setId("sbsh");
            sbsh.setName("上报审核");
            tabList.add(sbsh);
 
            TabButtonInfoDTO jash = new TabButtonInfoDTO();
            jash.setId("jash");
            jash.setName("结案审核");
            tabList.add(jash);
 
            TabButtonInfoDTO lhczsh = new TabButtonInfoDTO();
            lhczsh.setId("lhczsh");
            lhczsh.setName("联合处置申请审核");
            tabList.add(lhczsh);
 
            TabButtonInfoDTO lcdb = new TabButtonInfoDTO();
            lcdb.setId("lcdb");
            lcdb.setName("流程督办");
            tabList.add(lcdb);
 
            TabButtonInfoDTO daxx = new TabButtonInfoDTO();
            daxx.setId("daxx");
            daxx.setName("档案信息");
            tabList.add(daxx);
            tabButtonDTO.setTabList(tabList);
 
            List<TabButtonInfoDTO> buttonList = new LinkedList<>();
            TabButtonInfoDTO tjbljl = new TabButtonInfoDTO();
            tjbljl.setId("tjbljl");
            tjbljl.setName("添加办理记录");
            buttonList.add(tjbljl);
 
            TabButtonInfoDTO lhczsq = new TabButtonInfoDTO();
            lhczsq.setId("lhczsq");
            lhczsq.setName("联合处置申请");
            buttonList.add(lhczsq);
 
            TabButtonInfoDTO jasq = new TabButtonInfoDTO();
            jasq.setId("jasq");
            jasq.setName("结案申请");
            buttonList.add(jasq);
 
            TabButtonInfoDTO db = new TabButtonInfoDTO();
            db.setId("db");
            db.setName("督办");
            buttonList.add(db);
 
            TabButtonInfoDTO sl = new TabButtonInfoDTO();
            sl.setId("sl");
            sl.setName("受理");
            buttonList.add(sl);
 
            TabButtonInfoDTO ht = new TabButtonInfoDTO();
            ht.setId("ht");
            ht.setName("回退");
            buttonList.add(ht);
 
            TabButtonInfoDTO zxsl = new TabButtonInfoDTO();
            zxsl.setId("zxsl");
            zxsl.setName("自行受理");
            buttonList.add(zxsl);
 
            TabButtonInfoDTO jb = new TabButtonInfoDTO();
            jb.setId("jb");
            jb.setName("交办");
            buttonList.add(jb);
 
            TabButtonInfoDTO sb = new TabButtonInfoDTO();
            sb.setId("sb");
            sb.setName("上报");
            buttonList.add(sb);
            tabButtonDTO.setButtonList(buttonList);
            return tabButtonDTO;
        }catch (Exception e){
            log.error("[CaseTaskService.webGetTabButton]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.webGetTabButton", e);
        }
    }
 
    /**
     * web端-查询流程进度
     * @param caseId 纠纷编号
     * @return
     */
    public Map<String, Object> webListCaseFlow(String caseId, String userId){
        try{
            // 临时给前端联调数据
            Map<String, Object> result = Maps.newHashMap();
 
            List<CaseFlowDTO> handleCaseFlowList = new LinkedList<>();
            CaseFlowDTO lfdj = new CaseFlowDTO();
            lfdj.setNodeShowName("来访登记");
            lfdj.setHandleUnitName("白云区新市综治中心");
            lfdj.setHandleUserName("李晓明");
            lfdj.setTaskType(1);
            lfdj.setStatus(2);
            lfdj.setHandleTime(new Date());
            handleCaseFlowList.add(lfdj);
 
            CaseFlowDTO xtpd = new CaseFlowDTO();
            xtpd.setNodeShowName("事件流转");
            xtpd.setHandleUnitName("系统派单");
            xtpd.setHandleTime(new Date());
            xtpd.setHandleNotes("派单至:白云区新市司法所");
            xtpd.setTaskType(1);
            xtpd.setStatus(2);
            handleCaseFlowList.add(xtpd);
 
            CaseFlowDTO sjlz = new CaseFlowDTO();
            sjlz.setNodeShowName("事件流转");
            sjlz.setHandleUnitName("白云区新市司法所");
            sjlz.setHandleUserName("赵菲菲");
            sjlz.setHandleTime(new Date());
            sjlz.setHandleNotes("已签收");
            sjlz.setTaskType(1);
            sjlz.setStatus(2);
            handleCaseFlowList.add(sjlz);
 
            CaseFlowDTO sjht = new CaseFlowDTO();
            sjht.setNodeShowName("事件回退");
            sjht.setHandleUnitName("白云区新市司法所");
            sjht.setHandleUserName("赵菲菲");
            sjht.setHandleTime(new Date());
            sjht.setTaskType(2);
            sjht.setStatus(2);
            handleCaseFlowList.add(sjht);
 
            CaseFlowDTO htsh = new CaseFlowDTO();
            htsh.setNodeShowName("回退审核");
            htsh.setHandleUnitName("白云区新市综治中心");
            htsh.setHandleUserName("李晓明");
            htsh.setHandleTime(new Date());
            htsh.setAuditResult("24_00004-1");
            htsh.setAuditResultName("通过");
            htsh.setHandleTime(new Date());
            htsh.setTaskType(1);
            htsh.setStatus(2);
            handleCaseFlowList.add(htsh);
 
            CaseFlowDTO dsl = new CaseFlowDTO();
            dsl.setProcessName("待受理");
            dsl.setHandleUnitName("白云区新市综治中心");
            dsl.setTaskType(1);
            dsl.setStatus(1);
            handleCaseFlowList.add(dsl);
            result.put("handleCaseFlowList", handleCaseFlowList);
 
            List<CaseFlowDTO> assistCaseFlowList = new LinkedList<>();
            CaseFlowDTO xtpd2 = new CaseFlowDTO();
            xtpd2.setNodeShowName("事件流转");
            xtpd2.setHandleUnitName("联合处置申请");
            xtpd2.setHandleTime(new Date());
            xtpd2.setHandleNotes("联合处置申请:白云区永平司法所");
            xtpd2.setTaskType(1);
            xtpd2.setStatus(2);
            assistCaseFlowList.add(xtpd2);
            result.put("assistCaseFlowList", assistCaseFlowList);
            return result;
        }catch (Exception e){
            log.error("[CaseTaskService.webGetTabButton]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.webGetTabButton", e);
        }
    }
 
    /**
     * 按条件统计
     * @param userId 用户编号
     * @return long
     */
    public Map<String, Long> getCountList(String userId){
        CtUserDTO loginUser = custClient.clientGetUserAll(userId);
        Map<String, Object> terms = new HashMap<>();
        terms.put("candeUnitId", loginUser.getUnitId());
        terms.put("candeDeptId", loginUser.getDeptId());
        mapper.countTaskList(terms);
        superviseService.countCaseSuperviseList(0,loginUser.getUnitId());
        Map<String, Long> result = new HashMap<>();
        return result;
    }
 
    /**
     * wechat端-查询流程进度
     * @param caseId 纠纷编号
     * @return
     */
    public List<CaseFlowDTO> wechatListCaseFlow(String caseId, String userId){
        try{
            // 临时给前端联调数据
            List<CaseFlowDTO> list = new ArrayList<>();
            QueryWrapper<CaseTask> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("case_id", caseId);
            queryWrapper.orderByAsc("create_time");
            List<CaseTask> caseTasks = mapper.selectList(queryWrapper);
            if(ObjectUtils.isNotEmpty(caseTasks)){
                for (CaseTask caseTask : caseTasks) {
                    CaseFlowDTO caseFlowDTO = new CaseFlowDTO();
                    BeanUtils.copyProperties(caseTask, caseFlowDTO);
                    list.add(caseFlowDTO);
                }
            }
            return list;
        }catch (Exception e){
            log.error("[CaseTaskService.wechatListCaseFlow]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseTaskService.wechatListCaseFlow", e);
        }
    }
}