Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-api-cloud
This commit is contained in:
commit
f3b0891b56
6 files changed
+85
-4
No files matched your search
+4
-2
@@ -88,6 +88,7 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
|
||||
if (!CollectionUtils.isEmpty(updateStockDTOS)){
|
||||
canteenStockService.updateStock(updateStockDTOS);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -129,6 +130,7 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
|
||||
|
||||
List<CanteenInventoryRecordsItemEntity> insertItems = CanteenInventoryRecordsItemEntityList.stream().
|
||||
filter(CanteenInventoryRecordsItemEntity -> CanteenInventoryRecordsItemEntity.getId() == null).collect(Collectors.toList());
|
||||
insertItems.forEach(item -> {item.setInventoryId(smErpInventoryRecordsEntity.getId());});
|
||||
List<CanteenInventoryRecordsItemEntity> updateItems = CanteenInventoryRecordsItemEntityList.stream().
|
||||
filter(CanteenInventoryRecordsItemEntity -> CanteenInventoryRecordsItemEntity.getId() != null).collect(Collectors.toList());
|
||||
|
||||
@@ -146,8 +148,6 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
|
||||
});
|
||||
|
||||
|
||||
canteenInventoryRecordsItemMapper.updateById(updateItems);
|
||||
canteenInventoryRecordsItemMapper.insert(insertItems);
|
||||
|
||||
List<Long> existingCodeIds = canteenInventoryRecordsItemMapper.selectList(
|
||||
new LambdaQueryWrapper<CanteenInventoryRecordsItemEntity>()
|
||||
@@ -165,6 +165,8 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
|
||||
.filter(id -> !submittedCodeIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
canteenInventoryRecordsItemMapper.updateById(updateItems);
|
||||
canteenInventoryRecordsItemMapper.insert(insertItems);
|
||||
// 批量删除失效
|
||||
if (!toDeleteCodeIds.isEmpty()) {
|
||||
canteenInventoryRecordsItemMapper.deleteByIds(toDeleteCodeIds);
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public class SmErpSpuEntity extends Model<SmErpSpuEntity> {
|
||||
@Schema(description="成本单价,单位: 分")
|
||||
// @JsonSerialize(using = MoneySerializer.class) // 分 -> 元
|
||||
// @JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
|
||||
private Integer costPrice;
|
||||
private Double costPrice;
|
||||
|
||||
/**
|
||||
* 库存
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.sm.smspu;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SmErpCostPriceVo {
|
||||
|
||||
private Long erpSpuId;
|
||||
|
||||
private Double quantity;
|
||||
|
||||
private Integer realPrice;
|
||||
|
||||
private String inventoryType;
|
||||
|
||||
private Integer packageNum;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Integer totalAmount;
|
||||
}
|
||||
+8
@@ -6,9 +6,13 @@ import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.supermarket.dto.inventoryrecords.InventoryDetailQueryDTO;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpInventoryRecordsItemEntity;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.InventoryRecordSumVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpCostPriceVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface SmErpInventoryRecordsItemMapper extends PjcloudBaseMapper<SmErpInventoryRecordsItemEntity> {
|
||||
|
||||
@@ -21,4 +25,8 @@ public interface SmErpInventoryRecordsItemMapper extends PjcloudBaseMapper<SmErp
|
||||
* @return
|
||||
*/
|
||||
Page<InventoryRecordSumVo> selectInventoryTypeSumPageByScope(Page page, @Param("inventoryDetailQueryDTO") InventoryDetailQueryDTO inventoryDetailQueryDTO, DataScope of);
|
||||
|
||||
|
||||
|
||||
List<SmErpCostPriceVo> getRecordsItemListBySpuIdsAndInventoryType(@Param("currentSpuIds")List<Long> currentSpuIds);
|
||||
}
|
||||
+35
-1
@@ -18,6 +18,7 @@ import com.bsd.pjcloud.flow.task.dto.ProcessInstanceParamDto;
|
||||
import com.bsd.pjcloud.flow.task.dto.TaskDto;
|
||||
import com.bsd.pjcloud.flow.task.dto.TaskQueryParamDto;
|
||||
import com.bsd.pjcloud.flow.task.entity.Process;
|
||||
import com.bsd.pjcloud.supermarket.constant.InventoryTypeEnum;
|
||||
import com.bsd.pjcloud.supermarket.constant.OrderTypeEnum;
|
||||
import com.bsd.pjcloud.supermarket.constant.SupermarketFlowConstant;
|
||||
import com.bsd.pjcloud.supermarket.dto.cgdd.SmCgDDSaveItemDTO;
|
||||
@@ -30,6 +31,7 @@ import com.bsd.pjcloud.supermarket.vo.cgplan.ErpUnitVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.SmErpCgPlanItemVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.SmErpCgPlanVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.*;
|
||||
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpCostPriceVo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,6 +40,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
@@ -127,7 +130,7 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl<SmErpInventory
|
||||
}
|
||||
smErpInventoryRecordsItemMapper.insert(cgPlanItemEntities);
|
||||
|
||||
// //todo 实际上应该审批后才会入库,这里已经写完了,因为说要直接入库不审核,又改回去了
|
||||
// // 实际上应该审批后才会入库,这里已经写完了,因为说要直接入库不审核,又改回去了
|
||||
//更新库存
|
||||
if (!CollectionUtils.isEmpty(updateStockDTOS)){
|
||||
smErpStockService.updateStock(updateStockDTOS);
|
||||
@@ -138,6 +141,37 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl<SmErpInventory
|
||||
SmErpCgDdEntity updateSmErpCgDdEntity = new SmErpCgDdEntity();
|
||||
updateSmErpCgDdEntity.setLinkStatus("1");
|
||||
smErpCgDdMapper.update(updateSmErpCgDdEntity,queryWrapper);
|
||||
|
||||
|
||||
//计算库存商品的成本价= 采购金额*采购数量/采购数量
|
||||
if (inventoryRecordSaveDTO.getInventoryType().equals(InventoryTypeEnum.CKRK.getType())){
|
||||
// 获取当前采购入库的商品ID列表
|
||||
List<Long> currentSpuIds = cgPlanItemEntities.stream()
|
||||
.map(SmErpInventoryRecordsItemEntity::getErpSpuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<SmErpCostPriceVo> itemEntityList = smErpInventoryRecordsItemMapper.getRecordsItemListBySpuIdsAndInventoryType(
|
||||
currentSpuIds
|
||||
);
|
||||
Map<Long, List<SmErpCostPriceVo>> costPriceMap = itemEntityList.stream()
|
||||
.collect(Collectors.groupingBy(SmErpCostPriceVo::getErpSpuId));
|
||||
|
||||
// 计算并更新成本价
|
||||
cgPlanItemEntities.forEach(item -> {
|
||||
Long erpSpuId = item.getErpSpuId();
|
||||
List<SmErpCostPriceVo> smErpInventoryRecordsItemEntityList = costPriceMap.get(erpSpuId);
|
||||
Double totalNum = smErpInventoryRecordsItemEntityList.stream().filter(Objects::nonNull).mapToDouble(itemEntity -> itemEntity.getPackageNum() * itemEntity.getQuantity()).sum();
|
||||
|
||||
int totalRealRrice = smErpInventoryRecordsItemEntityList.stream().filter(Objects::nonNull).mapToInt(SmErpCostPriceVo::getTotalAmount).sum();
|
||||
double costPrice = (totalRealRrice / 100) / totalNum;
|
||||
|
||||
SmErpSpuEntity smErpSpuEntity = new SmErpSpuEntity();
|
||||
smErpSpuEntity.setCostPrice(costPrice);
|
||||
smErpSpuEntity.setId(erpSpuId);
|
||||
// 更新库存成本价
|
||||
smErpSpuMapper.updateById(smErpSpuEntity);
|
||||
});
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -37,4 +37,20 @@
|
||||
GROUP BY erp_spu_id
|
||||
|
||||
</select>
|
||||
<select id="getRecordsItemListBySpuIdsAndInventoryType" resultType="com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpCostPriceVo">
|
||||
SELECT r.inventory_type, i.erp_spu_id, i.quantity, i.real_price,i.total_amount,u.package_num,u.unit
|
||||
FROM `sm_erp_inventory_records_item` i
|
||||
LEFT JOIN sm_erp_inventory_records r
|
||||
on i.inventory_id = r.id
|
||||
LEFT JOIN sm_erp_unit u
|
||||
on i.unit_id=u.id
|
||||
where r.del_flag = '0'
|
||||
and r.inventory_type = 3
|
||||
and i.del_flag = '0' and
|
||||
erp_spu_id IN
|
||||
<foreach collection="currentSpuIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user