|
@@ -22,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -128,18 +130,19 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
/**
|
|
|
* 保存逻辑
|
|
|
* relationId
|
|
|
- * null
|
|
|
- * 新设备:插入设备、插入关联信息
|
|
|
- * 关联设备:更新设备、插入关联信息
|
|
|
- * notNull
|
|
|
- * 数据库新设备
|
|
|
- * 新设备:更新设备、原设备无需更新关联关系
|
|
|
- * 关联设备:更新设备、更新关联信息(若原设备无机构关联,应删除该设备)
|
|
|
- * 数据库关联设备
|
|
|
- * 新设备:插入设备、更新关联信息
|
|
|
- * 关联设备:更新设备、更新关联信息
|
|
|
+ * null
|
|
|
+ * 新设备:插入设备、插入关联信息
|
|
|
+ * 关联设备:更新设备、插入关联信息
|
|
|
+ * notNull
|
|
|
+ * 数据库新设备
|
|
|
+ * 新设备:更新设备、原设备无需更新关联关系
|
|
|
+ * 关联设备:更新设备、更新关联信息(若原设备无机构关联,应删除该设备)
|
|
|
+ * 数据库关联设备
|
|
|
+ * 新设备:插入设备、更新关联信息
|
|
|
+ * 关联设备:更新设备、更新关联信息
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException {
|
|
|
Integer relationId = productSaveDto.getRelationId();
|
|
|
Integer authType = productSaveDto.getAuthType();
|
|
@@ -190,7 +193,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
if (2 == certificateImageType && StringUtils.isEmpty(certificateImage)) {
|
|
|
return ResponseJson.error("授权牌不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 机构添加默认模板库生成
|
|
|
certificateImageType = 1;
|
|
|
}
|
|
@@ -258,6 +261,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 检测机构是否已关联该设备
|
|
|
ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
|
|
|
if (null != productRelation) {
|
|
|
+ // 设置手动回滚事务
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return ResponseJson.error("不能重复关联同一台设备");
|
|
|
}
|
|
|
// 关联设备,更新设备
|
|
@@ -273,6 +278,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 检测机构是否已关联该设备
|
|
|
ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
|
|
|
if (null != productRelation) {
|
|
|
+ // 设置手动回滚事务
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return ResponseJson.error("不能重复关联同一台设备");
|
|
|
}
|
|
|
// 更新机构设备关联关系
|
|
@@ -292,7 +299,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
authProductMapper.updateProductByProductId(product);
|
|
|
// 检测机构是否已关联该设备
|
|
|
ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
|
|
|
- if (null != productRelation) {
|
|
|
+ if (null != productRelation && !productRelation.getRelationId().equals(relationId)) {
|
|
|
+ // 设置手动回滚事务
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return ResponseJson.error("不能重复关联同一台设备");
|
|
|
}
|
|
|
}
|
|
@@ -391,7 +400,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
map.put("addWord2_style", Font.BOLD);
|
|
|
map.put("addWord2_size", (int) Math.round(90 * rate));
|
|
|
map.put("addWord2_x", (int) Math.round(2168 * rate));
|
|
|
- map.put("addWord2_y", (int) Math.round(3165 * rate));
|
|
|
+ map.put("addWord2_y", (int) Math.round(3160 * rate));
|
|
|
}
|
|
|
// 添加认证日期信息
|
|
|
if (null != product.getCreateTime()) {
|
|
@@ -419,112 +428,6 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /*private void insertProduct(Integer createBy, Integer source, ProductPo product) throws IOException {
|
|
|
- // 添加新设备
|
|
|
- // 原授权牌照
|
|
|
- product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
- if (1 == source && StringUtils.isNotEmpty(product.getCertificateImage()) && (null == addQrCodeFlag || 0 == addQrCodeFlag)) {
|
|
|
- //授权牌照不添加二维码,直接添加水印
|
|
|
- product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
|
- product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
|
- }
|
|
|
- if (1 == source && StringUtils.isNotEmpty(product.getCertificateImage()) && (null != addQrCodeFlag && 1 == addQrCodeFlag)) {
|
|
|
- // 生成二维码授权牌
|
|
|
- String addQrCodeImg = addQrCode(product.getCertificateImage(), product.getProductId(), addTemplateType);
|
|
|
- product.setCertificateImage(addQrCodeImg);
|
|
|
- //授权牌照添加水印
|
|
|
- product.setPcCertificateImage(addWaterMark(addQrCodeImg, 1));
|
|
|
- product.setAppletsCertificateImage(addWaterMark(addQrCodeImg, 2));
|
|
|
- //更新授权牌照
|
|
|
- authProductMapper.updateCertificateImage(product);
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- /*private void updateProduct(Integer productId, Integer addQrCodeFlag, Integer addTemplateType, Integer source, ProductPo product) throws IOException {
|
|
|
- // 商品id
|
|
|
- product.setProductId(productId);
|
|
|
- if (1 == source) {
|
|
|
- ProductPo dbProductImage = authProductMapper.getImageByProductId(productId);
|
|
|
- // 数据库该商品授权牌是否添加二维码
|
|
|
- Integer dbAddQrCodeFlag = dbProductImage.getAddQrCodeFlag();
|
|
|
- // 数据库该商品授权牌添加二维码模板
|
|
|
- Integer dbAddTemplateType = dbProductImage.getAddTemplateType();
|
|
|
- // 授权牌照是否重新上传
|
|
|
- boolean updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(dbProductImage.getCertificateImage())) || (StringUtils.isEmpty(dbProductImage.getPcCertificateImage()) || StringUtils.isEmpty(dbProductImage.getAppletsCertificateImage()));
|
|
|
- boolean addQrCodeSign = false;
|
|
|
- boolean addWaterMarkSign = false;
|
|
|
- if (StringUtils.isNotEmpty(product.getCertificateImage())) {
|
|
|
- if (null != dbAddQrCodeFlag && 1 == dbAddQrCodeFlag) {
|
|
|
- if (0 == addQrCodeFlag) {
|
|
|
- // 原本是,现在否
|
|
|
- if (updateImageFlag) {
|
|
|
- // 新上传图片,将原图片替换为当前图片,生成水印图片
|
|
|
- product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
- addWaterMarkSign = true;
|
|
|
- } else {
|
|
|
- // 原图片,将当前授权牌替换为原图,生成水印图片
|
|
|
- product.setCertificateImage(dbProductImage.getOriginalCertificateImage());
|
|
|
- addWaterMarkSign = true;
|
|
|
- }
|
|
|
- } else if (1 == addQrCodeFlag) {
|
|
|
- // 原本是,现在是
|
|
|
- if (updateImageFlag) {
|
|
|
- // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
- product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
- addQrCodeSign = true;
|
|
|
- addWaterMarkSign = true;
|
|
|
- } else if (!addTemplateType.equals(dbAddTemplateType)) {
|
|
|
- // 原图片,更改模板,将当前授权牌替换为原图,生成二维码授权牌,生成水印图片
|
|
|
- product.setCertificateImage(dbProductImage.getOriginalCertificateImage());
|
|
|
- addQrCodeSign = true;
|
|
|
- addWaterMarkSign = true;
|
|
|
- }
|
|
|
- // else 原图片,不更改模板,不做更改
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (1 == addQrCodeFlag) {
|
|
|
- // 原本否,现在是
|
|
|
- if (updateImageFlag) {
|
|
|
- // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
- product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
- addQrCodeSign = true;
|
|
|
- addWaterMarkSign = true;
|
|
|
- } else {
|
|
|
- // 原图片,生成二维码授权牌,生成水印图片
|
|
|
- addQrCodeSign = true;
|
|
|
- addWaterMarkSign = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 原本否,现在否
|
|
|
- if (updateImageFlag) {
|
|
|
- // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
- product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
- addWaterMarkSign = true;
|
|
|
- }
|
|
|
- // 原图片,不做更改
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- product.setPcCertificateImage(null);
|
|
|
- product.setAppletsCertificateImage(null);
|
|
|
- }
|
|
|
- if (addQrCodeSign) {
|
|
|
- // 生成二维码授权牌
|
|
|
- String addQrCodeImg = addQrCode(product.getCertificateImage(), productId, addTemplateType);
|
|
|
- product.setCertificateImage(addQrCodeImg);
|
|
|
- }
|
|
|
- if (addWaterMarkSign) {
|
|
|
- //授权牌照添加水印
|
|
|
- product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
|
- product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
|
- }
|
|
|
- }
|
|
|
- // 自动生成授权牌
|
|
|
-
|
|
|
- // 更新授权商品
|
|
|
- authProductMapper.updateProductByProductId(product);
|
|
|
- }*/
|
|
|
-
|
|
|
private String addWaterMark(String image,Integer type) throws IOException {
|
|
|
//type:1pc,2applets
|
|
|
ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
|
|
@@ -690,8 +593,12 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
@Override
|
|
|
public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, String authParty, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize) {
|
|
|
listType = null == listType ? 1 : listType;
|
|
|
- if (1 == listType && null == productTypeId) {
|
|
|
- return ResponseJson.error("参数异常,请输入设备分类id", null);
|
|
|
+ if (1 == listType) {
|
|
|
+ if (null == productTypeId) {
|
|
|
+ return ResponseJson.error("参数异常,请输入设备分类id", null);
|
|
|
+ } else if (StringUtils.isEmpty(snCode) && StringUtils.isEmpty(authParty)) {
|
|
|
+ return ResponseJson.error("搜索条件不能为空", null);
|
|
|
+ }
|
|
|
}
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, snCode);
|