|
|
|
@ -3,8 +3,13 @@ package com.op.mes.service.impl;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.op.common.core.constant.UserConstants;
|
|
|
|
|
import com.op.common.core.exception.ServiceException;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
|
import com.op.common.security.utils.DictUtils;
|
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.op.system.api.domain.SysDictType;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.op.mes.mapper.MesBoxMapper;
|
|
|
|
@ -55,7 +60,7 @@ public class MesBoxServiceImpl implements IMesBoxService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int insertMesBox(MesBox mesBox) {
|
|
|
|
|
mesBox.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
mesBox.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
mesBox.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return mesBoxMapper.insertMesBox(mesBox);
|
|
|
|
|
}
|
|
|
|
@ -83,7 +88,16 @@ public class MesBoxServiceImpl implements IMesBoxService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int deleteMesBoxByBoxIds(Long[] boxIds) {
|
|
|
|
|
return mesBoxMapper.deleteMesBoxByBoxIds(boxIds);
|
|
|
|
|
int n = 0;
|
|
|
|
|
for (Long boxId : boxIds) {
|
|
|
|
|
MesBox boxType = selectMesBoxByBoxId(boxId);
|
|
|
|
|
if (mesBoxMapper.countBoxDataByType(boxType.getBoxType()) > 0) {
|
|
|
|
|
throw new ServiceException(String.format("%1$s已分配,不能删除", boxType.getBoxName()));
|
|
|
|
|
}
|
|
|
|
|
n += mesBoxMapper.deleteMesBoxByBoxIds(boxIds);
|
|
|
|
|
}
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -103,4 +117,14 @@ public class MesBoxServiceImpl implements IMesBoxService {
|
|
|
|
|
public List<MesBox> selectDictTypeAll() {
|
|
|
|
|
return mesBoxMapper.selectDictTypeAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean checkBoxTypeUnique(MesBox mesBox) {
|
|
|
|
|
Long boxId = StringUtils.isNull(mesBox.getBoxId()) ? -1L : mesBox.getBoxId();
|
|
|
|
|
MesBox boxType = mesBoxMapper.checkBoxTypeUnique(mesBox.getBoxType());
|
|
|
|
|
if (StringUtils.isNotNull(boxType) && boxType.getBoxId().longValue() != boxId.longValue()) {
|
|
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
|
|
}
|
|
|
|
|
return UserConstants.UNIQUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|