|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.ruoyi.ams.inv.service.IInvLotLocIdService;
|
|
|
import com.ruoyi.ams.nieyan.dao.QcInfoFctAgvDao;
|
|
|
import com.ruoyi.ams.nieyan.dto.QcInfoFctAgvDTO;
|
|
|
import com.ruoyi.ams.nieyan.entity.QcInfoFctAgvEntity;
|
|
@@ -12,49 +13,75 @@ import com.ruoyi.ams.nieyan.service.IQcInfoFctAgvService;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.utils.ConvertUtils;
|
|
|
import com.ruoyi.framework.service.impl.CrudServiceImpl;
|
|
|
-import org.apache.commons.compress.utils.Lists;
|
|
|
-import org.apache.commons.compress.utils.Sets;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class QcInfoFctAgvService extends CrudServiceImpl<QcInfoFctAgvDao, QcInfoFctAgvEntity, QcInfoFctAgvDTO> implements IQcInfoFctAgvService {
|
|
|
|
|
|
|
|
|
- private static final String AVG_PROCESS = "1";
|
|
|
-
|
|
|
- private static final String PERSON_PROCESS = "2";
|
|
|
+ @Autowired
|
|
|
+ private IInvLotLocIdService invLotLocIdService;
|
|
|
|
|
|
/**
|
|
|
- * 根据批号获取质检信息列表
|
|
|
+ * 根据批次号获取质检信息
|
|
|
* @param lotNo 批次号
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<QcInfoFctAgvEntity> getQcInfoList(String lotNo) {
|
|
|
+ public QcInfoFctAgvDTO getQcInfo(String lotNo) {
|
|
|
LambdaQueryWrapper<QcInfoFctAgvEntity> queryWrapper = Wrappers.<QcInfoFctAgvEntity>lambdaQuery()
|
|
|
- .eq(StringUtils.isNotBlank(lotNo), QcInfoFctAgvEntity::getSlot, lotNo);
|
|
|
+ .eq(QcInfoFctAgvEntity::getSlot, lotNo).orderByDesc(QcInfoFctAgvEntity::getCreateDate);
|
|
|
List<QcInfoFctAgvEntity> qcInfoFctAgvEntities = baseDao.selectList(queryWrapper);
|
|
|
- return CollectionUtils.isEmpty(qcInfoFctAgvEntities) ?
|
|
|
- Lists.newArrayList() : ConvertUtils.sourceToTarget(qcInfoFctAgvEntities, QcInfoFctAgvEntity.class);
|
|
|
+ return CollectionUtils.isEmpty(qcInfoFctAgvEntities) || qcInfoFctAgvEntities.size() > 1
|
|
|
+ ? new QcInfoFctAgvDTO(): ConvertUtils.sourceToTarget(qcInfoFctAgvEntities.get(0), QcInfoFctAgvDTO.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新质检信息的状态
|
|
|
- * @param id 质检信息的id
|
|
|
- * @param status 信息的状态 0-未处理 1-AGV处理 2-人工处理
|
|
|
+ * 同步质检的状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
+ public void syncQcStatusTask() {
|
|
|
+ try{
|
|
|
+ //1.查询FCT_AGV2质检表中的已质检且未处理的状态
|
|
|
+ LambdaQueryWrapper<QcInfoFctAgvEntity> queryWrapper = Wrappers.<QcInfoFctAgvEntity>lambdaQuery()
|
|
|
+ .eq(QcInfoFctAgvEntity::getIsQcl, Constants.YES).eq(QcInfoFctAgvEntity::getProcessFlag, Constants.NO);
|
|
|
+ List<QcInfoFctAgvEntity> qcInfoFctAgvEntities = baseDao.selectList(queryWrapper);
|
|
|
+ if(CollectionUtils.isEmpty(qcInfoFctAgvEntities)){
|
|
|
+ log.warn("Qc info records are not found");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //2.以批次号为关联更新inv_lot_att中的字段lotatt05(质检结果)为HG (合格)
|
|
|
+ //3.根据批号查询FCT_AGV2质检表中的未处理的状态改为已处理
|
|
|
+ for(QcInfoFctAgvEntity qcInfoFctAgvEntity : qcInfoFctAgvEntities){
|
|
|
+ if(StringUtils.isBlank(qcInfoFctAgvEntity.getSlot())) continue;
|
|
|
+ if(invLotLocIdService.updateQcStatusByLotNo(qcInfoFctAgvEntity.getSlot(), "HG")){
|
|
|
+ updateQcInfoStatus(qcInfoFctAgvEntity.getSlot(), Constants.YES);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (RuntimeException ex){
|
|
|
+ log.warn("syncQcStatusTask error is hanppened, causeby:{}", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新质检信息的处理状态
|
|
|
+ * @param lotNo 质检信息的批次号
|
|
|
+ * @param processFlag 是否已处理(Y:已处理 N:未处理)
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean updateQcInfoStatus(String id, String status) {
|
|
|
- QcInfoFctAgvEntity qcInfoFctAgvEntity = new QcInfoFctAgvEntity();
|
|
|
- String processFlag = Sets.newHashSet(AVG_PROCESS, PERSON_PROCESS).add(status)
|
|
|
- ? Constants.NO : Constants.YES;
|
|
|
- qcInfoFctAgvEntity.setId(id).setProcessFlag(processFlag).setStatus(status);
|
|
|
- baseDao.updateById(qcInfoFctAgvEntity);
|
|
|
- return baseDao.updateById(qcInfoFctAgvEntity) == 1;
|
|
|
+ public Boolean updateQcInfoStatus(String lotNo, String processFlag) {
|
|
|
+ return baseDao.update(null, Wrappers.<QcInfoFctAgvEntity>lambdaUpdate()
|
|
|
+ .set(QcInfoFctAgvEntity::getProcessFlag, processFlag).eq(QcInfoFctAgvEntity::getSlot, lotNo)) > 0;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|