|
@@ -4,6 +4,9 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
|
|
+import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
@@ -19,16 +22,23 @@ import com.zhongzheng.modules.base.vo.CertificateTpVo;
|
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
|
import com.zhongzheng.modules.course.vo.CourseChapterVo;
|
|
import com.zhongzheng.modules.course.vo.CourseChapterVo;
|
|
|
import com.zhongzheng.modules.course.vo.CourseUserEducationTypeVo;
|
|
import com.zhongzheng.modules.course.vo.CourseUserEducationTypeVo;
|
|
|
|
|
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.user.bo.UserCertificateAddBo;
|
|
import com.zhongzheng.modules.user.bo.UserCertificateAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.service.IUserCertificateService;
|
|
import com.zhongzheng.modules.user.service.IUserCertificateService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
|
|
+import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
|
|
+import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
|
|
|
import com.zhongzheng.modules.user.vo.UserVo;
|
|
import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -64,6 +74,12 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
private IUserService iUserService;
|
|
private IUserService iUserService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OssService ossService;
|
|
private OssService ossService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IUserStudyRecordService iUserStudyRecordService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${certificate.host}")
|
|
|
|
|
+ private String CERTIFICATE_HOST;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public CertificateTpVo queryById(Long tpId){
|
|
public CertificateTpVo queryById(Long tpId){
|
|
@@ -131,6 +147,15 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
throw new CustomException("数据错误");
|
|
throw new CustomException("数据错误");
|
|
|
}
|
|
}
|
|
|
GoodsVo goodsVo = iGoodsService.selectDetail(bo.getGoodsId());
|
|
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);
|
|
|
|
|
+ //获取培训结束时间
|
|
|
|
|
+ ClassGradeUser classGradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getUserId, bo.getUserId()).eq(ClassGradeUser::getGradeId,bo.getGradeId()).last("limit 1"));
|
|
|
|
|
+ //获取章列表
|
|
|
List<CourseChapterVo> chapterList = iClassGradeUserService.findChapterList(bo);
|
|
List<CourseChapterVo> chapterList = iClassGradeUserService.findChapterList(bo);
|
|
|
UserVo userVo = iUserService.queryById(bo.getUserId());
|
|
UserVo userVo = iUserService.queryById(bo.getUserId());
|
|
|
if(Validator.isNotEmpty(goodsVo.getCertificateIds())){
|
|
if(Validator.isNotEmpty(goodsVo.getCertificateIds())){
|
|
@@ -159,21 +184,12 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
vo.setDateY(nowDate.substring(0, 4));
|
|
vo.setDateY(nowDate.substring(0, 4));
|
|
|
vo.setDateM(nowDate.substring(5, 7));
|
|
vo.setDateM(nowDate.substring(5, 7));
|
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
|
|
|
|
|
+ vo.setTrainStartTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
|
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
vo.setChapterList(chapterListTxt);
|
|
vo.setChapterList(chapterListTxt);
|
|
|
String ossPath = drawPic(vo);
|
|
String ossPath = drawPic(vo);
|
|
|
-
|
|
|
|
|
- UserCertificateAddBo addBo = new UserCertificateAddBo();
|
|
|
|
|
- addBo.setUserId(bo.getUserId());
|
|
|
|
|
- addBo.setGoodsId(bo.getGoodsId());
|
|
|
|
|
- addBo.setGradeId(bo.getGradeId());
|
|
|
|
|
- addBo.setCertificateTpId(tpVo.getTpId());
|
|
|
|
|
- addBo.setCertificateCode(code);
|
|
|
|
|
- addBo.setCertificatePath(ossPath);
|
|
|
|
|
- addBo.setClassHours(goodsVo.getClassHours());
|
|
|
|
|
- addBo.setEducationTypeId(goodsVo.getEducationTypeId());
|
|
|
|
|
- addBo.setProjectId(goodsVo.getProjectId());
|
|
|
|
|
- addBo.setBusinessId(goodsVo.getBusinessId());
|
|
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
iUserCertificateService.insertByAddBo(addBo);
|
|
iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -191,14 +207,18 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
vo.setDateY(nowDate.substring(0, 4));
|
|
vo.setDateY(nowDate.substring(0, 4));
|
|
|
vo.setDateM(nowDate.substring(5, 7));
|
|
vo.setDateM(nowDate.substring(5, 7));
|
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
|
|
|
|
|
+ vo.setTrainStartTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
|
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
vo.setChapterList(chapterListTxt);
|
|
vo.setChapterList(chapterListTxt);
|
|
|
- drawPic(vo);
|
|
|
|
|
|
|
+ String ossPath = drawPic(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if("certificate03".equals(tpVo.getKeyValue())){
|
|
else if("certificate03".equals(tpVo.getKeyValue())){
|
|
|
CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
|
- String code = "XYZC"+nowDate.substring(2, 4)+"03"+getCertificateCode();
|
|
|
|
|
|
|
+ String code = "XYPX01YJ"+nowDate.substring(0, 4)+getCertificateCode();
|
|
|
vo.setCode(code);
|
|
vo.setCode(code);
|
|
|
vo.setRealname(userVo.getRealname());
|
|
vo.setRealname(userVo.getRealname());
|
|
|
vo.setIdCard(userVo.getIdCard());
|
|
vo.setIdCard(userVo.getIdCard());
|
|
@@ -217,16 +237,149 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
vo.setDateD(nowDate.substring(8, 10));
|
|
|
vo.setMajor("一级建造师继续教育培训");
|
|
vo.setMajor("一级建造师继续教育培训");
|
|
|
vo.setRemark1("其中必修");
|
|
vo.setRemark1("其中必修");
|
|
|
- vo.setRemark2("课 60 学时,测试成绩合格。");
|
|
|
|
|
|
|
+ vo.setRemark2("课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
|
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
vo.setChapterList(chapterListTxt);
|
|
vo.setChapterList(chapterListTxt);
|
|
|
- drawPicOneBuild(vo);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ String ossPath =drawPicOneBuild(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("certificate04".equals(tpVo.getKeyValue())){
|
|
|
|
|
+ CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
|
|
|
+ String code = "XYPX02YJ"+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));
|
|
|
|
|
+ vo.setType("选修");
|
|
|
|
|
+ vo.setMajor("网络班");
|
|
|
|
|
+ String sex = "男";
|
|
|
|
|
+ if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
|
|
|
|
|
+ sex = "女";
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setSex(sex);
|
|
|
|
|
+ vo.setClassHours(goodsVo.getClassHours()+"");
|
|
|
|
|
+ vo.setDateY(nowDate.substring(0, 4));
|
|
|
|
|
+ vo.setDateM(nowDate.substring(5, 7));
|
|
|
|
|
+ vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setMajor("一级建造师继续教育培训");
|
|
|
|
|
+ vo.setRemark1("其中建");
|
|
|
|
|
+ vo.setRemark2("筑工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
|
|
|
|
|
+ List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
|
|
+ vo.setChapterList(chapterListTxt);
|
|
|
|
|
+ String ossPath =drawPicOneBuild(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("certificate05".equals(tpVo.getKeyValue())){
|
|
|
|
|
+ CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
|
|
|
+ String code = "XYPX02YJ"+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));
|
|
|
|
|
+ vo.setType("选修");
|
|
|
|
|
+ vo.setMajor("网络班");
|
|
|
|
|
+ String sex = "男";
|
|
|
|
|
+ if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
|
|
|
|
|
+ sex = "女";
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setSex(sex);
|
|
|
|
|
+ vo.setClassHours(goodsVo.getClassHours()+"");
|
|
|
|
|
+ vo.setDateY(nowDate.substring(0, 4));
|
|
|
|
|
+ vo.setDateM(nowDate.substring(5, 7));
|
|
|
|
|
+ vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setMajor("一级建造师继续教育培训");
|
|
|
|
|
+ vo.setRemark1("其中机");
|
|
|
|
|
+ vo.setRemark2("电工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
|
|
|
|
|
+ List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
|
|
+ vo.setChapterList(chapterListTxt);
|
|
|
|
|
+ String ossPath =drawPicOneBuild(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("certificate06".equals(tpVo.getKeyValue())){
|
|
|
|
|
+ CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
|
|
|
+ String code = "XYPX02YJ"+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));
|
|
|
|
|
+ vo.setType("选修");
|
|
|
|
|
+ vo.setMajor("网络班");
|
|
|
|
|
+ String sex = "男";
|
|
|
|
|
+ if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
|
|
|
|
|
+ sex = "女";
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setSex(sex);
|
|
|
|
|
+ vo.setClassHours(goodsVo.getClassHours()+"");
|
|
|
|
|
+ vo.setDateY(nowDate.substring(0, 4));
|
|
|
|
|
+ vo.setDateM(nowDate.substring(5, 7));
|
|
|
|
|
+ vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setMajor("一级建造师继续教育培训");
|
|
|
|
|
+ vo.setRemark1("其中市");
|
|
|
|
|
+ vo.setRemark2("政公用工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
|
|
|
|
|
+ List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
|
|
+ vo.setChapterList(chapterListTxt);
|
|
|
|
|
+ String ossPath =drawPicOneBuild(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("certificate07".equals(tpVo.getKeyValue())){
|
|
|
|
|
+ CertificatePhotoVo vo = new CertificatePhotoVo();
|
|
|
|
|
+ String code = "XYPX02YJ"+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));
|
|
|
|
|
+ vo.setType("选修");
|
|
|
|
|
+ vo.setMajor("网络班");
|
|
|
|
|
+ String sex = "男";
|
|
|
|
|
+ if(Validator.isNotEmpty(userVo.getSex())&&userVo.getSex()==2){
|
|
|
|
|
+ sex = "女";
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setSex(sex);
|
|
|
|
|
+ vo.setClassHours(goodsVo.getClassHours()+"");
|
|
|
|
|
+ vo.setDateY(nowDate.substring(0, 4));
|
|
|
|
|
+ vo.setDateM(nowDate.substring(5, 7));
|
|
|
|
|
+ vo.setDateD(nowDate.substring(8, 10));
|
|
|
|
|
+ vo.setMajor("一级建造师继续教育培训");
|
|
|
|
|
+ vo.setRemark1("其中公");
|
|
|
|
|
+ vo.setRemark2("路工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
|
|
|
|
|
+ List<String> chapterListTxt = changeChapterList(chapterList);
|
|
|
|
|
+ vo.setChapterList(chapterListTxt);
|
|
|
|
|
+ String ossPath =drawPicOneBuild(vo);
|
|
|
|
|
+ UserCertificateAddBo addBo = mergeData(bo,goodsVo,vo,tpVo.getTpId(),ossPath);
|
|
|
|
|
+ iUserCertificateService.insertByAddBo(addBo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private UserCertificateAddBo mergeData(ClassGradeUserQueryBo bo, GoodsVo goodsVo,CertificatePhotoVo vo,Long certificateTpId,String certificatePath){
|
|
|
|
|
+ UserCertificateAddBo addBo = new UserCertificateAddBo();
|
|
|
|
|
+ addBo.setUserId(bo.getUserId());
|
|
|
|
|
+ addBo.setGoodsId(bo.getGoodsId());
|
|
|
|
|
+ addBo.setGradeId(bo.getGradeId());
|
|
|
|
|
+ addBo.setCertificateTpId(certificateTpId);
|
|
|
|
|
+ addBo.setCertificateCode(vo.getCode());
|
|
|
|
|
+ addBo.setCertificatePath(certificatePath);
|
|
|
|
|
+ addBo.setClassHours(goodsVo.getClassHours());
|
|
|
|
|
+ addBo.setEducationTypeId(goodsVo.getEducationTypeId());
|
|
|
|
|
+ addBo.setProjectId(goodsVo.getProjectId());
|
|
|
|
|
+ addBo.setBusinessId(goodsVo.getBusinessId());
|
|
|
|
|
+ addBo.setSchoolId(goodsVo.getGoodsId());
|
|
|
|
|
+ addBo.setMajorId(goodsVo.getMajorId());
|
|
|
|
|
+ addBo.setYear(vo.getYear());
|
|
|
|
|
+ addBo.setPushDate(DateUtils.getDate());
|
|
|
|
|
+ addBo.setChapterStr(ArrayUtils.toString(vo.getChapterList(), ","));
|
|
|
|
|
+ return addBo;
|
|
|
|
|
+ }
|
|
|
private String getCertificateCode(){
|
|
private String getCertificateCode(){
|
|
|
Long id = iUserCertificateService.selectMaxId();
|
|
Long id = iUserCertificateService.selectMaxId();
|
|
|
String nowId = Long.toString(id);
|
|
String nowId = Long.toString(id);
|
|
@@ -310,6 +463,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
g.drawString(entity.getDateY(), 2280, 1599);
|
|
g.drawString(entity.getDateY(), 2280, 1599);
|
|
|
g.drawString(entity.getDateM(), 2505, 1599);
|
|
g.drawString(entity.getDateM(), 2505, 1599);
|
|
|
g.drawString(entity.getDateD(), 2712, 1599);
|
|
g.drawString(entity.getDateD(), 2712, 1599);
|
|
|
|
|
+ //二维码
|
|
|
|
|
+ String qrTxt = CERTIFICATE_HOST+"certificate.html?code="+entity.getCode();
|
|
|
|
|
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
|
|
|
+ BitMatrix bitMatrix = qrCodeWriter.encode(qrTxt, BarcodeFormat.QR_CODE, 320, 320);
|
|
|
|
|
+ BufferedImage qrImage = toBufferedImage(bitMatrix);
|
|
|
|
|
+ // 在模板上添加用户二维码(地址,左边距,上边距,图片宽度,图片高度,未知)
|
|
|
|
|
+ g.drawImage(qrImage, 320, 1330, 320, 320, null);
|
|
|
// 完成模板修改
|
|
// 完成模板修改
|
|
|
g.dispose();
|
|
g.dispose();
|
|
|
// 获取新文件的地址
|
|
// 获取新文件的地址
|
|
@@ -360,12 +520,22 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
g.drawString(entity.getDateM(), 1019, 677);
|
|
g.drawString(entity.getDateM(), 1019, 677);
|
|
|
g.drawString(entity.getDateD(), 1071, 677);
|
|
g.drawString(entity.getDateD(), 1071, 677);
|
|
|
|
|
|
|
|
|
|
+ //二维码
|
|
|
|
|
+ String qrTxt = CERTIFICATE_HOST+"certificate.html?code="+entity.getCode();
|
|
|
|
|
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
|
|
|
+ BitMatrix bitMatrix = qrCodeWriter.encode(qrTxt, BarcodeFormat.QR_CODE, 120, 120);
|
|
|
|
|
+ BufferedImage qrImage = toBufferedImage(bitMatrix);
|
|
|
|
|
+ // 在模板上添加用户二维码(地址,左边距,上边距,图片宽度,图片高度,未知)
|
|
|
|
|
+ g.drawImage(qrImage, 128, 660, 120, 120, null);
|
|
|
// 完成模板修改
|
|
// 完成模板修改
|
|
|
g.dispose();
|
|
g.dispose();
|
|
|
// 获取新文件的地址
|
|
// 获取新文件的地址
|
|
|
File outputfile = new File(imgName);
|
|
File outputfile = new File(imgName);
|
|
|
// 生成新的合成过的用户二维码并写入新图片
|
|
// 生成新的合成过的用户二维码并写入新图片
|
|
|
- ImageIO.write(imageLocal, "jpg", outputfile);
|
|
|
|
|
|
|
+ // ImageIO.write(imageLocal, "jpg", outputfile);
|
|
|
|
|
+ //上传OSS
|
|
|
|
|
+ InputStream is = bufferedImageToInputStream(imageLocal);
|
|
|
|
|
+ return ossService.uploadInputStream(is,7);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -378,7 +548,7 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
public InputStream bufferedImageToInputStream(BufferedImage image){
|
|
public InputStream bufferedImageToInputStream(BufferedImage image){
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
try {
|
|
try {
|
|
|
- ImageIO.write(image, "png", os);
|
|
|
|
|
|
|
+ ImageIO.write(image, "jpg", os);
|
|
|
InputStream input = new ByteArrayInputStream(os.toByteArray());
|
|
InputStream input = new ByteArrayInputStream(os.toByteArray());
|
|
|
return input;
|
|
return input;
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -387,6 +557,46 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public BufferedImage toBufferedImage(BitMatrix matrix) {
|
|
|
|
|
+ int black = 0xFF000000;
|
|
|
|
|
+ int white = 0x00FFFFFF;
|
|
|
|
|
+ int width = matrix.getWidth();
|
|
|
|
|
+ int height = matrix.getHeight();
|
|
|
|
|
+ BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
|
|
|
|
+ for (int x = 0; x < width; x++) {
|
|
|
|
|
+ for (int y = 0; y < height; y++) {
|
|
|
|
|
+ image.setRGB(x, y, matrix.get(x, y) ? black : white);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ int imgHeight = image.getHeight();//取得图片的长和宽
|
|
|
|
|
+ int imgWidth = image.getWidth();
|
|
|
|
|
+ int c = image.getRGB(3, 3);
|
|
|
|
|
+ int alpha = 10;
|
|
|
|
|
+ //防止越位
|
|
|
|
|
+ if (alpha < 0) {
|
|
|
|
|
+ alpha = 0;
|
|
|
|
|
+ } else if (alpha > 10) {
|
|
|
|
|
+ alpha = 10;
|
|
|
|
|
+ }
|
|
|
|
|
+ BufferedImage tmpImg = new BufferedImage(imgWidth, imgHeight,BufferedImage.TYPE_4BYTE_ABGR);//新建一个类型支持透明的BufferedImage
|
|
|
|
|
+ for(int i = 0; i < imgWidth; ++i)//把原图片的内容复制到新的图片,同时把背景设为透明
|
|
|
|
|
+ {
|
|
|
|
|
+ for(int j = 0; j < imgHeight; ++j){
|
|
|
|
|
+ //把背景设为透明
|
|
|
|
|
+ if(image.getRGB(i, j) == c){
|
|
|
|
|
+ tmpImg .setRGB(i, j, c & 0x00ffffff);
|
|
|
|
|
+ }
|
|
|
|
|
+ //设置透明度
|
|
|
|
|
+ else{
|
|
|
|
|
+ int rgb = tmpImg .getRGB(i, j);
|
|
|
|
|
+ rgb = ((alpha * 255 / 10) << 24) | (rgb & 0x00ffffff);
|
|
|
|
|
+ tmpImg .setRGB(i, j, rgb);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return tmpImg ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<CertificateTpVo> selectList(CertificateTpQueryBo bo) {
|
|
public List<CertificateTpVo> selectList(CertificateTpQueryBo bo) {
|
|
|
return this.baseMapper.selectList(bo);
|
|
return this.baseMapper.selectList(bo);
|