| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.exception.CustomException; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.param.GridSet; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.common.utils.WordToPdfUtils; |
| | | import org.springblade.core.oss.model.BladeFile; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.resource.builder.oss.OssBuilder; |
| | | import org.springblade.modules.task.entity.TaskNoFraudReportingEntity; |
| | | import org.springblade.modules.task.entity.TaskPlaceRecordEntity; |
| | | import org.springblade.modules.task.excel.TaskNoExplosionExcel; |
| | |
| | | import org.springblade.modules.task.service.ITaskService; |
| | | import org.springblade.modules.task.vo.TaskNoFraudReportingVO; |
| | | import org.springblade.modules.task.vo.TaskPlaceRecordVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Service |
| | | public class TaskNoFraudReportingServiceImpl extends ServiceImpl<TaskNoFraudReportingMapper, TaskNoFraudReportingEntity> implements ITaskNoFraudReportingService { |
| | | |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(TaskNoFraudReportingServiceImpl.class); |
| | | |
| | | /** |
| | | * 对象存储构建类 |
| | | */ |
| | | @Autowired |
| | | private OssBuilder ossBuilder; |
| | | |
| | | @Override |
| | | public IPage<TaskNoFraudReportingVO> selectTaskNoFraudReportingPage(IPage<TaskNoFraudReportingVO> page, TaskNoFraudReportingVO taskNoFraudReporting) { |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskNoFraudReportingVO.class, taskNoFraudReporting); |
| | |
| | | commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getGridCodeList()); |
| | | // 上报数量 |
| | | for (TaskNoFraudReportingVO taskNoFraudReportingVO : taskNoFraudReportingVOS) { |
| | | int number = 0; |
| | | for (TaskPlaceRecordVO patrolRecord : taskNoFraudReportingVO.getTaskPlaceRecordVOList()) { |
| | | if (StringUtils.isNotBlank(patrolRecord.getImageUrls())) { |
| | | number++; |
| | | } |
| | | } |
| | | taskNoFraudReportingVO.setNumber(number); |
| | | } |
| | | return page.setRecords(taskNoFraudReportingVOS); |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectTaskNoFraudReportingCount(TaskNoFraudReportingVO taskNoFraudReporting) { |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskNoFraudReportingVO.class, taskNoFraudReporting); |
| | | Integer count = baseMapper.selectTaskNoFraudReportingCount( |
| | | taskNoFraudReporting, |
| | | commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getGridCodeList()); |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return false; |
| | | } |
| | | taskNoFraudReporting.setTaskId(aLong); |
| | | // 计算网格 |
| | | if (StringUtils.isNotBlank(taskNoFraudReporting.getLng()) && StringUtils.isNotBlank(taskNoFraudReporting.getLat())) { |
| | | // 点落面计算警格,网格,警格 |
| | | GridSet invoke = new GridSet().invoke(TaskNoFraudReportingVO.class, taskNoFraudReporting, |
| | | "lng", "lat", "gridCode", "jwGridCode"); |
| | | } |
| | | // 2.保存任务详情 |
| | | boolean save = save(taskNoFraudReporting); |
| | | if (save) { |
| | |
| | | item.setTaskPlaceSelfCheckId(taskNoFraudReporting.getId()); |
| | | item.setCreateUser(AuthUtil.getUserId()); |
| | | item.setType("2"); |
| | | // 判断是否有生成pdf |
| | | if (StringUtils.isBlank(item.getPdfPath()) && StringUtils.isNotBlank(item.getImageUrls())) { |
| | | // 生成pdf |
| | | String filePath; |
| | | FileInputStream file = null; |
| | | try { |
| | | // filePath = WordToPdfUtils.wordToPdf(item.getOriginalName(), item.getImageUrls()); |
| | | // file = new FileInputStream(filePath); |
| | | // BladeFile bladeFile = ossBuilder.template().putFile(item.getOriginalName(), file); |
| | | // item.setPdfPath(bladeFile.getLink()); |
| | | } catch (Exception e) { |
| | | logger.error("生成pdf失败", e); |
| | | // throw new RuntimeException(e); |
| | | } finally { |
| | | if (file != null) { |
| | | try { |
| | | file.close(); |
| | | } catch (IOException e) { |
| | | logger.error("关闭流异常", e); |
| | | /* 异常处理 */ |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | List<TaskPlaceRecordEntity> collect = taskPlaceRecordList.stream().filter(item -> StringUtils.isNotBlank(item.getImageUrls())).collect(Collectors.toList()); |
| | | List<TaskPlaceRecordEntity> collect = taskPlaceRecordList.stream().collect(Collectors.toList()); |
| | | if (collect.size() > 0) { |
| | | bean.saveBatch(collect); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 更新 |
| | | * |
| | | * @param taskNoFraudReporting |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateTaskNoFraudReporting(TaskNoFraudReportingVO taskNoFraudReporting){ |
| | | public Boolean updateTaskNoFraudReporting(TaskNoFraudReportingVO taskNoFraudReporting) { |
| | | // 1.更新任务表 |
| | | ITaskService taskService = SpringUtils.getBean(ITaskService.class); |
| | | Long aLong = taskService.updateTask(null, null, null, taskNoFraudReporting.getReasonFailure(), AuthUtil.getUserId(), taskNoFraudReporting.getTaskId(), taskNoFraudReporting.getStatus()); |
| | |
| | | List<TaskPlaceRecordEntity> recordEntityList = BeanUtil.copy(taskPlaceRecordList, TaskPlaceRecordEntity.class); |
| | | for (TaskPlaceRecordEntity taskPlaceRecordEntity : recordEntityList) { |
| | | taskPlaceRecordEntity.setType("2"); |
| | | // 判断是否有生成pdf |
| | | if (StringUtils.isBlank(taskPlaceRecordEntity.getPdfPath()) && StringUtils.isNotBlank(taskPlaceRecordEntity.getImageUrls())) { |
| | | // 生成pdf |
| | | String filePath; |
| | | try { |
| | | // filePath = WordToPdfUtils.wordToPdf(taskPlaceRecordEntity.getOriginalName(), taskPlaceRecordEntity.getImageUrls()); |
| | | // FileInputStream file = new FileInputStream(filePath); |
| | | // BladeFile bladeFile = ossBuilder.template().putFile(taskPlaceRecordEntity.getOriginalName(), file); |
| | | // taskPlaceRecordEntity.setPdfPath(bladeFile.getLink()); |
| | | } catch (Exception e) { |
| | | logger.error("生成pdf失败", e); |
| | | // throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | boolean result = bean.saveOrUpdateBatch(recordEntityList); |
| | | if (result) { |