|
|
@@ -1,22 +1,40 @@
|
|
|
package org.springblade.finance.fince;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.entity.CorpsDesc;
|
|
|
+import org.springblade.client.entity.FeesDesc;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
+import org.springblade.client.feign.IFeesDescClient;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springblade.core.excel.util.ExcelUtil;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.finance.excel.DealWithExcel;
|
|
|
+import org.springblade.finance.excel.DealWithItemExcel;
|
|
|
+import org.springblade.finance.excel.ProfitExcel;
|
|
|
+import org.springblade.finance.excel.ProfitItemExcel;
|
|
|
import org.springblade.finance.service.IAccService;
|
|
|
import org.springblade.finance.vo.AccVO;
|
|
|
import org.springblade.finance.vo.CostMessage;
|
|
|
+import org.springblade.finance.vojo.Acc;
|
|
|
import org.springblade.finance.vojo.Settlement;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 利润总账
|
|
|
*/
|
|
|
@@ -27,7 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class Profit extends BladeController {
|
|
|
private final IAccService accService;
|
|
|
private final ICorpsDescClient corpsDescClient;
|
|
|
-
|
|
|
+ private final IFeesDescClient iFeesDescClient;
|
|
|
/**
|
|
|
* 分页 利润总账
|
|
|
*/
|
|
|
@@ -35,7 +53,137 @@ public class Profit extends BladeController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "利润总账分页", notes = "传入settlement")
|
|
|
public R<IPage<CostMessage>> list(AccVO accVO, Query query) {
|
|
|
-
|
|
|
- return null;
|
|
|
+ if (StringUtils.isBlank(accVO.getTradeType())){
|
|
|
+ throw new SecurityException("请选择查询的贸易类型");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(accVO.getTenantId())){
|
|
|
+ accVO.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ IPage<CostMessage> costMessageIPage = accService.salaryProfit(accVO, Condition.getPage(query));
|
|
|
+ if (CollectionUtils.isNotEmpty(costMessageIPage.getRecords())){
|
|
|
+ costMessageIPage.getRecords().stream().forEach(item ->{
|
|
|
+ if (item.getCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ item.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return R.data(costMessageIPage);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 导出-利润总账
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "利润总账")
|
|
|
+ public void export(AccVO accVO, HttpServletResponse response) {
|
|
|
+ if (StringUtils.isBlank(accVO.getTradeType())){
|
|
|
+ throw new SecurityException("请选择查询的贸易类型");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(accVO.getTenantId())){
|
|
|
+ accVO.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<ProfitExcel> list = new ArrayList<>();
|
|
|
+ List<CostMessage> costMessageList = accService.salaryProfit(accVO);
|
|
|
+ if (CollectionUtils.isNotEmpty(costMessageList)){
|
|
|
+ costMessageList.stream().forEach(item ->{
|
|
|
+ if (item.getCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ item.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ list = BeanUtil.copy(costMessageList, ProfitExcel.class);
|
|
|
+ }
|
|
|
+ ExcelUtil.export(response, "利润总账", "利润总账", list, ProfitExcel.class);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "详情", notes = "传入acc")
|
|
|
+ public R detail(AccVO acc, Query query) {
|
|
|
+ if (StringUtils.isBlank(acc.getTradeType())){
|
|
|
+ throw new SecurityException("请选择查询的贸易类型");
|
|
|
+ }
|
|
|
+ if (acc.getCorpId() == null){
|
|
|
+ throw new SecurityException("请选择查询的明细");
|
|
|
+ }
|
|
|
+ acc.setTenantId(SecureUtil.getTenantId());
|
|
|
+ IPage<Acc> page = accService.page(Condition.getPage(query), Condition.getQueryWrapper(acc));
|
|
|
+ if (CollectionUtils.isNotEmpty(page.getRecords())){
|
|
|
+ page.getRecords().stream().forEach(item ->{
|
|
|
+ if (item.getCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ item.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //费用名称
|
|
|
+ if (StringUtils.isNotBlank(item.getCostType())) {
|
|
|
+ R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
|
|
|
+ if (detail.isSuccess() && detail.getData() != null) {
|
|
|
+ item.setItemName(detail.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("d")){
|
|
|
+ item.setDc("收费");
|
|
|
+ }else if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("c")){
|
|
|
+ item.setDc("付费");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 导出-利润总账明细
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ @GetMapping("/exportItem")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "利润总账明细")
|
|
|
+ public void exportItem(AccVO accVO, HttpServletResponse response) {
|
|
|
+ if (StringUtils.isBlank(accVO.getTradeType())){
|
|
|
+ throw new SecurityException("请选择查询的贸易类型");
|
|
|
+ }
|
|
|
+ if (accVO.getCorpId() == null){
|
|
|
+ throw new SecurityException("请选择查询的明细");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(accVO.getTenantId())){
|
|
|
+ accVO.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<ProfitItemExcel> list = new ArrayList<>();
|
|
|
+ List<Acc> costMessageList = accService.list(Condition.getQueryWrapper(accVO));
|
|
|
+ if (CollectionUtils.isNotEmpty(costMessageList)){
|
|
|
+ costMessageList.stream().forEach(item ->{
|
|
|
+ if (item.getCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ item.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //费用名称
|
|
|
+ if (StringUtils.isNotBlank(item.getCostType())) {
|
|
|
+ R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
|
|
|
+ if (detail.isSuccess() && detail.getData() != null) {
|
|
|
+ item.setItemName(detail.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("d")){
|
|
|
+ item.setDc("收费");
|
|
|
+ }else if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("c")){
|
|
|
+ item.setDc("付费");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(costMessageList)){
|
|
|
+ list = BeanUtil.copy(costMessageList, ProfitItemExcel.class);
|
|
|
+ }
|
|
|
+ ExcelUtil.export(response, "利润总账明细", "利润总账明细", list, ProfitItemExcel.class);
|
|
|
}
|
|
|
}
|