Browse Source

IFS库存初始化导入

master
han\hanst 3 months ago
parent
commit
9aaf1e6c25
  1. 9
      src/main/java/com/gaotao/modules/factory/dao/PartAttributeMapper.java
  2. 15
      src/main/java/com/gaotao/modules/factory/entity/PartAttribute.java
  3. 36
      src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java
  4. 4
      src/main/resources/mapper/factory/PartAttributeMapper.xml

9
src/main/java/com/gaotao/modules/factory/dao/PartAttributeMapper.java

@ -8,6 +8,7 @@ import com.gaotao.modules.factory.entity.dto.PartAttributeQueryDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
/**
@ -15,19 +16,19 @@ import java.util.List;
*/
@Mapper
public interface PartAttributeMapper extends BaseMapper<PartAttribute> {
/**
* 分页查询料件属性列表
*/
IPage<PartAttribute> getPartAttributeList(Page<PartAttribute> page, @Param("params") PartAttributeQueryDto queryDto);
/**
* 查询料件属性列表不分页
*/
List<PartAttribute> getPartAttributeList(@Param("params") PartAttributeQueryDto queryDto);
/**
* 根据站点和料号查询料件属性
*/
PartAttribute getPartAttributeByKey(@Param("site") String site, @Param("partNo") String partNo);
PartAttribute getPartAttributeByKey(@Param("site") String site, @Param("partNo") String partNo, @Param("height") BigDecimal height);
}

15
src/main/java/com/gaotao/modules/factory/entity/PartAttribute.java

@ -57,5 +57,18 @@ public class PartAttribute {
*/
private BigDecimal diameter;
private String isCommonlyUsed; // 是否常用
/**
* 是否常用 (Y/N)
*/
private String isCommonlyUsed;
/**
* HU标志
*/
private String handlingUnitFlag;
/**
* 托盘类型
*/
private String palletType;
}

36
src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java

@ -554,7 +554,7 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
* <li>R列: 最大直径max -> diameter直径mm</li>
* <li>S列: HU -> handling_unit_flagHU标志</li>
* <li>T列: 密封性 -> is_commonly_used是否常用</li>
* <li>U列: A02型号 -> 暂不处理</li>
* <li>U列: A02型号 -> pallet_type托盘类型</li>
* </ul>
* <p><b>默认值</b>print_qty=0, inventory_stock_ifs.length=0, inventory_stock_ifs.width=0</p>
* <p><b>注意</b></p>
@ -617,7 +617,7 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
String diameterStr = getValue(data, 17); // R列: 最大直径max
String handlingUnitFlag = getValue(data, 18); // S列: HU
String isCommonlyUsed = getValue(data, 19); // T列: 密封性
// U列(20): A02型号 - 暂不处理
String palletType = getValue(data, 20); // U列: A02型号(托盘类型)
// 检查是否为空行所有必填字段都为空
if (StringUtils.isBlank(rowSite) && StringUtils.isBlank(partNo)
@ -697,7 +697,9 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
|| StringUtils.isNotBlank(widthStr)
|| StringUtils.isNotBlank(heightStr)
|| StringUtils.isNotBlank(diameterStr)
|| StringUtils.isNotBlank(isCommonlyUsed);
|| StringUtils.isNotBlank(handlingUnitFlag)
|| StringUtils.isNotBlank(isCommonlyUsed)
|| StringUtils.isNotBlank(palletType);
if (hasPartAttributeData) {
PartAttribute partAttribute = new PartAttribute();
@ -708,9 +710,11 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
partAttribute.setWeight(parseBigDecimal(weightStr));
partAttribute.setLength(parseBigDecimal(lengthStr));
partAttribute.setWidth(parseBigDecimal(widthStr));
partAttribute.setHeight(parseBigDecimal(heightStr));
partAttribute.setHeight(parseBigDecimal(heightStr)!=null ? parseBigDecimal(heightStr) : BigDecimal.ZERO); // 高度不能为空默认0
partAttribute.setDiameter(parseBigDecimal(diameterStr));
partAttribute.setHandlingUnitFlag(normalizeYN(handlingUnitFlag));
partAttribute.setIsCommonlyUsed(normalizeYN(isCommonlyUsed));
partAttribute.setPalletType(palletType);
rowData.put("part_attribute", partAttribute);
}
@ -823,9 +827,7 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
try {
// 检查是否已存在
PartAttribute existing = partAttributeMapper.getPartAttributeByKey(
partAttribute.getSite(),
partAttribute.getPartNo()
);
partAttribute.getSite(), partAttribute.getPartNo(), partAttribute.getHeight());
if (existing != null) {
log.debug("料件属性已存在,跳过: site={}, partNo={}",
@ -887,7 +889,7 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
/**
* 批量删除IFS库存数据真实删除
*
*
* @param items 删除项列表
* @return 删除的记录数
*/
@ -895,9 +897,9 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
@Transactional
public int batchDeleteInventory(List<Map<String, String>> items) {
log.info("=== 开始批量删除IFS库存 === 删除项数量: {}", items.size());
int deletedCount = 0;
for (Map<String, String> item : items) {
try {
String site = item.get("site");
@ -906,15 +908,15 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
String batchNo = item.get("batchNo");
String locationId = item.get("locationId");
String wdr = item.get("wdr");
log.info("删除记录: site={}, warehouse={}, partNo={}, batchNo={}, location={}, wdr={}",
log.info("删除记录: site={}, warehouse={}, partNo={}, batchNo={}, location={}, wdr={}",
site, warehouseId, partNo, batchNo, locationId, wdr);
// 执行删除
String deleteSql = "DELETE FROM inventory_stock_ifs " +
"WHERE site = ? AND ISNULL(warehouse_id, '') = ISNULL(?, '') AND part_no = ? " +
"AND batch_no = ? AND location_id = ? AND ISNULL(wdr, '') = ISNULL(?, '')";
int rows = jdbcTemplate.update(deleteSql,
site,
warehouseId,
@ -923,16 +925,16 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService {
locationId,
wdr
);
deletedCount += rows;
log.debug("删除成功: 影响行数={}", rows);
} catch (Exception e) {
log.error("删除记录失败: {}", e.getMessage(), e);
throw new RuntimeException("删除失败: " + e.getMessage());
}
}
log.info("=== 批量删除完成 === 总删除记录数: {}", deletedCount);
return deletedCount;
}

4
src/main/resources/mapper/factory/PartAttributeMapper.xml

@ -45,7 +45,7 @@
</sql>
<!-- 分页查询料件属性列表 -->
<select id="getPartAttributeList" parameterType="com.gaotao.modules.factory.entity.dto.PartAttributeQueryDto"
<select id="getPartAttributeList" parameterType="com.gaotao.modules.factory.entity.dto.PartAttributeQueryDto"
resultMap="PartAttributeResult">
<include refid="selectPartAttributeVo"/>
<include refid="whereCondition"/>
@ -55,7 +55,7 @@
<!-- 根据站点和料号查询料件属性 -->
<select id="getPartAttributeByKey" resultMap="PartAttributeResult">
<include refid="selectPartAttributeVo"/>
WHERE site = #{site} AND part_no = #{partNo}
WHERE site = #{site} AND part_no = #{partNo} and height=#{height}
</select>
</mapper>
Loading…
Cancel
Save