diff --git a/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/urk/ImageResizer.java b/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/urk/ImageResizer.java index b14ea43..763494b 100644 --- a/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/urk/ImageResizer.java +++ b/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/urk/ImageResizer.java @@ -29,66 +29,6 @@ public class ImageResizer { - /** - * 将bast64转成需要的图片格式 - * @param filePath - * @param file - * @param - * @return - */ - public static String transImageByJpg(String filePath, File file ){ - try{ - String suffix=".png"; - String path="/temp/"; - File folder = new File(filePath+path); - if (folder.exists() && folder.isDirectory()) { - System.out.println("文件夹存在"); - } else { - folder.mkdir(); - System.out.println("文件夹不存在"); - } - // 创建临时文件,将bast64转成字节流 - // 创建临时文件,确保文件名具有唯一性 - // 将字节数据写入文件 - String newJpgPath=null; - //不是jpg的先转成jpg的 - getFileType(); - if (!fileType.contains(suffix)){ - String roundId2= StringUtils.randomUUID(); - //jpg的路径 - newJpgPath=filePath+path+roundId2+".jpg"; - BufferedImage pngImage = ImageIO.read(file); - BufferedImage jpgImage = new BufferedImage(pngImage.getWidth(), pngImage.getHeight(), BufferedImage.TYPE_INT_RGB); - // 绘制PNG图片到jpgImage - jpgImage.createGraphics().drawImage(pngImage, 0, 0, Color.WHITE, null); - ImageIO.write(jpgImage, "jpg", new File(newJpgPath)); - } - // - File inputFile; - //是jpg格式的 - if(newJpgPath==null){ - inputFile=file; - }else{ - inputFile = new File(newJpgPath); - } - BufferedImage originalImage = ImageIO.read(inputFile); - BufferedImage resizedImage = resizeImage(originalImage, 1080, 800); - // 保存为PNG格式 - String roundId3= StringUtils.randomUUID(); - String lastPath=filePath+path+roundId3+".jpg"; - saveImage(resizedImage, "jpg", lastPath); - if(newJpgPath!=null){ - boolean isde=new File(newJpgPath).delete(); - System.err.println("删除->"+isde); - } -// boolean delete=file.delete(); -// System.err.println("删除->"+delete); - return lastPath; - }catch (Exception e){ - log.error(e.toString(),e); - } - return null; - } /** * 将bast64转成需要的图片格式 @@ -99,8 +39,15 @@ public class ImageResizer { */ public static String transImageByJpg( String bast64){ try{ + +// byte[] decodedBytes = Base64.getDecoder().decode(bast64); +// // 计算字节数组的大小 +// long sizeInBytes = decodedBytes.length; +// if(sizeInBytes<1024*1024*0.5){ +// return bast64; +// } String path=""; - String suffix=".png"; + String suffix=".jpg"; String roundId=StringUtils.randomUUID(); String osName = System.getProperty("os.name").toLowerCase(); @@ -142,7 +89,7 @@ public class ImageResizer { inputFile = new File(newJpgPath); } BufferedImage originalImage = ImageIO.read(inputFile); - BufferedImage resizedImage = resizeImage(originalImage, 480, 640); + BufferedImage resizedImage = resizeImage(originalImage, 640, 640); // 保存为PNG格式 String roundId3=StringUtils.randomUUID(); String lastPath=path+roundId3+".jpg"; diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/UrkSendServiceImpl.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/UrkSendServiceImpl.java index 4cc433b..9041ea4 100644 --- a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/UrkSendServiceImpl.java +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/UrkSendServiceImpl.java @@ -34,7 +34,9 @@ public class UrkSendServiceImpl implements UrkSendService { /** * 默认分页数据 */ - public final static int PAGE_SIZE=10; + public final static int SET_USER_INFO_SIZE=5; + + public final static int PAGE_SIZE=25; /** * 考勤机 下发人员 * @param deviceCode @@ -203,7 +205,7 @@ public class UrkSendServiceImpl implements UrkSendService { public void sendUserToDeviceList(List userId,String key,int pageNum, int type,BmwKqCmdTaskVo taskVo){ List list ; - PageHelper.startPage(pageNum, PAGE_SIZE); + PageHelper.startPage(pageNum, SET_USER_INFO_SIZE); String proId=key.split("-")[0]; String teamId=key.split("-")[2]; String supId=key.split("-")[1]; @@ -219,12 +221,12 @@ public class UrkSendServiceImpl implements UrkSendService { list=mapper.getDeviceVoByProId(Integer.parseInt(proId),Integer.parseInt(teamId),Integer.parseInt(supId)); if(StringUtils.isEmpty(list)){ type=2; - PageHelper.startPage(pageNum, PAGE_SIZE); + PageHelper.startPage(pageNum, SET_USER_INFO_SIZE); list=mapper.getDeviceVoByProId(Integer.parseInt(proId),Integer.parseInt(teamId),0); } if(StringUtils.isEmpty(list)) { type=3; - PageHelper.startPage(pageNum, PAGE_SIZE); + PageHelper.startPage(pageNum, SET_USER_INFO_SIZE); list=mapper.getDeviceVoByProId(Integer.parseInt(proId), 0, 0); } } @@ -284,7 +286,7 @@ public class UrkSendServiceImpl implements UrkSendService { * @param taskVo */ public void getUserSendToDev(int proId,int subId,int teamId,int pageNum, BmwKqCmdTaskVo taskVo) { - PageHelper.startPage(pageNum, PAGE_SIZE); + PageHelper.startPage(pageNum, SET_USER_INFO_SIZE); //依据工程班组分包 查询在场人员 List list=mapper.getOnSiteUser(proId,subId,teamId); PageInfo pageInfo =new PageInfo(list); @@ -315,7 +317,7 @@ public class UrkSendServiceImpl implements UrkSendService { */ public void sendUserToDevice(int userId,int proId,int supId,int teamId,int pageNum, int type,BmwKqCmdTaskVo taskVo){ List list; - PageHelper.startPage(pageNum,PAGE_SIZE); + PageHelper.startPage(pageNum,SET_USER_INFO_SIZE); if(type==1){ list=mapper.getDeviceVoByProId(proId,supId,teamId); }else if(type==2){ @@ -328,12 +330,12 @@ public class UrkSendServiceImpl implements UrkSendService { list=mapper.getDeviceVoByProId(proId,supId,teamId); if(StringUtils.isEmpty(list)){ type=2; - PageHelper.startPage(pageNum,PAGE_SIZE); + PageHelper.startPage(pageNum,SET_USER_INFO_SIZE); list=mapper.getDeviceVoByProId(proId,supId,0); } if(StringUtils.isEmpty(list)){ type=3; - PageHelper.startPage(pageNum,PAGE_SIZE); + PageHelper.startPage(pageNum,SET_USER_INFO_SIZE); list=mapper.getDeviceVoByProId(proId,0,0); } }