he2802 1 年之前
父节点
当前提交
1890d75e10

+ 6 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -32,6 +32,7 @@ import com.zhongzheng.modules.bank.service.IQuestionOtherService;
 import com.zhongzheng.modules.bank.service.IQuestionService;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.base.bo.ConfigQueryBo;
+import com.zhongzheng.modules.base.service.ICertificateTpService;
 import com.zhongzheng.modules.course.bo.ExternalQuestionBo;
 import com.zhongzheng.modules.course.bo.ReplenishExamBo;
 import com.zhongzheng.modules.course.vo.ExternalQuestionVo;
@@ -165,6 +166,8 @@ public class CommonController extends BaseController {
     private IQuestionOtherService iQuestionOtherService;
     @Autowired
     private OssService ossService;
+    @Autowired
+    private ICertificateTpService iCertificateTpService;
     /**
      * 通用下载请求
      *
@@ -478,10 +481,11 @@ public class CommonController extends BaseController {
     }
 
     @ApiOperation("测试分班")
-    @GetMapping("common/jzs/grade")
-    public AjaxResult<Void> testGrade() {
+    @PostMapping("common/free/grade")
+    public AjaxResult<Void> testGrade(@RequestBody ClassGradeUserQueryBo bo) {
         //   iClassGradeService.checkEjjjPeopleNumLimit(195L,984L);
         //   iUserService.batchUpdateTelId();
+        iCertificateTpService.makeCertificatePhoto(bo);
         return AjaxResult.success();
     }
 

二进制
zhongzheng-common/src/main/resources/static/001.png


二进制
zhongzheng-common/src/main/resources/static/004.jpg


二进制
zhongzheng-common/src/main/resources/static/005.jpg


二进制
zhongzheng-common/src/main/resources/static/006.jpg


+ 439 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/CertificateTpServiceImpl.java

@@ -30,10 +30,8 @@ import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
 import com.zhongzheng.modules.course.service.ICourseMenuService;
 import com.zhongzheng.modules.course.service.ICourseModuleService;
-import com.zhongzheng.modules.course.vo.CourseChapterVo;
-import com.zhongzheng.modules.course.vo.CourseMenuVo;
-import com.zhongzheng.modules.course.vo.CourseModuleVo;
-import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.course.service.IMajorService;
+import com.zhongzheng.modules.course.vo.*;
 import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
@@ -102,9 +100,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
     @Autowired
     private ICourseModuleService iCourseModuleService;
 
+    @Autowired
+    private IMajorService iMajorService;
+
     @Value("${certificate.host}")
     private String CERTIFICATE_HOST;
 
+
     @Override
     public CertificateTpVo queryById(Long tpId){
         CertificateTp db = this.baseMapper.selectById(tpId);
@@ -176,13 +178,15 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         if(Validator.isEmpty(bo.getUserId())||Validator.isEmpty(bo.getGradeId())||Validator.isEmpty(bo.getGoodsId())){
             throw new CustomException("数据错误");
         }
+        bo.setPageSize(null);
+        bo.setPageNum(null);
         GoodsVo goodsVo = iGoodsService.selectDetail(bo.getGoodsId());
         //获取培训开始时间
         UserStudyRecordQueryBo studyRecordQueryBo = new UserStudyRecordQueryBo();
         studyRecordQueryBo.setUserId(bo.getUserId());
         studyRecordQueryBo.setGoodsId(bo.getGoodsId());
         studyRecordQueryBo.setGradeId(bo.getGradeId());
-        UserStudyRecordVo studyRecordVo = iUserStudyRecordService.queryLast(studyRecordQueryBo);
+        UserStudyRecordVo studyRecordVo = iUserStudyRecordService.queryFirst(studyRecordQueryBo);
         //获取培训结束时间
         ClassGradeUser classGradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>()
                 .eq(ClassGradeUser::getUserId, bo.getUserId())
@@ -193,10 +197,17 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
             //获取章列表
             List<CourseChapterVo> chapterList =  iClassGradeUserService.findChapterList(bo);
             BigDecimal totalTime = new BigDecimal(0);
+            BigDecimal publicTotalTime = new BigDecimal(0);
             for(CourseChapterVo chapterVo : chapterList){
-                totalTime=totalTime.add(new BigDecimal(courseMenuMapper.countChapterTotalTime(chapterVo.getChapterId())));
+                if(Validator.isEmpty(chapterVo.getCommonSign())||chapterVo.getCommonSign()==0){
+                    totalTime=totalTime.add(new BigDecimal(courseMenuMapper.countChapterTotalTime(chapterVo.getChapterId())));
+                }else if(chapterVo.getCommonSign()==1){
+                    publicTotalTime=publicTotalTime.add(new BigDecimal(courseMenuMapper.countChapterTotalTime(chapterVo.getChapterId())));
+                }
+
             }
             goodsVo.setClassHours(totalTime.divide(new BigDecimal(45*60),BigDecimal.ROUND_HALF_UP));
+            goodsVo.setPublicClassHours(publicTotalTime.divide(new BigDecimal(45*60),BigDecimal.ROUND_HALF_UP));
             if(Validator.isNotEmpty(goodsVo.getCertificateTpId())){
                 //        String[] s = goodsVo.getCertificateIds().split(",");
                 List<Long> tpIds = new ArrayList<>();
@@ -482,6 +493,102 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
             UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath,moduleId);
             iUserCertificateService.insertByAddBo(addBo);
         }
+        else if("certificate09".equals(tpVo.getKeyValue())){
+            CertificatePhotoVo vo = new CertificatePhotoVo();
+            if(Validator.isEmpty(goodsVo.getMajorId())){
+                throw new CustomException("生成证书专业缺失");
+            }
+            if(Validator.isEmpty(userVo.getOneInchPhotos())){
+                throw new CustomException("生成证书一寸照片缺失");
+            }
+            MajorVo majorVo = iMajorService.queryById(goodsVo.getMajorId());
+            String onePhoto = userVo.getOneInchPhotos();
+            String code = "XYSGXC"+nowDate.substring(0, 4)+getCertificateCode();
+            vo.setOneInchPhotos(onePhoto);
+            vo.setCode(code);
+            vo.setRealname(userVo.getRealname());
+            vo.setIdCard(userVo.getIdCard());
+            String date = DateUtils.timestampToDate(goodsVo.getCreateTime());
+            vo.setYear(date.substring(0, 4));
+            String sex = "男";
+            if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
+                sex = "女";
+            }
+            vo.setSex(sex);
+            vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
+            vo.setPublicClassHours(goodsVo.getPublicClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
+            vo.setDateY(nowDate.substring(0, 4));
+            vo.setDateM(nowDate.substring(5, 7));
+            vo.setDateD(nowDate.substring(8, 10));
+            vo.setMajor(majorVo.getCategoryName());
+            vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
+            vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
+            List<String> chapterListTxt = changeChapterList(chapterList);
+            vo.setChapterList(chapterListTxt);
+            String ossPath =drawPicSGXC(vo);
+            UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath,moduleId);
+            iUserCertificateService.insertByAddBo(addBo);
+        }
+        else if("certificate10".equals(tpVo.getKeyValue())){
+            if(Validator.isEmpty(goodsVo.getMajorId())){
+                throw new CustomException("生成证书专业缺失");
+            }
+            MajorVo majorVo = iMajorService.queryById(goodsVo.getMajorId());
+            CertificatePhotoVo vo = new CertificatePhotoVo();
+            String code = "XYEZJJ"+nowDate.substring(0, 4)+getCertificateCode();
+            vo.setCode(code);
+            vo.setRealname(userVo.getRealname());
+            vo.setIdCard(userVo.getIdCard());
+            String date = DateUtils.timestampToDate(goodsVo.getCreateTime());
+            vo.setYear(date.substring(0, 4));
+            String sex = "男";
+            if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
+                sex = "女";
+            }
+            vo.setSex(sex);
+            vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
+            vo.setDateY(nowDate.substring(0, 4));
+            vo.setDateM(nowDate.substring(5, 7));
+            vo.setDateD(nowDate.substring(8, 10));
+            vo.setMajor(majorVo.getCategoryName());
+            vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
+            vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
+            List<String> chapterListTxt = changeChapterList2(chapterList);
+            vo.setChapterList(chapterListTxt);
+            String ossPath =drawPicErZao(vo);
+            UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath,moduleId);
+            iUserCertificateService.insertByAddBo(addBo);
+        }
+        else if("certificate11".equals(tpVo.getKeyValue())){
+            if(Validator.isEmpty(goodsVo.getMajorId())){
+                throw new CustomException("生成证书专业缺失");
+            }
+            MajorVo majorVo = iMajorService.queryById(goodsVo.getMajorId());
+            CertificatePhotoVo vo = new CertificatePhotoVo();
+            String code = "XYEJJJ"+nowDate.substring(0, 4)+getCertificateCode();
+            vo.setCode(code);
+            vo.setRealname(userVo.getRealname());
+            vo.setIdCard(userVo.getIdCard());
+            String date = DateUtils.timestampToDate(goodsVo.getCreateTime());
+            vo.setYear(date.substring(0, 4));
+            String sex = "男";
+            if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
+                sex = "女";
+            }
+            vo.setSex(sex);
+            vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
+            vo.setDateY(nowDate.substring(0, 4));
+            vo.setDateM(nowDate.substring(5, 7));
+            vo.setDateD(nowDate.substring(8, 10));
+            vo.setMajor(majorVo.getCategoryName());
+            vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
+            vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
+            List<String> chapterListTxt = changeChapterList2(chapterList);
+            vo.setChapterList(chapterListTxt);
+            String ossPath =drawPicErJian(vo);
+            UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath,moduleId);
+            iUserCertificateService.insertByAddBo(addBo);
+        }
     }
 
     private UserCertificateAddBo mergeData(ClassGradeUserQueryBo bo, GoodsVo goodsVo,CertificatePhotoVo vo,Long certificateTpId,String certificatePath,Long moduleId){
@@ -503,13 +610,14 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         addBo.setTrainStartTime(vo.getTrainStartTime());
         addBo.setTrainEndTime(vo.getTrainEndTime());
         addBo.setChapterStr(ArrayUtils.toString(vo.getChapterList(), ","));
+        addBo.setPublicClassHours(goodsVo.getPublicClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP ));
         return addBo;
     }
     private String getCertificateCode(){
         Long id = iUserCertificateService.selectMaxId();
         String nowId = Long.toString(id);
         String result = "";
-        result = String.format("%0" + 4 + "d", Integer.parseInt(nowId) + 1);
+        result = String.format("%0" + 5 + "d", Integer.parseInt(nowId) + 1);
         return result;
     }
 
@@ -546,6 +654,57 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         return chapterListTxt;
     }
 
+    private List<String> changeChapterList2(List<CourseChapterVo> chapterList){
+        List<String> chapterListTxt = new ArrayList<>();
+        for(int i =0; i<chapterList.size(); i++){
+            String numTag = "";
+            if(i==0){
+                numTag = "1. ";
+            }
+            else if(i==1){
+                numTag = "2. ";
+            }
+            else if(i==2){
+                numTag = "3. ";
+            }
+            else if(i==3){
+                numTag = "4. ";
+            }
+            else if(i==4){
+                numTag = "5. ";
+            }
+            else if(i==5){
+                numTag = "6. ";
+            }
+            else if(i==6){
+                numTag = "7. ";
+            }
+            else if(i==7){
+                numTag = "8. ";
+            }
+            else if(i==8){
+                numTag = "9. ";
+            }
+            else if(i==9){
+                numTag = "10. ";
+            }
+            else if(i==10){
+                numTag = "11. ";
+            }
+            else if(i==11){
+                numTag = "12. ";
+            }
+            else if(i==12){
+                numTag = "13. ";
+            }
+            else if(i==13){
+                numTag = "14. ";
+            }
+            chapterListTxt.add(numTag+chapterList.get(i).getName());
+        }
+        return chapterListTxt;
+    }
+
     private String drawPic(CertificatePhotoVo entity){
         Font font = new Font("微软雅黑", Font.PLAIN, 45);// 添加字体的属性设置
         String projectUrl = "D:\\test\\";
@@ -679,6 +838,279 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         return imgName;
     }
 
+    private  String drawPicSGXC(CertificatePhotoVo entity){
+        Font font = new Font("微软雅黑", Font.PLAIN, 55);// 添加字体的属性设置 微软雅黑
+        Font font2 = new Font("微软雅黑", Font.BOLD, 58);
+        String imgName = null;
+        try {
+            // 加载图片
+            InputStream imgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/004.jpg");
+            //        String imageLocalUrl = projectUrl + "003.jpg";
+            //         BufferedImage imageLocal = ImageIO.read(new File(imageLocalUrl));
+            BufferedImage imageLocal = ImageIO.read(imgStream);
+            // 以本地图片为模板
+            Graphics2D g = imageLocal.createGraphics();
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+            // 设置文本样式
+            g.setFont(font);
+            g.setColor(Color.BLACK);
+
+            InputStream oneInchPhotos =  ossService.getStreamByObject(entity.getOneInchPhotos());
+            BufferedImage oneInchBuffered = ImageIO.read(oneInchPhotos);
+            g.drawImage(oneInchBuffered, 430, 960, 300, 400, null);
+
+
+
+            g.drawString(entity.getCode(), 1235, 1245);
+            g.drawString(entity.getRealname(), 1235, 1011);
+            g.drawString(entity.getIdCard(), 1235, 1126);
+            g.drawString(entity.getMajor(), 1235, 1368);
+/*
+            g.drawString(entity.getDateY(), 780, 365);
+            g.drawString(entity.getDateM(), 905, 365);
+
+            g.drawString(entity.getRemark1(), 1035, 408);
+            g.drawString(entity.getRemark2(), 728, 460);
+*/
+
+            g.drawString(entity.getDateY(), 1332, 2973);
+            g.drawString(entity.getDateM(), 1594, 2973);
+            g.drawString(entity.getDateD(), 1781, 2973);
+
+            g.setFont(font2);
+            g.drawString(entity.getRealname(), 455, 1616);
+            g.drawString(entity.getDateY()+"年"+entity.getDateM()+"月"+entity.getDateD()+"日", 846, 1616);
+            g.drawString("施工现场专业人员", 1508, 1616);
+
+            g.drawString(entity.getDateY(), 311, 1770);
+            g.drawString(String.valueOf(Integer.parseInt(entity.getPublicClassHours())+Integer.parseInt(entity.getClassHours())), 1341, 1770);
+
+            g.drawString(entity.getPublicClassHours(), 311, 1920);
+            g.drawString(entity.getClassHours(), 881, 1920);
+
+            InputStream logoStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/001.png");
+            BufferedImage logoBuffered = ImageIO.read(logoStream);
+            g.drawImage(logoBuffered, 1438, 2555, 529, 528, null);
+
+            //二维码
+            String qrTxt = CERTIFICATE_HOST+"pages/certificate/index?code="+entity.getCode();
+            QRCodeWriter qrCodeWriter = new QRCodeWriter();
+            BitMatrix bitMatrix = qrCodeWriter.encode(qrTxt, BarcodeFormat.QR_CODE, 360, 360);
+            BufferedImage qrImage = toBufferedImage(bitMatrix);
+            // 在模板上添加用户二维码(地址,左边距,上边距,图片宽度,图片高度,未知)
+            g.drawImage(qrImage, 324, 2583, 360, 360, null);
+            // 完成模板修改
+            g.dispose();
+            // 获取新文件的地址
+            // 生成新的合成过的用户二维码并写入新图片
+            //        ImageIO.write(imageLocal, "jpg", outputfile);
+            //上传OSS
+            InputStream is =  bufferedImageToInputStream(imageLocal);
+            String ossPath = ossService.uploadInputStream(is,7);
+            if(imgStream!=null){
+                imgStream.close();
+            }
+            return ossPath;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        // 返回给页面的图片地址(因为绝对路径无法访问)
+        //    imgName = Constants.PROJECT_URL + "codeImg/" + userId + ".png";
+
+        return imgName;
+    }
+
+    private  String drawPicErZao(CertificatePhotoVo entity){
+        Font font = new Font("微软雅黑", Font.PLAIN, 31);// 添加字体的属性设置 微软雅黑
+        Font font2 = new Font("微软雅黑", Font.BOLD, 38);
+        String imgName = null;
+        try {
+            // 加载本地图片
+            InputStream imgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/005.jpg");
+            //        String imageLocalUrl = projectUrl + "003.jpg";
+            //         BufferedImage imageLocal = ImageIO.read(new File(imageLocalUrl));
+            BufferedImage imageLocal = ImageIO.read(imgStream);
+            // 以本地图片为模板
+            Graphics2D g = imageLocal.createGraphics();
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+            // 设置文本样式
+            g.setFont(font2);
+            g.setColor(Color.BLACK);
+            g.drawString(entity.getRealname(), 165, 486);
+
+            g.setFont(font);
+
+            g.drawString(entity.getCode(), 169, 236 );
+
+            g.drawString(entity.getRealname(), 126, 696);
+
+            g.drawString(entity.getIdCard(), 298, 696);
+
+            g.drawString("二级注册造价师", 677, 668);
+            if("必修".equals(entity.getMajor())){
+                g.drawString(entity.getMajor(), 768, 718);
+            }else{
+                g.drawString("选修("+entity.getMajor()+")", 705, 718);
+            }
+
+
+            if("必修".equals(entity.getMajor())){
+                g.drawString(entity.getClassHours(), 980, 696);
+                g.drawString("0", 1105, 696);
+            }else{
+                g.drawString("0", 980, 696);
+                g.drawString(entity.getClassHours(), 1105, 696);
+            }
+            Integer startY = 810;
+            Integer j = 0;
+            for(String name : entity.getChapterList()){
+                if(j<6){
+                    g.drawString(name, 300, startY);
+                    startY+=50;
+                }else{
+                    g.drawString("....", 300, startY);
+                    break;
+                }
+                j++;
+            }
+
+            g.drawString(DateUtils.timestampToDateFormat(entity.getTrainStartTime(),"yyyy.MM.dd"), 1214, 666);
+            g.drawString("至", 1279, 705);
+            g.drawString(DateUtils.timestampToDateFormat(entity.getTrainEndTime(),"yyyy.MM.dd"), 1214, 739);
+
+
+            g.drawString(entity.getDateY(), 842, 1967);
+            g.drawString(entity.getDateM(), 979, 1967);
+            g.drawString(entity.getDateD(), 1069, 1967);
+
+            InputStream logoStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/001.png");
+            BufferedImage logoBuffered = ImageIO.read(logoStream);
+            g.drawImage(logoBuffered, 1012, 1666, 330, 330, null);
+
+            //二维码
+            String qrTxt = CERTIFICATE_HOST+"pages/certificate/index?code="+entity.getCode();
+            QRCodeWriter qrCodeWriter = new QRCodeWriter();
+            BitMatrix bitMatrix = qrCodeWriter.encode(qrTxt, BarcodeFormat.QR_CODE, 150, 150);
+            BufferedImage qrImage = toBufferedImage(bitMatrix);
+            // 在模板上添加用户二维码(地址,左边距,上边距,图片宽度,图片高度,未知)
+            g.drawImage(qrImage, 1233, 175, 150, 150, null);
+            // 完成模板修改
+            g.dispose();
+            // 获取新文件的地址
+            // 生成新的合成过的用户二维码并写入新图片
+            //        ImageIO.write(imageLocal, "jpg", outputfile);
+            //上传OSS
+            InputStream is =  bufferedImageToInputStream(imageLocal);
+            String ossPath = ossService.uploadInputStream(is,7);
+            if(imgStream!=null){
+                imgStream.close();
+            }
+            return ossPath;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        // 返回给页面的图片地址(因为绝对路径无法访问)
+        //    imgName = Constants.PROJECT_URL + "codeImg/" + userId + ".png";
+
+        return imgName;
+    }
+
+    private  String drawPicErJian(CertificatePhotoVo entity){
+        Font font = new Font("微软雅黑", Font.PLAIN, 31);// 添加字体的属性设置 微软雅黑
+        Font font2 = new Font("微软雅黑", Font.BOLD, 38);
+        String imgName = null;
+        try {
+            // 加载本地图片
+            InputStream imgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/006.jpg");
+            //        String imageLocalUrl = projectUrl + "003.jpg";
+            //         BufferedImage imageLocal = ImageIO.read(new File(imageLocalUrl));
+            BufferedImage imageLocal = ImageIO.read(imgStream);
+            // 以本地图片为模板
+            Graphics2D g = imageLocal.createGraphics();
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+            // 设置文本样式
+            g.setFont(font2);
+            g.setColor(Color.BLACK);
+            g.drawString(entity.getRealname(), 165, 486);
+
+            g.setFont(font);
+
+            g.drawString(entity.getCode(), 169, 236 );
+
+            g.drawString(entity.getRealname(), 126, 696);
+
+            g.drawString(entity.getIdCard(), 298, 696);
+
+            g.drawString("二级注册建造师", 677, 668);
+            if("必修".equals(entity.getMajor())){
+                g.drawString(entity.getMajor(), 768, 718);
+            }else{
+                g.drawString("选修("+entity.getMajor()+")", 705, 718);
+            }
+
+
+            if("必修".equals(entity.getMajor())){
+                g.drawString(entity.getClassHours(), 980, 696);
+                g.drawString("0", 1105, 696);
+            }else{
+                g.drawString("0", 980, 696);
+                g.drawString(entity.getClassHours(), 1105, 696);
+            }
+            Integer startY = 810;
+            Integer j = 0;
+            for(String name : entity.getChapterList()){
+                if(j<14){
+                    g.drawString(name, 300, startY);
+                    startY+=50;
+                }else{
+                    g.drawString("....", 300, startY);
+                    break;
+                }
+                j++;
+            }
+
+            g.drawString(DateUtils.timestampToDateFormat(entity.getTrainStartTime(),"yyyy.MM.dd"), 1214, 666);
+            g.drawString("至", 1279, 705);
+            g.drawString(DateUtils.timestampToDateFormat(entity.getTrainEndTime(),"yyyy.MM.dd"), 1214, 739);
+
+
+            g.drawString(entity.getDateY(), 842, 1967);
+            g.drawString(entity.getDateM(), 979, 1967);
+            g.drawString(entity.getDateD(), 1069, 1967);
+
+            InputStream logoStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/001.png");
+            BufferedImage logoBuffered = ImageIO.read(logoStream);
+            g.drawImage(logoBuffered, 1012, 1666, 330, 330, null);
+
+            //二维码
+            String qrTxt = CERTIFICATE_HOST+"pages/certificate/index?code="+entity.getCode();
+            QRCodeWriter qrCodeWriter = new QRCodeWriter();
+            BitMatrix bitMatrix = qrCodeWriter.encode(qrTxt, BarcodeFormat.QR_CODE, 150, 150);
+            BufferedImage qrImage = toBufferedImage(bitMatrix);
+            // 在模板上添加用户二维码(地址,左边距,上边距,图片宽度,图片高度,未知)
+            g.drawImage(qrImage, 1233, 175, 150, 150, null);
+            // 完成模板修改
+            g.dispose();
+            // 获取新文件的地址
+            // 生成新的合成过的用户二维码并写入新图片
+            //        ImageIO.write(imageLocal, "jpg", outputfile);
+            //上传OSS
+            InputStream is =  bufferedImageToInputStream(imageLocal);
+            String ossPath = ossService.uploadInputStream(is,7);
+            if(imgStream!=null){
+                imgStream.close();
+            }
+            return ossPath;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        // 返回给页面的图片地址(因为绝对路径无法访问)
+        //    imgName = Constants.PROJECT_URL + "codeImg/" + userId + ".png";
+
+        return imgName;
+    }
+
+
     public InputStream bufferedImageToInputStream(BufferedImage image){
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         try {

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/vo/CertificatePhotoVo.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 
@@ -24,6 +25,8 @@ public class CertificatePhotoVo {
 	private String realname;
 	@ApiModelProperty("身份证号")
 	private String idCard;
+	@ApiModelProperty("一寸照片")
+	private String oneInchPhotos;
 
 	@ApiModelProperty("年份")
 	private String year;
@@ -54,5 +57,8 @@ public class CertificatePhotoVo {
 	/** 培训结束时间 */
 	@ApiModelProperty("培训结束时间")
 	private Long trainEndTime;
+	@Excel(name = "公共学时")
+	@ApiModelProperty("公共学时")
+	private String publicClassHours;
 
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java

@@ -129,6 +129,10 @@ public class GoodsVo {
 	@Excel(name = "学时")
 	@ApiModelProperty("学时")
 	private BigDecimal classHours;
+
+	@Excel(name = "公共学时")
+	@ApiModelProperty("公共学时")
+	private BigDecimal publicClassHours;
 	/** 标准价格详情json */
 	@Excel(name = "标准价格详情json")
 	@ApiModelProperty("标准价格详情json")

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserCertificateAddBo.java

@@ -85,4 +85,6 @@ public class UserCertificateAddBo {
     /** 1单证书 2多证书 */
     @ApiModelProperty("1单证书 2多证书")
     private Integer moreCertificateStatus;
+    @ApiModelProperty("公共学时")
+    private BigDecimal publicClassHours;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserCertificate.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.user.domain;
 
 import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
@@ -70,4 +71,6 @@ private static final long serialVersionUID=1L;
     private Long moduleId;
     /** 1单证书 2多证书 */
     private Integer moreCertificateStatus;
+
+    private BigDecimal publicClassHours;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserVisitLog.java

@@ -40,4 +40,6 @@ private static final long serialVersionUID=1L;
     private String ip;
     /** 访问日期 */
     private Long dateTime;
+
+    private String browser;
 }

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserCertificateServiceImpl.java

@@ -6,7 +6,9 @@ import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
+import com.zhongzheng.modules.course.service.IMajorService;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
+import com.zhongzheng.modules.course.vo.MajorVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.user.bo.UserCertificateAddBo;
@@ -44,6 +46,9 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateMappe
     @Autowired
     private CourseMenuMapper courseMenuMapper;
 
+    @Autowired
+    private IMajorService iMajorService;
+
     @Override
     public UserCertificateVo queryById(Long id){
         UserCertificate db = this.baseMapper.selectById(id);
@@ -80,6 +85,11 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateMappe
         if(Validator.isEmpty(userCertificateVo)){
             throw new CustomException("证书不存在");
         }
+        MajorVo majorVo = iMajorService.queryById(userCertificateVo.getMajorId());
+        if(Validator.isEmpty(majorVo)){
+            throw new CustomException("专业不存在");
+        }
+        userCertificateVo.setMajor(majorVo.getCategoryName());
         ClassGradeUserQueryBo queryBo = new ClassGradeUserQueryBo();
         queryBo.setUserId(userCertificateVo.getUserId());
         queryBo.setGoodsId(userCertificateVo.getGoodsId());

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserVisitLogServiceImpl.java

@@ -3,6 +3,8 @@ package com.zhongzheng.modules.user.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.useragent.UserAgent;
+import cn.hutool.http.useragent.UserAgentUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -87,6 +89,7 @@ public class UserVisitLogServiceImpl extends ServiceImpl<UserVisitLogMapper, Use
         UserVisitLog add = BeanUtil.toBean(bo, UserVisitLog.class);
         validEntityBeforeSave(add);
         add.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+        add.setBrowser(ServletUtils.getRequest().getHeader("User-Agent"));
         add.setDateTime(zeroTime);
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserCertificateVo.java

@@ -122,4 +122,9 @@ public class UserCertificateVo {
 	@Excel(name = "1单证书 2多证书")
 	@ApiModelProperty("1单证书 2多证书")
 	private Integer moreCertificateStatus;
+
+	private BigDecimal publicClassHours;
+
+	@ApiModelProperty("专业")
+	private String major;
 }

+ 7 - 3
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -240,6 +240,7 @@
     <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterVo" id="CourseChapterResultVo">
         <result property="chapterId" column="chapter_id"/>
         <result property="name" column="name"/>
+        <result property="commonSign" column="common_sign"/>
     </resultMap>
 
     <select id="selectUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
@@ -1531,22 +1532,25 @@
         SELECT ui.* from (SELECT
         cc.chapter_id,
         cc.`name`,
-        m.sort
+        m.sort,
+        cm.common_sign
         FROM
         course_module_chapter p
         LEFT JOIN course_chapter cc ON p.chapter_id = cc.chapter_id
         LEFT JOIN course_menu m ON m.menu_id = p.module_id
         LEFT JOIN goods_course gc ON gc.course_id = m.course_id
+        LEFT JOIN course_module cm ON p.module_id = cm.module_id
         WHERE
         gc.goods_id = #{goodsId}
         <if test="moduleId != null and moreCertificateStatus == 2 ">
             AND p.module_id = #{moduleId}
         </if>
-        AND m.type =  1 UNION
+        AND m.type =  1 UNION ALL
         SELECT
         cc.chapter_id,
         cc.`name`,
-        m.sort
+        m.sort,
+         0 as common_sign
         FROM
         course_menu m
         LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id