修复
This commit is contained in:
@@ -51,6 +51,8 @@ public class GearStockIoOrderBo extends BaseEntity {
|
||||
|
||||
private Long supplierId;
|
||||
|
||||
private Integer materialTypeSnapshot;
|
||||
|
||||
private Date planArrivalTime;
|
||||
|
||||
private Date actualArrivalTime;
|
||||
|
||||
@@ -46,6 +46,12 @@ public class GearPurchasePlanDetailVo {
|
||||
@ExcelProperty(value = "原材料名称")
|
||||
private String rawMaterialName;
|
||||
|
||||
/**
|
||||
* 厂家
|
||||
*/
|
||||
@ExcelProperty(value = "厂家")
|
||||
private String factory;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
|
||||
@@ -103,4 +103,6 @@ public class GearStockIoOrderVo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
private String materialNames;
|
||||
|
||||
private String factoryNames;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gear.oa.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gear.oa.domain.GearPurchasePlanDetail;
|
||||
@@ -8,6 +7,8 @@ import com.gear.oa.domain.vo.GearPurchasePlanDetailVo;
|
||||
import com.gear.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购计划明细Mapper接口
|
||||
*
|
||||
@@ -17,4 +18,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface GearPurchasePlanDetailMapper extends BaseMapperPlus<GearPurchasePlanDetailMapper, GearPurchasePlanDetail, GearPurchasePlanDetailVo> {
|
||||
|
||||
Page<GearPurchasePlanDetailVo> selectVoPagePlus(Page<Object> build,@Param("ew") QueryWrapper<GearPurchasePlanDetail> lqw);
|
||||
|
||||
List<GearPurchasePlanDetailVo> selectVoListPlus(@Param("ew") QueryWrapper<GearPurchasePlanDetail> lqw);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
|
||||
public interface MatMaterialSimpleMapper {
|
||||
|
||||
@Select("select material_id as materialId, material_name as materialName, material_type as materialType, unit as unit, current_stock as currentStock " +
|
||||
@Select("select material_id as materialId, material_name as materialName, material_type as materialType, unit as unit, factory as factory, current_stock as currentStock " +
|
||||
"from mat_material where material_id = #{materialId} and del_flag = 0 limit 1")
|
||||
Map<String, Object> selectSnapshot(@Param("materialId") Long materialId);
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ public class GearPurchasePlanDetailServiceImpl implements IGearPurchasePlanDetai
|
||||
*/
|
||||
@Override
|
||||
public List<GearPurchasePlanDetailVo> queryList(GearPurchasePlanDetailBo bo) {
|
||||
LambdaQueryWrapper<GearPurchasePlanDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
QueryWrapper<GearPurchasePlanDetail> lqw = buildQueryWrapperPlus(bo);
|
||||
return baseMapper.selectVoListPlus(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<GearPurchasePlanDetail> buildQueryWrapper(GearPurchasePlanDetailBo bo) {
|
||||
|
||||
@@ -102,25 +102,42 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
return;
|
||||
}
|
||||
Map<Long, LinkedHashSet<String>> namesMap = new HashMap<>();
|
||||
Map<Long, LinkedHashSet<String>> factoryMap = new HashMap<>();
|
||||
Map<Long, String> materialFactoryCache = new HashMap<>();
|
||||
for (GearStockIoOrderDetail d : details) {
|
||||
if (d == null || d.getOrderId() == null) {
|
||||
continue;
|
||||
}
|
||||
String name = d.getItemName();
|
||||
if (StringUtils.isBlank(name)) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
namesMap.computeIfAbsent(d.getOrderId(), k -> new LinkedHashSet<>()).add(name);
|
||||
}
|
||||
if (!"material".equals(d.getItemType()) || d.getItemId() == null) {
|
||||
continue;
|
||||
}
|
||||
namesMap.computeIfAbsent(d.getOrderId(), k -> new LinkedHashSet<>()).add(name);
|
||||
String factory = materialFactoryCache.get(d.getItemId());
|
||||
if (factory == null) {
|
||||
Map<String, Object> snapshot = matMaterialMapper.selectSnapshot(d.getItemId());
|
||||
Object factoryObj = snapshot == null ? null : snapshot.get("factory");
|
||||
factory = factoryObj == null ? "" : String.valueOf(factoryObj);
|
||||
materialFactoryCache.put(d.getItemId(), factory);
|
||||
}
|
||||
if (StringUtils.isNotBlank(factory)) {
|
||||
factoryMap.computeIfAbsent(d.getOrderId(), k -> new LinkedHashSet<>()).add(factory);
|
||||
}
|
||||
}
|
||||
for (GearStockIoOrderVo o : orders) {
|
||||
if (o == null || o.getOrderId() == null) {
|
||||
continue;
|
||||
}
|
||||
LinkedHashSet<String> set = namesMap.get(o.getOrderId());
|
||||
if (set == null || set.isEmpty()) {
|
||||
continue;
|
||||
if (set != null && !set.isEmpty()) {
|
||||
o.setMaterialNames(String.join("、", set));
|
||||
}
|
||||
LinkedHashSet<String> factorySet = factoryMap.get(o.getOrderId());
|
||||
if (factorySet != null && !factorySet.isEmpty()) {
|
||||
o.setFactoryNames(String.join("、", factorySet));
|
||||
}
|
||||
o.setMaterialNames(String.join("、", set));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +165,9 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
lqw.apply(bo.getSupplierId() != null,
|
||||
"exists (select 1 from gear_stock_io_order_detail d left join gear_purchase_plan_detail ppd on d.source_detail_no = ppd.detail_code and ppd.del_flag = 0 where d.del_flag = '0' and d.order_id = gear_stock_io_order.order_id and ppd.supplier_id = {0})",
|
||||
bo.getSupplierId());
|
||||
lqw.apply(bo.getMaterialTypeSnapshot() != null,
|
||||
"exists (select 1 from gear_stock_io_order_detail d where d.del_flag = '0' and d.order_id = gear_stock_io_order.order_id and d.material_type_snapshot = {0})",
|
||||
bo.getMaterialTypeSnapshot());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDelayStatus()), GearStockIoOrder::getDelayStatus, bo.getDelayStatus());
|
||||
lqw.orderByDesc(GearStockIoOrder::getCreateTime);
|
||||
return lqw;
|
||||
@@ -168,6 +188,7 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
bo.getItemName());
|
||||
qw.like(StringUtils.isNotBlank(bo.getFactory()), "m.factory", bo.getFactory());
|
||||
qw.eq(bo.getSupplierId() != null, "ppd.supplier_id", bo.getSupplierId());
|
||||
qw.eq(bo.getMaterialTypeSnapshot() != null, "d.material_type_snapshot", bo.getMaterialTypeSnapshot());
|
||||
return qw;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
d.detail_code,
|
||||
d.supplier_id,
|
||||
d.raw_material_name,
|
||||
m.factory as factory,
|
||||
d.owner,
|
||||
d.quantity,
|
||||
d.unit,
|
||||
@@ -44,6 +45,43 @@
|
||||
s.name as supplierName
|
||||
from gear_purchase_plan_detail d
|
||||
left join gear_supplier s on d.supplier_id = s.supplier_id and s.del_flag = 0
|
||||
left join (
|
||||
select material_name, max(factory) as factory
|
||||
from mat_material
|
||||
where del_flag = 0
|
||||
group by material_name
|
||||
) m on m.material_name = d.raw_material_name
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectVoListPlus" resultType="com.gear.oa.domain.vo.GearPurchasePlanDetailVo">
|
||||
select d.detail_id,
|
||||
d.detail_code,
|
||||
d.supplier_id,
|
||||
d.raw_material_name,
|
||||
m.factory as factory,
|
||||
d.owner,
|
||||
d.quantity,
|
||||
d.unit,
|
||||
d.unit_price,
|
||||
d.total_amount,
|
||||
d.annex,
|
||||
d.status,
|
||||
d.remark,
|
||||
d.del_flag,
|
||||
d.create_time,
|
||||
d.create_by,
|
||||
d.update_time,
|
||||
d.update_by,
|
||||
s.name as supplierName
|
||||
from gear_purchase_plan_detail d
|
||||
left join gear_supplier s on d.supplier_id = s.supplier_id and s.del_flag = 0
|
||||
left join (
|
||||
select material_name, max(factory) as factory
|
||||
from mat_material
|
||||
where del_flag = 0
|
||||
group by material_name
|
||||
) m on m.material_name = d.raw_material_name
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
d.item_type AS itemType,
|
||||
d.item_id AS itemId,
|
||||
d.material_type_snapshot AS materialTypeSnapshot,
|
||||
CASE WHEN d.material_type_snapshot = 2 THEN '主材' ELSE '辅材' END AS materialTypeName,
|
||||
CASE
|
||||
WHEN d.material_type_snapshot = 2 THEN '主材'
|
||||
WHEN d.material_type_snapshot = 1 THEN '辅材'
|
||||
ELSE '-'
|
||||
END AS materialTypeName,
|
||||
o.order_code AS orderCode,
|
||||
o.io_type AS ioType,
|
||||
o.biz_type AS bizType,
|
||||
@@ -37,7 +41,7 @@
|
||||
COALESCE(d.unit, m.unit) AS unit,
|
||||
d.batch_no AS batchNo,
|
||||
d.unit_price AS unitPrice,
|
||||
d.amount AS amount,
|
||||
COALESCE(d.amount, d.unit_price * d.quantity) AS amount,
|
||||
d.source_detail_no AS sourceDetailNo,
|
||||
d.remark AS remark
|
||||
FROM gear_stock_io_order_detail d
|
||||
@@ -52,4 +56,3 @@
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user