浏览代码

设备在线查询接口调整

qiangxuan 6 月之前
父节点
当前提交
5d7bc0c205

+ 12 - 7
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/HomePageDataServiceImpl.java

@@ -1,11 +1,13 @@
 package org.jeecg.modules.homePageData.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.common.ModelCodeContant;
+import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
-import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
 import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
+import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
 import org.jeecg.modules.fpgLeanModel.entity.DeviceStatiscsModelMongodb;
 import org.jeecg.modules.fpgLeanModel.entity.FpgLeanModel;
@@ -53,6 +55,9 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
     @Autowired
     private MongoTemplate mongoTemplate;
 
+    @Autowired
+    private IDeviceInformationService deviceInformationService;
+
     @Override
     public List<Map<String, String>> regionPfvElectricity(String modelId) {
         String leanModelCode = queryLeanModelCodeById(modelId);
@@ -114,15 +119,15 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
         AtomicReference<Integer> offline = new AtomicReference<>(0);
         if(oConvertUtils.listIsNotEmpty(list)){
             list.forEach(deviceRegion -> {
-                List<DeviceRegionInformation> devicePointList = devicePointMapper.getPointInformation(deviceRegion.getId());
+                List<DeviceInformation> deviceInformationList = deviceInformationService.list(new LambdaQueryWrapper<DeviceInformation>().eq(DeviceInformation::getDeviceRegionId, deviceRegion.getId()));
                 Map<String, Object> map = new HashMap<>();
                 map.put("online",  0);
                 map.put("offline",  0);
-                devicePointList.forEach(devicePointInfo -> {
-                    if("1".equals(devicePointInfo.getGatherStatus())){ // 在线
-                        map.put("online",  devicePointInfo.getSum());
-                    }else if("0".equals(devicePointInfo.getGatherStatus())){ // 离线
-                        map.put("offline", devicePointInfo.getSum());
+                deviceInformationList.forEach(x -> {
+                    if("0".equals(x.getStatus())){ // 在线
+                        map.put("online", (int) map.get("online") + 1);
+                    }else{ // 离线
+                        map.put("offline", (int) map.get("offline") + 1);
                     }
                 });
                 map.put("name", deviceRegion.getRegionTitle());

+ 17 - 0
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;
@@ -104,6 +105,22 @@ public class BilletHotsendBaseController extends JeecgController<BilletHotsend,
         return Result.OK("棒线新增成功!");
     }
 
+    @AutoLog(value = "新增钢坯热送基础信息")
+    @ApiOperation(value="新增钢坯热送基础信息", notes="新增钢坯热送基础信息")
+    @PostMapping(value = "/addBilletHotsendInfo")
+    public Result<?> addBilletHotsend(@RequestBody BilletHotsendDetailsVo billetHotsendDetailsVo) {
+        // 根据铸机号、炉号查询热送单信息是否存在
+        String ccmNo = billetHotsendDetailsVo.getBilletHotsend().getCcmNo();
+        String heatNo = billetHotsendDetailsVo.getBilletHotsend().getHeatNo();
+        BilletHotsend billetHotsend = billetHotsendBaseService.getOne(new LambdaQueryWrapper<BilletHotsend>()
+                .eq(BilletHotsend::getCcmNo, ccmNo).eq(BilletHotsend::getHeatNo, heatNo));
+        if (oConvertUtils.isNotEmpty(billetHotsend)){
+            return Result.OK("该炉次钢坯热送信息已存在!");
+        }
+        JSONObject jsonObject = billetHotsendBaseService.addBilletHotsendInfo(billetHotsendDetailsVo);
+        return Result.OK("钢坯热送信息新增成功!");
+    }
+
 
     /**
      *   添加

+ 2 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/service/IBilletHotsendBaseService.java

@@ -28,4 +28,6 @@ public interface IBilletHotsendBaseService extends IService<BilletHotsend> {
     Integer queryEndNumByCcmNo(String ccmNo, String heatNo, String belongTable);
 
     void saveBilletHotsendDetailsCar(BilletHotsendDetailsVo billetHotsendDetailsVo);
+
+    JSONObject addBilletHotsendInfo(BilletHotsendDetailsVo billetHotsendDetailsVo);
 }

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

@@ -52,6 +52,7 @@ 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;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -110,6 +111,9 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 	private IHeatsActualsService heatsActualsService;
 	@Autowired
 	private IBilletHotsendChangeShiftService billetHotsendChangeShiftService;
+	@Autowired
+	public RedisTemplate redisTemplate;
+
 	@Override
 	public void updateDesc(BilletHotsend billetHotsend) {
 		RulerDefaultConfig last = rulerDefaultConfigService.getLast(billetHotsend.getCcmNo());
@@ -1096,6 +1100,51 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		storageCarLogService.save(storageCarLog);
 	}
 
+	@Override
+	public JSONObject addBilletHotsendInfo(BilletHotsendDetailsVo billetHotsendDetailsVo) {
+		JSONObject result = new JSONObject();
+
+		BilletHotsend billetHotsend = billetHotsendDetailsVo.getBilletHotsend();
+		// 新保存 钢坯热送基础信息
+		String cacheShint = billetHotsend.getShift();
+		String cacheShintGroup = billetHotsend.getShiftGroup();
+		HeatsActuals heatsActuals = heatsActualsService.getOne(new LambdaQueryWrapper<HeatsActuals>()
+				.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo())
+				.eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo()));
+		if (heatsActuals != null){
+			cacheShint = heatsActuals.getShift();
+			cacheShintGroup = heatsActuals.getShiftGroup();
+		}
+		LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+		queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+				.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+				.eq(BilletHotsend::getShift, cacheShint)
+				.eq(BilletHotsend::getShiftGroup, cacheShintGroup);
+		BilletHotsend check = baseMapper.selectOne(queryWrapper);
+		if (oConvertUtils.isNotEmpty(check)){
+			result.put("fail", "该炉次信息已存在!");
+			return result;
+		}
+		billetHotsend.setShiftGroup(cacheShintGroup);
+		billetHotsend.setShift(cacheShint);
+		if (oConvertUtils.isEmpty(check)){
+			billetHotsend.setRollclubtwoNum(0);
+			billetHotsend.setRollcluboneNum(0);
+			billetHotsend.setRolloutshippNum(0);
+			billetHotsend.setRollheightNum(0);
+			billetHotsend.setRollclubthreeNum(0);
+			billetHotsend.setAmountTotal(0);
+			billetHotsend.setStackNum(0);
+			baseMapper.insert(billetHotsend);
+			billetHotsend.setId(billetHotsend.getId());
+			operateLogService.add(billetHotsend,null,BilletHotsend.class);
+			result.put("success", "新增钢坯热送单成功!");
+			return result;
+		}
+
+		return null;
+	}
+
 
 	@Override
 	public Integer queryEndNumByCcmNo(String ccmNo, String heatNo, String belongTable) {

+ 25 - 3
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/controller/BilletHotsendChangeShiftController.java

@@ -13,6 +13,9 @@ 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.oConvertUtils;
+import org.jeecg.modules.actualControl.heatsActuals.entity.HeatsActuals;
+import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
 import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
@@ -25,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Description: 钢坯交班记录
@@ -46,6 +50,9 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	@Autowired
 	public RedisTemplate redisTemplate;
 
+	@Autowired
+	private IHeatsActualsService heatsActualsService;
+
 	/**
 	 * 分页列表查询
 	 *
@@ -80,13 +87,28 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody BilletHotsendChangeShift billetHotsendChangeShiftVo) {
 
-		// 生成新的交班记录
 		String keyShiftGroup = String.format("class:shift:group:%s", billetHotsendChangeShiftVo.getCcmNo());
 		String keyShift = String.format("class:shift:%s", billetHotsendChangeShiftVo.getCcmNo());
+
+		String currentShintGroup = redisTemplate.opsForValue().get(keyShiftGroup).toString();
+		String currentShint = redisTemplate.opsForValue().get(keyShift).toString();
+
+		List<HeatsActuals> heatsActualsList = heatsActualsService.list(new LambdaQueryWrapper<HeatsActuals>()
+				.eq(HeatsActuals::getCasterCode, billetHotsendChangeShiftVo.getCcmNo())
+				.eq(HeatsActuals::getShift, currentShint)
+				.eq(HeatsActuals::getShiftGroup, currentShintGroup)
+				.orderByDesc(HeatsActuals::getCreateTime));
+		if (oConvertUtils.listIsNotEmpty(heatsActualsList)){
+			HeatsActuals heatsActuals = heatsActualsList.stream().findFirst().orElse(null);
+			if (oConvertUtils.isEmpty(heatsActuals.getStopPourTime())){
+				return Result.error("该炉次未停浇,不能交班!");
+			}
+		}
+
+		//更新班组班别缓存
 		redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
 		redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
-
-		// 初始化并保存入库
+		// 生成新的交班记录 初始化并保存入库
 		BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
 		billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
 		billetHotsendChangeShift1.setCcmNo(billetHotsendChangeShiftVo.getCcmNo());