ソースを参照

优化

shuiqilin
zhangxin 1年前
コミット
3ea7592b69
1個のファイルの変更277行の追加287行の削除
  1. 277
    287
      src/main/java/com/qtzl/alterSales/manager/service/AflProductInfoServiceImpl.java

+ 277
- 287
src/main/java/com/qtzl/alterSales/manager/service/AflProductInfoServiceImpl.java ファイルの表示

@@ -1,48 +1,26 @@
package com.qtzl.alterSales.manager.service;

import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.collect.Lists;
import com.qtzl.alterSales.dao.entity.second.AflProductHisInfo;
import com.qtzl.alterSales.dao.entity.second.AflProductInfo;
import com.qtzl.alterSales.dao.entity.second.AflSignChannelsProduct;
import com.qtzl.alterSales.dao.repo.jpa.second.AflProductHisInfoRepo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflProductInfoRepo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflSignChannelsProductRepo;
import com.qtzl.alterSales.manager.enums.AuditStatusEnum;
import com.qtzl.alterSales.manager.enums.GroundStatusEnum;
import com.qtzl.alterSales.manager.enums.IsDeleteEnum;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
import com.qtzl.alterSales.manager.model.protocol.sales.*;
import com.qtzl.alterSales.manager.service.third.ConstantConfig;
import com.qtzl.alterSales.manager.service.third.FmsService;
import com.qtzl.alterSales.manager.tools.ExcelUtils;
import com.qtzl.alterSales.manager.vo.AflProductInfoFindByIdVo;
import com.qtzl.alterSales.manager.vo.AflProductInfoImportVo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class AflProductInfoServiceImpl implements AflProductInfoService{

@Resource
AflProductInfoRepo aflProductInfoRepo;
@Resource
AflSignChannelsProductRepo aflSignChannelsProductRepo;
@Resource
AflProductHisInfoRepo aflProductHisInfoRepo;
// @Resource
// AflSignChannelsProductRepo aflSignChannelsProductRepo;
// @Resource
// AflProductHisInfoRepo aflProductHisInfoRepo;

@Resource
FmsService fmsService;
@@ -50,301 +28,313 @@ public class AflProductInfoServiceImpl implements AflProductInfoService{
@Resource
ConstantConfig constantConfig;

// @Override
// public void save(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
// verify(request);
// if (StringUtils.isEmpty(request.getCreator())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("创建人不能为空");
// }
// if (!StringUtils.isEmpty(request.getId())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该方法为新增,产品编号不可以指定");
// }
// AflProductInfo aflProductInfo = aflProductInfoRepo.findByProductCode(request.getProductCode());
// if (aflProductInfo!=null){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
// }
// aflProductInfo = new AflProductInfo();
// BeanUtils.copyProperties(request,aflProductInfo);
// aflProductInfo.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
// aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
// aflProductInfo.setInsertTime(new Date());
// aflProductInfoRepo.save(aflProductInfo);
// }

// @Override
// public void update(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
// verify(request);
// if (StringUtils.isEmpty(request.getUpdator())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("修改人不能为空");
// }
// AflProductInfo aflProductInfo = findById(request.getId());
// if (!aflProductInfo.getProductCode().equals(request.getProductCode())){
// AflProductInfo byProductCode = aflProductInfoRepo.findByProductCode(request.getProductCode());
// if (byProductCode!=null){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
// }
// }
// if (aflProductInfo.getGroundStatus()==null||aflProductInfo.getGroundStatus()== GroundStatusEnum.GROUND.getCode()){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("只能修改未上架或已下架产品");
// }
// //保存历史
// saveHis(aflProductInfo);
// //修改信息进入审核
// request.setCreator(aflProductInfo.getCreator());
// BeanUtils.copyProperties(request,aflProductInfo);
// aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
// aflProductInfo.setUpdateTime(new Date());
// aflProductInfoRepo.save(aflProductInfo);
// }

@Override
public void save(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
verify(request);
if (StringUtils.isEmpty(request.getCreator())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("创建人不能为空");
}
if (!StringUtils.isEmpty(request.getId())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该方法为新增,产品编号不可以指定");
}
AflProductInfo aflProductInfo = aflProductInfoRepo.findByProductCode(request.getProductCode());
if (aflProductInfo!=null){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
}
aflProductInfo = new AflProductInfo();
BeanUtils.copyProperties(request,aflProductInfo);
aflProductInfo.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
aflProductInfo.setInsertTime(new Date());
aflProductInfoRepo.save(aflProductInfo);
public void save(AflSignChannelsInfoSaveOrUpdateRequest request) throws ServiceHandleException {

}

@Override
public void update(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
verify(request);
if (StringUtils.isEmpty(request.getUpdator())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("修改人不能为空");
}
AflProductInfo aflProductInfo = findById(request.getId());
if (!aflProductInfo.getProductCode().equals(request.getProductCode())){
AflProductInfo byProductCode = aflProductInfoRepo.findByProductCode(request.getProductCode());
if (byProductCode!=null){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
}
}
if (aflProductInfo.getGroundStatus()==null||aflProductInfo.getGroundStatus()== GroundStatusEnum.GROUND.getCode()){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("只能修改未上架或已下架产品");
}
//保存历史
saveHis(aflProductInfo);
//修改信息进入审核
request.setCreator(aflProductInfo.getCreator());
BeanUtils.copyProperties(request,aflProductInfo);
aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
aflProductInfo.setUpdateTime(new Date());
aflProductInfoRepo.save(aflProductInfo);
public void update(AflSignChannelsInfoSaveOrUpdateRequest request) throws ServiceHandleException {

}

@Override
public AflProductInfo findById(String id) throws ServiceHandleException {
if (StringUtils.isEmpty(id)) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
}
AflProductInfo aflProductInfo= aflProductInfoRepo.findByIdAndIsDelete(id);
if (null == aflProductInfo) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品配置不存在");
}
return aflProductInfo;
public AflProductInfoFindByIdVo findById(String id) throws ServiceHandleException {
// if (StringUtils.isEmpty(id)) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
// }
// AflProductInfo aflProductInfo= aflProductInfoRepo.findByIdAndIsDelete(id);
// if (null == aflProductInfo) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品配置不存在");
// }
// return aflProductInfo;
return null;
}

@Override
public void delete(AflProductInfoDeleteRequest request) throws ServiceHandleException {
if (StringUtils.isEmpty(request.getId())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
}
AflProductInfo aflProductInfo = findById(request.getId());
aflProductInfo.setIsDelete(IsDeleteEnum.YES.getCode());//删除
aflProductInfoRepo.save(aflProductInfo);
// if (StringUtils.isEmpty(request.getId())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
// }
// AflProductInfo aflProductInfo = findById(request.getId());
// aflProductInfo.setIsDelete(IsDeleteEnum.YES.getCode());//删除
// aflProductInfoRepo.save(aflProductInfo);
}

@Override
public String export(AflProductInfoExportRequest request, HttpServletResponse response, Logger logger) throws ServiceHandleException {
String pathFile =null;
try {
if (request.getTemplate()){
pathFile = ExcelUtils.export(response, "产品信息模板", constantConfig.getFilePath(), null, AflProductInfoImportVo.class);
}else {
// AflProductInfoExportHqlRequest queryRequest = new AflProductInfoExportHqlRequest();
// BeanUtil.copyProperties(request, queryRequest);
// List<AflProductInfoFindByIdVo> aflProductInfoFindByIdVoList = aflProductInfoRepo.list(queryRequest);
//
// if (aflProductInfoFindByIdVoList == null || aflProductInfoFindByIdVoList.size() == 0) {
// String pathFile =null;
// try {
// if (request.getTemplate()){
// pathFile = ExcelUtils.export(response, "产品信息模板", constantConfig.getFilePath(), null, AflProductInfoImportVo.class);
// }else {
//// AflProductInfoExportHqlRequest queryRequest = new AflProductInfoExportHqlRequest();
//// BeanUtil.copyProperties(request, queryRequest);
//// List<AflProductInfoFindByIdVo> aflProductInfoFindByIdVoList = aflProductInfoRepo.list(queryRequest);
////
//// if (aflProductInfoFindByIdVoList == null || aflProductInfoFindByIdVoList.size() == 0) {
//// pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), null, AflProductInfoFindByIdVo.class);
//// } else {
//// pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), aflProductInfoFindByIdVoList, AflProductInfoFindByIdVo.class);
////
//// }
// List<AflProductInfo> select = select(request);
// if (select == null || select.size() == 0) {
// pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), null, AflProductInfoFindByIdVo.class);
// } else {
// pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), aflProductInfoFindByIdVoList, AflProductInfoFindByIdVo.class);
// List<AflProductInfoFindByIdVo> aflProductInfoFindByIdVos = new ArrayList<>();
// for (AflProductInfo aflProductInfo : select) {
// AflProductInfoFindByIdVo aflProductInfoFindByIdVo = new AflProductInfoFindByIdVo();
// BeanUtils.copyProperties(aflProductInfo,aflProductInfoFindByIdVo);
// aflProductInfoFindByIdVos.add(aflProductInfoFindByIdVo);
// }
// pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), aflProductInfoFindByIdVos, AflProductInfoFindByIdVo.class);
//
// }
List<AflProductInfo> select = select(request);
if (select == null || select.size() == 0) {
pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), null, AflProductInfoFindByIdVo.class);
} else {
List<AflProductInfoFindByIdVo> aflProductInfoFindByIdVos = new ArrayList<>();
for (AflProductInfo aflProductInfo : select) {
AflProductInfoFindByIdVo aflProductInfoFindByIdVo = new AflProductInfoFindByIdVo();
BeanUtils.copyProperties(aflProductInfo,aflProductInfoFindByIdVo);
aflProductInfoFindByIdVos.add(aflProductInfoFindByIdVo);
}
pathFile = ExcelUtils.export(response, "产品信息", constantConfig.getFilePath(), aflProductInfoFindByIdVos, AflProductInfoFindByIdVo.class);

}
}
if (StringUtils.isEmpty(pathFile)){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
}
String s = null;
try {
s = fmsService.uploadFile(constantConfig.getUploadFile(),pathFile, 90000);
} catch (ServiceHandleException e) {
logger.error("选装-产品信息管理导出失败:{}", e.getMessage());
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage());
}

if (StringUtils.isEmpty(s)){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
}
return s;
} catch (Exception e) {
if (e instanceof ServiceHandleException) {
throw e;
}
logger.error("选装-产品信息管理导出失败:{}", e.getMessage());
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
}finally {
File file = null;
try {
file = new File(pathFile);
} catch (Exception e) {

}
if (file!=null){
file.delete();
}
}
// }
// if (StringUtils.isEmpty(pathFile)){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
// }
// String s = null;
// try {
// s = fmsService.uploadFile(constantConfig.getUploadFile(),pathFile, 90000);
// } catch (ServiceHandleException e) {
// logger.error("选装-产品信息管理导出失败:{}", e.getMessage());
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage());
// }
//
// if (StringUtils.isEmpty(s)){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
// }
// return s;
// } catch (Exception e) {
// if (e instanceof ServiceHandleException) {
// throw e;
// }
// logger.error("选装-产品信息管理导出失败:{}", e.getMessage());
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品信息管理导出失败");
// }finally {
// File file = null;
// try {
// file = new File(pathFile);
// } catch (Exception e) {
//
// }
// if (file!=null){
// file.delete();
// }
// }
return null;
}

@Override
public void updateStatus(AflProductInfoUpdateGroundStatusRequest request) throws ServiceHandleException {

if (StringUtils.isEmpty(request.getUpdator())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("修改人不能为空");
}
AflProductInfo aflProductInfo = findById(request.getId());
if (aflProductInfo.getGroundStatus()==request.getGroundStatus()) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("上架状态没有发生改变");
}
//保存历史
saveHis(aflProductInfo);
//
aflProductInfo.setGroundStatus(request.getGroundStatus());
aflProductInfo.setGroundTime(new Date());
aflProductInfo.setUpdator(request.getUpdator());
aflProductInfoRepo.save(aflProductInfo);
// if (StringUtils.isEmpty(request.getUpdator())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("修改人不能为空");
// }
// AflProductInfo aflProductInfo = findById(request.getId());
// if (aflProductInfo.getGroundStatus()==request.getGroundStatus()) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("上架状态没有发生改变");
// }
// //保存历史
// saveHis(aflProductInfo);
// //
// aflProductInfo.setGroundStatus(request.getGroundStatus());
// aflProductInfo.setGroundTime(new Date());
// aflProductInfo.setUpdator(request.getUpdator());
// aflProductInfoRepo.save(aflProductInfo);
}

@Override
public void audit(AflProductInfoAuditRequest request) throws ServiceHandleException {
if (StringUtils.isEmpty(request.getId())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
}
if (StringUtils.isEmpty(request.getAuditor())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("审核人不能为空");
}
//审核失败,审核原因必填
if (request.getAuditStatus()==2){
if (StringUtils.isEmpty(request.getReason())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("审核失败,请填入审核原因");
}
}
AflProductInfo aflProductInfo = findById(request.getId());
if (aflProductInfo.getAuditStatus()==request.getAuditStatus()){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品审核状态未发生改变");
}
//保存历史
saveHis(aflProductInfo);
BeanUtils.copyProperties(request,aflProductInfo);
aflProductInfo.setGroundStatus(GroundStatusEnum.NOTGROUND.getCode());
aflProductInfoRepo.save(aflProductInfo);
// if (StringUtils.isEmpty(request.getId())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定产品配置编号");
// }
// if (StringUtils.isEmpty(request.getAuditor())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("审核人不能为空");
// }
// //审核失败,审核原因必填
// if (request.getAuditStatus()==2){
// if (StringUtils.isEmpty(request.getReason())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("审核失败,请填入审核原因");
// }
// }
// AflProductInfo aflProductInfo = findById(request.getId());
// if (aflProductInfo.getAuditStatus()==request.getAuditStatus()){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品审核状态未发生改变");
// }
//
// //保存历史
// saveHis(aflProductInfo);
//
// BeanUtils.copyProperties(request,aflProductInfo);
// aflProductInfo.setGroundStatus(GroundStatusEnum.NOTGROUND.getCode());
// aflProductInfoRepo.save(aflProductInfo);
}

@Override
public void importProductInfo(AflProductInfoImportRequest request, Logger logger) throws ServiceHandleException {
if (StringUtils.isEmpty(request.getDownloadUrl())){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定文件下载地址");
}
// String downloadFilePath = fmsService.downloadFile(request.getFileId(),constantConfig.getFilePath(), "产品信息");
String downloadFilePath = fmsService.downloadNetworkFile(request.getDownloadUrl(),constantConfig.getFilePath(), "产品信息");
if (StringUtils.isEmpty(downloadFilePath)){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("下载失败");
}
File file = new File(downloadFilePath);
try {
List<AflProductInfoImportVo> aflProductInfoImportVos= ExcelUtils.readFile(file, AflProductInfoImportVo.class);
if (aflProductInfoImportVos==null||aflProductInfoImportVos.size()==0){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导入失败,没有数据");
}
for (AflProductInfoImportVo aflProductInfoImportVo : aflProductInfoImportVos) {
AflProductInfo byProductCode = aflProductInfoRepo.findByProductCode(aflProductInfoImportVo.getProductCode());
if (byProductCode!=null){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
}
AflProductInfo aflProductInfo = new AflProductInfo();
BeanUtil.copyProperties(aflProductInfoImportVo,aflProductInfo);
aflProductInfo.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
aflProductInfo.setInsertTime(new Date());
aflProductInfoRepo.save(aflProductInfo);
}
} catch (Exception e) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导入失败!");
}finally {
if (file!=null){
file.delete();
}
}
}

@Override
public void addSignChannels(AflSignChannelsProductSaveRequest request) throws ServiceHandleException {
if (StringUtils.isEmpty(request.getProductId())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品id不能为空");
}
if (StringUtils.isEmpty(request.getChannelCode())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("签约渠道编码不能为空");
}
AflSignChannelsProduct aflSignChannelsProduct = new AflSignChannelsProduct();
BeanUtils.copyProperties(request,aflSignChannelsProduct);
aflSignChannelsProduct.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
aflSignChannelsProductRepo.save(aflSignChannelsProduct);
// if (StringUtils.isEmpty(request.getDownloadUrl())){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定文件下载地址");
// }
//// String downloadFilePath = fmsService.downloadFile(request.getFileId(),constantConfig.getFilePath(), "产品信息");
// String downloadFilePath = fmsService.downloadNetworkFile(request.getDownloadUrl(),constantConfig.getFilePath(), "产品信息");
// if (StringUtils.isEmpty(downloadFilePath)){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("下载失败");
// }
// File file = new File(downloadFilePath);
// try {
// List<AflProductInfoImportVo> aflProductInfoImportVos= ExcelUtils.readFile(file, AflProductInfoImportVo.class);
// if (aflProductInfoImportVos==null||aflProductInfoImportVos.size()==0){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导入失败,没有数据");
// }
// for (AflProductInfoImportVo aflProductInfoImportVo : aflProductInfoImportVos) {
// AflProductInfo byProductCode = aflProductInfoRepo.findByProductCode(aflProductInfoImportVo.getProductCode());
// if (byProductCode!=null){
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("已存在该产品编码的配置,不允许重复");
// }
// AflProductInfo aflProductInfo = new AflProductInfo();
// BeanUtil.copyProperties(aflProductInfoImportVo,aflProductInfo);
// aflProductInfo.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
// aflProductInfo.setAuditStatus(AuditStatusEnum.PENDINGREVIEW.getCode());
// aflProductInfo.setInsertTime(new Date());
// aflProductInfoRepo.save(aflProductInfo);
// }
// } catch (Exception e) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导入失败!");
// }finally {
// if (file!=null){
// file.delete();
// }
// }
}

private void verify(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
// @Override
// public void addSignChannels(AflSignChannelsProductSaveRequest request) throws ServiceHandleException {
// if (StringUtils.isEmpty(request.getProductId())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品id不能为空");
// }
// if (StringUtils.isEmpty(request.getChannelCode())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("签约渠道编码不能为空");
// }
// AflSignChannelsProduct aflSignChannelsProduct = new AflSignChannelsProduct();
// BeanUtils.copyProperties(request,aflSignChannelsProduct);
// aflSignChannelsProduct.setIsDelete(IsDeleteEnum.NO.getCode());//默认未删除
// aflSignChannelsProductRepo.save(aflSignChannelsProduct);
// }

if (StringUtils.isEmpty(request.getProductCode())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品编码不能为空");
}
if (StringUtils.isEmpty(request.getProductName())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品名称不能为空");
}
if (StringUtils.isEmpty(request.getProductIcon())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品图标不能为空");
}
if (request.getProductEffectiveTime()==null) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品有效期不能为空");
}
if (StringUtils.isEmpty(request.getProductDescribe())) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品描述不能为空");
}
}
private void saveHis(AflProductInfo aflProductInfo ){
AflProductHisInfo aflProductHisInfo = new AflProductHisInfo();
BeanUtils.copyProperties(aflProductInfo,aflProductHisInfo);
aflProductHisInfo.setId(UUID.randomUUID().toString().replace("-", ""));
aflProductHisInfo.setHisId(aflProductInfo.getId());
aflProductHisInfoRepo.save(aflProductHisInfo);
}
private List<AflProductInfo> select(AflProductInfoExportRequest request) throws ServiceHandleException {
// private void verify(AflProductInfoSaveOrUpdateRequest request) throws ServiceHandleException {
//
// if (StringUtils.isEmpty(request.getProductCode())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品编码不能为空");
// }
// if (StringUtils.isEmpty(request.getProductName())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品名称不能为空");
// }
// if (StringUtils.isEmpty(request.getProductIcon())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品图标不能为空");
// }
// if (request.getProductEffectiveTime()==null) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品有效期不能为空");
// }
// if (StringUtils.isEmpty(request.getProductDescribe())) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("产品描述不能为空");
// }
// }
// private void saveHis(AflProductInfo aflProductInfo ){
// AflProductHisInfo aflProductHisInfo = new AflProductHisInfo();
// BeanUtils.copyProperties(aflProductInfo,aflProductHisInfo);
// aflProductHisInfo.setId(UUID.randomUUID().toString().replace("-", ""));
// aflProductHisInfo.setHisId(aflProductInfo.getId());
// aflProductHisInfoRepo.save(aflProductHisInfo);
// }

return aflProductInfoRepo.findAll(((root, query, cb) -> {
List<Predicate> list = Lists.newArrayList();
if (!StringUtils.isEmpty(request.getProductCode())) {
list.add(cb.equal(root.<String>get("productCode"), request.getProductCode()));
}
if (!StringUtils.isEmpty(request.getProductName())) {
list.add(cb.equal(root.get("productName"), request.getProductName()));
}
if (request.getAuditStatus()!=null) {
list.add(cb.equal(root.<Integer>get("auditStatus"), request.getAuditStatus()));
}
if (request.getGroundStatus()!=null) {
list.add(cb.equal(root.<Integer>get("groundStatus"), request.getGroundStatus()));
}
if (request.getGroundTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeEnd()));
}
if (request.getGroundTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeStart()));
}
if (request.getUndercarriageTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeEnd()));
}
if (request.getUndercarriageTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeStart()));
}
if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
}
if (request.getInsertTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
}
//查询为未删除的数据
list.add(cb.equal(root.<Integer>get("isDelete"), IsDeleteEnum.NO.getCode()));
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}), Sort.by(Sort.Direction.DESC, "insertTime"));
}
// private List<AflProductInfo> select(AflProductInfoExportRequest request) throws ServiceHandleException {
//
// return aflProductInfoRepo.findAll(((root, query, cb) -> {
// List<Predicate> list = Lists.newArrayList();
// if (!StringUtils.isEmpty(request.getProductCode())) {
// list.add(cb.equal(root.<String>get("productCode"), request.getProductCode()));
// }
// if (!StringUtils.isEmpty(request.getProductName())) {
// list.add(cb.equal(root.get("productName"), request.getProductName()));
// }
// if (request.getAuditStatus()!=null) {
// list.add(cb.equal(root.<Integer>get("auditStatus"), request.getAuditStatus()));
// }
// if (request.getGroundStatus()!=null) {
// list.add(cb.equal(root.<Integer>get("groundStatus"), request.getGroundStatus()));
// }
// if (request.getGroundTimeEnd()!=null) {
// list.add(cb.lessThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeEnd()));
// }
// if (request.getGroundTimeStart()!=null) {
// list.add(cb.greaterThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeStart()));
// }
// if (request.getUndercarriageTimeEnd()!=null) {
// list.add(cb.lessThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeEnd()));
// }
// if (request.getUndercarriageTimeStart()!=null) {
// list.add(cb.greaterThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeStart()));
// }
// if (request.getInsertTimeEnd()!=null) {
// list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
// }
// if (request.getInsertTimeStart()!=null) {
// list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
// }
// //查询为未删除的数据
// list.add(cb.equal(root.<Integer>get("isDelete"), IsDeleteEnum.NO.getCode()));
// Predicate[] p = new Predicate[list.size()];
// return cb.and(list.toArray(p));
// }), Sort.by(Sort.Direction.DESC, "insertTime"));
// }
}

読み込み中…
キャンセル
保存