qiangxuan 1 mesiac pred
rodič
commit
510c7d57b2

+ 26 - 5
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/service/impl/BilletBasicInfoServiceImpl.java

@@ -2,18 +2,17 @@ package org.jeecg.modules.billetActual.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.billetActual.entity.*;
-import org.jeecg.modules.billetActual.mapper.BilletBasicInfoMapper;
-import org.jeecg.modules.billetActual.mapper.BilletHotsendChangeShiftMapper;
-import org.jeecg.modules.billetActual.mapper.BilletHotsendMapper;
-import org.jeecg.modules.billetActual.mapper.BilletRulerConfigMapper;
+import org.jeecg.modules.billetActual.mapper.*;
 import org.jeecg.modules.billetActual.service.IBilletBasicInfoService;
 import org.jeecg.modules.heatsActuals.entity.HeatsActuals;
 import org.jeecg.modules.heatsActuals.mapper.HeatsActualsMapper;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -47,6 +46,9 @@ public class BilletBasicInfoServiceImpl extends ServiceImpl<BilletBasicInfoMappe
 
     @Autowired
     BilletHotsendChangeShiftMapper billetHotsendChangeShiftMapper;
+
+    @Autowired
+    BilletBasicInfoExceptionMapper billetBasicInfoExceptionMapper;
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void addC(BilletBasicInfo billetBasicInfo) {
@@ -115,7 +117,26 @@ public class BilletBasicInfoServiceImpl extends ServiceImpl<BilletBasicInfoMappe
                 billetBasicInfo.setShift(classShiftStr);
                 billetBasicInfo.setBrandNum(brandNumStr);
                 billetBasicInfo.setShiftGroup(classShiftGroupStr);
-
+                // 判断组批号是否为空,不为空时,通过组批号查询钢坯实绩总数,超过4条,重置组批号并保存到钢坯异常表
+                if (oConvertUtils.isNotEmpty(billetBasicInfo.getAssemblyNumber())) {
+                    LambdaQueryWrapper<BilletBasicInfo> queryAssemblyNumberWrapper = new LambdaQueryWrapper<>();
+                    queryAssemblyNumberWrapper.eq(BilletBasicInfo::getCcmNo, billetBasicInfo.getCcmNo());
+                    queryAssemblyNumberWrapper.eq(BilletBasicInfo::getAssemblyNumber, billetBasicInfo.getAssemblyNumber());
+                    // 查询该组批号下的钢坯实绩总数
+                    long count = baseMapper.selectCount(queryAssemblyNumberWrapper);
+                    if (count > 4){
+                        BilletBasicInfoException billetBasicInfoException = new BilletBasicInfoException();
+                        BeanUtils.copyProperties(billetBasicInfo, billetBasicInfoException);
+                        billetBasicInfoException.setId(String.valueOf(IdWorker.getId()));
+                        String timeStamp = String.valueOf(System.currentTimeMillis());
+                        String assemblyNumber = billetBasicInfo.getAssemblyNumber();
+                        String timestampSuffix = timeStamp.substring(timeStamp.length() - 7);
+                        String newAssemblyNumber = assemblyNumber.substring(0, 8) + timestampSuffix;
+                        billetBasicInfoException.setAssemblyNumber(newAssemblyNumber);
+                        billetBasicInfoExceptionMapper.insert(billetBasicInfoException);
+                        return;
+                    }
+                }
                 log.info("{}{}", "新增钢坯实绩时班组班别:", billetBasicInfo.getShiftGroup() + " " + billetBasicInfo.getShift());
                 baseMapper.insert(billetBasicInfo);