Commit 028d6814 authored by 刘林's avatar 刘林

fix(jg):证书下载,企业管理导出功能bug修改

parent e9f90d0d
...@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.module.ymt.api.vo.XianElevatorVo; ...@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.module.ymt.api.vo.XianElevatorVo;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -52,6 +53,7 @@ import java.util.concurrent.CompletableFuture; ...@@ -52,6 +53,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -814,6 +816,21 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService { ...@@ -814,6 +816,21 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
} }
return idsList; return idsList;
} }
public static <T, R> List<R> batchQuery(List<T> list, int batchSize, Function<List<T>, List<R>> function) {
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
List<R> result = new ArrayList<>();
for (int i = 0; i < list.size(); i += batchSize) {
int end = Math.min(i + batchSize, list.size());
List<T> subList = list.subList(i, end);
List<R> batch = function.apply(subList);
if (CollectionUtils.isNotEmpty(batch)) {
result.addAll(batch);
}
}
return result;
}
/** /**
* 基础设置-企业信息列表数据导出 * 基础设置-企业信息列表数据导出
...@@ -824,7 +841,8 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService { ...@@ -824,7 +841,8 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
public void enterpriseInformationExport(String uuid, String ids, Map<String, Object> map) { public void enterpriseInformationExport(String uuid, String ids, Map<String, Object> map) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
List<String> enterSeqs = getEnterSeqs(ids, map); List<String> enterSeqs = getEnterSeqs(ids, map);
List<Map<String, String>> enterInfoWithExport = tzBaseEnterpriseInfoMapper.getEnterInfoWithExport(enterSeqs); List<Map<String, String>> enterInfoWithExport =
batchQuery(enterSeqs, 500, sequenceNbrs -> tzBaseEnterpriseInfoMapper.getEnterInfoWithExport(sequenceNbrs));
List<BaseEnterpriseVo> exportData = JSON.parseArray(JSON.toJSONString(enterInfoWithExport), BaseEnterpriseVo.class); List<BaseEnterpriseVo> exportData = JSON.parseArray(JSON.toJSONString(enterInfoWithExport), BaseEnterpriseVo.class);
exportData.forEach(item -> { exportData.forEach(item -> {
String categoryJson = item.getEquipCategory(); String categoryJson = item.getEquipCategory();
......
...@@ -64,6 +64,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -64,6 +64,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -757,38 +758,59 @@ public class JgUseRegistrationManageServiceImpl extends BaseService<JgUseRegistr ...@@ -757,38 +758,59 @@ public class JgUseRegistrationManageServiceImpl extends BaseService<JgUseRegistr
} }
public void exportUseRegistrationCertificate(JgUseRegistrationManage manage, HttpServletResponse response, String printType) { public void exportUseRegistrationCertificate(JgUseRegistrationManage manage, HttpServletResponse response, String printType) {
if (ValidationUtil.isEmpty(manage)) { try {
throw new BadRequest("使用登记信息为空,导出失败!"); if (ValidationUtil.isEmpty(manage)) {
} throw new BadRequest("使用登记信息为空,导出失败!");
List<JSONObject> deviceList = this.queryEquByCertificate(manage); }
if (ValidationUtil.isEmpty(deviceList)) { List<JSONObject> deviceList = this.queryEquByCertificate(manage);
throw new BadRequest("使用登记证下无设备,导出失败!"); if (ValidationUtil.isEmpty(deviceList)) {
throw new BadRequest("使用登记证下无设备,导出失败!");
}
Map<String, Object> params = buildExportParams(manage, deviceList);
JSONObject tagJson = Optional.ofNullable(manage.getCertificatePrintTag())
.map(JSONObject::parseObject)
.orElse(new JSONObject());
switch (printType) {
case CERTIFICATE_NORMAL://证 普打
commonService.generateCertificateReport(params, response);
tagJson.put(CERTIFICATE_NORMAL, 2);
break;
case CERTIFICATE_NESTED://证 套打
commonService.generateCertificateReportDoc(params, response);
tagJson.put(CERTIFICATE_NESTED, 2);
break;
case USE_FLAG_NORMAL://标志 普打
commonService.useFlagGenerate(this.buildUseFlagParamDto(deviceList, manage, params), response);
tagJson.put(USE_FLAG_NORMAL, 2);
break;
case USE_FLAG_NESTED://标志 套打
commonService.fightUseFlagGenerate(this.buildUseFlagParamDto(deviceList, manage, params), response);
tagJson.put(USE_FLAG_NESTED, 2);
break;
default:
throw new BadRequest("无效的打印类型!");
}
manage.setCertificatePrintTag(JSONObject.toJSONString(tagJson));
} catch (BadRequest e) {
writeErrorResponse(response, e.getMessage());
} }
Map<String, Object> params = buildExportParams(manage, deviceList); }
JSONObject tagJson = Optional.ofNullable(manage.getCertificatePrintTag())
.map(JSONObject::parseObject) private void writeErrorResponse(HttpServletResponse response, String message) {
.orElse(new JSONObject()); try {
switch (printType) { response.reset();
case CERTIFICATE_NORMAL://证 普打 response.setCharacterEncoding("UTF-8");
commonService.generateCertificateReport(params, response); response.setContentType("application/json;charset=UTF-8");
tagJson.put(CERTIFICATE_NORMAL, 2); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
break; ResponseModel<Object> result = new ResponseModel<>();
case CERTIFICATE_NESTED://证 套打 result.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
commonService.generateCertificateReportDoc(params, response); result.setMessage(message);
tagJson.put(CERTIFICATE_NESTED, 2); result.setTraceId(RequestContext.getTraceId());
break; response.getWriter().write(JSONObject.toJSONString(result));
case USE_FLAG_NORMAL://标志 普打 response.getWriter().flush();
commonService.useFlagGenerate(this.buildUseFlagParamDto(deviceList, manage, params), response); } catch (Exception ex) {
tagJson.put(USE_FLAG_NORMAL, 2); log.error("写错误响应失败", ex);
break;
case USE_FLAG_NESTED://标志 套打
commonService.fightUseFlagGenerate(this.buildUseFlagParamDto(deviceList, manage, params), response);
tagJson.put(USE_FLAG_NESTED, 2);
break;
default:
throw new BadRequest("无效的打印类型!");
} }
manage.setCertificatePrintTag(JSONObject.toJSONString(tagJson));
} }
private Map<String, Object> buildExportParams(JgUseRegistrationManage manage, List<JSONObject> deviceList) { private Map<String, Object> buildExportParams(JgUseRegistrationManage manage, List<JSONObject> deviceList) {
......
...@@ -916,6 +916,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -916,6 +916,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.list(); .list();
records = useInfoRecords.stream().map(IdxBizJgUseInfo::getRecord).collect(toList()); records = useInfoRecords.stream().map(IdxBizJgUseInfo::getRecord).collect(toList());
} }
log.info("status db={}, data={}", useRegistrationDb.getStatus(), data.getStatus());
EquipUsedCheckStrategyContext.getUsedStrategy(DEFINITION_KEY) EquipUsedCheckStrategyContext.getUsedStrategy(DEFINITION_KEY)
.delDataForCheckEquipRepeatUsed(records, data.getUseUnitCreditCode()); .delDataForCheckEquipRepeatUsed(records, data.getUseUnitCreditCode());
} }
......
...@@ -514,6 +514,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -514,6 +514,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
* 删除 redis校验重复引用设备的数据 * 删除 redis校验重复引用设备的数据
*/ */
private void delRepeatUseEquipData(JgVehicleInformation notice) { private void delRepeatUseEquipData(JgVehicleInformation notice) {
log.info("status = {}", notice.getStatus());
if (NOT_FLOWING_STATE.contains(notice.getStatus())) { if (NOT_FLOWING_STATE.contains(notice.getStatus())) {
LambdaQueryWrapper<JgVehicleInformationEq> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JgVehicleInformationEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgVehicleInformationEq::getVehicleId, notice.getSequenceNbr()); queryWrapper.eq(JgVehicleInformationEq::getVehicleId, notice.getSequenceNbr());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment