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.
176 lines
8.4 KiB
Java
176 lines
8.4 KiB
Java
package com.glxp.api.util;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.glxp.api.entity.basic.BasicProductSetEntity;
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
import com.glxp.api.req.basic.SupplementRequest;
|
|
import com.glxp.api.service.basic.BasicProductSetService;
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.Map;
|
|
|
|
@Service
|
|
public class SupplementVailUtil {
|
|
|
|
@Resource
|
|
BasicProductSetService basicProductSetService;
|
|
@Resource
|
|
SystemParamConfigService systemParamConfigService;
|
|
|
|
|
|
public static final int SUP_SELECT = 1;
|
|
public static final int SUP_ADD = 2;
|
|
public static final int LOCAL_ADD = 3;
|
|
public static final int LOCAL_EIDT = 4;
|
|
|
|
|
|
public String vail(SupplementRequest supplementRequest, int type) {
|
|
//验证产品信息是否必填
|
|
Map<String, BasicProductSetEntity> basicProductSetEntityMap = basicProductSetService.filterAllEnable();
|
|
Map<String, SystemParamConfigEntity> systemParamConfigEntityMap = systemParamConfigService.findBasicAll();
|
|
if (basicProductSetEntityMap.size() > 0) {
|
|
BasicProductSetEntity basicProductSetEntity = null;
|
|
|
|
basicProductSetEntity = basicProductSetEntityMap.get("sptm");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getSptm())) {
|
|
return "商品条码不能为空";
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("ybbm");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getYbbm())) {
|
|
return "医保编码不能为空";
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("measname");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmptyIfStr(supplementRequest.getMeasname())) {
|
|
return "计量单位不能为空";
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("manufactory");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmptyIfStr(supplementRequest.getManufactory())) {
|
|
return "生产厂家不能为空";
|
|
}
|
|
}
|
|
|
|
basicProductSetEntity = basicProductSetEntityMap.get("spmc");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmptyIfStr(supplementRequest.getSpmc())) {
|
|
return "商品名称不能为空";
|
|
}
|
|
}
|
|
|
|
basicProductSetEntity = basicProductSetEntityMap.get("cpms");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmptyIfStr(supplementRequest.getCpms())) {
|
|
return "产品描述不能为空";
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("price");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmptyIfStr(supplementRequest.getPrice())) {
|
|
return "产品价格不能为空";
|
|
}
|
|
}
|
|
|
|
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak1");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak1())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak1");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak2");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak2())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak2");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak3");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak3())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak3");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak4");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak4())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak4");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak5");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak5())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak5");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak6");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak6())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak6");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak7");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak7())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak7");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
basicProductSetEntity = basicProductSetEntityMap.get("basicPrductRemak8");
|
|
if (isMustFill(type, basicProductSetEntity)) {
|
|
if (StrUtil.isEmpty(supplementRequest.getBasicPrductRemak8())) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntityMap.get("basicPrductRemak8");
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
return systemParamConfigEntity.getParamValue() + "不能为空";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
public boolean isMustFill(int type, BasicProductSetEntity basicProductSetEntity) {
|
|
if (basicProductSetEntity == null)
|
|
return false;
|
|
if (type == SUP_SELECT && basicProductSetEntity.isSupSelect()) {
|
|
return true;
|
|
} else if (type == SUP_ADD && basicProductSetEntity.isSupAdd()) {
|
|
return true;
|
|
} else if (type == LOCAL_ADD && basicProductSetEntity.isLocalAdd()) {
|
|
return true;
|
|
} else if (type == LOCAL_EIDT && basicProductSetEntity.isLocalEdit()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|