|
|
|
@ -9,10 +9,7 @@ import java.time.Instant; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
@ -448,48 +445,54 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS |
|
|
|
|
|
|
|
@Override |
|
|
|
public int insertQrCode(String num) { |
|
|
|
// 先将与之关联的其他二维码都失效
|
|
|
|
QrCodeGenerateHistory qrParams = new QrCodeGenerateHistory(); |
|
|
|
qrParams.setEnterpriseNumber(num); |
|
|
|
qrParams.setStatus(1); |
|
|
|
iQrCodeGenerateHistoryService.updateQrCodeGenerateHistoryByNumber(qrParams); |
|
|
|
|
|
|
|
// 通过 企业编码 获取该编码在数据库中的企业信息, 将salt拿出来做生成参数
|
|
|
|
EnterpriseInformation info = new EnterpriseInformation(); |
|
|
|
info.setEnterpriseNumber(num); |
|
|
|
List<EnterpriseInformation> enterpriseInformations = enterpriseInformationMapper.selectEnterpriseInformationList(info); |
|
|
|
if (null != enterpriseInformations && enterpriseInformations.size() > 0) { |
|
|
|
EnterpriseInformation enterpriseInformation = enterpriseInformations.get(0); |
|
|
|
Date current=new Date(); |
|
|
|
QrCodeGenerateHistory qr=iQrCodeGenerateHistoryService.selectQrCodeGenerateHistoryByNewest(num); |
|
|
|
if(current.getTime()-qr.getGenerateTime().getTime()>86400000L) { |
|
|
|
// 先将与之关联的其他二维码都失效
|
|
|
|
QrCodeGenerateHistory qrParams = new QrCodeGenerateHistory(); |
|
|
|
qrParams.setEnterpriseNumber(num); |
|
|
|
qrParams.setStatus(1); |
|
|
|
iQrCodeGenerateHistoryService.updateQrCodeGenerateHistoryByNumber(qrParams); |
|
|
|
|
|
|
|
// 通过 企业编码 获取该编码在数据库中的企业信息, 将salt拿出来做生成参数
|
|
|
|
EnterpriseInformation info = new EnterpriseInformation(); |
|
|
|
info.setEnterpriseNumber(num); |
|
|
|
List<EnterpriseInformation> enterpriseInformations = enterpriseInformationMapper.selectEnterpriseInformationList(info); |
|
|
|
if (null != enterpriseInformations && enterpriseInformations.size() > 0) { |
|
|
|
EnterpriseInformation enterpriseInformation = enterpriseInformations.get(0); |
|
|
|
// String text = enterpriseInformation.getSalt();
|
|
|
|
String uuid = IdUtil.simpleUUID(); |
|
|
|
Map<String, String> jsonMap = new HashMap<>(); |
|
|
|
jsonMap.put("salt", enterpriseInformation.getSalt()); |
|
|
|
jsonMap.put("codeId", uuid); |
|
|
|
jsonMap.put("type", "zfjd"); |
|
|
|
String text = JSON.toJSONString(jsonMap); |
|
|
|
//这里设置自定义网站url
|
|
|
|
String logoPath = qrCodeUrl; |
|
|
|
try { |
|
|
|
File encode = QRCodeUtil.encodeFile(text, logoPath, filePath, true); |
|
|
|
MultipartFile multipartFile = QRCodeUtil.getMultipartFile(encode); |
|
|
|
String upload = fileUploadApi.upload(multipartFile); |
|
|
|
|
|
|
|
QrCodeGenerateHistory qrCodeGenerateHistory = new QrCodeGenerateHistory(); |
|
|
|
qrCodeGenerateHistory.setId(uuid); |
|
|
|
//生成时间
|
|
|
|
qrCodeGenerateHistory.setGenerateTime(DateUtils.getNowDate()); |
|
|
|
//二维码地址
|
|
|
|
qrCodeGenerateHistory.setQrCodeUrl(upload); |
|
|
|
//统一信用代码
|
|
|
|
qrCodeGenerateHistory.setEnterpriseNumber(enterpriseInformation.getEnterpriseNumber()); |
|
|
|
//变更原因
|
|
|
|
qrCodeGenerateHistory.setReasonsChange("登记"); |
|
|
|
return iQrCodeGenerateHistoryService.insertQrCodeGenerateHistory(qrCodeGenerateHistory); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
String uuid = IdUtil.simpleUUID(); |
|
|
|
Map<String, String> jsonMap = new HashMap<>(); |
|
|
|
jsonMap.put("salt", enterpriseInformation.getSalt()); |
|
|
|
jsonMap.put("codeId", uuid); |
|
|
|
jsonMap.put("type", "zfjd"); |
|
|
|
String text = JSON.toJSONString(jsonMap); |
|
|
|
//这里设置自定义网站url
|
|
|
|
String logoPath = qrCodeUrl; |
|
|
|
try { |
|
|
|
File encode = QRCodeUtil.encodeFile(text, logoPath, filePath, true); |
|
|
|
MultipartFile multipartFile = QRCodeUtil.getMultipartFile(encode); |
|
|
|
String upload = fileUploadApi.upload(multipartFile); |
|
|
|
|
|
|
|
QrCodeGenerateHistory qrCodeGenerateHistory = new QrCodeGenerateHistory(); |
|
|
|
qrCodeGenerateHistory.setId(uuid); |
|
|
|
//生成时间
|
|
|
|
qrCodeGenerateHistory.setGenerateTime(DateUtils.getNowDate()); |
|
|
|
//二维码地址
|
|
|
|
qrCodeGenerateHistory.setQrCodeUrl(upload); |
|
|
|
//统一信用代码
|
|
|
|
qrCodeGenerateHistory.setEnterpriseNumber(enterpriseInformation.getEnterpriseNumber()); |
|
|
|
//变更原因
|
|
|
|
qrCodeGenerateHistory.setReasonsChange("登记"); |
|
|
|
return iQrCodeGenerateHistoryService.insertQrCodeGenerateHistory(qrCodeGenerateHistory); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}else{ |
|
|
|
return 3; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|