青羊经侦大队-数据平台
wl
2022-07-19 df8b1094a09897b3f881529a31db8893d298ed12
src/main/java/com/example/jz/service/impl/ReportServiceImpl.java
@@ -13,10 +13,13 @@
import com.example.jz.dao.GroupDao;
import com.example.jz.dao.GroupUserDao;
import com.example.jz.dao.ReportDao;
import com.example.jz.dao.UserDao;
import com.example.jz.modle.dto.AddReportDto;
import com.example.jz.modle.dto.ReportParamDto;
import com.example.jz.modle.entity.Group;
import com.example.jz.modle.entity.GroupUser;
import com.example.jz.modle.entity.Report;
import com.example.jz.modle.entity.User;
import com.example.jz.modle.vo.ReportListVo;
import com.example.jz.dao.*;
import com.example.jz.modle.entity.*;
@@ -24,6 +27,7 @@
import com.example.jz.service.MinIOService;
import com.example.jz.service.ReportService;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -109,16 +113,28 @@
                    ArrayList<ImageData> imageDataList = new ArrayList<>();
                    if (StringUtils.isNotBlank(a.getReportMaterials())) {
                        String[] urls = a.getReportMaterials().split(",");
                        for (int i = 0; i < urls.length; i++) {
                        if (urls.length==1){
                            int width=600;
                            try {
                                ImageData imageData = new ImageData();
                                imageData.setImage(IoUtils.toByteArray(new URL(minIOService.getPreviewFileUrl(urls[i])).openConnection().getInputStream()));
                                imageData.setLeft(width/ urls.length*i);
                                imageData.setRight(width-width/ urls.length*(i+1));
                                imageData.setImage(IoUtils.toByteArray(new URL(minIOService.getPreviewFileUrl(urls[0])).openConnection().getInputStream()));
                                imageData.setRight(width/2);
                                imageDataList.add(imageData);
                            } catch (Exception e) {
                                throw new RuntimeException(e);
                            }
                        }else {
                            for (int i = 0; i < urls.length; i++) {
                                int width = 600;
                                try {
                                    ImageData imageData = new ImageData();
                                    imageData.setImage(IoUtils.toByteArray(new URL(minIOService.getPreviewFileUrl(urls[i])).openConnection().getInputStream()));
                                    imageData.setLeft(width / urls.length * i);
                                    imageData.setRight(width - width / urls.length * (i + 1));
                                    imageDataList.add(imageData);
                                } catch (Exception e) {
                                    throw new RuntimeException(e);
                                }
                            }
                        }
                        }
@@ -152,5 +168,27 @@
        aaa.getRecords().stream().forEach(x -> x.setIdcard(x.getIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*")));
        return aaa;
    }
    @Override
    @Transactional
    public Boolean addReport(AddReportDto addReportDto) {
        User user = userDao.selectOne(new LambdaQueryWrapper<User>(User.class).eq(User::getUserIdcard, addReportDto.getIdcard()));
        if (user == null) {
            // 如果用户不存在 则添加用户
            user = new User().setUserIdcard(addReportDto.getIdcard()).setUserMobile(addReportDto.getMobile()).setRealName(addReportDto.getReporterName())
                    .setModifyTime(new Date()).setUserRegtime(new Date()).setPic(addReportDto.getPic());
            userDao.insert(user);
        }
        // 添加报案信息
        Report report = new Report();
        BeanUtils.copyProperties(addReportDto, report);
        report
                .setUserId(user.getId())
                .setCtime(new Date())
                .setStatus(0)
                .setReportMethod("现场录入")
                .setIsCommission("0").setReportTime(new Date());
        return reportDao.insert(report) > 0;
    }
}