| | |
| | | package org.springblade.modules.disputeRecord.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.param.GridSet; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.backblast.entity.BackblastWarnHanRecEntity; |
| | | import org.springblade.modules.community.dto.CommunityDTO; |
| | | import org.springblade.modules.disputeRecord.entity.DisputeRecordEntity; |
| | | import org.springblade.modules.disputeRecord.excel.DisputeRecordExcel; |
| | | import org.springblade.modules.disputeRecord.excel.ExportDisputeRecordExcel; |
| | | import org.springblade.modules.disputeRecord.vo.DisputeRecordVO; |
| | | import org.springblade.modules.disputeRecord.mapper.DisputeRecordMapper; |
| | | import org.springblade.modules.disputeRecord.service.IDisputeRecordService; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springblade.modules.task.entity.ECallEventEntity; |
| | | import org.springblade.modules.task.service.IECallEventService; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 矛盾纠纷记录表 服务实现类 |
| | |
| | | public DisputeRecordVO getDetail(DisputeRecordVO disputeRecord) { |
| | | return baseMapper.getDetail(disputeRecord); |
| | | } |
| | | |
| | | /** |
| | | * 矛盾纠纷事件数据导入类 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String importDisputeRecord(List<DisputeRecordExcel> data, Boolean isCovered) { |
| | | int totalNum = data.size(); |
| | | int importNum = 0; |
| | | int updateNum = 0; |
| | | int errorNum = 0; |
| | | for (DisputeRecordExcel disputeRecordExcel : data) { |
| | | // 判断地址,时间 |
| | | if (Strings.isBlank(disputeRecordExcel.getAddress()) |
| | | ) { |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | // 获取转换数据对象 |
| | | DisputeRecordEntity disputeRecordEntity |
| | | = Objects.requireNonNull(BeanUtil.copy(disputeRecordExcel, DisputeRecordEntity.class)); |
| | | //处理经纬度 |
| | | GridSet gridSet |
| | | = new GridSet<>().invoke(DisputeRecordEntity.class, disputeRecordEntity, "lng", "lat", "gridCode", "jwGridCode"); |
| | | //处理需要转换的数据(字典/非字典) |
| | | // 纠纷类型 |
| | | if (!Strings.isBlank(disputeRecordExcel.getDisputeType())) { |
| | | disputeRecordEntity.setDisputeType(Integer.parseInt(disputeRecordExcel.getDisputeType())); |
| | | } |
| | | // 信息来源 |
| | | if (!Strings.isBlank(disputeRecordExcel.getSource())) { |
| | | disputeRecordEntity.setSource(Integer.parseInt(disputeRecordExcel.getSource())); |
| | | } |
| | | // 受伤情况 0:否 1:是 |
| | | if (!Strings.isBlank(disputeRecordExcel.getInjuryFlag())) { |
| | | if (disputeRecordExcel.getInjuryFlag().equals("是")){ |
| | | disputeRecordEntity.setInjuryFlag(1); |
| | | } |
| | | if (disputeRecordExcel.getInjuryFlag().equals("否")){ |
| | | disputeRecordEntity.setInjuryFlag(0); |
| | | } |
| | | } |
| | | // 当事人1性别 1:男 2:女 |
| | | if (!Strings.isBlank(disputeRecordExcel.getGenderOne())) { |
| | | if (disputeRecordExcel.getGenderOne().contains("男")){ |
| | | disputeRecordEntity.setGenderOne(1); |
| | | } |
| | | if (disputeRecordExcel.getGenderOne().contains("女")){ |
| | | disputeRecordEntity.setGenderOne(2); |
| | | } |
| | | } |
| | | // 当事人2性别 1:男 2:女 |
| | | if (!Strings.isBlank(disputeRecordExcel.getGenderTwo())) { |
| | | if (disputeRecordExcel.getGenderTwo().contains("男")){ |
| | | disputeRecordEntity.setGenderTwo(1); |
| | | } |
| | | if (disputeRecordExcel.getGenderTwo().contains("女")){ |
| | | disputeRecordEntity.setGenderTwo(2); |
| | | } |
| | | } |
| | | // 处理结果 1:已化解 2:未化解 3:移送e呼即办 |
| | | if (!Strings.isBlank(disputeRecordExcel.getHandleResult())) { |
| | | if (disputeRecordExcel.getHandleResult().equals("已化解")) { |
| | | disputeRecordEntity.setHandleResult(1); |
| | | } |
| | | if (disputeRecordExcel.getHandleResult().equals("未化解")) { |
| | | disputeRecordEntity.setHandleResult(2); |
| | | } |
| | | if (disputeRecordExcel.getHandleResult().equals("移送e呼即办")) { |
| | | disputeRecordEntity.setHandleResult(3); |
| | | } |
| | | } |
| | | // 日期处理 |
| | | if (!Strings.isBlank(disputeRecordExcel.getEventTime())) { |
| | | try { |
| | | Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(disputeRecordExcel.getEventTime()); |
| | | disputeRecordEntity.setEventTime(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // 判断是否重复 |
| | | QueryWrapper<DisputeRecordEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("address", disputeRecordExcel.getAddress()) |
| | | .eq("event_time", disputeRecordEntity.getEventTime()) |
| | | .eq("is_deleted", 0); |
| | | // 查询 |
| | | List<DisputeRecordEntity> list = list(queryWrapper); |
| | | if (list.size()>0){ |
| | | updateNum++; |
| | | if (isCovered) { |
| | | // 更新 |
| | | disputeRecordEntity.setId(list.get(0).getId()); |
| | | // 更新 |
| | | updateById(disputeRecordEntity); |
| | | importNum++; |
| | | } |
| | | }else { |
| | | // 插入 |
| | | save(disputeRecordEntity); |
| | | importNum ++; |
| | | } |
| | | } |
| | | StringBuilder builder = new StringBuilder("导入完成!"); |
| | | builder.append("其中本次表格共有 ").append(totalNum).append(" 条数据,") |
| | | .append("成功导入 ").append(importNum).append(" 条数据。"); |
| | | if (updateNum>0) { |
| | | builder.append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | } |
| | | if (errorNum>0){ |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无地址信息未导入!"); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 导出矛盾纠纷记录表 |
| | | * @param disputeRecord |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ExportDisputeRecordExcel> exportDisputeRecordList(DisputeRecordVO disputeRecord) { |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(DisputeRecordVO.class, disputeRecord); |
| | | return baseMapper.exportDisputeRecordList( |
| | | disputeRecord, |
| | | commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getGridCodeList()); |
| | | } |
| | | |
| | | /** |
| | | * e呼即办数据临时转换到矛盾纠纷 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void eCallToDis() { |
| | | // 查询所有的e 呼即办数据 |
| | | IECallEventService callEventService = SpringUtils.getBean(IECallEventService.class); |
| | | IDictBizService dictBizService = SpringUtils.getBean(IDictBizService.class); |
| | | // 查询所有 |
| | | QueryWrapper<ECallEventEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0); |
| | | List<ECallEventEntity> eCallEventEntityList = callEventService.list(queryWrapper); |
| | | // 遍历处理 |
| | | for (ECallEventEntity eCallEventEntity : eCallEventEntityList) { |
| | | if (eCallEventEntity.getName().contains("纠纷")) { |
| | | DisputeRecordEntity disputeRecordEntity = new DisputeRecordEntity(); |
| | | disputeRecordEntity.setAddress(eCallEventEntity.getAddress()); |
| | | disputeRecordEntity.setLng(eCallEventEntity.getLng()); |
| | | disputeRecordEntity.setLat(eCallEventEntity.getLat()); |
| | | disputeRecordEntity.setEventTime(eCallEventEntity.getOccurrenceTime()); |
| | | disputeRecordEntity.setDisputeContent(eCallEventEntity.getRemark()); |
| | | disputeRecordEntity.setAddress(eCallEventEntity.getAddress()); |
| | | // 设置处置结果,暂时放在受伤结果里面 |
| | | disputeRecordEntity.setInjuryDesc(eCallEventEntity.getDisRes()); |
| | | // 设置网格,警格编号 |
| | | GridSet gridSet |
| | | = new GridSet().invoke(DisputeRecordEntity.class, disputeRecordEntity, "lng", "lat", "gridCode", "jwGridCode"); |
| | | // 纠纷类型转换 |
| | | QueryWrapper<DictBiz> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("code", "disputeType").eq("is_deleted", 0).eq("dict_value", eCallEventEntity.getName()); |
| | | DictBiz one = dictBizService.getOne(wrapper); |
| | | if (null!=one){ |
| | | disputeRecordEntity.setDisputeType(Integer.parseInt(one.getDictKey())); |
| | | }else { |
| | | // 设置为其他纠纷 |
| | | disputeRecordEntity.setDisputeType(8); |
| | | } |
| | | // 保存 |
| | | save(disputeRecordEntity); |
| | | } |
| | | } |
| | | } |
| | | } |