|
@@ -3,6 +3,8 @@ package org.jeecg.modules.billet.storageBill.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -12,8 +14,10 @@ import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBa
|
|
|
import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
|
|
|
import org.jeecg.modules.billet.billetAutoTmp.entity.BilletAutoTmp;
|
|
|
import org.jeecg.modules.billet.billetAutoTmp.service.IBilletAutoTmpService;
|
|
|
+import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.RollClubCommon;
|
|
|
+import org.jeecg.modules.billet.billetHotsend.mapper.BilletHotsendBaseMapper;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
|
|
@@ -21,20 +25,28 @@ import org.jeecg.modules.billet.billetHotsendConfig.service.IBilletHotsendTypeCo
|
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
|
|
|
import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollClubThree.entity.RollClubThree;
|
|
|
import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
|
|
|
import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
|
|
|
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwo;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoService;
|
|
|
import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
|
|
|
import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
|
|
|
import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
|
|
|
import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.BilletHotsendDetails;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.ShiftEnum;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.StorageBill;
|
|
|
import org.jeecg.modules.billet.storageBill.mapper.StorageBillMapper;
|
|
|
import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
|
|
|
+import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
|
|
|
+import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -42,10 +54,12 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -61,7 +75,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
@Autowired
|
|
|
private IBilletHotsendTypeConfigService billetHotsendTypeConfigService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private StorageBillMapper storageBillMapper;
|
|
|
|
|
|
@Autowired
|
|
@@ -94,6 +108,21 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
@Autowired
|
|
|
private IBilletAutoTmpService billetAutoTmpService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IRollClubTwoService rollClubTwoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRollClubThreeService rollClubThreeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRollOutShippService rollOutShippService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IStorageCarLogService storageCarLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BilletHotsendBaseMapper billetHotsendBaseMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void departHandle(BilletHotsendDetailsVo billetHotsendDetailsVo) {
|
|
|
StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
|
|
@@ -108,6 +137,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
if (oConvertUtils.isNotEmpty(oldStorageBill)){
|
|
|
operateLogService.add(oldStorageBill,storageBill,StorageBill.class);
|
|
|
}
|
|
|
+
|
|
|
//查询并批量更新钢坯基础信息 belongTable
|
|
|
List<RollClubCommon> rollClubCommonLists = billetHotsendDetailsVo.getRollClubCommonList();
|
|
|
if (oConvertUtils.listIsEmpty(rollClubCommonLists)){
|
|
@@ -203,10 +233,11 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
public JSONObject storageBillSave(StorageBill storageBill) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
|
- String keyShiftGroup = String.format("class:shift:group:%s", storageBill.getCcmNo());
|
|
|
- String keyShift = String.format("class:shift:%s", storageBill.getCcmNo());
|
|
|
- String shiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
|
|
|
- String shift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ String shiftGroup = getShiftInfo(storageBill.getCcmNo(), "class:shift:group:%s");
|
|
|
+ String shift = getShiftInfo(storageBill.getCcmNo(), "class:shift:%s");
|
|
|
+
|
|
|
LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
|
|
|
.eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
|
|
@@ -219,8 +250,16 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
result.put("fail", "存在未发车车辆,新增钢坯装运单失败!");
|
|
|
return result;
|
|
|
}
|
|
|
+ // 判断车位是否存在未发车车辆
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(new LambdaQueryWrapper<StorageBill>()
|
|
|
+ .eq(StorageBill::getPositionNum, storageBill.getPositionNum())
|
|
|
+ .isNull(StorageBill::getOutTime));
|
|
|
+ if (oConvertUtils.listIsNotEmpty(storageBillList)){
|
|
|
+ log.info("该车位存在未发车车辆,车牌号为:{},新增钢坯装运单失败!", storageBill.getLicensePlate());
|
|
|
+ result.put("fail", "该车位存在未发车车辆,新增钢坯装运单失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
storageBill.setArrivalTime(new Date());// 到达时间
|
|
|
-
|
|
|
LambdaQueryWrapper<StorageBill> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
queryWrapper1.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
|
|
|
.eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
|
|
@@ -250,14 +289,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
storageBill.setAmountTotal(0);
|
|
|
storageBill.setShiftGroup(shiftGroup);
|
|
|
storageBill.setShift(shift);
|
|
|
- String uniqueCode = DateUtils.date2Str(new Date(), DateUtils.yyyymmddhhmmss.get()) + "-" + storageBill.getCcmNo() + "#" + ShiftEnum.fromCode(shift).name()+ "-" + ShiftGroupEnum.fromCode(shiftGroup).name();
|
|
|
+ String uniqueCode = generateUniqueCode(new Date(), storageBill.getCcmNo(), shift, shiftGroup);
|
|
|
storageBill.setUniqueCode(uniqueCode);
|
|
|
- // B端创建装运单时,车位号 六号机操作默认是3,五号机新增直接就是1
|
|
|
- if ("5".equals(storageBill.getCcmNo())){
|
|
|
- storageBill.setPositionNum(1);
|
|
|
- }else {
|
|
|
- storageBill.setPositionNum(3);
|
|
|
- }
|
|
|
baseMapper.insert(storageBill);
|
|
|
operateLogService.add(storageBill,null,StorageBill.class);
|
|
|
result.put("success", "钢坯装运单添加成功!");
|
|
@@ -377,4 +410,408 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
paramMap.put("coldReceive", 24);// 冷装接收
|
|
|
return paramMap;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StorageBill> queryStorageBillByPositionNum() {
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(new LambdaQueryWrapper<StorageBill>()
|
|
|
+ .ne(StorageBill::getLicensePlate, "堆垛辊道")
|
|
|
+ .ne(StorageBill::getLicensePlate, "辊道")
|
|
|
+ .isNull(StorageBill::getOutTime)
|
|
|
+ .isNotNull(StorageBill::getArrivalTime)
|
|
|
+ .orderByAsc(StorageBill::getPositionNum));
|
|
|
+ return storageBillList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public JSONObject addParkingSpaceDepart(StorageBill storageBill) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ // 根据装运单ID,校验钢坯装运单是否存在
|
|
|
+ StorageBill storageBillInfo = baseMapper.selectById(storageBill.getId());
|
|
|
+ if (storageBillInfo == null){
|
|
|
+ result.put("fail", "钢坯装运单不存在,车位发车失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 根据装运单ID查询钢坯临时表
|
|
|
+ List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>()
|
|
|
+ .eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
|
|
|
+ if (oConvertUtils.listIsEmpty(billetAutoTmpList)){
|
|
|
+ result.put("fail", "钢坯装运明细不存在,车位发车失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<RollClubCommon> rollClubCommonList = new ArrayList<>();
|
|
|
+ billetAutoTmpList.forEach(x ->{
|
|
|
+ RollClubCommon rollClubCommon = new RollClubCommon();
|
|
|
+ BeanUtils.copyProperties(x, rollClubCommon);
|
|
|
+ rollClubCommon.setGrade(x.getSteel());
|
|
|
+ rollClubCommon.setLength(Integer.valueOf(x.getSize()));
|
|
|
+ rollClubCommon.setBilletWeight(x.getBlankOutput());
|
|
|
+ rollClubCommonList.add(rollClubCommon);
|
|
|
+ });
|
|
|
+ if (oConvertUtils.isEmpty(storageBill.getTypeConfigId())){
|
|
|
+ result.put("fail", "钢坯装运单中目的地ID为空,车位发车失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 根据ID获取钢坯配置信息
|
|
|
+ BilletHotsend billetHotsend = new BilletHotsend();
|
|
|
+ billetHotsend.setCcmNo(storageBill.getCcmNo());
|
|
|
+
|
|
|
+ BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
|
|
|
+ BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
|
|
|
+ billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
|
|
|
+ billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
|
|
|
+ billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
|
|
|
+ billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
|
|
|
+ billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
|
|
|
+ billetHotsendDetailsVo.setStorageBill(storageBill);
|
|
|
+ billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
|
|
|
+ billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonList);
|
|
|
+
|
|
|
+ Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonList);
|
|
|
+ /**
|
|
|
+ * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
|
|
|
+ * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
|
|
|
+ */
|
|
|
+ for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
|
|
|
+ String[] parts = entry.getKey().split(",");
|
|
|
+ billetHotsend.setHeatNo(parts[0]);// 炉号
|
|
|
+ billetHotsend.setShiftGroup(parts[1]);// 班组
|
|
|
+ billetHotsend.setShift(parts[2]);// 班别
|
|
|
+ List<RollClubCommon> groupRollClubCommonList = entry.getValue();
|
|
|
+ JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
|
|
|
+ if (jsonObject.containsKey("fail")) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ log.info("{}{}", "B端钢坯装运单车位发车操作失败,事务回滚!", jsonObject);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
|
|
|
+ //查询并批量更新钢坯基础信息 belongTable
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
|
|
|
+ .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
|
|
|
+ .in(BilletBasicInfo::getBilletNo, billetNos);
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperls);
|
|
|
+ billetBasicInfoList.forEach(x ->{
|
|
|
+ if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ x.setBelongTable("roll_club_two");
|
|
|
+ }else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ x.setBelongTable("roll_club_three");
|
|
|
+ }else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ x.setBelongTable("roll_out_shipp");
|
|
|
+ }
|
|
|
+ x.setBhtcId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
|
|
|
+ x.setUpdateTime(new Date());
|
|
|
+ });
|
|
|
+ billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
|
|
|
+
|
|
|
+ // 更新装运单目的地、发车时间
|
|
|
+ storageBill.setOutTime(new Date());
|
|
|
+ storageBill.setUpdateTime(new Date());
|
|
|
+ baseMapper.updateById(storageBill);
|
|
|
+ // 添加编辑日志
|
|
|
+ operateLogService.add(storageBillInfo, storageBill, StorageBill.class);
|
|
|
+ // 发车后,新增储运记录 storage_car_log
|
|
|
+ StorageCarLog storageCarLog = new StorageCarLog();
|
|
|
+ BeanUtils.copyProperties(storageBill, storageCarLog);
|
|
|
+ storageCarLog.setCarNm(storageBill.getLicensePlate());// 车牌号
|
|
|
+ storageCarLog.setTypeConfigId(storageBill.getTypeConfigId()); // 钢坯配置类型ID
|
|
|
+
|
|
|
+ List<String> sizeList = rollClubCommonList.stream().map(RollClubCommon::getSize).distinct().collect(Collectors.toList());
|
|
|
+ List<String> heatNoList = rollClubCommonList.stream().map(RollClubCommon::getHeatNo).distinct().collect(Collectors.toList());
|
|
|
+ long count = rollClubCommonList.stream().count();
|
|
|
+
|
|
|
+ storageCarLog.setHeatNo(String.join(",", heatNoList));
|
|
|
+ storageCarLog.setSize(String.join(",", sizeList));// 定尺
|
|
|
+ storageCarLog.setAmount(Integer.valueOf((int) count));// 支数
|
|
|
+
|
|
|
+ storageCarLog.setDataTime(new Date());
|
|
|
+ storageCarLog.setCreateTime(new Date());
|
|
|
+ storageCarLogService.save(storageCarLog);
|
|
|
+ log.info("{}{}", "B端钢坯车位发车成功!", storageBill.getLicensePlate());
|
|
|
+ // 物理删除钢坯临时表记录
|
|
|
+ billetAutoTmpService.removeBatchByIds(billetAutoTmpList.stream().map(BilletAutoTmp::getId).collect(Collectors.toList()));
|
|
|
+ result.put("success", "B端钢坯车位发车成功!");
|
|
|
+ return result;
|
|
|
+ }catch (Exception e){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ // 记录异常日志
|
|
|
+ log.error("钢坯车位发车发生异常", e.getMessage());
|
|
|
+ result.put("fail", "系统错误,请稍后再试!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 钢坯热送信息查询、更新
|
|
|
+ * 棒一、棒二、棒三、上若、高线 基础表和明细 新增、更新
|
|
|
+ * 交班记录表查询 更新
|
|
|
+ * @param billetHotsend
|
|
|
+ * @param billetHotsendDetailsVo
|
|
|
+ * @param billetHotsendTypeConfig
|
|
|
+ * @param storageBill
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private JSONObject commonBilletHotsenAndDetailsHandle(BilletHotsend billetHotsend, BilletHotsendDetailsVo billetHotsendDetailsVo, BilletHotsendTypeConfig billetHotsendTypeConfig, StorageBill storageBill, List<RollClubCommon> rollClubCommonList, String rollClubOneOrHeightStorageBillId){
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
|
|
|
+ .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
|
|
|
+ .eq(BilletHotsend::getShift, billetHotsend.getShift())
|
|
|
+ .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
|
|
|
+ BilletHotsend check = billetHotsendBaseMapper.selectOne(queryWrapper);
|
|
|
+ if (oConvertUtils.isEmpty(check)){
|
|
|
+ result.put("fail", "钢坯热送信息不存在,B端车位发车棒线操作失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
|
|
|
+ if (oConvertUtils.isEmpty(check.getRollclubtwoNum())){
|
|
|
+ billetHotsend.setRollclubtwoNum(rollClubCommonList.size());
|
|
|
+ }else {
|
|
|
+ billetHotsend.setRollclubtwoNum(check.getRollclubtwoNum() + rollClubCommonList.size());
|
|
|
+ }
|
|
|
+ }else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
|
|
|
+ if (oConvertUtils.isEmpty(check.getRollclubthreeNum())){
|
|
|
+ billetHotsend.setRollclubthreeNum(rollClubCommonList.size());
|
|
|
+ }else {
|
|
|
+ billetHotsend.setRollclubthreeNum(check.getRollclubthreeNum() + rollClubCommonList.size());
|
|
|
+ }
|
|
|
+ }else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
|
|
|
+ if (oConvertUtils.isEmpty(check.getRolloutshippNum())){
|
|
|
+ billetHotsend.setRolloutshippNum(rollClubCommonList.size());
|
|
|
+ }else {
|
|
|
+ billetHotsend.setRolloutshippNum(check.getRolloutshippNum() + rollClubCommonList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ billetHotsend.setUpdateTime(new Date());
|
|
|
+ LambdaUpdateWrapper<BilletHotsend> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
|
|
|
+ .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
|
|
|
+ .eq(BilletHotsend::getShift, billetHotsend.getShift())
|
|
|
+ .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
|
|
|
+ billetHotsendBaseMapper.update(billetHotsend, updateWrapper);
|
|
|
+
|
|
|
+ AtomicLong timeOffset = new AtomicLong(); // 初始时间偏移量,单位毫秒,可以根据实际需求调整每次的偏移量大小
|
|
|
+ // 保存 钢坯热送单炉支数传递单明细
|
|
|
+ if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ // 保存棒一信息
|
|
|
+ RollClubTwo rollClubTwo = new RollClubTwo();
|
|
|
+ BeanUtils.copyProperties(billetHotsend, rollClubTwo);
|
|
|
+ rollClubTwo.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
|
|
|
+ rollClubTwo.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
|
|
|
+ rollClubTwo.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
|
|
|
+ rollClubTwo.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
|
|
|
+ rollClubTwo.setStorageBillId(storageBill.getId());
|
|
|
+ LambdaQueryWrapper<RollClubTwo> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(RollClubTwo::getCcmNo, billetHotsend.getCcmNo())
|
|
|
+ .eq(RollClubTwo::getHeatNo, billetHotsend.getHeatNo())
|
|
|
+ .eq(RollClubTwo::getShift, billetHotsend.getShift())
|
|
|
+ .eq(RollClubTwo::getShiftGroup, billetHotsend.getShiftGroup())
|
|
|
+ .eq(RollClubTwo::getStorageBillId, storageBill.getId());
|
|
|
+ RollClubTwo rollClubTwo1 = rollClubTwoService.getOne(queryWrapper1);
|
|
|
+ if (oConvertUtils.isEmpty(rollClubTwo1)){
|
|
|
+ rollClubTwo.setCreateDate(new Date());
|
|
|
+ rollClubTwo.setAmountTotal(rollClubCommonList.size());// 总支数
|
|
|
+ rollClubTwoService.save(rollClubTwo);
|
|
|
+ }else {
|
|
|
+ rollClubTwo.setId(rollClubTwo1.getId());
|
|
|
+ rollClubTwo.setAmountTotal(rollClubTwo1.getAmountTotal() + rollClubCommonList.size());// 总支数
|
|
|
+ rollClubTwo.setBlankOutput(rollClubTwo1.getBlankOutput() + rollClubTwo.getBlankOutput());//出坯量
|
|
|
+ rollClubTwo.setUpdateTime(new Date());
|
|
|
+ rollClubTwoService.updateById(rollClubTwo);
|
|
|
+ }
|
|
|
+ // 保存棒二明细信息
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = new ArrayList<>();
|
|
|
+ rollClubCommonList.forEach(x ->{
|
|
|
+ RollClubTwoDetails rollClubTwoDetails = new RollClubTwoDetails();
|
|
|
+ BeanUtils.copyProperties(x, rollClubTwoDetails);
|
|
|
+ rollClubTwoDetails.setId(String.valueOf(IdWorker.getId()));
|
|
|
+ rollClubTwoDetails.setShift(billetHotsend.getShift());
|
|
|
+ rollClubTwoDetails.setShiftGroup(billetHotsend.getShiftGroup());
|
|
|
+ rollClubTwoDetails.setStorageBillId(storageBill.getId());
|
|
|
+ rollClubTwoDetails.setLicensePlate(storageBill.getLicensePlate());
|
|
|
+ rollClubTwoDetails.setSize(String.valueOf(x.getLength()));
|
|
|
+ rollClubTwoDetails.setSteel(x.getGrade());
|
|
|
+ rollClubTwoDetails.setCreateTime(new Date(System.currentTimeMillis() + timeOffset.get()));
|
|
|
+ rollClubTwoDetails.setBlankOutput(x.getBilletWeight());//出坯量
|
|
|
+ rollClubTwoDetailsList.add(rollClubTwoDetails);
|
|
|
+ timeOffset.addAndGet(1000); // 这里假设每次增加1秒(1000毫秒)的时间偏移量
|
|
|
+ });
|
|
|
+ rollClubTwoDetailsService.saveBatch(rollClubTwoDetailsList);
|
|
|
+ // 更新交班表中的热装总支数
|
|
|
+ updateShiftInfoByType(billetHotsend.getCcmNo(), billetHotsend.getShift(), billetHotsend.getShiftGroup(), rollClubTwoDetailsList.size(), "roll_club_two", "hotCharge");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ // 保存棒三信息
|
|
|
+ RollClubThree rollClubThree = new RollClubThree();
|
|
|
+ BeanUtils.copyProperties(billetHotsend, rollClubThree);
|
|
|
+ rollClubThree.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
|
|
|
+ rollClubThree.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
|
|
|
+ rollClubThree.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
|
|
|
+ rollClubThree.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
|
|
|
+ rollClubThree.setStorageBillId(storageBill.getId());
|
|
|
+ LambdaQueryWrapper<RollClubThree> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(RollClubThree::getCcmNo, billetHotsend.getCcmNo())
|
|
|
+ .eq(RollClubThree::getHeatNo, billetHotsend.getHeatNo())
|
|
|
+ .eq(RollClubThree::getShift, billetHotsend.getShift())
|
|
|
+ .eq(RollClubThree::getShiftGroup, billetHotsend.getShiftGroup())
|
|
|
+ .eq(RollClubThree::getStorageBillId, storageBill.getId());
|
|
|
+ RollClubThree rollClubThree1 = rollClubThreeService.getOne(queryWrapper1);
|
|
|
+ if (oConvertUtils.isEmpty(rollClubThree1)){
|
|
|
+ rollClubThree.setCreateDate(new Date());
|
|
|
+ rollClubThree.setAmountTotal(rollClubCommonList.size());// 总支数
|
|
|
+ rollClubThreeService.save(rollClubThree);
|
|
|
+ }else {
|
|
|
+ rollClubThree.setId(rollClubThree1.getId());
|
|
|
+ rollClubThree.setAmountTotal(rollClubThree1.getAmountTotal() + rollClubCommonList.size());// 总支数
|
|
|
+ rollClubThree.setBlankOutput(rollClubThree1.getBlankOutput() + rollClubThree.getBlankOutput());//出坯量
|
|
|
+ rollClubThree.setUpdateTime(new Date());
|
|
|
+ rollClubThreeService.updateById(rollClubThree);
|
|
|
+ }
|
|
|
+ // 保存棒三明细信息
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = new ArrayList<>();
|
|
|
+ rollClubCommonList.forEach(x ->{
|
|
|
+ RollClubThreeDetails rollClubThreeDetails = new RollClubThreeDetails();
|
|
|
+ BeanUtils.copyProperties(x, rollClubThreeDetails);
|
|
|
+ rollClubThreeDetails.setId(String.valueOf(IdWorker.getId()));
|
|
|
+ rollClubThreeDetails.setShift(billetHotsend.getShift());
|
|
|
+ rollClubThreeDetails.setShiftGroup(billetHotsend.getShiftGroup());
|
|
|
+ rollClubThreeDetails.setStorageBillId(storageBill.getId());
|
|
|
+ rollClubThreeDetails.setLicensePlate(storageBill.getLicensePlate());
|
|
|
+ rollClubThreeDetails.setSize(String.valueOf(x.getLength()));
|
|
|
+ rollClubThreeDetails.setSteel(x.getGrade());
|
|
|
+ rollClubThreeDetails.setCreateTime(new Date(System.currentTimeMillis() + timeOffset.get()));
|
|
|
+ rollClubThreeDetails.setBlankOutput(x.getBilletWeight());//出坯量
|
|
|
+ rollClubThreeDetailsList.add(rollClubThreeDetails);
|
|
|
+ timeOffset.addAndGet(1000); // 这里假设每次增加1秒(1000毫秒)的时间偏移量
|
|
|
+ });
|
|
|
+ rollClubThreeDetailsService.saveBatch(rollClubThreeDetailsList);
|
|
|
+ // 更新交班表中的热装总支数
|
|
|
+ updateShiftInfoByType(billetHotsend.getCcmNo(), billetHotsend.getShift(), billetHotsend.getShiftGroup(), rollClubThreeDetailsList.size(), "roll_club_three", "hotCharge");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存上若信息
|
|
|
+ */
|
|
|
+ if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
|
|
|
+ RollOutShipp rollOutShipp = new RollOutShipp();
|
|
|
+ BeanUtils.copyProperties(billetHotsend, rollOutShipp);
|
|
|
+
|
|
|
+ rollOutShipp.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
|
|
|
+ rollOutShipp.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
|
|
|
+ rollOutShipp.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
|
|
|
+ rollOutShipp.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
|
|
|
+ rollOutShipp.setStorageBillId(storageBill.getId());
|
|
|
+ LambdaQueryWrapper<RollOutShipp> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(RollOutShipp::getCcmNo, billetHotsend.getCcmNo())
|
|
|
+ .eq(RollOutShipp::getHeatNo, billetHotsend.getHeatNo())
|
|
|
+ .eq(RollOutShipp::getShift, billetHotsend.getShift())
|
|
|
+ .eq(RollOutShipp::getShiftGroup, billetHotsend.getShiftGroup())
|
|
|
+ .eq(RollOutShipp::getStorageBillId, storageBill.getId());
|
|
|
+ RollOutShipp rollOutShipp1 = rollOutShippService.getOne(queryWrapper1);
|
|
|
+ if (oConvertUtils.isEmpty(rollOutShipp1)){
|
|
|
+ rollOutShipp.setCreateDate(new Date());
|
|
|
+ rollOutShipp.setAmountTotal(rollClubCommonList.size());// 总支数
|
|
|
+ rollOutShippService.save(rollOutShipp);
|
|
|
+ }else {
|
|
|
+ rollOutShipp.setId(rollOutShipp1.getId());
|
|
|
+ rollOutShipp.setAmountTotal(rollOutShipp1.getAmountTotal() + rollClubCommonList.size());// 总支数
|
|
|
+ rollOutShipp.setBlankOutput(rollOutShipp1.getBlankOutput() + rollOutShipp.getBlankOutput());//出坯量
|
|
|
+ rollOutShipp.setUpdateTime(new Date());
|
|
|
+ rollOutShippService.updateById(rollOutShipp);
|
|
|
+ }
|
|
|
+ // 保存上若明细信息
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = new ArrayList<>();
|
|
|
+ rollClubCommonList.forEach(x ->{
|
|
|
+ RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
|
|
|
+ BeanUtils.copyProperties(x, rollOutShippDetails);
|
|
|
+ rollOutShippDetails.setId(String.valueOf(IdWorker.getId()));
|
|
|
+ rollOutShippDetails.setShift(billetHotsend.getShift());
|
|
|
+ rollOutShippDetails.setShiftGroup(billetHotsend.getShiftGroup());
|
|
|
+ rollOutShippDetails.setStorageBillId(storageBill.getId());
|
|
|
+ rollOutShippDetails.setLicensePlate(storageBill.getLicensePlate());
|
|
|
+ rollOutShippDetails.setSize(String.valueOf(x.getLength()));
|
|
|
+ rollOutShippDetails.setSteel(x.getGrade());
|
|
|
+ rollOutShippDetails.setCreateTime(new Date(System.currentTimeMillis() + timeOffset.get()));
|
|
|
+ rollOutShippDetails.setBlankOutput(x.getBilletWeight());//出坯量
|
|
|
+ rollOutShippDetailsList.add(rollOutShippDetails);
|
|
|
+ timeOffset.addAndGet(1000); // 这里假设每次增加1秒(1000毫秒)的时间偏移量
|
|
|
+ });
|
|
|
+ rollOutShippDetailsService.saveBatch(rollOutShippDetailsList);
|
|
|
+ // 更新交班表中的热装总支数
|
|
|
+ updateShiftInfoByType(billetHotsend.getCcmNo(), billetHotsend.getShift(), billetHotsend.getShiftGroup(), rollOutShippDetailsList.size(), "roll_out_shipp", "hotCharge");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成综合唯一编码
|
|
|
+ * @param date
|
|
|
+ * @param ccmNo
|
|
|
+ * @param shift
|
|
|
+ * @param shiftGroup
|
|
|
+ * @return uniqueCode
|
|
|
+ */
|
|
|
+ public String generateUniqueCode(Date date, String ccmNo, String shift, String shiftGroup) {
|
|
|
+ // 将日期转换为指定格式的字符串
|
|
|
+ String dateStr = DateUtils.date2Str(date, DateUtils.yyyymmddhhmmss.get());
|
|
|
+ // 将 shift 转换为 ShiftEnum 的名称
|
|
|
+ String shiftName = ShiftEnum.fromCode(shift).name();
|
|
|
+ // 将 shiftGroup 转换为 ShiftGroupEnum 的名称
|
|
|
+ String shiftGroupName = ShiftGroupEnum.fromCode(shiftGroup).name();
|
|
|
+ // 组合生成唯一代码
|
|
|
+ String uniqueCode = dateStr + "-" + ccmNo + "#" + shiftName + "-" + shiftGroupName;
|
|
|
+ return uniqueCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从Redis中获取班组班别
|
|
|
+ * @param ccmNo
|
|
|
+ * @param keyFormat
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getShiftInfo(String ccmNo, String keyFormat) {
|
|
|
+ String key = String.format(keyFormat, ccmNo);
|
|
|
+ return oConvertUtils.getString(redisTemplate.opsForValue().get(key));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据班组、班别、炉号对钢坯信息进行分组
|
|
|
+ * @param rollClubCommonList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Map<String, List<RollClubCommon>> groupByShiftAttributes(List<RollClubCommon> rollClubCommonList) {
|
|
|
+ return rollClubCommonList.stream().collect(Collectors.groupingBy(rollClubCommon -> rollClubCommon.getHeatNo() + "," + rollClubCommon.getShiftGroup() + "," + rollClubCommon.getShift()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据铸机号、班次、班别查询当天交班记录,并根据提供的日志列表更新相应的热送总支数
|
|
|
+ *
|
|
|
+ * @param ccmNo 铸机号
|
|
|
+ * @param cacheShint 班次信息
|
|
|
+ * @param cacheShintGroup 班别信息
|
|
|
+ * @param sum 热送总支数
|
|
|
+ */
|
|
|
+ public void updateShiftInfoByType(String ccmNo, String cacheShint, String cacheShintGroup, Integer sum, String type, String updateType) {
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapperCS.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, cacheShint)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, cacheShintGroup)
|
|
|
+ .between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapperCS);
|
|
|
+ if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)) {
|
|
|
+ String operationName = type.equals("hotSend")? "热送" : "热装";
|
|
|
+ log.info("{}{}", ">>>>>B端车位发车统计当前班次" + operationName + "总支数:", sum + "班组:" + cacheShintGroup + "班次:" + cacheShint);
|
|
|
+ billetHotsendChangeShift.setUpdateTime(new Date());
|
|
|
+ if ("hotSend".equals(updateType)){
|
|
|
+ billetHotsendChangeShift.setHotsendAmount(billetHotsendChangeShift.getHotsendAmount() + sum);
|
|
|
+ }else{
|
|
|
+ billetHotsendChangeShift.setHotfeignAmount(billetHotsendChangeShift.getHotfeignAmount() + sum);
|
|
|
+ }
|
|
|
+ billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|