Forráskód Böngészése

钢坯装运单新增逻辑优化

qiangxuan 5 hónapja
szülő
commit
122896a13a

+ 13 - 5
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/controller/BilletHotsendBaseController.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.billet.billetHotsend.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -12,13 +13,13 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
+import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
 import org.jeecg.modules.billet.billetHotsend.entity.RealtimeStats;
 import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
-import org.jeecg.modules.billet.billetHotsend.service.IRulerDefaultConfigService;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
-import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingAndLoadingVehiclesService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
@@ -41,12 +42,12 @@ import java.util.List;
 public class BilletHotsendBaseController extends JeecgController<BilletHotsend, IBilletHotsendBaseService> {
    @Autowired
    private IBilletHotsendBaseService billetHotsendBaseService;
+
    @Autowired
    private IOperateLogService operateLogService;
+
    @Autowired
-   private IRulerDefaultConfigService rulerDefaultConfigService;
-   @Autowired
-   private IStackingAndLoadingVehiclesService stackingAndLoadingVehiclesService;
+   private IBilletBasicInfoService billetBasicInfoService;
 
    /**
     * 分页列表查询
@@ -108,6 +109,13 @@ public class BilletHotsendBaseController extends JeecgController<BilletHotsend,
     @ApiOperation(value="新增钢坯热送基础信息", notes="新增钢坯热送基础信息")
     @PostMapping(value = "/addBilletHotsendInfo")
     public Result<?> addBilletHotsend(@RequestBody BilletHotsendDetailsVo billetHotsendDetailsVo) {
+        LambdaQueryWrapper<BilletBasicInfo> queryWrapperBB = new LambdaQueryWrapper<BilletBasicInfo>()
+                .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsendDetailsVo.getBilletHotsend().getCcmNo()))
+                .eq(BilletBasicInfo::getHeatNo, billetHotsendDetailsVo.getBilletHotsend().getHeatNo());
+        List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperBB);
+        if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+            return Result.error("炉次信息不存在,新增失败!");
+        }
         // 根据铸机号、炉号查询热送单信息是否存在
         JSONObject jsonObject = billetHotsendBaseService.addBilletHotsendInfo(billetHotsendDetailsVo);
         if (jsonObject.containsKey("fail")){

+ 1 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/service/impl/BilletHotsendBaseServiceImpl.java

@@ -491,7 +491,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 				.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
 				.eq(BilletHotsend::getShift, billetHotsend.getShift())
 				.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
-		baseMapper.update(billetHotsend,  updateWrapper);
+		baseMapper.update(billetHotsend, updateWrapper);
 
 		// 保存 钢坯热送单炉支数传递单明细
 		if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable())){

+ 5 - 61
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.billet.storageBill.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -12,15 +13,11 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
-import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
 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.service.IStorageBillService;
 import org.jeecg.modules.billet.storageBill.service.ITripsManageService;
@@ -108,64 +105,11 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	 @ApiOperation(value="钢坯装运单-添加", notes="钢坯装运单-添加")
 	 @PostMapping(value = "/add")
 	 public Result<String> add(@RequestBody StorageBill storageBill) {
-		 try {
-			 String keyShiftGroup = String.format("class:shift:group:%s", storageBill.getCcmNo());
-			 String keyShift = String.format("class:shift:%s", storageBill.getCcmNo());
-			 String text1 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
-			 String text2 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
-
-			 LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
-			 queryWrapper.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-					 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
-					 .eq(StorageBill::getShiftGroup, text1)
-					 .eq(StorageBill::getShift, text2)
-					 .isNull(StorageBill::getOutTime);
-			 StorageBill isStorageBill = storageBillService.getOne(queryWrapper);
-			 if (oConvertUtils.isNotEmpty(isStorageBill)) {
-				 log.info("查询到存在未发车车辆,车牌号为:{},新增钢坯装运单失败!", storageBill.getLicensePlate());
-				 return Result.OK("存在未发车车辆,新增钢坯装运单失败!");
-			 }
-			 storageBill.setCarAllNum(oConvertUtils.listIsEmpty(storageBillService.list()) ? 0 : storageBillService.list().size() + 1);// 车次总序号
-			 storageBill.setArrivalTime(new Date());// 到达时间
-
-			 LambdaQueryWrapper<StorageBill> queryWrapper1 = new LambdaQueryWrapper<>();
-			 queryWrapper1.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-					 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
-					 .eq(StorageBill::getShiftGroup, text1)
-					 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
-			 List<StorageBill> storageBillList = storageBillService.list(queryWrapper1);
-
-			 LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
-			 queryWrapper2.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-					 .eq(StorageBill::getShiftGroup, text1)
-					 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
-			 storageBill.setCarNum(storageBillList.size() + 1);
-			 storageBill.setCarAllNum(storageBillService.list(queryWrapper2).size() + 1);
-
-			 // 通过铸机号、班组、班别去查询交班记录并初始化 车次
-			 LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper3 = new LambdaQueryWrapper<>();
-			 queryWrapper3.eq(BilletHotsendChangeShift::getCcmNo, storageBill.getCcmNo())
-					 .eq(BilletHotsendChangeShift::getShiftGroup, text1)
-					 .eq(BilletHotsendChangeShift::getShift, text2).between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
-			 BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper3);
-			 if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)){
-				 billetHotsendChangeShift.setOutCarNum(billetHotsendChangeShift.getOutCarNum() + 1);
-				 billetHotsendChangeShift.setUpdateTime(new Date());
-				 billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
-			 }
-			 storageBill.setAmountTotal(0);
-			 storageBill.setShiftGroup(text1);
-			 storageBill.setShift(text2);
-			 String uniqueCode = DateUtils.date2Str(new Date(), DateUtils.yyyymmddhhmmss.get()) + "-" + storageBill.getCcmNo() + "#" +ShiftEnum.fromCode(text2).name()+ "-" + ShiftGroupEnum.fromCode(text1).name();
-			 storageBill.setUniqueCode(uniqueCode);
-			 storageBillService.save(storageBill);
-			 operateLogService.add(storageBill,null,StorageBill.class);
-			 return Result.OK("钢坯装运单添加成功!");
-		 } catch (Exception e) {
-			 // 记录异常日志
-			 log.error("添加钢坯装运单时发生异常", e);
-			 return Result.error("系统错误,请稍后再试!");
+		 JSONObject jsonObject = storageBillService.storageBillSave(storageBill);
+		 if (jsonObject.containsKey("fail")){
+			 return Result.OK((String) jsonObject.get("fail"));
 		 }
+		 return Result.OK((String) jsonObject.get("success"));
 	 }
 
 	/**

+ 3 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/IStorageBillService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.billet.storageBill.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
 import org.jeecg.modules.billet.storageBill.entity.BilletHotsendDetails;
@@ -26,4 +27,6 @@ public interface IStorageBillService extends IService<StorageBill> {
     BilletHotsendDetails findBilletHotsendDetails(StorageBill storageBill);
 
     List<StorageBill> findCar(String ccmNo, String destination);
+
+    JSONObject storageBillSave(StorageBill storageBill);
 }

+ 83 - 5
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -1,15 +1,20 @@
 package org.jeecg.modules.billet.storageBill.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
 import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
 import org.jeecg.modules.billet.billetHotsend.entity.RollClubCommon;
+import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
+import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
 import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billet.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
+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.RollClubThreeDetails;
@@ -20,15 +25,15 @@ import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
-import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingDownLogService;
-import org.jeecg.modules.billet.storageBill.entity.BilletHotsendDetails;
-import org.jeecg.modules.billet.storageBill.entity.GetStatsResponse;
-import org.jeecg.modules.billet.storageBill.entity.StorageBill;
+import org.jeecg.modules.billet.storageBill.entity.*;
 import org.jeecg.modules.billet.storageBill.mapper.StorageBillMapper;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
 import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.util.Date;
 import java.util.List;
@@ -72,7 +77,13 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     private IBilletBasicInfoService billetBasicInfoService;
 
     @Autowired
-    private IStackingDownLogService stackingDownLogService;
+    public RedisTemplate redisTemplate;
+
+    @Autowired
+    private IBilletHotsendChangeShiftService billetHotsendChangeShiftService;
+
+    @Autowired
+    private IOperateLogService operateLogService;
 
     @Override
     public void subCarTimes(Integer times) {
@@ -175,4 +186,71 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     public List<StorageBill> findCar(String ccmNo, String destination) {
         return storageBillMapper.findCar(ccmNo, destination);
     }
+
+    @Override
+    @Transactional
+    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));
+            LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
+                    .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
+                    .eq(StorageBill::getShiftGroup, shiftGroup)
+                    .eq(StorageBill::getShift, shift)
+                    .isNull(StorageBill::getOutTime);
+            StorageBill isStorageBill = baseMapper.selectOne(queryWrapper);
+            if (oConvertUtils.isNotEmpty(isStorageBill)) {
+                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())
+                    .eq(StorageBill::getShiftGroup, shiftGroup)
+                    .eq(StorageBill::getShift, shift).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+            long carNum = baseMapper.selectCount(queryWrapper1);
+            storageBill.setCarNum(Math.toIntExact(carNum) + 1);
+
+            LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
+            queryWrapper2.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
+                    .eq(StorageBill::getShiftGroup, shiftGroup)
+                    .eq(StorageBill::getShift, shift).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+            long carAllNum = baseMapper.selectCount(queryWrapper2);
+            storageBill.setCarAllNum(Math.toIntExact(carAllNum) + 1);
+
+            // 通过铸机号、班组、班别去查询交班记录并初始化 车次
+            LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper3 = new LambdaQueryWrapper<>();
+            queryWrapper3.eq(BilletHotsendChangeShift::getCcmNo, storageBill.getCcmNo())
+                    .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
+                    .eq(BilletHotsendChangeShift::getShift, shift).between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+            BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper3);
+            if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)){
+                billetHotsendChangeShift.setOutCarNum(billetHotsendChangeShift.getOutCarNum() + 1);
+                billetHotsendChangeShift.setUpdateTime(new Date());
+                billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
+            }
+            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();
+            storageBill.setUniqueCode(uniqueCode);
+            baseMapper.insert(storageBill);
+            operateLogService.add(storageBill,null,StorageBill.class);
+            result.put("success", "钢坯装运单添加成功!");
+            return result;
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            // 记录异常日志
+            log.error("添加钢坯装运单时发生异常", e.getMessage());
+            result.put("fail", "系统错误,请稍后再试!");
+            return result;
+        }
+    }
 }