|
@@ -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);
|
|
@@ -193,10 +195,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 +491,43 @@ 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));
|
|
|
+ vo.setMajor("施工现场专业人员");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private UserCertificateAddBo mergeData(ClassGradeUserQueryBo bo, GoodsVo goodsVo,CertificatePhotoVo vo,Long certificateTpId,String certificatePath,Long moduleId){
|
|
@@ -503,6 +549,7 @@ 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(){
|
|
@@ -679,6 +726,88 @@ 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;
|
|
|
+ }
|
|
|
+
|
|
|
public InputStream bufferedImageToInputStream(BufferedImage image){
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
try {
|