人才培养方案
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
package com.roomroot.jwgl.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.roomroot.jwgl.entity.ZYB;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 专业表插入时补齐达梦非空列。达梦将空串视为 NULL,缺省值必须是非空文本或数字。
|
||||
*/
|
||||
@Component
|
||||
public class ZybInsertFillHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
Object origin = metaObject.getOriginalObject();
|
||||
if (!(origin instanceof ZYB)) {
|
||||
return;
|
||||
}
|
||||
ZYB entity = (ZYB) origin;
|
||||
fillNotNullColumns(entity);
|
||||
strictInsertFill(metaObject, "xnz", String.class, entity.getXnz());
|
||||
strictInsertFill(metaObject, "xqs", Integer.class, entity.getXqs());
|
||||
strictInsertFill(metaObject, "gfmc", String.class, entity.getGfmc());
|
||||
strictInsertFill(metaObject, "jclb", String.class, entity.getJclb());
|
||||
strictInsertFill(metaObject, "xtms", String.class, entity.getXtms());
|
||||
strictInsertFill(metaObject, "zgzy", Boolean.class, entity.getZgzy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
// 仅插入补齐
|
||||
}
|
||||
|
||||
/** @deprecated 使用 {@link #fillNotNullColumns(ZYB)} */
|
||||
public static void fillAcademicYears(ZYB entity) {
|
||||
fillNotNullColumns(entity);
|
||||
}
|
||||
|
||||
public static void fillNotNullColumns(ZYB entity) {
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
String name = blankToNull(entity.getZymc());
|
||||
String xnz = blankToNull(entity.getXnz());
|
||||
if (xnz == null) {
|
||||
if (entity.getXqs() != null && entity.getXqs() > 0) {
|
||||
xnz = String.valueOf(Math.max(1, (entity.getXqs() + 1) / 2));
|
||||
} else {
|
||||
xnz = "4";
|
||||
}
|
||||
}
|
||||
entity.setXnz(xnz);
|
||||
if (entity.getXqs() == null) {
|
||||
int years = 4;
|
||||
try {
|
||||
years = (int) Math.round(Double.parseDouble(xnz));
|
||||
} catch (NumberFormatException ignored) {
|
||||
years = 4;
|
||||
}
|
||||
entity.setXqs(Math.max(1, years) * 2);
|
||||
}
|
||||
if (blankToNull(entity.getGfmc()) == null) {
|
||||
entity.setGfmc(name != null ? name : "-");
|
||||
}
|
||||
if (blankToNull(entity.getZybsh()) == null && blankToNull(entity.getZydh()) != null) {
|
||||
entity.setZybsh(entity.getZydh());
|
||||
}
|
||||
if (blankToNull(entity.getJc()) == null) {
|
||||
entity.setJc(name != null ? name : "-");
|
||||
}
|
||||
if (blankToNull(entity.getZyfx()) == null) {
|
||||
entity.setZyfx("-");
|
||||
}
|
||||
if (blankToNull(entity.getZybb()) == null) {
|
||||
entity.setZybb("-");
|
||||
}
|
||||
if (blankToNull(entity.getPxlx2()) == null) {
|
||||
entity.setPxlx2("其他");
|
||||
}
|
||||
if (blankToNull(entity.getXylb()) == null) {
|
||||
entity.setXylb("其他");
|
||||
}
|
||||
if (blankToNull(entity.getJclb()) == null) {
|
||||
entity.setJclb("双节次");
|
||||
}
|
||||
if (blankToNull(entity.getXtms()) == null) {
|
||||
entity.setXtms("军校模式");
|
||||
}
|
||||
if (blankToNull(entity.getZdyfl()) == null) {
|
||||
entity.setZdyfl("-");
|
||||
}
|
||||
if (blankToNull(entity.getZygf()) == null) {
|
||||
entity.setZygf("-");
|
||||
}
|
||||
if (entity.getZgzy() == null) {
|
||||
entity.setZgzy(false);
|
||||
}
|
||||
if (entity.getTy() == null) {
|
||||
entity.setTy(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String blankToNull(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = value.trim();
|
||||
return trimmed.isEmpty() ? null : trimmed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user