Explorar o código

批量生成图片 批量保存等功能

xiao547607 %!s(int64=4) %!d(string=hai) anos
pai
achega
2bd30a304b

+ 60 - 0
common/src/main/java/com/jpsoft/campus/modules/common/utils/OSSUtil.java

@@ -438,4 +438,64 @@ public class OSSUtil {
             }
         }
     }
+
+
+
+    public static String uploadOfferImg(OSSConfig ossConfig,
+                                String subFolder, String fileName,
+                                String outImgUrl,String offerCode,String personName,
+                                        String userName,String schoolName) {
+        String retUrl = "";
+
+        try {
+            File _file = new File(outImgUrl);
+            Image srcImage = ImageIO.read(_file);
+            int imageWidth = srcImage.getWidth(null);
+            int imageHeight = srcImage.getHeight(null);
+
+            int fontHeight = imageHeight / 20;
+
+            fontHeight = Math.min(30, fontHeight);
+
+            Color color = new Color(128, 128, 128, 200);   // 水印颜色
+            Font font = new Font("宋体", Font.ITALIC, fontHeight);  //水印字体
+
+            BufferedImage bufferedImage = new BufferedImage(
+                    srcImage.getWidth(null), srcImage.getHeight(null),
+                    BufferedImage.TYPE_INT_RGB);
+
+            Graphics2D g = bufferedImage.createGraphics();
+
+            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+            g.drawImage(srcImage.getScaledInstance(imageWidth, imageHeight, Image.SCALE_SMOOTH), 0,
+                    0, null);
+
+            g.setColor(color); //水印颜色
+            g.setFont(font); //水印字体
+
+            int markWidth = g.getFontMetrics(g.getFont()).charsWidth(offerCode.toCharArray(), 0, offerCode.length());
+
+            g.rotate(Math.toRadians(-45), imageWidth / 2, imageHeight / 2);
+
+            for (int i=0;i<imageHeight/3;i++) {
+                g.drawString(offerCode, (imageWidth - markWidth) / 2, imageHeight*i/3); //水印位置
+            }
+
+            g.dispose(); //释放资源
+
+            ByteArrayOutputStream outImgStream = new ByteArrayOutputStream();
+            ImageIO.write(bufferedImage, "jpg", outImgStream);
+
+            byte[] outImg = outImgStream.toByteArray();
+
+            ByteArrayInputStream inputImgStream = new ByteArrayInputStream(outImg);
+
+            retUrl = upload(ossConfig,subFolder,fileName,inputImgStream);
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+        }
+
+        return retUrl;
+    }
 }

+ 7 - 0
common/src/main/java/com/jpsoft/campus/modules/common/utils/WeixinUtil.java

@@ -106,6 +106,11 @@ public class WeixinUtil {
 		AccessToken accessToken = null;
 
 		String requestUrl = tokenUrl.replace("APPID", appid).replace("APPSECRET", appsecret);
+//			String commonAccessTokenUrl = "http://ykt.xiaoxinda.com/weixin/token"
+//			String requestUrl = commonAccessTokenUrl
+//					+ "?grant_type=client_credential"
+//					+ "&appid=" + appid
+//					+ "&secret=" + appsecret;
 		JSONObject jsonObject =HttpConnectionUtil.httpRequest(requestUrl, "GET", null);
 		// 如果请求成功
 		if (null != jsonObject) {
@@ -120,6 +125,8 @@ public class WeixinUtil {
 				log.error("获取token失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
 			}
 		}
+
+
 		return accessToken;
 	}
 

+ 116 - 96
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationMiddleController.java

@@ -19,8 +19,6 @@ import com.jpsoft.campus.modules.sys.entity.User;
 import com.jpsoft.campus.modules.sys.service.DataDictionaryService;
 import com.jpsoft.campus.modules.sys.service.UserRoleService;
 import com.jpsoft.campus.modules.sys.service.UserService;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -1348,11 +1346,16 @@ public class ApplicationMiddleController {
 
         try {
             ApplicationMiddle applicationMiddle = applicationMiddleService.get(id);
+            User user = userService.get(subject);
 
             ApprovalInfo approvalInfo = new ApprovalInfo();
             approvalInfo.setId(UUID.randomUUID().toString());
             approvalInfo.setApplicationId(id);
-            approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus())+":" + typeValue);
+            if("90".equals(status)) {
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus()));
+            }else{
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus())+":" + typeValue);
+            }
             approvalInfo.setRemark(remark);
             approvalInfo.setFileUrl("");
             approvalInfo.setDelFlag(false);
@@ -1393,24 +1396,32 @@ public class ApplicationMiddleController {
                     off.setEnrollmentType("2");//中学
                     off.setSchoolId(applicationMiddle.getSchoolId());
                     off.setSerialNum(serialNum);
-
                     off.setCode(code);
-                    off.setDelFlag(false);
-                    off.setCreateBy(subject);
-                    off.setCreateTime(new Date());
-                    offerInfoService.insert(off);
 
                     applicationMiddle.setOfferCode(code);
 
-                    applicationMiddle.setOfferCode(code);
                     SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getSchoolId());
                     PersonInfo personInfo = personInfoService.get(applicationMiddle.getPersonId());
                     StudentInfo studentInfo = studentInfoService.get(applicationMiddle.getStudentId());
                     String bdUrl = toPressText(code,personInfo.getName(),studentInfo.getName(), schoolInfo.getName());
                     String uploadUrl = uploadImg(bdUrl);
-                    applicationMiddle.setOfferImg(uploadUrl);
-                    String content =  "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
-                    sendMessage(content,applicationMiddle.getPersonId());
+                    if(StringUtils.isNotEmpty(uploadUrl)) {
+                        off.setDelFlag(false);
+                        off.setCreateBy(subject);
+                        off.setCreateTime(new Date());
+                        offerInfoService.insert(off);
+                        applicationMiddle.setOfferImg(uploadUrl);
+                        new Thread(() -> {
+                            try {
+                                String content =  "尊敬的家长您好,您的报名申请已通过,请前往“荆州开发区网上入学”--报名查询,下载电子版入学通知书。";
+                                sendMessage(content,applicationMiddle.getPersonId(),user.getRealName());
+                            } catch (Exception ex) {
+                                ex.printStackTrace();
+                            }
+                        }).start();
+                    }else{
+                        applicationMiddle.setStatus("80");
+                    }
                 }
                 applicationMiddleService.update(applicationMiddle);
 
@@ -1549,18 +1560,14 @@ public class ApplicationMiddleController {
             }else if("70".equals(applicationMiddle.getStatus())){
                 //微信消息推送 发送预录取通知
                 applicationMiddle.setStatus(nextStatus);
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-                String backDate = sdf.format(new Date());
-//                SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
-                String backRemark = "";
-                PersonInfo pi = personInfoService.get(applicationMiddle.getPersonId());
-                String appId = wechatConfig.getAppId();
-                String appSecret = wechatConfig.getAppSecret();
-
-                boolean messageResult = WechatMessageUtil.sendMessageTemplate(
-                        user.getUserName(),"尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。",
-                        backRemark,backDate,pi.getOpenId(),
-                        wechatConfig.getBackNoticeTemplateId(),wechatConfig.getTokenUrl(),appId,appSecret);
+//                new Thread(() -> {
+//                        try {
+//                            String content =  "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
+//                            sendMessage(content,applicationMiddle.getPersonId(),user.getRealName());
+//                        } catch (Exception ex) {
+//                            ex.printStackTrace();
+//                        }
+//                    }).start();
             }else if("80".equals(applicationMiddle.getStatus())){
                 //微信消息推送 发送完成录取通知
                 applicationMiddle.setStatus(nextStatus);
@@ -1582,26 +1589,29 @@ public class ApplicationMiddleController {
                 off.setSchoolId(applicationMiddle.getSchoolId());
                 off.setSerialNum(serialNum);
                 off.setCode(code);
-                off.setDelFlag(false);
-                off.setCreateBy(subject);
-                off.setCreateTime(new Date());
-                int oicount = offerInfoService.insert(off);
-
                 applicationMiddle.setOfferCode(code);
 
-                if(oicount > 0) {
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-                    String backDate = sdf.format(new Date());
-//                SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
-                    String backRemark = "";
-                    PersonInfo pi = personInfoService.get(applicationMiddle.getPersonId());
-                    String appId = wechatConfig.getAppId();
-                    String appSecret = wechatConfig.getAppSecret();
-
-                    boolean messageResult = WechatMessageUtil.sendMessageTemplate(
-                            user.getUserName(), "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。",
-                            backRemark, backDate, pi.getOpenId(),
-                            wechatConfig.getBackNoticeTemplateId(), wechatConfig.getTokenUrl(), appId, appSecret);
+                SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getSchoolId());
+                PersonInfo personInfo = personInfoService.get(applicationMiddle.getPersonId());
+                StudentInfo studentInfo = studentInfoService.get(applicationMiddle.getStudentId());
+                String bdUrl = toPressText(code, personInfo.getName(), studentInfo.getName(), schoolInfo.getName());
+                String uploadUrl = uploadImg(bdUrl);
+                if(StringUtils.isNotEmpty(uploadUrl)){
+                    off.setDelFlag(false);
+                    off.setCreateBy(subject);
+                    off.setCreateTime(new Date());
+                    offerInfoService.insert(off);
+                    applicationMiddle.setOfferImg(uploadUrl);
+                    new Thread(() -> {
+                        try {
+                            String content =  "尊敬的家长您好,您的报名申请已通过,请前往“荆州开发区网上入学”--报名查询,下载电子版入学通知书。";
+                            sendMessage(content,applicationMiddle.getPersonId(),user.getRealName());
+                        } catch (Exception ex) {
+                            ex.printStackTrace();
+                        }
+                    }).start();
+                }else{
+                    applicationMiddle.setStatus("80");
                 }
             }else{
                 applicationMiddle.setStatus(nextStatus);
@@ -1613,7 +1623,11 @@ public class ApplicationMiddleController {
             ApprovalInfo approvalInfo = new ApprovalInfo();
             approvalInfo.setId(UUID.randomUUID().toString());
             approvalInfo.setApplicationId(applicationMiddle.getId());
-            approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus())+":通过审核");
+            if("80".equals(status)) {
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus()));
+            }else{
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("中学招生审核流程",applicationMiddle.getStatus())+":通过审核");
+            }
             approvalInfo.setRemark("通过审核");
             approvalInfo.setFileUrl("");
             approvalInfo.setDelFlag(false);
@@ -1637,62 +1651,69 @@ public class ApplicationMiddleController {
     }
 
     public String toPressText(String offerCode,String personName,String userName,String schoolName){
-        String in = "static/primary_tzs.jpg";
-        String out = "uploadImg/primary_tzs_" + offerCode + ".jpg";
+        String in = "static/middle_tzs.jpg";
+        String out = "uploadImg/middle_tzs_" + offerCode + ".jpg";
         String inImg = Resource.class.getResource("/").getPath() + in;
         String outImg = Resource.class.getResource("/").getPath() + out;
-        try
-        {
-            FileInputStream fis = new FileInputStream(inImg);//创建输入流对象
-            FileOutputStream fos = new FileOutputStream(outImg); //创建输出流对象
-            byte datas[] = new byte[1024*8];//创建搬运工具
-            int len = 0;//创建长度
-            while((len = fis.read(datas))!=-1)//循环读取数据
-            {
-                fos.write(datas,0,len);
-            }
-            fis.close();//释放资源
-            fis.close();//释放资源
-        }
-        catch (Exception e)
-        {
+
+        try{
+            BufferedImage im =ImageIO.read(new FileInputStream(inImg));
+            int mothh = DateUtil.thisMonth() +1;
+            Graphics g = im.getGraphics();
+            g.setColor(new Color(0,0,0));
+            Font font = new Font("宋体",Font.PLAIN,40);  //设置字体
+            g.setFont(font);
+            Random ran = new Random();  // 随机位置
+            g.drawString(offerCode,1000,400);
+            g.drawString(personName,410,600);
+            g.drawString(userName,830,680);
+            g.drawString("8",730,940);
+            g.drawString("25",820,940);
+            g.drawString("8",980,940);
+            g.drawString("25",1050,940);
+            g.drawString(schoolName,580,1015);
+            g.drawString(mothh+"",1000,1590);
+            g.drawString(DateUtil.thisDayOfMonth()+"",1060,1590);
+            g.dispose();
+            ImageIO.write(im,"jpg",new File(outImg));
+        }catch (IOException e){
             e.printStackTrace();
         }
+        return outImg;
 
         //加水印
-        pressText(offerCode,outImg,"宋体",0,new Color(0,0,0),40,1000,400);
-        pressText(personName,outImg,"宋体",0,new Color(0,0,0),40,410,600);
-        pressText(userName,outImg,"宋体",0,new Color(0,0,0),40,830,680);
-        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,660,940);
-        pressText("25",outImg,"宋体",0,new Color(0,0,0),40,730,940);
-        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,890,940);
-        pressText("25",outImg,"宋体",0,new Color(0,0,0),40,970,940);
-        pressText(schoolName,outImg,"宋体",0,new Color(0,0,0),40,480,1015);
-        pressText(DateUtil.thisMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1000,1590);
-        pressText(DateUtil.thisDayOfMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1060,1590);
-        return outImg;
+//        pressText(offerCode,outImg,"宋体",0,new Color(0,0,0),40,1000,400);
+//        pressText(personName,outImg,"宋体",0,new Color(0,0,0),40,410,600);
+//        pressText(userName,outImg,"宋体",0,new Color(0,0,0),40,830,680);
+//        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,660,940);
+//        pressText("25",outImg,"宋体",0,new Color(0,0,0),40,730,940);
+//        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,890,940);
+//        pressText("25",outImg,"宋体",0,new Color(0,0,0),40,970,940);
+//        pressText(schoolName,outImg,"宋体",0,new Color(0,0,0),40,480,1015);
+//        pressText(DateUtil.thisMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1000,1590);
+//        pressText(DateUtil.thisDayOfMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1060,1590);
     }
 
     public void pressText(String pressText, String targetImg, String fontName, int fontStyle, Color color, int fontSize, int x, int y){
-        try{
-            File _file = new File(targetImg);
-            Image src = ImageIO.read(_file);
-            int weidth = src.getWidth(null);
-            int height = src.getHeight(null);
-            BufferedImage image = new BufferedImage(weidth,height,BufferedImage.TYPE_INT_RGB);
-            Graphics g = image.createGraphics();
-            g.drawImage(src,0,0,weidth,height,null);
-            g.setColor(color);
-            g.setFont(new Font(fontName,fontStyle,fontSize));
-            g.drawString(pressText,x,y);
-            g.dispose();
-            FileOutputStream out = new FileOutputStream(targetImg);
-            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
-            encoder.encode(image);
-            out.close();
-        } catch (java.io.IOException e) {
-            e.printStackTrace();
-        }
+//        try{
+//            File _file = new File(targetImg);
+//            Image src = ImageIO.read(_file);
+//            int weidth = src.getWidth(null);
+//            int height = src.getHeight(null);
+//            BufferedImage image = new BufferedImage(weidth,height,BufferedImage.TYPE_INT_RGB);
+//            Graphics g = image.createGraphics();
+//            g.drawImage(src,0,0,weidth,height,null);
+//            g.setColor(color);
+//            g.setFont(new Font(fontName,fontStyle,fontSize));
+//            g.drawString(pressText,x,y);
+//            g.dispose();
+//            FileOutputStream out = new FileOutputStream(targetImg);
+//            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+//            encoder.encode(image);
+//            out.close();
+//        } catch (java.io.IOException e) {
+//            e.printStackTrace();
+//        }
     }
 
     public String uploadImg(String imgUrl){
@@ -1712,7 +1733,7 @@ public class ApplicationMiddleController {
         return returnUrl;
     }
 
-    public boolean sendMessage(String content,String personId){
+    public boolean sendMessage(String content,String personId,String adminName){
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         String backDate = sdf.format(new Date());
 //                SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
@@ -1720,11 +1741,10 @@ public class ApplicationMiddleController {
         PersonInfo pi = personInfoService.get(personId);
         String appId = wechatConfig.getAppId();
         String appSecret = wechatConfig.getAppSecret();
-        boolean messageResult = false;
-//                boolean messageResult = WechatMessageUtil.sendMessageTemplate(
-//                        user.getUserName(),content,
-//                        backRemark,backDate,pi.getOpenId(),
-//                        wechatConfig.getBackNoticeTemplateId(),wechatConfig.getTokenUrl(),appId,appSecret);
+        boolean messageResult = WechatMessageUtil.sendMessageTemplate(
+                adminName,content,
+                backRemark,backDate,pi.getOpenId(),
+                wechatConfig.getBackNoticeTemplateId(),wechatConfig.getTokenUrl(),appId,appSecret);
         return messageResult;
     }
 

+ 165 - 105
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationPrimaryController.java

@@ -22,10 +22,6 @@ import com.jpsoft.campus.modules.sys.service.DataDictionaryService;
 import com.jpsoft.campus.modules.sys.service.UserRoleService;
 import com.jpsoft.campus.modules.sys.service.UserService;
 import com.jpsoft.campus.modules.wechat.entity.AccessToken;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-import com.sun.imageio.plugins.jpeg.JPEGImageReaderResources;
-import io.jsonwebtoken.io.IOException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -1503,11 +1499,17 @@ public class ApplicationPrimaryController {
 
         try {
             ApplicationPrimary applicationPrimary = applicationPrimaryService.get(id);
+            User user = userService.get(subject);
 
             ApprovalInfo approvalInfo = new ApprovalInfo();
             approvalInfo.setId(UUID.randomUUID().toString());
             approvalInfo.setApplicationId(id);
-            approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程",applicationPrimary.getStatus())+":" + typeValue);
+            if("90".equals(status)) {
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程",applicationPrimary.getStatus()));
+            }else{
+                approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程",applicationPrimary.getStatus())+":" + typeValue);
+            }
+
             approvalInfo.setRemark(remark);
             approvalInfo.setFileUrl("");
             approvalInfo.setDelFlag(false);
@@ -1549,21 +1551,30 @@ public class ApplicationPrimaryController {
                     off.setSchoolId(applicationPrimary.getSchoolId());
                     off.setSerialNum(serialNum);
 
-                    off.setCode(code);
-                    off.setDelFlag(false);
-                    off.setCreateBy(subject);
-                    off.setCreateTime(new Date());
-                    offerInfoService.insert(off);
-
                     applicationPrimary.setOfferCode(code);
                     SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
                     PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
                     StudentInfo studentInfo = studentInfoService.get(applicationPrimary.getStudentId());
                     String bdUrl = toPressText(code,personInfo.getName(),studentInfo.getName(), schoolInfo.getName());
                     String uploadUrl = uploadImg(bdUrl);
-                    applicationPrimary.setOfferImg(uploadUrl);
-                    String content =  "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
-                    sendMessage(content,applicationPrimary.getPersonId());
+                    if(StringUtils.isNotEmpty(uploadUrl)){
+                        applicationPrimary.setOfferImg(uploadUrl);
+                        off.setCode(code);
+                        off.setDelFlag(false);
+                        off.setCreateBy(subject);
+                        off.setCreateTime(new Date());
+                        offerInfoService.insert(off);
+                        new Thread(() -> {
+                            try {
+                                String content = "尊敬的家长您好,您的报名申请已通过,请前往“荆州开发区网上入学”--报名查询,下载电子版入学通知书。";
+                                sendMessage(content, applicationPrimary.getPersonId(),user.getRealName());
+                            } catch (Exception ex) {
+                                ex.printStackTrace();
+                            }
+                        }).start();
+                    }else{
+                        applicationPrimary.setStatus("80");
+                    }
                 }
                 applicationPrimaryService.update(applicationPrimary);
 
@@ -1711,14 +1722,14 @@ public class ApplicationPrimaryController {
                     //微信消息推送 发送预录取通知
                     applicationPrimary.setStatus(nextStatus);
 
-                    new Thread(() -> {
-                        try {
-                            String content = "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
-                            sendMessage(content, applicationPrimary.getPersonId());
-                        } catch (Exception ex) {
-                            ex.printStackTrace();
-                        }
-                    }).start();
+//                    new Thread(() -> {
+////                        try {
+////                            String content = "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
+////                            sendMessage(content,applicationPrimary.getPersonId(),user.getRealName());
+////                        } catch (Exception ex) {
+////                            ex.printStackTrace();
+////                        }
+////                    }).start();
                 } else if ("80".equals(applicationPrimary.getStatus())) {
                     //微信消息推送 发送完成录取通知
                     applicationPrimary.setStatus(nextStatus);
@@ -1743,24 +1754,34 @@ public class ApplicationPrimaryController {
                     off.setDelFlag(false);
                     off.setCreateBy(subject);
                     off.setCreateTime(new Date());
-                    int oicount = offerInfoService.insert(off);
+
                     applicationPrimary.setOfferCode(code);
-                    if (oicount > 0) {
-                        SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
-                        PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
-                        StudentInfo studentInfo = studentInfoService.get(applicationPrimary.getStudentId());
-                        String bdUrl = toPressText(code, personInfo.getName(), studentInfo.getName(), schoolInfo.getName());
-                        String uploadUrl = uploadImg(bdUrl);
+                    SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
+                    PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
+                    StudentInfo studentInfo = studentInfoService.get(applicationPrimary.getStudentId());
+                    String bdUrl = toPressText(code, personInfo.getName(), studentInfo.getName(), schoolInfo.getName());
+                    String uploadUrl = uploadImg(bdUrl);
+
+                    if(StringUtils.isNotEmpty(uploadUrl)){
+                        off.setCode(code);
+                        off.setDelFlag(false);
+                        off.setCreateBy(subject);
+                        off.setCreateTime(new Date());
+                        offerInfoService.insert(off);
+
                         applicationPrimary.setOfferImg(uploadUrl);
-//                        new Thread(() -> {
-//                            try {
-//                                String content = "尊敬的家长您好,您的报名申请已通过。关注“荆州开发区网上入学”--报名查询,我们将于近期推送电子版入学通知书。";
-//                                sendMessage(content, applicationPrimary.getPersonId());
-//                            } catch (Exception ex) {
-//                                ex.printStackTrace();
-//                            }
-//                        }).start();
+                        new Thread(() -> {
+                            try {
+                                String content = "尊敬的家长您好,您的报名申请已通过,请前往“荆州开发区网上入学”--报名查询,下载电子版入学通知书。";
+                                sendMessage(content, applicationPrimary.getPersonId(),user.getRealName());
+                            } catch (Exception ex) {
+                                ex.printStackTrace();
+                            }
+                        }).start();
+                    }else{
+                        applicationPrimary.setStatus("80");
                     }
+
                 } else {
                     applicationPrimary.setStatus(nextStatus);
                 }
@@ -1770,7 +1791,11 @@ public class ApplicationPrimaryController {
                 ApprovalInfo approvalInfo = new ApprovalInfo();
                 approvalInfo.setId(UUID.randomUUID().toString());
                 approvalInfo.setApplicationId(applicationPrimary.getId());
-                //approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程", applicationPrimary.getStatus()) + ":通过审核");
+                if("80".equals(status)) {
+                    approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程",applicationPrimary.getStatus()));
+                }else{
+                    approvalInfo.setOperation(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程", applicationPrimary.getStatus()) + ":通过审核");
+                }
                 approvalInfo.setRemark("通过审核");
                 approvalInfo.setFileUrl("");
                 approvalInfo.setDelFlag(false);
@@ -1796,84 +1821,120 @@ public class ApplicationPrimaryController {
     }
 
     public static void main(String[] args) {
-        //appId: wx0c81770a72543e27
-        //  appSecret: ea8c0d18eae536e3ec16333864e71252
-        //public static boolean sendNoticeMessage(String noticeName, String content, String openId, String noticeDetailId, String noticeTemplateId, String appId, String appSecret) {
-//        WechatMessageUtil.sendMessageTemplate("测试",
-//                "测试内容",
-//                "备注",
-//                "2020-07-12",
-//                "ouJckwC1ysrEzgyF14X4pSJAPNFk",
-//                "Ya2TByTerPfIxfqMwfFq2G-BMsuyWZOslk-g5cHSWfs",
-//                "http://ykt.xiaoxinda.com/weixin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET",
-//                "wx0c81770a72543e27",
-//                "ea8c0d18eae536e3ec16333864e71252");
-
-        //小学http://rccs.oss-cn-hangzhou.aliyuncs.com/upload/service/primary_tzs.jpg
-        //中学http://rccs.oss-cn-hangzhou.aliyuncs.com/upload/service/middle_tzs.jpg
-
-
-//        String uploadPath = Resource.class.getResource("/").getPath() +"uploadImg";
-//        delAllFile(uploadPath);
-
+        String in = "static/primary_tzs.jpg";
+        String out = "uploadImg/primary_tzs_" + "11111" + ".jpg";
+        String inImg = Resource.class.getResource("/").getPath() + in;
+        String outImg = Resource.class.getResource("/").getPath() + out;
+        try{
+            BufferedImage im =ImageIO.read(new FileInputStream(inImg));
+            int mothh = DateUtil.thisMonth() +1;
+            Graphics g = im.getGraphics();
+            g.setColor(new Color(0,0,0));
+            //g.setColor(Color.BLUE);
+            Font font = new Font("宋体",Font.PLAIN,40);  //设置字体
+            g.setFont(font);
+            g.drawString("5555555",1000,400);
+            g.drawString("舒爸爸",410,600);
+            g.drawString("舒展",830,680);
+            g.drawString("8",660,940);
+            g.drawString("27",730,940);
+            g.drawString("8",890,940);
+            g.drawString("27",970,940);
+            g.drawString("湖北省荆州市沙市区小学",480,1015);
+            g.drawString(mothh+"",1000,1590);
+            g.drawString(DateUtil.thisDayOfMonth()+"",1060,1590);
+            g.dispose();
+            ImageIO.write(im,"jpg",new File(outImg));
+        }catch (IOException e){
+            e.printStackTrace();
+        }
     }
 
+    @ApiOperation(value="全部通过")
+    @RequestMapping(value = "toPressText",method = RequestMethod.POST)
     public String toPressText(String offerCode,String personName,String userName,String schoolName){
         String in = "static/primary_tzs.jpg";
         String out = "uploadImg/primary_tzs_" + offerCode + ".jpg";
         String inImg = Resource.class.getResource("/").getPath() + in;
         String outImg = Resource.class.getResource("/").getPath() + out;
-        try
-        {
-            FileInputStream fis = new FileInputStream(inImg);//创建输入流对象
-            FileOutputStream fos = new FileOutputStream(outImg); //创建输出流对象
-            byte datas[] = new byte[1024*8];//创建搬运工具
-            int len = 0;//创建长度
-            while((len = fis.read(datas))!=-1)//循环读取数据
-            {
-                fos.write(datas,0,len);
-            }
-            fis.close();//释放资源
-        }
-        catch (Exception e)
-        {
+
+        try{
+            BufferedImage im =ImageIO.read(new FileInputStream(inImg));
+            int mothh = DateUtil.thisMonth() +1;
+            Graphics g = im.getGraphics();
+            g.setColor(new Color(0,0,0));
+            Font font = new Font("宋体",Font.PLAIN,40);  //设置字体
+            g.setFont(font);
+            Random ran = new Random();  // 随机位置
+            g.drawString(offerCode,1000,400);
+            g.drawString(personName,410,600);
+            g.drawString(userName,830,680);
+            g.drawString("8",660,940);
+            g.drawString("27",730,940);
+            g.drawString("8",890,940);
+            g.drawString("27",970,940);
+            g.drawString(schoolName,480,1015);
+            g.drawString(mothh+"",1000,1590);
+            g.drawString(DateUtil.thisDayOfMonth()+"",1060,1590);
+            g.dispose();
+            ImageIO.write(im,"jpg",new File(outImg));
+        }catch (IOException e){
             e.printStackTrace();
         }
-
-        //加水印
-        pressText(offerCode,outImg,"宋体",0,new Color(0,0,0),40,1000,400);
-        pressText(personName,outImg,"宋体",0,new Color(0,0,0),40,410,600);
-        pressText(userName,outImg,"宋体",0,new Color(0,0,0),40,830,680);
-        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,660,940);
-        pressText("27",outImg,"宋体",0,new Color(0,0,0),40,730,940);
-        pressText("8",outImg,"宋体",0,new Color(0,0,0),40,890,940);
-        pressText("27",outImg,"宋体",0,new Color(0,0,0),40,970,940);
-        pressText(schoolName,outImg,"宋体",0,new Color(0,0,0),40,480,1015);
-        pressText(DateUtil.thisMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1000,1590);
-        pressText(DateUtil.thisDayOfMonth()+"",outImg,"宋体",0,new Color(0,0,0),40,1060,1590);
         return outImg;
     }
 
-    public void pressText(String pressText, String targetImg, String fontName, int fontStyle, Color color, int fontSize, int x, int y){
+    public void pressText(String pressText, String targetImg,String outImg, String fontName, int fontStyle, Color color, int x, int y){
         try{
-            File _file = new File(targetImg);
-            Image src = ImageIO.read(_file);
-            int weidth = src.getWidth(null);
-            int height = src.getHeight(null);
-            BufferedImage image = new BufferedImage(weidth,height,BufferedImage.TYPE_INT_RGB);
-            Graphics g = image.createGraphics();
-            g.drawImage(src,0,0,weidth,height,null);
+            BufferedImage im =ImageIO.read(new FileInputStream(outImg));
+            int iw = im.getWidth();
+            int ih = im.getHeight();
+            Graphics g = im.getGraphics();
             g.setColor(color);
-            g.setFont(new Font(fontName,fontStyle,fontSize));
-            g.drawString(pressText,x,y);
+            //g.setColor(Color.BLUE);
+            Font font = new Font("宋体",Font.PLAIN,40);  //设置字体
+            g.setFont(font);
+            String str = "12345";
+            //int x = iw/2;
+            //int y = ih/2;
+            Random ran = new Random();  // 随机位置
+            g.drawString(str,x,y);
             g.dispose();
-            FileOutputStream out = new FileOutputStream(targetImg);
-            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
-            encoder.encode(image);
-            out.close();
-        } catch (java.io.IOException e) {
+            ImageIO.write(im,"jpg",new File(outImg));
+        }catch (IOException e){
             e.printStackTrace();
         }
+
+
+
+
+
+
+
+
+
+
+
+
+//        try{
+//            File _file = new File(targetImg);
+//            Image src = ImageIO.read(_file);
+//            int weidth = src.getWidth(null);
+//            int height = src.getHeight(null);
+//            BufferedImage image = new BufferedImage(weidth,height,BufferedImage.TYPE_INT_RGB);
+//            Graphics g = image.createGraphics();
+//            g.drawImage(src,0,0,weidth,height,null);
+//            g.setColor(color);
+//            g.setFont(new Font(fontName,fontStyle,fontSize));
+//            g.drawString(pressText,x,y);
+//            g.dispose();
+//            FileOutputStream out = new FileOutputStream(targetImg);
+//            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+//            encoder.encode(image);
+//            out.close();
+//        } catch (java.io.IOException e) {
+//            e.printStackTrace();
+//        }
     }
 
     public String uploadImg(String imgUrl){
@@ -1890,7 +1951,7 @@ public class ApplicationPrimaryController {
         return returnUrl;
     }
 
-    public boolean sendMessage(String content,String personId){
+    public boolean sendMessage(String content,String personId,String adminName){
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         String backDate = sdf.format(new Date());
 //                SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
@@ -1898,11 +1959,10 @@ public class ApplicationPrimaryController {
         PersonInfo pi = personInfoService.get(personId);
         String appId = wechatConfig.getAppId();
         String appSecret = wechatConfig.getAppSecret();
-        boolean messageResult = false;
-//                boolean messageResult = WechatMessageUtil.sendMessageTemplate(
-//                        user.getUserName(),content,
-//                        backRemark,backDate,pi.getOpenId(),
-//                        wechatConfig.getBackNoticeTemplateId(),wechatConfig.getTokenUrl(),appId,appSecret);
+        boolean messageResult = WechatMessageUtil.sendMessageTemplate(
+                adminName,content,
+                backRemark,backDate,pi.getOpenId(),
+                wechatConfig.getBackNoticeTemplateId(),wechatConfig.getTokenUrl(),appId,appSecret);
         return messageResult;
     }
 

+ 4 - 0
web/src/main/java/com/jpsoft/campus/modules/mobile/controller/PrimarySchoolApiController.java

@@ -652,6 +652,8 @@ public class PrimarySchoolApiController {
                 applicationPrimaryDTO.setSchoolId(applicationPrimary.getSchoolId());
                 applicationPrimaryDTO.setStudentId(applicationPrimary.getStudentId());
                 applicationPrimaryDTO.setStatus(applicationPrimary.getStatus());
+                applicationPrimaryDTO.setOfferCode(applicationPrimary.getOfferCode());
+                applicationPrimaryDTO.setOfferImg(applicationPrimary.getOfferImg());
             }else {
                 applicationPrimaryDTO.setApplicationId(applicationId);
                 applicationPrimaryDTO.setType(applicationMiddle.getType());
@@ -662,6 +664,8 @@ public class PrimarySchoolApiController {
                 applicationPrimaryDTO.setStudentId(applicationMiddle.getStudentId());
                 applicationPrimaryDTO.setChooseReason(applicationMiddle.getChooseReason());
                 applicationPrimaryDTO.setStatus(applicationMiddle.getStatus());
+                applicationPrimaryDTO.setOfferCode(applicationMiddle.getOfferCode());
+                applicationPrimaryDTO.setOfferImg(applicationMiddle.getOfferImg());
             }
 
             if(studentInfo!=null){

+ 1 - 1
web/src/main/resources/application-test.yml

@@ -5,7 +5,7 @@ server:
 
 spring:
   datasource:
-    url: jdbc:log4jdbc:mysql://192.168.33.20:3306/campus_admission?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:log4jdbc:mysql://47.92.161.104:3306/campus_admission?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
     password: jpsoft2016
   devtools: