You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.4 KiB
Java
89 lines
3.4 KiB
Java
package com.glxp.api.util.udi;
|
|
|
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
import com.glxp.api.entity.inout.IoCodeTempEntity;
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
import com.glxp.api.service.basic.UdiProductService;
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
import com.glxp.api.util.IntUtil;
|
|
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@Service
|
|
public class UdiCalCountUtil {
|
|
|
|
@Resource
|
|
UdiRelevanceService udiRelevanceService;
|
|
@Resource
|
|
UdiProductService udiProductService;
|
|
|
|
|
|
public int getActCount(UdiRelevanceResponse udiRelevanceResponse) {
|
|
//启用使用单元
|
|
if (udiRelevanceResponse.getUseDy()) {
|
|
if (udiRelevanceResponse.getDiType() == 1) {
|
|
if (udiRelevanceResponse.getZxxsbzbhsydysl() == null || udiRelevanceResponse.getZxxsbzbhsydysl() == 0) {
|
|
udiRelevanceResponse.setZxxsbzbhsydysl(1);
|
|
}
|
|
return udiRelevanceResponse.getZxxsbzbhsydysl();
|
|
} else if (udiRelevanceResponse.getDiType() == 4) {
|
|
if (udiRelevanceResponse.getBhzxxsbzsl() == 0) {
|
|
udiRelevanceResponse.setBhzxxsbzsl(1);
|
|
}
|
|
if (udiRelevanceResponse.getZxxsbzbhsydysl() == null || udiRelevanceResponse.getZxxsbzbhsydysl() == 0) {
|
|
udiRelevanceResponse.setZxxsbzbhsydysl(1);
|
|
}
|
|
return udiRelevanceResponse.getBhzxxsbzsl() * udiRelevanceResponse.getZxxsbzbhsydysl();
|
|
} else {
|
|
return udiRelevanceResponse.getBhzxxsbzsl();
|
|
}
|
|
} else {//不启用使用单元
|
|
if (udiRelevanceResponse.getDiType() == 1) {
|
|
return 1;
|
|
} else if (udiRelevanceResponse.getDiType() == 4) {
|
|
if (udiRelevanceResponse.getBhzxxsbzsl() == 0) {
|
|
udiRelevanceResponse.setBhzxxsbzsl(1);
|
|
}
|
|
return udiRelevanceResponse.getBhzxxsbzsl();
|
|
} else {
|
|
return udiRelevanceResponse.getBhzxxsbzsl();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int getActCount(IoCodeTempEntity codeTempEntity) {
|
|
if (codeTempEntity.getRelId() != null) {
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(codeTempEntity.getRelId());
|
|
int count = getActCount(udiRelevanceResponse);
|
|
return codeTempEntity.getCount() * count;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
public int getActCount(String nameCode) {
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(nameCode);
|
|
int count = getActCount(udiRelevanceResponse);
|
|
return count;
|
|
}
|
|
|
|
public String getMinDi(Long relId) {
|
|
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(relId);
|
|
UdiProductEntity udiProductEntity = null;
|
|
if (IntUtil.value(udiRelevanceEntity.getIsUseDy())) {
|
|
udiProductEntity = udiProductService.selectMinUdiByUuid(udiRelevanceEntity.getUuid(), 1);
|
|
} else {
|
|
udiProductEntity = udiProductService.selectMinUdiByUuid(udiRelevanceEntity.getUuid(), 2);
|
|
}
|
|
if (udiProductEntity != null) {
|
|
return udiProductEntity.getNameCode();
|
|
} else
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
}
|