|
@@ -1,11 +1,24 @@
|
|
|
package org.jeecg.modules.billet.billetHotsendChangeShift.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+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.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.mapper.BilletHotsendChangeShiftMapper;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
+import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 钢坯交班记录
|
|
|
* @Author: jeecg-boot
|
|
@@ -15,4 +28,92 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotsendChangeShiftMapper, BilletHotsendChangeShift> implements IBilletHotsendChangeShiftService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBilletBasicInfoService billetBasicInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOperateLogService operateLogService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject billetHotsendChangeShiftHandle(BilletHotsendChangeShift billetHotsendChangeShiftVo) {
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ //先更新班组班别缓存
|
|
|
+ String keyShiftGroup = String.format("class:shift:group:%s", billetHotsendChangeShiftVo.getCcmNo());
|
|
|
+ String keyShift = String.format("class:shift:%s", billetHotsendChangeShiftVo.getCcmNo());
|
|
|
+ redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
|
|
|
+ redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
|
|
|
+ // 获取当前班组班别
|
|
|
+ List<BilletHotsendChangeShift> billetHotsendChangeShiftList = baseMapper.selectList(new LambdaQueryWrapper<BilletHotsendChangeShift>()
|
|
|
+ .eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime));
|
|
|
+ if (oConvertUtils.listIsNotEmpty(billetHotsendChangeShiftList)){
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftList.stream().findFirst().orElse(null);
|
|
|
+ // 获取当前最新炉号
|
|
|
+ BilletBasicInfo billetBasicInfo = billetBasicInfoService.list(new LambdaQueryWrapper<BilletBasicInfo>().orderByDesc(BilletBasicInfo::getCreateTime)).stream().findFirst().orElse(null);
|
|
|
+ if (oConvertUtils.isNotEmpty(billetBasicInfo)){
|
|
|
+ // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
|
|
|
+ .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsendChangeShiftVo.getCcmNo()))
|
|
|
+ .eq(BilletBasicInfo::getHeatNo, billetBasicInfo.getHeatNo())
|
|
|
+ .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
|
|
|
+ .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
|
|
|
+ .orderByDesc(BilletBasicInfo::getCreateTime);
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(billetBasicInfoList)){
|
|
|
+ List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
|
|
|
+ updateBilletBasicInfo.forEach(x ->{
|
|
|
+ x.setShift(billetHotsendChangeShiftVo.getShift());
|
|
|
+ x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
|
|
|
+ x.setUpdateTime(new Date());
|
|
|
+ });
|
|
|
+ billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成新的交班记录 初始化并保存入库
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
|
|
|
+ billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
|
|
|
+ billetHotsendChangeShift1.setCcmNo(billetHotsendChangeShiftVo.getCcmNo());
|
|
|
+ billetHotsendChangeShift1.setShift(billetHotsendChangeShiftVo.getShift());
|
|
|
+ billetHotsendChangeShift1.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
|
|
|
+ billetHotsendChangeShift1.setHotfeignAmount(0);// 当前热装支数
|
|
|
+ billetHotsendChangeShift1.setProductAmount(0);//当前生产支数
|
|
|
+ billetHotsendChangeShift1.setHotsendAmount(0);// 当前热送支数
|
|
|
+ billetHotsendChangeShift1.setStackAmount(0);//当前起垛支数
|
|
|
+ billetHotsendChangeShift1.setOutCarNum(0);//车次
|
|
|
+ billetHotsendChangeShift1.setShiftSum(0);//当班总数
|
|
|
+ billetHotsendChangeShift1.setShiftProduct(0d); // 当班总重
|
|
|
+ billetHotsendChangeShift1.setWasteAmount(0);// 当前废品支数
|
|
|
+ billetHotsendChangeShift1.setCreateTime(new Date());
|
|
|
+ baseMapper.insert(billetHotsendChangeShift1);
|
|
|
+ operateLogService.add(billetHotsendChangeShift1,null, BilletHotsendChangeShift.class);
|
|
|
+
|
|
|
+ result.put("success", "交班操作成功!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算余数并提取相应元素
|
|
|
+ * @param billetBasicInfoList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<BilletBasicInfo> extractRemainderData(List<BilletBasicInfo> billetBasicInfoList) {
|
|
|
+ List<BilletBasicInfo> remainderList = new ArrayList<>();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(billetBasicInfoList)) {
|
|
|
+ int size = billetBasicInfoList.size();
|
|
|
+ int remainder = size % 4;
|
|
|
+ if (remainder > 0) {
|
|
|
+ for (int i = size - remainder; i < size; i++) {
|
|
|
+ remainderList.add(billetBasicInfoList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return remainderList;
|
|
|
+ }
|
|
|
}
|