Compare commits
2 Commits
b44d6b6d94
...
5ee255a1be
| Author | SHA1 | Date |
|---|---|---|
|
|
5ee255a1be | |
|
|
4c42afc6b9 |
|
|
@ -3,6 +3,9 @@ package com.nflg.mobilebroken.quotation.controller.admin;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.QuotationAdminSearchRequest;
|
||||
|
|
@ -18,10 +21,20 @@ import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
|||
import com.nflg.mobilebroken.repository.service.IQuotationShoppingOrderAdjustService;
|
||||
import com.nflg.mobilebroken.repository.service.IQuotationShoppingOrderService;
|
||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -63,4 +76,32 @@ public class AdminShoppingController extends ControllerBase {
|
|||
.list()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出报价单
|
||||
* @param id 报价单ID
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<org.springframework.core.io.Resource> exportPdf(HttpServletResponse response, @RequestParam Long id) {
|
||||
// response.setContentType(MediaType.APPLICATION_PDF_VALUE);
|
||||
// String encode = URLEncoder.encode( "demo.pdf", StandardCharsets.UTF_8);
|
||||
// response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "inline;filename=" + encode);
|
||||
// try {
|
||||
// ITextRenderer renderer = new ITextRenderer();
|
||||
// renderer.getFontResolver().addFont("fonts/simsun.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||
// renderer.setDocumentFromString(html);
|
||||
// renderer.layout();
|
||||
// try (OutputStream outputStream = response.getOutputStream()) {
|
||||
// renderer.createPDF(outputStream);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("生成pdf出错", e);
|
||||
// throw new NflgException(STATE.BusinessError, "生成pdf出错");
|
||||
// }
|
||||
org.springframework.core.io.Resource resource = new ClassPathResource("templates/demo.pdf");
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_PDF)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"demo.pdf\"")
|
||||
.body(resource);
|
||||
}
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@ public class RatioConfigController extends ControllerBase {
|
|||
TargetUserVO vo = new TargetUserVO();
|
||||
if (isMarketingDirector) {
|
||||
List<QuotationModelRatioAgentItemDTO> agentItems = ratioAgentItemService.getEffectives();
|
||||
if (CollectionUtil.isNotEmpty(agentItems)) {
|
||||
vo.setAppUsers(
|
||||
appUserService.lambdaQuery()
|
||||
.in(AppUser::getId, agentItems.stream().map(QuotationModelRatioAgentItemDTO::getUserId).collect(Collectors.toList()))
|
||||
|
|
@ -83,7 +84,9 @@ public class RatioConfigController extends ControllerBase {
|
|||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
||||
if (CollectionUtil.isNotEmpty(directItems)) {
|
||||
vo.setAdminUsers(
|
||||
adminUserService.lambdaQuery()
|
||||
.in(AdminUser::getId, directItems.stream().map(QuotationModelRatioDirectItemDTO::getUserId).collect(Collectors.toList()))
|
||||
|
|
@ -97,6 +100,7 @@ public class RatioConfigController extends ControllerBase {
|
|||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
||||
return ApiResult.success(vo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.core.io.ClassPathResource;
|
|||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -212,7 +213,7 @@ public class ShoppingController extends ControllerBase {
|
|||
vo.setDiscount(vo.getTotalFee().subtract(vo.getActualFee()));
|
||||
log.debug("机型【{}】价格为{},优惠{}", request.getModelNo(), vo.getActualFee(), vo.getDiscount());
|
||||
//获取部件配置
|
||||
List<ModelConfigEffectiveDTO> parts = modelConfigService.getEffectives(modelPrice.getPriceId(), categoryId, MultilingualUtil.getLanguage());
|
||||
List<ModelConfigEffectiveDTO> parts = modelConfigService.getEffectives(modelPrice.getConfigId(),modelPrice.getPriceId(), categoryId, MultilingualUtil.getLanguage());
|
||||
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(parts)).throwMessage("未获取到部件信息");
|
||||
vo.setStandardParts(parts.stream()
|
||||
.filter(part -> part.getParentId() == 0L && part.getType() == 1)
|
||||
|
|
@ -851,4 +852,32 @@ public class ShoppingController extends ControllerBase {
|
|||
return categoryId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出报价单
|
||||
* @param id 报价单ID
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<org.springframework.core.io.Resource> exportPdf(HttpServletResponse response, @RequestParam Long id) {
|
||||
// response.setContentType(MediaType.APPLICATION_PDF_VALUE);
|
||||
// String encode = URLEncoder.encode( "demo.pdf", StandardCharsets.UTF_8);
|
||||
// response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "inline;filename=" + encode);
|
||||
// try {
|
||||
// ITextRenderer renderer = new ITextRenderer();
|
||||
// renderer.getFontResolver().addFont("fonts/simsun.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||
// renderer.setDocumentFromString(html);
|
||||
// renderer.layout();
|
||||
// try (OutputStream outputStream = response.getOutputStream()) {
|
||||
// renderer.createPDF(outputStream);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("生成pdf出错", e);
|
||||
// throw new NflgException(STATE.BusinessError, "生成pdf出错");
|
||||
// }
|
||||
org.springframework.core.io.Resource resource = new ClassPathResource("templates/demo.pdf");
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_PDF)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"demo.pdf\"")
|
||||
.body(resource);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -23,5 +23,5 @@ public interface QuotationModelConfigMapper extends BaseMapper<QuotationModelCon
|
|||
|
||||
IPage<ModelConfigVO> search(ModelConfigSearchRequest request, Page<?> objectPage);
|
||||
|
||||
List<ModelConfigEffectiveDTO> getEffectives(Long priceId, Long categoryId, String language);
|
||||
List<ModelConfigEffectiveDTO> getEffectives(Long configId,Long priceId, Long categoryId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ public interface IQuotationModelConfigService extends IService<QuotationModelCon
|
|||
|
||||
IPage<ModelConfigVO> search(ModelConfigSearchRequest request);
|
||||
|
||||
List<ModelConfigEffectiveDTO> getEffectives(Long priceId, Long categoryId, String language);
|
||||
List<ModelConfigEffectiveDTO> getEffectives(Long configId,Long priceId, Long categoryId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class QuotationModelConfigServiceImpl extends ServiceImpl<QuotationModelC
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ModelConfigEffectiveDTO> getEffectives(Long priceId, Long categoryId, String language) {
|
||||
return baseMapper.getEffectives(priceId,categoryId,language);
|
||||
public List<ModelConfigEffectiveDTO> getEffectives(Long configId,Long priceId, Long categoryId, String language) {
|
||||
return baseMapper.getEffectives(configId,priceId,categoryId,language);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,17 @@
|
|||
</select>
|
||||
|
||||
<select id="getEffectives" resultType="com.nflg.mobilebroken.common.pojo.dto.ModelConfigEffectiveDTO">
|
||||
SELECT qmci.id,qmci.parent_id,qmcil.part_name,qmcil.part_remark,qmci.image_url,qmpia.amount,qmci.type,qmci.optional_type
|
||||
FROM quotation_model_price qmp
|
||||
INNER JOIN quotation_model_price_item qmpi ON qmpi.price_id=qmp.id
|
||||
INNER JOIN quotation_model_config_item qmci ON qmci.unique_id=qmpi.config_item_unique_id
|
||||
INNER JOIN quotation_model_config_item_language qmcil ON qmcil.config_item_id=qmci.id
|
||||
INNER JOIN `language` l ON l.id=qmcil.language_id
|
||||
INNER JOIN quotation_model_price_item_area qmpia ON qmpia.price_item_id=qmpi.id
|
||||
WHERE qmp.id=#{priceId} AND l.`code`=#{language} AND qmpia.area_id=#{categoryId}
|
||||
SELECT qmci.id,qmci.parent_id,qmcil.part_name,qmcil.part_remark,qmci.image_url,pp.amount,qmci.type,qmci.optional_type
|
||||
FROM quotation_model_config_item qmci
|
||||
LEFT JOIN quotation_model_config_item_language qmcil ON qmcil.config_item_id=qmci.id
|
||||
LEFT JOIN `language` l ON l.id=qmcil.language_id
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT qmpi.config_item_unique_id,qmpia.amount
|
||||
FROM quotation_model_price_item qmpi
|
||||
LEFT JOIN quotation_model_price_item_area qmpia ON qmpia.price_item_id=qmpi.id
|
||||
WHERE qmpia.price_id=#{priceId} AND qmpia.area_id=#{categoryId}
|
||||
) pp ON qmci.unique_id=pp.config_item_unique_id
|
||||
WHERE qmci.`enable` AND qmci.config_id=#{configId} AND l.`code`=#{language}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue