Browse Source

2024/11/26

master
qiezi 2 years ago
parent
commit
e44b6b0528
  1. 2
      src/main/java/com/spring/modules/shipment/mapper/ShipmentRollMapper.java
  2. 39
      src/main/java/com/spring/modules/shipment/service/impl/ShipmentRollServiceImpl.java
  3. 2
      src/main/resources/mapper/shipment/ShipmentRollMapper.xml

2
src/main/java/com/spring/modules/shipment/mapper/ShipmentRollMapper.java

@ -23,7 +23,7 @@ public interface ShipmentRollMapper extends BaseMapper<ShipmentRoll> {
List<SoFinalRollData> selectSoFinalRollDataByRollNo(@Param("params") SoFinalRollData rollData, @Param("num") int num); List<SoFinalRollData> selectSoFinalRollDataByRollNo(@Param("params") SoFinalRollData rollData, @Param("num") int num);
String getPartPackageNum(@Param("site") String site, @Param("partNo") String partNo);
String getPartPackageNum(@Param("site") String site, @Param("partNo") String partNo,@Param("itemNo") String itemNo);
InventoryStockRoll selectInventoryStockRoll(SoFinalRollData rollData); InventoryStockRoll selectInventoryStockRoll(SoFinalRollData rollData);

39
src/main/java/com/spring/modules/shipment/service/impl/ShipmentRollServiceImpl.java

@ -16,6 +16,7 @@ import com.spring.modules.shipment.service.ShipmentRollService;
import com.spring.modules.shipment.vo.ShipmentRollPrint; import com.spring.modules.shipment.vo.ShipmentRollPrint;
import com.spring.modules.shipment.vo.ShipmentRollVo; import com.spring.modules.shipment.vo.ShipmentRollVo;
import com.spring.modules.shipment.vo.ShipmentVo; import com.spring.modules.shipment.vo.ShipmentVo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -25,6 +26,10 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -59,9 +64,28 @@ public class ShipmentRollServiceImpl extends ServiceImpl<ShipmentRollMapper, Shi
throw new RuntimeException("卷号:" + rollData.getFinalRollNo() + "状态为" + rollData.getStatus()); throw new RuntimeException("卷号:" + rollData.getFinalRollNo() + "状态为" + rollData.getStatus());
} }
shipmentRollVo.setRollNo(rollData.getFinalRollNo()); shipmentRollVo.setRollNo(rollData.getFinalRollNo());
// 获取PartNo 的属性
String packageNum = baseMapper.getPartPackageNum(rollData.getSite(), rollData.getPartNo());
int value = 0; int value = 0;
// 获取 物料最小失效天数
String effectiveDays = baseMapper.getPartPackageNum(rollData.getSite(), rollData.getPartNo(),"P00019");
try {
value = Integer.parseInt(effectiveDays);
} catch (Exception e) {
throw new RuntimeException(rollData.getPartNo() + "的最小失效天数格式不正确");
}
if (value <= 0) {
throw new RuntimeException(rollData.getPartNo() + "的最小失效天数维护不正确");
}
LocalDate now = LocalDate.now();
LocalDate date = LocalDate.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(rollData.getExpiredDate()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
long days = date.toEpochDay() - now.toEpochDay();
// 判断当前日期 是否在失效日期之前
if (new Date().after(rollData.getExpiredDate()) || days <= value) {
throw new RuntimeException(rollData.getPartNo() + "在最小失效日期内");
}
value = 0;
// 获取PartNo 的属性
String packageNum = baseMapper.getPartPackageNum(rollData.getSite(), rollData.getPartNo(),"P00014");
try { try {
value = Integer.parseInt(packageNum); value = Integer.parseInt(packageNum);
} catch (Exception e) { } catch (Exception e) {
@ -106,15 +130,15 @@ public class ShipmentRollServiceImpl extends ServiceImpl<ShipmentRollMapper, Shi
Integer count = lambdaQuery() Integer count = lambdaQuery()
.eq(ShipmentRoll::getShipmentId, shipmentRollVo.getShipmentId()) .eq(ShipmentRoll::getShipmentId, shipmentRollVo.getShipmentId())
.eq(ShipmentRoll::getPartNo, rollData.getPartNo()) .eq(ShipmentRoll::getPartNo, rollData.getPartNo())
// .eq(ShipmentRoll::getBoxNo, shipmentRollVo.getBoxNo())
//.eq(ShipmentRoll::getBoxNo, shipmentRollVo.getBoxNo())
.eq(ShipmentRoll::getSite, shipmentRollVo.getSite()).count(); .eq(ShipmentRoll::getSite, shipmentRollVo.getSite()).count();
BigDecimal needNum = num.subtract(new BigDecimal(count));
if (BigDecimal.ZERO.compareTo(needNum) == 0){
BigDecimal needRollNum = num.subtract(new BigDecimal(count));
if (BigDecimal.ZERO.compareTo(needRollNum) <= 0){
throw new RuntimeException("该物料已满足发货数量,无法再次添加!"); throw new RuntimeException("该物料已满足发货数量,无法再次添加!");
} }
log.info("needNum:{}",needNum);
log.info("needNum:{}",needRollNum);
// 先入先出 // 先入先出
List<SoFinalRollData> soFinalRollData = baseMapper.selectSoFinalRollDataByRollNo(rollData, needNum.intValue());
List<SoFinalRollData> soFinalRollData = baseMapper.selectSoFinalRollDataByRollNo(rollData, needRollNum.intValue());
if (soFinalRollData.isEmpty()){ if (soFinalRollData.isEmpty()){
throw new RuntimeException("卷号:"+rollData.getFinalRollNo()+",已被删除,请刷新后重试"); throw new RuntimeException("卷号:"+rollData.getFinalRollNo()+",已被删除,请刷新后重试");
} }
@ -124,6 +148,7 @@ public class ShipmentRollServiceImpl extends ServiceImpl<ShipmentRollMapper, Shi
if (rollData.getCreatedDate().after(latestTime)){ if (rollData.getCreatedDate().after(latestTime)){
throw new RuntimeException("请按照先入先出规则,出库早生产的箱子,当前允许扫的最晚时间为:"+latestTime.toLocaleString()); throw new RuntimeException("请按照先入先出规则,出库早生产的箱子,当前允许扫的最晚时间为:"+latestTime.toLocaleString());
} }
// 最终校验是否重复扫描 // 最终校验是否重复扫描
if (!lambdaQuery() if (!lambdaQuery()
.eq(ShipmentRoll::getRollNo,shipmentRollVo.getRollNo()) .eq(ShipmentRoll::getRollNo,shipmentRollVo.getRollNo())

2
src/main/resources/mapper/shipment/ShipmentRollMapper.xml

@ -66,7 +66,7 @@
</select> </select>
<select id="getPartPackageNum" resultType="java.lang.String"> <select id="getPartPackageNum" resultType="java.lang.String">
select dbo.Get_PartPropertiesValue(#{site},#{partNo},'P00014')
select dbo.Get_PartPropertiesValue(#{site},#{partNo},#{itemNo})
</select> </select>
<select id="selectInventoryStockRoll" resultType="com.spring.modules.base.entity.InventoryStockRoll"> <select id="selectInventoryStockRoll" resultType="com.spring.modules.base.entity.InventoryStockRoll">

Loading…
Cancel
Save