| | |
| | | public static final String USER_CARD_HEADER_IMG ="USER_CARD_HEADER_IMG" ; |
| | | public static final String USER_CARD_PHONE_IMG ="USER_CARD_PHONE_IMG" ; |
| | | public static final String USER_CARD_ADDR_IMG ="USER_CARD_ADDR_IMG" ; |
| | | public static final String USER_CARD_SHOP_IMG ="USER_CARD_SHOP_IMG" ; |
| | | public static final String USER_CARD_LOGO_IMG ="USER_CARD_LOGO_IMG" ; |
| | | |
| | | public static Integer parseIntByStr(String idtOrgStatus) { |
| | | try { |
| | |
| | | } |
| | | |
| | | private static final int width = 750; |
| | | private static final int height = 1140; |
| | | private static final int height = 1194; |
| | | |
| | | /** |
| | | * 生成分享图片 |
| | |
| | | } |
| | | return resMatrix; |
| | | } |
| | | public static InputStream generateUserCardImg(String imgurl, String qrcode, String name,String type, String phone, String shopaddr, String shopname,String phoneIcon,String addrIcon) { |
| | | public static InputStream generateUserCardImg(String imgurl, String qrcode, String name,String type, String phone |
| | | , String shopaddr, String shopname |
| | | ,String phoneIcon |
| | | ,String addrIcon |
| | | ,String shopIcon |
| | | ,String logoIcon) { |
| | | |
| | | BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| | | BufferedImage bi = new BufferedImage(750, 1194, BufferedImage.TYPE_INT_RGB); |
| | | //得到它的绘制环境(这张图片的笔) |
| | | Graphics2D g2 = (Graphics2D) bi.getGraphics(); |
| | | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2.fillRect(0, 0, width, height); |
| | | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
| | | g2.fillRect(0, 0, 750, 1194); |
| | | //背景图片 |
| | | BufferedImage img1 =getImgIO(imgurl); |
| | | if(img1!=null){ |
| | | int w = img1.getWidth(); |
| | | int h = img1.getHeight(); |
| | | int h1 = (int)((double)w *700/750); |
| | | int w1 = (int)((double)h *750/700); |
| | | if(h>h1){ |
| | | h = h1; |
| | | } |
| | | if(w>w1){ |
| | | w = w1; |
| | | } |
| | | img1 = img1.getSubimage(0,0,w,h); |
| | | g2.drawImage(img1, 0, 0, 750, 700, null); |
| | | }else{ |
| | | g2.setColor(new Color(102, 102, 102, 1)); |
| | | g2.drawRect( 0, 0, 750, 700); |
| | | } |
| | | |
| | | //商品名称 |
| | | int th = 30; |
| | | //名称 |
| | | if(name.length()>5){ |
| | | name = name.substring(0,5)+"..."; |
| | | } |
| | | g2.setColor(Color.black); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 40)); |
| | | g2.drawString(name, 40, 990-242); |
| | | g2.drawString(name, 40, 742+th); |
| | | |
| | | int w = 40+ name.length()*40; |
| | | g2.setColor(Color.GRAY); |
| | | int w = 60+ name.length()* 40; |
| | | g2.setColor(new Color(176, 135, 113)); |
| | | g2.drawRoundRect(w,744-10,85,50,15,15);//画一个圆角矩形 |
| | | |
| | | g2.setColor(new Color(176, 135, 113)); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(type, w, 990-242); |
| | | g2.drawString(type, w+12, 741+th); |
| | | |
| | | if(StringUtils.isNotBlank(qrcode)){ |
| | | //个人二维码 |
| | | BufferedImage img2 = getImgIO(qrcode); |
| | | if(img2!=null){ |
| | | g2.drawImage(img2, 522, 982-242, 188, 188, null); |
| | | g2.drawImage(img2, 522, 740, 188, 188, null); |
| | | } |
| | | |
| | | g2.setColor(Color.GRAY); |
| | | g2.setColor(new Color(176, 135, 113)); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 24)); |
| | | g2.drawString("扫码添加好友", 544, 1186-242); |
| | | g2.drawString("扫码添加好友", 544, 944+th); |
| | | } |
| | | |
| | | //手机号 |
| | | BufferedImage img4 = getImgIO(phoneIcon); |
| | | if(img4!=null){ |
| | | g2.drawImage(img4, 40, 1072-28-242, 34, 36, null); |
| | | g2.drawImage(img4, 40, 830 , 34, 36, null); |
| | | } |
| | | g2.setColor(Color.GRAY); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(phone, 94, 1072-242); |
| | | g2.drawString(phone, 94, 828+th); |
| | | //门店名称 |
| | | BufferedImage img5 = getImgIO(shopIcon); |
| | | if(img4!=null){ |
| | | g2.drawImage(img5, 40, 904 , 34, 36, null); |
| | | } |
| | | if(shopname.length()>11){ |
| | | shopname = shopname.substring(0,11)+"..."; |
| | | } |
| | | g2.setColor(Color.GRAY); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(shopname, 94,901+th); |
| | | |
| | | |
| | | BufferedImage img3 = getImgIO(addrIcon); |
| | | if(img3!=null){ |
| | | g2.drawImage(img3, 40, 1142-28-242, 34, 36, null); |
| | | g2.drawImage(img3, 40, 980, 34, 36, null); |
| | | } |
| | | if(shopaddr.length()>12){ |
| | | shopaddr = shopaddr.substring(0,12)+"\n"+shopaddr.substring(12); |
| | | } |
| | | //地址 |
| | | g2.setColor(Color.GRAY); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(shopaddr, 94, 1142-242); |
| | | |
| | | dealDrawShopAddr(g2,94,973+th,shopaddr); |
| | | //底部 |
| | | if(shopname.length()>15){ |
| | | shopname = shopname.substring(0,15)+"..."; |
| | | |
| | | BufferedImage img6 = getImgIO(logoIcon); |
| | | if(img6!=null){ |
| | | g2.drawImage(img6, 254, 1126+th-20, 242, 28, null); |
| | | } |
| | | g2.setColor(Color.GRAY); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(shopname, 180, 1300-242); |
| | | |
| | | InputStream inputStream = bufferedImageToInputStream(bi); |
| | | return inputStream; |
| | | } |
| | | |
| | | private static void dealDrawShopAddr(Graphics2D g2, int x, int y, String shopaddr) { |
| | | int num =shopaddr.length() / 13; |
| | | for (int i = 0; i <= num; i++) { |
| | | String temp =""; |
| | | if(shopaddr.length() >= (i+1)*13){ |
| | | temp = shopaddr.substring(i*13,(i+1)*13); |
| | | }else{ |
| | | temp=shopaddr.substring( i*13); |
| | | } |
| | | //地址 |
| | | g2.setColor(Color.GRAY); |
| | | g2.setFont(new Font("黑体", Font.PLAIN, 30)); |
| | | g2.drawString(temp, x, y+i*40); |
| | | } |
| | | } |
| | | |
| | | private static BufferedImage getImgIO(String imgurl) { |
| | | try { |
| | | return ImageIO.read(new URL(imgurl)); |
| | |
| | | @ApiModelProperty(value = "邮箱") |
| | | @ExcelColumn(name="邮箱") |
| | | private String email; |
| | | @ApiModelProperty(value = "名片") |
| | | @ExcelColumn(name="名片") |
| | | private String cardImg; |
| | | |
| | | @ApiModelProperty(value = "用户类型,区分HR内部员工和加盟商员工,10001加盟商,10002HR内部员工,多个使用英文逗号隔开") |
| | | @ExcelColumn(name="用户类型,区分HR内部员工和加盟商员工,10001加盟商,10002HR内部员工,多个使用英文逗号隔开") |
| | |
| | | |
| | | @Override |
| | | public Users findById(Long id) { |
| | | return usersMapper.selectById(id); |
| | | MPJLambdaWrapper<Users> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.leftJoin(Shop.class,Shop::getId,Users::getDepartmentId) |
| | | .selectAs(Shop::getName,Users::getShopName) |
| | | .selectAs(Shop::getAddress,Users::getShopAddress) |
| | | .selectAs(Shop::getType,Users::getShopType) |
| | | .selectAs(Shop::getSecondType,Users::getShopSecType) |
| | | .selectAll(Users.class) |
| | | .eq(Users::getId,id); |
| | | return usersMapper.selectJoinOne(Users.class,queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public String getUserCard(Users users){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.RESOURCE_PATH).getCode(); |
| | | String folder = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.USERS_FILE).getCode(); |
| | | if(StringUtils.isNotBlank(users.getCardImg()) && !StringUtils.equals(users.getCardImg(),"-")){ |
| | | return path + folder+users.getCardImg(); |
| | | } |
| | | String defualtHeader = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_HEADER_IMG).getCode(); |
| | | String defualtPhone = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_PHONE_IMG).getCode(); |
| | | String defualtAddr = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_ADDR_IMG).getCode(); |
| | | String imgurl =StringUtils.isNotBlank(users.getImgurl())?path+users.getImgurl():defualtHeader; |
| | | String qrcode =StringUtils.isNotBlank(users.getQrcodeImg())?path+users.getQrcodeImg():null; |
| | | String defualtShop = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_SHOP_IMG).getCode(); |
| | | String defualtLogo = systemDictDataBiz.queryByCode(Constants.WEIXIN_DEFAULT_IMGS, Constants.USER_CARD_LOGO_IMG).getCode(); |
| | | String imgurl =StringUtils.isNotBlank(users.getImgurl())?path+folder+users.getImgurl():defualtHeader; |
| | | String qrcode =StringUtils.isNotBlank(users.getQrcodeImg())?path+folder+users.getQrcodeImg():null; |
| | | InputStream inputStream = GeneratePicUtil.generateUserCardImg( |
| | | imgurl |
| | | ,qrcode |
| | |
| | | ,"导购" |
| | | ,StringUtils.defaultString(users.getPhone(),"-") |
| | | ,StringUtils.defaultString(users.getShopAddress(),"-") |
| | | ,"ZBOM志邦家居|"+ StringUtils.defaultString(users.getShopName(),"-") |
| | | , StringUtils.defaultString(users.getShopName(),"-") |
| | | ,defualtPhone |
| | | ,defualtAddr); |
| | | ,defualtAddr |
| | | ,defualtShop |
| | | ,defualtLogo); |
| | | TyyZosUtil obs = new TyyZosUtil( systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ENDPOINT).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ACCESS_ID).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.ACCESS_KEY).getCode()); |
| | | String fileName =folder+ DateUtil.getNowShortDate()+"/"+UUID.randomUUID().toString() + ".jpg"; |
| | | String key = DateUtil.getNowShortDate()+"/"+UUID.randomUUID().toString() + ".jpg"; |
| | | String fileName =folder+ key; |
| | | if (obs.uploadInputstreamObject(inputStream,systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.BUCKETNAME).getCode(), fileName)) { |
| | | Users update = new Users(); |
| | | update.setId(users.getId()); |
| | | update.setCardImg(key); |
| | | usersMapper.updateById(update); |
| | | return path+fileName; |
| | | } |
| | | return null; |