| | |
| | | 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) { |
| | |
| | | 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().collect(Collectors.toList()); |
| | | if (collect.size() > 0) { |
| | |
| | | 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) { |