Browse Source

20230223 17:10

wangzhuo 2 years ago
parent
commit
f256c7dfe9

+ 14 - 0
blade-service-api/blade-box-tube-api/src/main/java/org/springblade/box/tube/entity/AnnualBudget.java

@@ -1,5 +1,6 @@
 package org.springblade.box.tube.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -49,6 +50,13 @@ public class AnnualBudget implements Serializable {
 	 */
 	@ApiModelProperty(value = "创建人")
 	private Long createUser;
+
+	/**
+	 * 创建人名称
+	 */
+	@TableField(exist = false)
+	private String createUserName;
+
 	/**
 	 * 创建部门
 	 */
@@ -65,6 +73,11 @@ public class AnnualBudget implements Serializable {
 	@ApiModelProperty(value = "修改人")
 	private Long updateUser;
 	/**
+	 * 创建人名称
+	 */
+	@TableField(exist = false)
+	private String updateUserName;
+	/**
 	 * 修改时间
 	 */
 	@ApiModelProperty(value = "修改时间")
@@ -101,5 +114,6 @@ public class AnnualBudget implements Serializable {
 	/**
 	 * 明细集合
 	 */
+	@TableField(exist = false)
 	List<AnnualBudgetItem> itemList;
 }

+ 24 - 0
blade-service-api/blade-box-tube-api/src/main/java/org/springblade/box/tube/entity/AnnualBudgetItem.java

@@ -88,6 +88,12 @@ public class AnnualBudgetItem implements Serializable {
 	private Long corpId;
 
 	/**
+	 * 客户名称
+	 */
+	@ApiModelProperty(value = "客户名称")
+	private String corpName;
+
+	/**
 	 * 年
 	 */
 	@ApiModelProperty(value = "年")
@@ -237,4 +243,22 @@ public class AnnualBudgetItem implements Serializable {
 	@TableField(exist = false)
 	private String corpIds;
 
+	/**
+	 * 计划量汇总
+	 */
+	@ApiModelProperty(value = "计划量汇总")
+	private BigDecimal quantitySummary;
+
+	/**
+	 * 订单汇总
+	 */
+	@TableField(exist = false)
+	private BigDecimal orderSummary;
+
+	/**
+	 * 发货汇总
+	 */
+	@TableField(exist = false)
+	private BigDecimal deliverySummary;
+
 }

+ 121 - 0
blade-service-api/blade-box-tube-api/src/main/java/org/springblade/box/tube/excel/AnnualBudgetExcel.java

@@ -0,0 +1,121 @@
+package org.springblade.box.tube.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ *  统计分析 年度预算报表导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class AnnualBudgetExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 年
+	 */
+	@ExcelProperty(value = "年")
+	private Integer year;
+
+	/**
+	 * 月
+	 */
+	@ExcelProperty(value = "月")
+	private Integer month;
+
+	/**
+	 * 客户名称
+	 */
+	@ExcelProperty(value = "客户名称")
+	private String corpName;
+
+	/**
+	 * 登马计划量
+	 */
+	@ExcelProperty(value = "登马计划量")
+	private BigDecimal drivemaster;
+
+	/**
+	 * 登马订单数量
+	 */
+	@ExcelProperty(value = "登马订单数量")
+	private BigDecimal drivemasterOrdQuantity;
+
+	/**
+	 * 登马发货数量
+	 */
+	@ExcelProperty(value = "登马发货数量")
+	private BigDecimal drivemasterDeliverQuantity;
+
+	/**
+	 * 路迈计划量
+	 */
+	@ExcelProperty(value = "路迈计划量")
+	private BigDecimal luxxan;
+
+	/**
+	 * 路迈订单数量
+	 */
+	@ExcelProperty(value = "路迈订单数量")
+	private BigDecimal luxxanOrdQuantity;
+
+	/**
+	 * 路迈发货数量
+	 */
+	@ExcelProperty(value = "路迈发货数量")
+	private BigDecimal luxxanDeliverQuantity;
+
+	/**
+	 * 艾特路计划量
+	 */
+	@ExcelProperty(value = "艾特路计划量")
+	private BigDecimal xcentway;
+
+	/**
+	 * 艾特路订单数量
+	 */
+	@ExcelProperty(value = "艾特路订单数量")
+	private BigDecimal xcentwayOrdQuantity;
+
+	/**
+	 * 艾特路发货数量
+	 */
+	@ExcelProperty(value = "艾特路发货数量")
+	private BigDecimal xcentwayDeliverQuantity;
+
+	/**
+	 * 欧记计划量
+	 */
+	@ExcelProperty(value = "欧记计划量")
+	private BigDecimal keter;
+
+	/**
+	 * 欧记订单数量
+	 */
+	@ExcelProperty(value = "欧记订单数量")
+	private BigDecimal keterOrdQuantity;
+
+	/**
+	 * 欧记发货数量
+	 */
+	@ExcelProperty(value = "欧记发货数量")
+	private BigDecimal keterDeliverQuantity;
+
+	/**
+	 * 计划量汇总
+	 */
+	@ExcelProperty(value = "汇总")
+	private BigDecimal quantitySummary;
+}

+ 3 - 6
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/vo/DatasetVO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 数据明细返回类
@@ -63,12 +64,8 @@ public class DatasetVO {
 	private BigDecimal actualQuantity;
 
 	/**
-	 * 发货日期开始
+	 * 发货日期数组
 	 */
-	private String beginReceiptTime;
+	private List<String> receiptTimeList;
 
-	/**
-	 * 发货日期结束
-	 */
-	private String endReceiptTime;
 }

+ 50 - 0
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/annualBudget/controller/AnnualBudgetController.java

@@ -2,6 +2,7 @@ package org.springblade.box.tube.annualBudget.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -10,6 +11,8 @@ import lombok.AllArgsConstructor;
 import org.springblade.box.tube.annualBudget.service.IAnnualBudgetService;
 import org.springblade.box.tube.entity.AnnualBudget;
 import org.springblade.box.tube.vo.AnnualBudgetVO;
+import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.feign.IRedisClient;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
@@ -17,9 +20,13 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.system.user.entity.User;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 年度预算控制器
@@ -32,6 +39,9 @@ public class AnnualBudgetController extends BladeController {
 
 	private final IAnnualBudgetService annualBudgetService;
 
+	private final RedisTemplate<String, Object> redisTemplate;
+	private final IRedisClient redisClient;//redis缓存处理
+
 	/**
 	 * 详情
 	 */
@@ -58,6 +68,25 @@ public class AnnualBudgetController extends BladeController {
 
 		IPage<AnnualBudget> page = annualBudgetService.page(Condition.getPage(query), lambdaQueryWrapper);
 
+		redisClient.basicData("all");
+		List<User> userList = castToList(redisTemplate.opsForValue().get("user"), User.class);
+
+		if (CollectionUtils.isNotEmpty(page.getRecords())) {
+			page.getRecords().forEach(item -> {
+				if (item.getCreateUser() != null){
+					User user = userList.stream().filter(e -> e.getId().equals(item.getCreateUser())).findFirst().orElse(null);
+					if (ObjectUtil.isNotEmpty(user)){
+						item.setCreateUserName(user.getName());
+					}
+				}
+				if (item.getUpdateUser() != null){
+					User user = userList.stream().filter(e -> e.getId().equals(item.getUpdateUser())).findFirst().orElse(null);
+					if (ObjectUtil.isNotEmpty(user)){
+						item.setUpdateUserName(user.getName());
+					}
+				}
+			});
+		}
 		return R.data(page);
 	}
 
@@ -112,4 +141,25 @@ public class AnnualBudgetController extends BladeController {
 		return R.status(annualBudgetService.removeByIds(Func.toLongList(ids)));
 	}
 
+	/**
+	 * 将Object转换成List类型
+	 *
+	 * @param obj   Object对象
+	 * @param clazz 数据类型
+	 * @param <T>   泛型类型
+	 * @return List类型
+	 */
+	public static <T> List<T> castToList(Object obj, Class<T> clazz) {
+		List<T> resList = new ArrayList<>();
+		// 如果不是List<?>对象,是没有办法转换的
+		if (obj instanceof List<?>) {
+			for (Object o : (List<?>) obj) {
+				// 将对应的元素进行类型转换
+				resList.add(clazz.cast(o));
+			}
+			return resList;
+		}
+		return resList;
+	}
+
 }

+ 18 - 0
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/annualBudget/controller/AnnualBudgetItemController.java

@@ -11,18 +11,24 @@ import org.springblade.box.tube.annualBudget.service.IAnnualBudgetItemService;
 import org.springblade.box.tube.entity.AgreementFiles;
 import org.springblade.box.tube.entity.AnnualBudget;
 import org.springblade.box.tube.entity.AnnualBudgetItem;
+import org.springblade.box.tube.excel.AnnualBudgetExcel;
 import org.springblade.box.tube.vo.AgreementFilesVO;
 import org.springblade.box.tube.vo.AnnualBudgetItemVO;
 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.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.finance.excel.ChargeExcel;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 年度预算明细控制器
@@ -119,4 +125,16 @@ public class AnnualBudgetItemController extends BladeController {
 		return R.data(annualBudgetItemService.annualBudgetProfit(annualBudgetItem, query));
 	}
 
+	/**
+	 * 年度预算报表导出
+	 */
+	@GetMapping("/annualBudgetProfitExcel")
+	@ApiOperationSupport(order = 9)
+	@ApiOperation(value = "修改", notes = "传入annualBudgetItem")
+	public void annualBudgetProfitExcel(AnnualBudgetItem annualBudgetItem, HttpServletResponse response) {
+		List<AnnualBudgetItem> list = annualBudgetItemService.annualBudgetProfitExcel(annualBudgetItem);
+		List<AnnualBudgetExcel> annualBudgetItemExcelList = BeanUtil.copy(list, AnnualBudgetExcel.class);
+		ExcelUtil.export(response, "年度预算分析", "年度预算分析", annualBudgetItemExcelList, AnnualBudgetExcel.class);
+	}
+
 }

+ 7 - 0
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/annualBudget/service/IAnnualBudgetItemService.java

@@ -6,6 +6,8 @@ import org.springblade.box.tube.entity.AnnualBudgetItem;
 import org.springblade.box.tube.vo.AnnualBudgetItemVO;
 import org.springblade.core.mp.support.Query;
 
+import java.util.List;
+
 /**
  * 年度预算明细表 服务类
  *
@@ -27,4 +29,9 @@ public interface IAnnualBudgetItemService extends IService<AnnualBudgetItem> {
 	 * 年度预算报表
 	 */
 	IPage<AnnualBudgetItem> annualBudgetProfit(AnnualBudgetItem annualBudgetItem, Query query);
+
+	/**
+	 * 年度预算报表导出
+	 */
+	List<AnnualBudgetItem> annualBudgetProfitExcel(AnnualBudgetItem annualBudgetItem);
 }

+ 59 - 0
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/annualBudget/service/impl/AnnualBudgetItemServiceImpl.java

@@ -77,6 +77,10 @@ public class AnnualBudgetItemServiceImpl extends ServiceImpl<AnnualBudgetItemMap
 							e.setDrivemasterDeliverQuantity(o.getActualQuantity());
 						}
 					});
+					//订单汇总
+					e.setOrderSummary(e.getKeterOrdQuantity().add(e.getXcentwayOrdQuantity()).add(e.getLuxxanOrdQuantity()).add(e.getDrivemasterOrdQuantity()));
+					//发货汇总
+					e.setDeliverySummary(e.getKeterDeliverQuantity().add(e.getXcentwayDeliverQuantity()).add(e.getLuxxanDeliverQuantity()).add(e.getDrivemasterDeliverQuantity()));
 				}else {
 					e.setKeterOrdQuantity(BigDecimal.ZERO);
 					e.setKeterDeliverQuantity(BigDecimal.ZERO);
@@ -86,9 +90,64 @@ public class AnnualBudgetItemServiceImpl extends ServiceImpl<AnnualBudgetItemMap
 					e.setLuxxanDeliverQuantity(BigDecimal.ZERO);
 					e.setDrivemasterOrdQuantity(BigDecimal.ZERO);
 					e.setDrivemasterDeliverQuantity(BigDecimal.ZERO);
+					e.setOrderSummary(BigDecimal.ZERO);
+					e.setDeliverySummary(BigDecimal.ZERO);
 				}
 			});
 		}
 		return iPage;
 	}
+
+	/**
+	 * 年度预算报表
+	 */
+	@Override
+	public List<AnnualBudgetItem> annualBudgetProfitExcel(AnnualBudgetItem annualBudgetItem) {
+		//根据检索条件查询出符合条件的年度预算明细
+		LambdaQueryWrapper<AnnualBudgetItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+		lambdaQueryWrapper.eq(AnnualBudgetItem::getTenantId, AuthUtil.getTenantId())
+			.eq(AnnualBudgetItem::getIsDeleted, 0)
+			.eq(ObjectUtil.isNotEmpty(annualBudgetItem.getCorpId()), AnnualBudgetItem::getCorpId, annualBudgetItem.getCorpId())
+			.eq(ObjectUtil.isNotEmpty(annualBudgetItem.getYear()), AnnualBudgetItem::getYear, annualBudgetItem.getYear())
+			.eq(ObjectUtil.isNotEmpty(annualBudgetItem.getMonth()), AnnualBudgetItem::getMonth, annualBudgetItem.getMonth());
+
+		List<AnnualBudgetItem> list = baseMapper.selectList(lambdaQueryWrapper);
+
+		if (ObjectUtil.isNotEmpty(list)){
+			//根据年月和客户查询订单数量和发货数量
+			list.forEach(e -> {
+				List<OrderStatisticsVo> orderList = orderDescClient.getByOrderQuantity(e.getYear(), e.getMonth(), e.getCorpId());
+				if (ObjectUtil.isNotEmpty(orderList)){
+					orderList.forEach(o -> {
+						if ("KETER".equals(o.getBrand())){//欧记
+							e.setKeterOrdQuantity(o.getOrderQuantity());
+							e.setKeterDeliverQuantity(o.getActualQuantity());
+						}
+						if ("XCENTWAY".equals(o.getBrand())){//艾特路
+							e.setXcentwayOrdQuantity(o.getOrderQuantity());
+							e.setXcentwayDeliverQuantity(o.getActualQuantity());
+						}
+						if ("LUXXAN".equals(o.getBrand())){//路迈
+							e.setLuxxanOrdQuantity(o.getOrderQuantity());
+							e.setLuxxanDeliverQuantity(o.getActualQuantity());
+						}
+						if ("DRIVEMASTER".equals(o.getBrand())){//登马
+							e.setDrivemasterOrdQuantity(o.getOrderQuantity());
+							e.setDrivemasterDeliverQuantity(o.getActualQuantity());
+						}
+					});
+				}else {
+					e.setKeterOrdQuantity(BigDecimal.ZERO);
+					e.setKeterDeliverQuantity(BigDecimal.ZERO);
+					e.setXcentwayOrdQuantity(BigDecimal.ZERO);
+					e.setXcentwayDeliverQuantity(BigDecimal.ZERO);
+					e.setLuxxanOrdQuantity(BigDecimal.ZERO);
+					e.setLuxxanDeliverQuantity(BigDecimal.ZERO);
+					e.setDrivemasterOrdQuantity(BigDecimal.ZERO);
+					e.setDrivemasterDeliverQuantity(BigDecimal.ZERO);
+				}
+			});
+		}
+		return list;
+	}
 }

+ 1 - 1
blade-service/blade-client/src/main/java/org/springblade/client/goods/feign/GoodsDescClient.java

@@ -266,7 +266,7 @@ public class GoodsDescClient implements IGoodsDescClient {
 		LambdaQueryWrapper<GoodsDesc> goodsDescLambdaQueryWrapper = new LambdaQueryWrapper<>();
 		goodsDescLambdaQueryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId())
 			.eq(GoodsDesc::getIsDeleted, 0)
-			.and(i ->i.eq(GoodsDesc::getCname,cname).or().eq(GoodsDesc::getCnameInt,cname));
+			.and(i ->i.like(GoodsDesc::getCname,cname).or().like(GoodsDesc::getCode,cname));
 
 		return goodsDescService.list(goodsDescLambdaQueryWrapper);
 	}

+ 11 - 0
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryServiceImpl.java

@@ -131,6 +131,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 	private final JdCorpsMapper corpsMapper;
 	private IGoodsDescClient goodsDescClient;//获取商品信息
 	private final RedisTemplate<String, Object> redisTemplate;
+	private final IRedisClient redisClient;//redis缓存处理
 
 	private final IMessageClient messageClient;//消息
 
@@ -695,6 +696,9 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 		this.submitDelivery(select);
 		//验证收货单库存与传入库存是否一致,如果一直则修改库存
 		List<DeliveryItems> deliveryItemsList = select.getDeliveryItemsList();
+		//从缓存中获得库存
+		/*redisClient.basicData("all");
+		List<StockGoods> stockGoodsList = castToList(redisTemplate.opsForValue().get("stockGoods"), StockGoods.class);*/
 		if (CollectionUtils.isNotEmpty(deliveryItemsList)) {
 			List<BusinessOverpaymentItem> list = new ArrayList<>();
 			deliveryItemsList.forEach(e -> {
@@ -740,6 +744,13 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 					model.setCorpId(select.getCorpId());
 					model.setStorageId(select.getStorageId());//仓库
 					model.setItemType(e.getSpecificationAndModel());
+					/*model = stockGoodsList.stream().filter(s ->
+						s.getGoodsId().equals(e.getItemId())
+						&& s.getTradeType().equals("GN")
+						&& s.getCorpId().equals(select.getCorpId())
+						&& s.getStorageId().equals(select.getStorageId())
+						&& s.getItemType().equals(e.getSpecificationAndModel())
+					).findFirst().orElse(null);*/
 				} else {
 					throw new SecurityException("贸易类型未指定");
 				}

+ 4 - 4
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderItemsMapper.xml

@@ -504,11 +504,11 @@ WHERE
             <if test="dataset.endCreateTime !=null and dataset.endCreateTime != ''">
                 and t2.create_time &lt;= #{dataset.endCreateTime}
             </if>
-            <if test="dataset.beginReceiptTime !=null and dataset.beginReceiptTime != ''">
-                and t1.receipt_time &gt;= #{dataset.beginReceiptTime}
+            <if test="dataset.receiptTimeList !=null and dataset.receiptTimeList[0] !=null and dataset.receiptTimeList[0] != ''">
+                and t1.receipt_time &gt;= #{dataset.receiptTimeList[0]}
             </if>
-            <if test="dataset.endReceiptTime !=null and dataset.endReceiptTime != ''">
-                and t1.receipt_time &gt;= #{dataset.endReceiptTime}
+            <if test="dataset.receiptTimeList !=null and dataset.receiptTimeList[1] !=null and dataset.receiptTimeList[1] != ''">
+                and t1.receipt_time &gt;= #{dataset.receiptTimeList[1]}
             </if>
         </where>
         order by t2.create_time desc

+ 11 - 9
blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.xml

@@ -138,27 +138,29 @@
 
     <select id="SelChargeItem" resultType="org.springblade.finance.vojo.Acc">
         SELECT
-        FA.Src_parent_id AS orderId,
-        FA.AccSysNo AS accSysNo,
-        FA.quantity AS quantity,
-        FA.Amount AS amount,
-        FA.create_time AS createTime,
-        BO.actualQuantity AS actualQuantity,
-        BO.arrivalAmount - BO.thisUsedProfit AS arrivalAmount
+            FA.Src_parent_id AS orderId,
+            FA.AccSysNo AS accSysNo,
+            FA.quantity AS quantity,
+            FA.Amount AS amount,
+            FA.create_time AS createTime,
+            BO.actualQuantity AS actualQuantity,
+            BO.arrivalAmount - BO.thisUsedProfit + feesAmount AS arrivalAmount
         FROM finance_acc FA
         LEFT JOIN (
             SELECT
                 BO.id,
                 IFNULL( SUM(BOI.actual_quantity), 0) AS actualQuantity,
                 IFNULL( SUM( BOI.actual_quantity * BOI.price ) , 0 ) AS arrivalAmount,
-                IFNULL( BO.this_used_profit, 0 ) AS thisUsedProfit
+                IFNULL( BO.this_used_profit, 0 ) AS thisUsedProfit,
+                IFNULL( BOF.amount, 0 ) AS feesAmount
             FROM business_order BO
             LEFT JOIN business_order_items BOI ON BOI.pid = BO.id
+            LEFT JOIN business_order_fees BOF ON BOF.pid = BO.id
             WHERE
                 BO.is_deleted = 0
                 AND BOI.is_deleted = 0
             GROUP BY
-            BO.id
+                BO.id
         ) BO ON BO.id = FA.Src_parent_id
         <where>
             FA.tenant_id = #{acc.tenantId}