ccbill
- 目录
- 概述
- 需求:
- 设计思路
- 实现思路分析
- 1.BillState
- 2.DBList
- 3.DBListAttr
- 4.DBListDBSrc
- 5.DBListDBSrcs
- DBLists
Survive by day and develop by night.
talk for import biz , show your perfect code,full busy,skip hardness,make a better result,wait for change,challenge Survive.
happy for hardess to solve denpendies.
目录
概述
网络爬虫的是一个非常常见的需求
需求:
设计思路
实现思路分析
1.BillState
/**
单据状态
*/
public enum BillState
{
/**
空白
*/
None(0),
/**
草稿
*/
Draft(1),
/**
编辑中
*/
Editing(2),
/**
归档
*/
Over(100);
public static final int SIZE = java.lang.Integer.SIZE;
private int intValue;
private static java.util.HashMap<Integer, BillState> mappings;
private static java.util.HashMap<Integer, BillState> getMappings() {
if (mappings == null)
{
synchronized (BillState.class)
{
if (mappings == null)
{
mappings = new java.util.HashMap<Integer, BillState>();
}
}
}
return mappings;
}
private BillState(int value)
{intValue = value;
getMappings().put(value, this);
}
public int getValue() {
return intValue;
}
public static BillState forValue(int value)
{return getMappings().get(value);
}
}
2.DBList
package bp.ccbill;
import bp.da.*;
import bp.en.*;
import bp.wf.*;
import bp.sys.*;
/**
数据源实体
*/
public class DBList extends EntityNoName
{
///#region 权限控制.
@Override
public UAC getHisUAC() {
UAC uac = new UAC();
uac.OpenForAppAdmin();
uac.IsDelete = false;
uac.IsInsert = false;
return uac;
}
///#endregion 权限控制.
///#region 属性
/**
物理表
*/
public final String getPTable() {
String s = this.GetValStrByKey(MapDataAttr.PTable);
if (DataType.IsNullOrEmpty(s) == true)
{
return this.getNo();
}
return s;
}
public final void setPTable(String value)
{
this.SetValByKey(MapDataAttr.PTable, value);
}
/**
实体类型:@0=单据@1=编号名称实体@2=树结构实体
*/
public final EntityType getEntityType() {
return EntityType.forValue(this.GetValIntByKey(DBListAttr.EntityType));
}
public final void setEntityType(EntityType value)
{
this.SetValByKey(DBListAttr.EntityType, value.getValue());
}
/**
表单类型 (0=傻瓜,2=自由 ...)
*/
public final FrmType getFrmType() {
return FrmType.forValue(this.GetValIntByKey(MapDataAttr.FrmType));
}
public final void setFrmType(FrmType value)
{
this.SetValByKey(MapDataAttr.FrmType, value.getValue());
}
/**
表单树
*/
public final String getFKFormTree()
{
return this.GetValStrByKey(MapDataAttr.FK_FormTree);
}
public final void setFK_FormTree(String value)
{
this.SetValByKey(MapDataAttr.FK_FormTree, value);
}
/**
新建模式 @0=表格模式@1=卡片模式@2=不可用
*/
public final int getBtnNewModel()
{
return this.GetValIntByKey(DBListAttr.BtnNewModel);
}
public final void setBtnNewModel(int value)
{
this.SetValByKey(DBListAttr.BtnNewModel, value);
}
/**
单据格式(流水号4)
*/
public final String getBillNoFormat() {
String str = this.GetValStrByKey(DBListAttr.BillNoFormat);
if (DataType.IsNullOrEmpty(str) == true)
{
str = "{LSH4}";
}
return str;
}
public final void setBillNoFormat(String value)
{
this.SetValByKey(DBListAttr.BillNoFormat, value);
}
/**
单据编号生成规则
*/
public final String getTitleRole() {
String str = this.GetValStrByKey(DBListAttr.TitleRole);
if (DataType.IsNullOrEmpty(str) == true)
{
str = "@WebUser.FK_DeptName @WebUser.Name @RDT";
}
return str;
}
public final void setTitleRole(String value)
{
this.SetValByKey(DBListAttr.BillNoFormat, value);
}
/**
新建标签
*/
public final String getBtnNewLable()
{
return this.GetValStrByKey(DBListAttr.BtnNewLable);
}
/**
删除标签
*/
public final String getBtnDelLable()
{
return this.GetValStrByKey(DBListAttr.BtnDelLable);
}
/**
保存标签
*/
public final String getBtnSaveLable()
{
return this.GetValStrByKey(DBListAttr.BtnSaveLable);
}
/**
提交标签
*/
public final String getBtnSubmitLable()
{
return this.GetValStrByKey(DBListAttr.BtnSubmitLable);
}
/**
查询标签
*/
public final String getBtnSearchLabel()
{
return this.GetValStrByKey(DBListAttr.BtnSearchLabel);
}
/**
数据快照
*/
public final String getBtnDataVer()
{
return this.GetValStrByKey(DBListAttr.BtnDataVer);
}
/**
分组按钮
*/
public final boolean getBtnGroupEnable()
{
return this.GetValBooleanByKey(DBListAttr.BtnGroupEnable);
}
public final String getBtnGroupLabel()
{
return this.GetValStrByKey(DBListAttr.BtnGroupLabel);
}
/**
打印HTML按钮
*/
public final boolean getBtnPrintHtmlEnable()
{
return this.GetValBooleanByKey(DBListAttr.BtnPrintHtmlEnable);
}
public final String getBtnPrintHtml()
{
return this.GetValStrByKey(DBListAttr.BtnPrintHtml);
}
/**
打印PDF按钮
*/
public final boolean getBtnPrintPDFEnable()
{
return this.GetValBooleanByKey(DBListAttr.BtnPrintPDFEnable);
}
public final String getBtnPrintPDF()
{
return this.GetValStrByKey(DBListAttr.BtnPrintPDF);
}
/**
打印RTF按钮
*/
public final boolean getBtnPrintRTFEnable()
{
return this.GetValBooleanByKey(DBListAttr.BtnPrintRTFEnable);
}
public final String getBtnPrintRTF()
{
return this.GetValStrByKey(DBListAttr.BtnPrintRTF);
}
/**
打印CCWord按钮
*/
public final boolean getBtnPrintCCWordEnable()
{
return this.GetValBooleanByKey(DBListAttr.BtnPrintCCWordEnable);
}
public final String getBtnPrintCCWord()
{
return this.GetValStrByKey(DBListAttr.BtnPrintCCWord);
}
/**
数据源类型
*/
public final int getDBType()
{
return this.GetValIntByKey(MapDataAttr.DBType);
}
public final String getDBSrc()
{
return this.GetValStrByKey(MapDataAttr.DBSrc);
}
public final void setDBSrc(String value)
{
this.SetValByKey(MapDataAttr.DBSrc, value);
}
public final String getExpEn()
{
return this.GetValStrByKey(MapDataAttr.ExpEn);
}
public final void setExpEn(String value)
{
this.SetValByKey(MapDataAttr.ExpEn, value);
}
public final String getExpList()
{
return this.GetValStrByKey(MapDataAttr.ExpList);
}
public final void setExpList(String value)
{
this.SetValByKey(MapDataAttr.ExpList, value);
}
public final String getExpCount()
{
return this.GetValStrByKey(MapDataAttr.ExpCount);
}
public final void setExpCount(String value)
{
this.SetValByKey(MapDataAttr.ExpCount, value);
}
public final String getMainTable()
{
return this.GetValStrByKey(DBListAttr.MainTable);
}
public final void setMainTable(String value)
{
this.SetValByKey(DBListAttr.MainTable, value);
}
public final String getMainTablePK()
{
return this.GetValStrByKey(DBListAttr.MainTablePK);
}
public final void setMainTablePK(String value)
{
this.SetValByKey(DBListAttr.MainTablePK, value);
}
///#endregion
///#region 构造方法
/**
数据源实体
*/
public DBList() {
}
/**
数据源实体
param no 映射编号
*/
public DBList(String no) throws Exception {
super(no);
}
/**
EnMap
*/
@Override
public bp.en.Map getEnMap() {
if (this.get_enMap() != null)
{
return this.get_enMap();
}
Map map = new Map("Sys_MapData", "数据源实体");
map.setCodeStruct("4");
///#region 基本属性.
map.AddGroupAttr("基本属性");
map.AddTBStringPK(MapDataAttr.No, null, "表单编号", true, true, 1, 190, 20);
map.SetHelperAlert(MapDataAttr.No, "也叫表单ID,系统唯一.");
map.AddDDLSysEnum(MapDataAttr.FrmType, 0, "表单类型", true, true, "BillFrmType", "@0=傻瓜表单@1=自由表单@8=开发者表单");
// map.AddTBString(MapDataAttr.PTable, null, "存储表", false, false, 0, 500, 20, true);
// map.SetHelperAlert(MapDataAttr.PTable, "存储的表名,如果您修改一个不存在的系统将会自动创建一个表.");
map.AddTBString(MapDataAttr.Name, null, "表单名称", true, false, 0, 200, 20, true);
// map.AddDDLEntities(MapDataAttr.FK_FormTree, "01", "表单类别", new SysFormTrees(), false);
///#endregion 基本属性.
///#region 数据源.
map.AddGroupAttr("数据源");
map.AddTBInt(MapDataAttr.DBType, 0, "数据源类型", true, true);
map.AddTBString(MapDataAttr.DBSrc, null, "数据源", false, false, 0, 600, 20);
map.AddTBString(MapDataAttr.ExpEn, null, "实体数据源", false, false, 0, 600, 20, true);
map.AddTBString(MapDataAttr.ExpList, null, "列表数据源", false, false, 0, 600, 20, true);
map.AddTBString(DBListAttr.MainTable, null, "列表数据源主表", false, false, 0, 50, 20, false);
map.AddTBString(DBListAttr.MainTablePK, null, "列表数据源主表主键", false, false, 0, 50, 20, false);
map.AddTBString(MapDataAttr.ExpCount, null, "列表总数", false, false, 0, 600, 20, true);
///#endregion 数据源.
///#region 外观.
map.AddGroupAttr("外观");
map.AddDDLSysEnum(FrmAttr.RowOpenModel, 2, "行记录打开模式", true, true, "RowOpenMode", "@0=新窗口打开@1=在本窗口打开@2=弹出窗口打开,关闭后不刷新列表@3=弹出窗口打开,关闭后刷新列表");
String cfg = "@0=MyDictFrameWork.htm 实体与实体相关功能编辑器";
cfg += "@1=MyDict.htm 实体编辑器";
cfg += "@2=MyBill.htm 单据编辑器";
cfg += "@9=自定义URL";
map.AddDDLSysEnum("SearchDictOpenType", 0, "双击行打开内容", true, true, "SearchDictOpenType", cfg);
map.AddTBString(EnCfgAttr.UrlExt, null, "要打开的Url", true, false, 0, 500, 60, true);
map.AddTBInt(FrmAttr.PopHeight, 500, "弹窗高度", true, false);
map.AddTBInt(FrmAttr.PopWidth, 760, "弹窗宽度", true, false);
map.AddDDLSysEnum(MapDataAttr.TableCol, 0, "表单显示列数", true, true, "傻瓜表单显示方式", "@0=4列@1=6列@2=上下模式3列");
map.AddDDLSysEnum(FrmAttr.EntityEditModel, 0, "编辑模式", true, true, FrmAttr.EntityEditModel, "@0=表格@1=行编辑");
map.SetHelperAlert(FrmAttr.EntityEditModel, "用什么方式打开实体列表进行编辑0=只读查询模式SearchDict.htm,1=行编辑模式SearchEditer.htm");
///#endregion 外观.
///#region 数据源实体.
map.AddDDLSysEnum(DBListAttr.EntityType, 0, "业务类型", true, false, DBListAttr.EntityType, "@0=独立表单@1=单据@2=编号名称实体@3=树结构实体");
map.SetHelperAlert(DBListAttr.EntityType, "该实体的类型,@0=单据@1=编号名称实体@2=树结构实体.");
map.AddTBString(DBListAttr.BillNoFormat, null, "实体编号规则", true, false, 0, 100, 20, true);
map.SetHelperAlert(DBListAttr.BillNoFormat, "\t\n实体编号规则: \t\n 2标识:01,02,03等, 3标识:001,002,003,等..");
map.AddTBString(FrmBillAttr.SortColumns, null, "排序字段", true, false, 0, 100, 20, true);
map.AddTBString(FrmBillAttr.ColorSet, null, "颜色设置", true, false, 0, 100, 20, true);
map.AddTBString(FrmBillAttr.FieldSet, null, "字段求和求平均设置", true, false, 0, 100, 20, true);
//字段格式化函数.
map.AddTBString("ForamtFunc", null, "字段格式化函数", true, false, 0, 200, 60, true);
String msg = "对字段的显示使用函数进行处理";
msg += "\t\n 1. 对于字段内容需要处理后在输出出来.";
msg += "\t\n 2. 比如:原字段内容 @zhangsa,张三@lisi,李四 显示的内容为 张三,李四";
msg += "\t\n 3. 配置格式: 字段名@函数名; 比如: FlowEmps@DealFlowEmps; ";
msg += "\t\n 4. 函数写入到 \\DataUser\\JSLibData\\SearchSelf.js";
map.SetHelperAlert("ForamtFunc", msg);
///#endregion 数据源实体.
//增加参数字段.
map.AddTBAtParas(4000);
///#region 基本功能.
RefMethod rm = new RefMethod();
rm = new RefMethod();
rm.Title = "步骤1: 设置数据源."; // "设计表单";
rm.ClassMethodName = this.toString() + ".DoDBSrc";
rm.Icon = "../../WF/Img/Event.png";
rm.Visable = true;
rm.refMethodType = RefMethodType.RightFrameOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "步骤2: 实体数据"; // "设计表单";
rm.ClassMethodName = this.toString() + ".DoExpEn";
rm.Icon = "../../WF/Img/Event.png";
rm.Visable = true;
rm.refMethodType = RefMethodType.RightFrameOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "步骤3: 列表数据"; // "设计表单";
rm.ClassMethodName = this.toString() + ".DoExpList";
rm.Icon = "../../WF/Img/Event.png";
rm.Visable = true;
rm.refMethodType = RefMethodType.RightFrameOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
//rm = new RefMethod();
//rm.Title = "步骤4: 总数数据"; // "设计表单";
//rm.ClassMethodName = this.ToString() + ".DoExpCount";
//rm.Icon = "../../WF/Img/Event.png";
//rm.Visable = true;
//rm.refMethodType = RefMethodType.RightFrameOpen;
//rm.Target = "_blank";
//map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "步骤4: 测试"; // "设计表单";
rm.ClassMethodName = this.toString() + ".DoDBList";
rm.Icon = "../../WF/Img/Event.png";
rm.Visable = true;
rm.refMethodType = RefMethodType.RightFrameOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "查询条件"; // "设计表单";
// rm.GroupName = "高级选项";
rm.ClassMethodName = this.toString() + ".DoSearch";
rm.Icon = "../../WF/Img/Event.png";
rm.Visable = true;
rm.refMethodType = RefMethodType.RightFrameOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "视频教程"; // "设计表单";
rm.ClassMethodName = this.toString() + ".DoVideo";
rm.Visable = true;
rm.refMethodType = RefMethodType.LinkeWinOpen;
rm.Target = "_blank";
map.AddRefMethod(rm);
///#endregion 基本功能.
this.set_enMap(map);
return this.get_enMap();
}
///#endregion
public final String DoVideo() {
return "https://www.bilibili.com/video/BV15P4y1p7Sj";
}
public final String DoDBSrc() {
return "../../Comm/RefFunc/EnOnly.htm?EnName=BP.CCBill.DBListDBSrc&No=" + this.getNo();
}
public final String DoExpEn() {
return "../../CCBill/Admin/DBList/FieldsORM.htm?s=34&FrmID=" + this.getNo() + "&ExtType=PageLoadFull&RefNo=ss3";
}
public final String DoExpList() {
return "../../CCBill/Admin/DBList/ListDBSrc.htm?s=34&FrmID=" + this.getNo() + "&ExtType=PageLoadFull&RefNo=ss3";
}
public final String DoExpCount() {
return "../../CCBill/Admin/DBList/ListDBCount.htm?s=34&FrmID=" + this.getNo() + "&ExtType=PageLoadFull&RefNo=ss3";
}
public final String DoDBList() {
return "../../CCBill/SearchDBList.htm?FrmID=" + this.getNo();
}
public final String DoSearch() {
return "../../CCBill/Admin/Collection/SearchCond.htm?s=34&FrmID=" + this.getNo() + "&ExtType=PageLoadFull&RefNo=ss3";
}
@Override
protected void afterInsertUpdateAction() throws Exception {
super.afterInsertUpdateAction();
}
/**
检查enittyNoName类型的实体
*/
public final void CheckEnityTypeAttrsFor_EntityNoName() throws Exception {
//取出来全部的属性.
MapAttrs attrs = new MapAttrs(this.getNo());
///#region 补充上流程字段到 NDxxxRpt.
if (attrs.contains(this.getNo() + "_" + GERptAttr.OID) == false)
{
/* WorkID */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setKeyOfEn("OID");
attr.setName("主键ID");
attr.setMyDataType(DataType.AppInt);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setDefVal( "0");
attr.setEditType(EditType.Readonly);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_" + GERptAttr.BillNo) == false)
{
/* 单据编号 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn(GERptAttr.BillNo);
attr.setName("编号"); // 单据编号
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(true);
attr.setUIIsEnable(false);
attr.setUIIsLine(false);
attr.setMinLen(0);
attr.setMaxLen(100);
attr.setIdx( -100);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_" + GERptAttr.Title) == false)
{
/* 名称 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn(GERptAttr.Title); // "FlowEmps";
attr.setName("名称"); // 单据模式, ccform的模式.
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(true);
attr.setUIIsEnable(true);
attr.setUIIsLine(true);
attr.setMinLen(0);
attr.setMaxLen(400);
attr.setIdx( -90);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_BillState") == false)
{
/* 单据状态 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("BillState"); // "FlowEmps";
attr.setName("单据状态");
attr.setMyDataType(DataType.AppInt);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setUIIsLine(true);
attr.setMinLen(0);
attr.setMaxLen(10);
attr.setIdx( -98);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_Starter") == false)
{
/* 发起人 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("Starter");
attr.setName("创建人");
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setMinLen(0);
attr.setMaxLen(32);
attr.setIdx( -1);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_StarterName") == false)
{
/* 创建人名称 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("StarterName");
attr.setName("创建人名称");
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setMinLen(0);
attr.setMaxLen(32);
attr.setIdx( -1);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_" + GERptAttr.AtPara) == false)
{
/* 参数 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn(GERptAttr.AtPara);
attr.setName("参数"); // 单据编号
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setUIIsLine(false);
attr.setMinLen(0);
attr.setMaxLen(4000);
attr.setIdx( -99);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_RDT") == false)
{
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("RDT");
attr.setName("创建时间");
attr.setMyDataType(DataType.AppDateTime);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setUIIsLine(false);
attr.setIdx( -97);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_FK_Dept") == false)
{
/* 创建人部门 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("FK_Dept");
attr.setName("创建人部门");
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setMinLen(0);
attr.setMaxLen(100);
attr.setIdx( -1);
attr.Insert();
}
if (attrs.contains(this.getNo() + "_OrgNo") == false)
{
/* 创建人名称 */
MapAttr attr = new MapAttr();
attr.setFK_MapData(this.getNo());
attr.setHisEditType( EditType.UnDel);
attr.setKeyOfEn("OrgNo");
attr.setName("创建人所在的组织");
attr.setMyDataType(DataType.AppString);
attr.setUIContralType(UIContralType.TB);
attr.setLGType(FieldTypeS.Normal);
attr.setUIVisible(false);
attr.setUIIsEnable(false);
attr.setMinLen(0);
attr.setMaxLen(32);
attr.setIdx( -1);
attr.Insert();
}
///#endregion 补充上流程字段。
}
}
3.DBListAttr
package bp.ccbill;
/**
数据源实体 - Attr
*/
public class DBListAttr extends FrmAttr
{
public static final String MainTable = "MainTable";
public static final String MainTablePK = "MainTablePK";
}
4.DBListDBSrc
package bp.ccbill;
import bp.en.*;
import bp.sys.*;
/**
数据源实体
*/
public class DBListDBSrc extends EntityNoName
{
///#region 权限控制.
@Override
public UAC getHisUAC() {
UAC uac = new UAC();
uac.OpenForAppAdmin();
uac.IsDelete = false;
uac.IsInsert = false;
return uac;
}
/**
数据源实体
*/
public DBListDBSrc() {
}
/**
数据源实体
param no 映射编号
*/
public DBListDBSrc(String no) throws Exception {
super(no);
}
public final int getDBType()
{
return this.GetValIntByKey(MapDataAttr.DBType);
}
/**
EnMap
*/
@Override
public bp.en.Map getEnMap() {
if (this.get_enMap() != null)
{
return this.get_enMap();
}
Map map = new Map("Sys_MapData", "数据源实体");
map.setCodeStruct("4");
///#region 基本属性.
map.AddTBStringPK(MapDataAttr.No, null, "表单编号", true, true, 1, 190, 20);
///#endregion 基本属性.
///#region 数据源.
map.AddDDLSysEnum(MapDataAttr.DBType, 0, "数据源类型", true, true, "DBListDBType", "@0=数据库查询SQL@1=执行Url返回Json@2=执行存储过程");
map.AddDDLEntities(MapDataAttr.DBSrc, null, "数据源", new SFDBSrcs(), true);
map.SetHelperAlert(MapDataAttr.DBSrc, "您可以在系统管理中新建SQL数据源.");
///#endregion 数据源.
this.set_enMap(map);
return this.get_enMap();
}
///#endregion
@Override
protected boolean beforeUpdate() throws Exception {
DBList db = new DBList(this.getNo());
if (db.getDBType() != this.getDBType())
{
db.setExpEn("");
db.setExpList("");
db.setExpCount("");
db.Update();
}
return super.beforeUpdate();
}
}
5.DBListDBSrcs
package bp.ccbill;
import bp.en.*;
import java.util.*;
/**
数据源实体s
*/
public class DBListDBSrcs extends EntitiesNoName
{
///#region 构造
/**
数据源实体s
*/
public DBListDBSrcs() throws Exception {
}
/**
得到它的 Entity
*/
@Override
public Entity getGetNewEntity() {
return new DBListDBSrc();
}
///#endregion
///#region 为了适应自动翻译成java的需要,把实体转换成List.
/**
转化成 java list,C#不能调用.
@return List
*/
public final java.util.List<DBListDBSrc> ToJavaList() {
return (java.util.List<DBListDBSrc>)(Object)this;
}
/**
转化成list
@return List
*/
public final ArrayList<DBListDBSrc> Tolist() {
ArrayList<DBListDBSrc> list = new ArrayList<DBListDBSrc>();
for (int i = 0; i < this.size(); i++)
{
list.add((DBListDBSrc)this.get(i));
}
return list;
}
///#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
DBLists
```java
package bp.ccbill;
import bp.tools.DateUtils;
import bp.tools.StringHelper;
import bp.wf.*;
import bp.en.*;
import bp.da.*;
import bp.web.*;
import bp.sys.*;
import bp.*;
import java.util.*;
import java.time.*;
import java.util.Map;
/**
接口调用
*/
public class Dev2Interface
{
/**
增加日志
param at
param frmID
param at
param msg
@return
*/
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras, String flowNo, String flowName, int nodeID, long workIDOfFlow) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, paras, flowNo, flowName, nodeID, workIDOfFlow, "");
}
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras, String flowNo, String flowName, int nodeID) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, paras, flowNo, flowName, nodeID, 0, "");
}
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras, String flowNo, String flowName) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, paras, flowNo, flowName, 0, 0, "");
}
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras, String flowNo) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, paras, flowNo, null, 0, 0, "");
}
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, paras, null, null, 0, 0, "");
}
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg) throws Exception {
Dict_AddTrack(frmID, frmWorkID, at, msg, null, null, null, 0, 0, "");
}
//ORIGINAL LINE: public static void Dict_AddTrack(string frmID, string frmWorkID, string at, string msg, string paras = null, string flowNo = null, string flowName = null, int nodeID = 0, Int64 workIDOfFlow = 0, string frmName = "")
public static void Dict_AddTrack(String frmID, String frmWorkID, String at, String msg, String paras, String flowNo, String flowName, int nodeID, long workIDOfFlow, String frmName) throws Exception {
bp.ccbill.Track tk = new bp.ccbill.Track();
tk.setWorkID(frmWorkID);
tk.setFrmID(frmID);
tk.setFrmName(frmName);
tk.setActionType(at);
switch (at)
{
case FrmActionType.BBS:
tk.setActionTypeText("评论");
break;
case FrmActionType.Create:
tk.setActionTypeText("创建");
break;
case FrmActionType.DataVerReback:
tk.setActionTypeText("数据版本");
break;
case FrmActionType.Save:
tk.setActionTypeText("保存");
break;
case FrmActionType.StartFlow:
tk.setActionTypeText("发起流程");
break;
default:
tk.setActionTypeText("其他");
break;
}
tk.setRec(WebUser.getNo());
tk.setRecName(WebUser.getName());
tk.setDeptNo(WebUser.getFK_Dept());
tk.setDeptName(WebUser.getFK_DeptName());
// 流程信息。
tk.setWorkIDOfFlow(workIDOfFlow);
tk.setNodeID(nodeID);
if (flowName != null)
{
tk.setFlowName(flowName);
}
if (flowNo != null)
{
tk.setFlowNo(flowNo);
}
//tk.setMyPK(tk.FrmID + "_" + tk.WorkID + "_" + tk.Rec + "_" + (int)BP.CCBill.FrmActionType.BBS;
tk.setMsg(msg);
tk.setRDT(DataType.getCurrentDataTime());
流程信息.
//tk.NodeID = nodeID;
//tk.NodeName = nodeName;
//tk.FlowNo = flowNo;
//tk.FlowName = flowName;
//tk.FID = fid;
tk.Insert();
}
/**
创建单据的WorkID
param frmID
param userNo
param htParas
param pDictFrmID
@return
*/
public static long CreateBlankBillID(String frmID, String userNo, java.util.Hashtable htParas, String pDictFrmID) throws Exception {
return CreateBlankBillID(frmID, userNo, htParas, pDictFrmID, 0);
}
public static long CreateBlankBillID(String frmID, String userNo, java.util.Hashtable htParas) throws Exception {
return CreateBlankBillID(frmID, userNo, htParas, null, 0);
}
public static long CreateBlankBillID(String frmID, String userNo) throws Exception {
return CreateBlankBillID(frmID, userNo, null, null, 0);
}
public static long CreateBlankBillID(String frmID) throws Exception {
return CreateBlankBillID(frmID, null, null, null, 0);
}
//ORIGINAL LINE: public static Int64 CreateBlankBillID(string frmID, string userNo = null, Hashtable htParas = null, string pDictFrmID = null, Int64 pDictWorkID = 0)
public static long CreateBlankBillID(String frmID, String userNo, Hashtable htParas, String pDictFrmID, long pDictWorkID) throws Exception {
if (userNo == null)
{
userNo = WebUser.getNo();
}
GenerBill gb = new GenerBill();
int i = gb.Retrieve(GenerBillAttr.FrmID, frmID, GenerBillAttr.Starter, userNo, GenerBillAttr.BillState, 0);
if (i == 1)
{
GERpt rpt1 = new GERpt(frmID);
rpt1.setOID(gb.getWorkID());
int count = rpt1.RetrieveFromDBSources();
if (htParas != null)
{
rpt1.Copy(htParas);
}
rpt1.SetValByKey("BillState", 0);
rpt1.SetValByKey("Starter", gb.getStarter());
rpt1.SetValByKey("StarterName", gb.getStarterName());
rpt1.SetValByKey("FK_Dept", WebUser.getFK_Dept());
rpt1.SetValByKey("RDT", gb.getRDT());
rpt1.SetValByKey("Title", gb.getTitle());
rpt1.SetValByKey("BillNo", gb.getBillNo());
if (pDictFrmID != null)
{
rpt1.SetValByKey("PWorkID", pDictWorkID);
rpt1.SetValByKey("PFrmID", pDictFrmID);
}
if (count == 0)
{
rpt1.InsertAsOID(gb.getWorkID());
}
else
{
rpt1.Update();
}
return gb.getWorkID();
}
FrmBill fb = new FrmBill(frmID);
gb.setWorkID(DBAccess.GenerOID("WorkID"));
gb.setBillState(BillState.None); //初始化状态.
gb.setStarter(WebUser.getNo());
gb.setStarterName(WebUser.getName());
gb.setFrmName(fb.getName()); //单据名称.
gb.setFrmID(fb.getNo()); //单据ID
//if (DataType.IsNullOrEmpty(billNo) == false)
// gb.BillNo = billNo; //BillNo
gb.setFK_Dept(WebUser.getFK_Dept());
gb.setDeptName(WebUser.getFK_DeptName());
gb.setFKFrmTree(fb.getFKFormTree()); //单据类别.
gb.setRDT(DataType.getCurrentDataTime());
gb.setNDStep(1);
gb.setNDStepName("启动");
//父字典信息.
if (pDictFrmID != null)
{
gb.setPFrmID(pDictFrmID);
gb.setPWorkID(pDictWorkID);
}
//创建rpt.
GERpt rpt = new GERpt(frmID);
//设置标题.
if (fb.getEntityType() == EntityType.FrmBill)
{
gb.setTitle(Dev2Interface.GenerTitle(fb.getTitleRole(), rpt));
//if (DataType.IsNullOrEmpty(billNo) == false)
// gb.BillNo = billNo;
//else
gb.setBillNo(bp.ccbill.Dev2Interface.GenerBillNo(fb.getBillNoFormat(), gb.getWorkID(), null, frmID));
}
if (fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict)
{
rpt.getEnMap().setCodeStruct(fb.getEnMap().getCodeStruct());
//if (DataType.IsNullOrEmpty(billNo) == false)
// gb.BillNo = billNo;
//else
gb.setBillNo(rpt.GenerNewNoByKey("BillNo", null));
// BP.CCBill.Dev2Interface.GenerBillNo(fb.BillNoFormat, gb.WorkID, null, frmID);
gb.setTitle("");
}
gb.DirectInsert(); //执行插入.
//如果.
if (htParas != null)
{
rpt.Copy(htParas);
}
//更新基础的数据到表单表.
// rpt = new BP.WF.GERpt(frmID);
rpt.SetValByKey("BillState", gb.getBillState().getValue());
rpt.SetValByKey("Starter", gb.getStarter());
rpt.SetValByKey("StarterName", gb.getStarterName());
rpt.SetValByKey("FK_Dept", WebUser.getFK_Dept());
rpt.SetValByKey("RDT", gb.getRDT());
rpt.SetValByKey("Title", gb.getTitle());
rpt.SetValByKey("BillNo", gb.getBillNo());
if (pDictFrmID != null)
{
rpt.SetValByKey("PWorkID", pDictWorkID);
rpt.SetValByKey("PFrmID", pDictFrmID);
}
rpt.setOID(gb.getWorkID());
rpt.InsertAsOID(gb.getWorkID());
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(rpt.getOID()), FrmActionType.Create, "创建记录");
return gb.getWorkID();
}
/**
创建一个实体ID
param frmID 实体ID
param userNo 用户编号
param htParas 参数
@return 一个实例的workid
*/
public static long CreateBlankDictID(String frmID, String userNo, Hashtable htParas) throws Exception {
if (userNo == null)
{
userNo = WebUser.getNo();
}
// 创建一个实体, 先检查一下是否有空白的数据.
GERpt rpt = new GERpt(frmID);
int i = rpt.Retrieve("Starter", userNo, "BillState", 0);
if (i >= 1)
{
if (htParas != null)
{
rpt.Copy(htParas);
}
rpt.SetValByKey("RDT", DataType.getCurrentDate());
rpt.Update();
return rpt.getOID(); //如果有空白的数据,就返回给他.
}
//执行copy数据.
if (htParas != null)
{
rpt.Copy(htParas);
}
FrmBill fb = new FrmBill(frmID);
//更新基础的数据到表单表.
rpt.SetValByKey("BillState", 0);
rpt.SetValByKey("Starter", WebUser.getNo());
rpt.SetValByKey("StarterName", WebUser.getName());
rpt.SetValByKey("FK_Dept", WebUser.getFK_Dept());
rpt.SetValByKey("RDT", DataType.getCurrentDate());
//设置编号生成规则.
rpt.getEnMap().setCodeStruct(fb.getBillNoFormat());
//rpt.SetValByKey("Title", gb.Title);
rpt.SetValByKey("BillNo", rpt.GenerNewNoByKey("BillNo", null));
rpt.setOID(DBAccess.GenerOID("WorkID"));
rpt.InsertAsOID(rpt.getOID());
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(rpt.getOID()), FrmActionType.Create, "创建记录");
return rpt.getOID();
}
/**
保存实体数据
param frmID 表单ID
param workid 工作ID
param htParas 参数数据
@return
*/
public static void SaveDictWork(String frmID, long workid, Hashtable htParas) throws Exception {
// 创建一个实体, 先检查一下是否有空白的数据.
GERpt rpt = new GERpt(frmID);
rpt.setOID(workid);
if (rpt.RetrieveFromDBSources() == 0)
{
if (htParas != null)
{
rpt.Copy(htParas);
}
//设置编号生成规则.
FrmBill fb = new FrmBill(frmID);
rpt.getEnMap().setCodeStruct(fb.getBillNoFormat());
rpt.SetValByKey("BillNo", rpt.GenerNewNoByKey("BillNo", null));
rpt.InsertAsOID(workid);
}
else
{
//执行copy数据.
if (htParas != null)
{
rpt.Copy(htParas);
}
}
//更新基础的数据到表单表.
rpt.SetValByKey("BillState", 100);
rpt.SetValByKey("Starter", WebUser.getNo());
rpt.SetValByKey("StarterName", WebUser.getName());
rpt.SetValByKey("FK_Dept", WebUser.getFK_Dept());
rpt.SetValByKey("RDT", DataType.getCurrentDate());
rpt.Update();
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(workid), FrmActionType.Save, "执行保存");
}
/**
保存
param frmID 表单ID
param workID 工作ID
@return 返回保存结果
*/
public static String SaveBillWork(String frmID, long workID) throws Exception {
FrmBill fb = new FrmBill(frmID);
GenerBill gb = new GenerBill();
gb.setWorkID(workID);
int i = gb.RetrieveFromDBSources();
if (i == 0)
{
return "";
}
gb.setBillState(BillState.Editing);
//创建rpt.
GERpt rpt = new GERpt(gb.getFrmID(), workID);
if (fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict)
{
gb.setTitle(rpt.getTitle());
gb.Update();
return "保存成功...";
}
//单据编号.
if (DataType.IsNullOrEmpty(gb.getBillNo()) == true && !(fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict))
{
gb.setBillNo(bp.ccbill.Dev2Interface.GenerBillNo(fb.getBillNoFormat(), workID, null, fb.getPTable()));
//更新单据里面的billNo字段.
if (DBAccess.IsExitsTableCol(fb.getPTable(), "BillNo") == true)
{
DBAccess.RunSQL("UPDATE " + fb.getPTable() + " SET BillNo='" + gb.getBillNo() + "' WHERE OID=" + workID);
}
}
//标题.
if (DataType.IsNullOrEmpty(gb.getTitle()) == true && !(fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict))
{
gb.setTitle(Dev2Interface.GenerTitle(fb.getTitleRole(), rpt));
//更新单据里面的 Title 字段.
if (DBAccess.IsExitsTableCol(fb.getPTable(), "Title") == true)
{
DBAccess.RunSQL("UPDATE " + fb.getPTable() + " SET Title='" + gb.getTitle() + "' WHERE OID=" + workID);
}
}
gb.Update();
//把通用的字段更新到数据库.
rpt.setTitle(gb.getTitle());
rpt.setBillNo(gb.getBillNo());
rpt.Update();
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(rpt.getOID()), FrmActionType.Save, "保存");
return "保存成功...";
}
/**
提交
param frmID 表单ID
param workID 工作ID
@return 返回保存结果
*/
public static String SubmitWork(String frmID, long workID) throws Exception {
FrmBill fb = new FrmBill(frmID);
GenerBill gb = new GenerBill();
gb.setWorkID(workID);
int i = gb.RetrieveFromDBSources();
if (i == 0)
{
return "";
}
//设置为归档状态.
gb.setBillState(BillState.Over);
//创建rpt.
GERpt rpt = new GERpt(gb.getFrmID(), workID);
if (fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict)
{
gb.setTitle(rpt.getTitle());
gb.Update();
return "提交成功...";
}
//单据编号.
if (DataType.IsNullOrEmpty(gb.getBillNo()) == true && !(fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict))
{
gb.setBillNo(bp.ccbill.Dev2Interface.GenerBillNo(fb.getBillNoFormat(), workID, null, fb.getPTable()));
//更新单据里面的billNo字段.
if (DBAccess.IsExitsTableCol(fb.getPTable(), "BillNo") == true)
{
DBAccess.RunSQL("UPDATE " + fb.getPTable() + " SET BillNo='" + gb.getBillNo() + "' WHERE OID=" + workID);
}
}
//标题.
if (DataType.IsNullOrEmpty(gb.getTitle()) == true && !(fb.getEntityType() == EntityType.EntityTree || fb.getEntityType() == EntityType.FrmDict))
{
gb.setTitle(Dev2Interface.GenerTitle(fb.getTitleRole(), rpt));
//更新单据里面的 Title 字段.
if (DBAccess.IsExitsTableCol(fb.getPTable(), "Title") == true)
{
DBAccess.RunSQL("UPDATE " + fb.getPTable() + " SET Title='" + gb.getTitle() + "' WHERE OID=" + workID);
}
}
gb.Update();
//把通用的字段更新到数据库.
rpt.setTitle(gb.getTitle());
rpt.setBillNo(gb.getBillNo());
rpt.Update();
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(workID), FrmActionType.Submit, "执行提交.");
return "提交成功...";
}
/**
保存
param frmID 表单ID
param workID 工作ID
@return 返回保存结果
*/
public static String SaveAsDraft(String frmID, long workID) throws Exception {
GenerBill gb = new GenerBill(workID);
if (gb.getBillState() != BillState.None)
{
return "err@只有在None的模式下才能保存草稿。";
}
if (gb.getBillState() != BillState.Editing)
{
gb.setBillState(BillState.Editing);
gb.Update();
}
return "保存成功...";
}
/**
删除单据
param frmID
param workID
@return
*/
public static String MyBill_Delete(String frmID, long workID) throws Exception {
FrmBill fb = new FrmBill(frmID);
String sqls = "DELETE FROM Frm_GenerBill WHERE WorkID=" + workID;
sqls += "@DELETE FROM " + fb.getPTable() + " WHERE OID=" + workID;
DBAccess.RunSQLs(sqls);
return "删除成功.";
}
public static String MyBill_DeleteBills(String frmID, String workIds) throws Exception {
FrmBill fb = new FrmBill(frmID);
String sqls = "DELETE FROM Frm_GenerBill WHERE WorkID in (" + workIds + ")";
sqls += "@DELETE FROM " + fb.getPTable() + " WHERE OID in (" + workIds + ")";
DBAccess.RunSQLs(sqls);
return "删除成功.";
}
/**
删除实体
param frmID
param workID
@return
*/
public static String MyDict_Delete(String frmID, long workID) throws Exception {
FrmBill fb = new FrmBill(frmID);
String sql = "@DELETE FROM " + fb.getPTable() + " WHERE OID=" + workID;
DBAccess.RunSQLs(sql);
return "删除成功.";
}
/**
删除实体单据
param frmID
param workIds
@return
*/
public static String MyDict_DeleteDicts(String frmID, String workIds) throws Exception {
FrmBill fb = new FrmBill(frmID);
String sql = "DELETE FROM " + fb.getPTable() + " WHERE OID in (" + workIds + ")";
DBAccess.RunSQLs(sql);
return "删除成功.";
}
/**
删除树形结构的实体表单
param frmID
param billNo
@return
*/
public static String MyEntityTree_Delete(String frmID, String billNo) throws Exception {
FrmBill fb = new FrmBill(frmID);
String sql = "DELETE FROM " + fb.getPTable() + " WHERE BillNo='" + billNo + "' OR ParentNo='" + billNo + "'";
DBAccess.RunSQLs(sql);
return "删除成功.";
}
/**
复制单据数据
param frmID
param workID
@return
*/
public static String MyBill_Copy(String frmID, long workID) throws Exception {
//获取单据的属性
FrmBill fb = new FrmBill(frmID);
GenerBill gb = new GenerBill();
gb.setWorkID(DBAccess.GenerOID("WorkID"));
gb.setBillState(BillState.Editing); //初始化状态.
gb.setStarter(WebUser.getNo());
gb.setStarterName(WebUser.getName());
gb.setFrmName(fb.getName()); //单据名称.
gb.setFrmID(fb.getNo()); //单据ID
gb.setFKFrmTree(fb.getFKFormTree()); //单据类别.
gb.setRDT(DataType.getCurrentDateTime());
gb.setNDStep(1);
gb.setNDStepName("启动");
//创建rpt.
GERpt rpt = new GERpt(frmID, workID);
//设置标题.
gb.setTitle(Dev2Interface.GenerTitle(fb.getTitleRole(), rpt));
gb.setBillNo(bp.ccbill.Dev2Interface.GenerBillNo(fb.getBillNoFormat(), gb.getWorkID(), null, frmID));
gb.DirectInsert(); //执行插入.
//更新基础的数据到表单表.
rpt.SetValByKey("BillState", gb.getBillState().getValue());
rpt.SetValByKey("Starter", gb.getStarter());
rpt.SetValByKey("StarterName", gb.getStarterName());
rpt.SetValByKey("RDT", gb.getRDT());
rpt.SetValByKey("Title", gb.getTitle());
rpt.SetValByKey("BillNo", gb.getBillNo());
rpt.setOID(gb.getWorkID());
rpt.InsertAsOID(gb.getWorkID());
///#region 复制其他数据.
//复制明细。
MapDtls dtls = new MapDtls(frmID);
if (!dtls.isEmpty())
{
for (MapDtl dtl : dtls.ToJavaList())
{
if (dtl.getIsCopyNDData() == false)
{
continue;
}
//new 一个实例.
GEDtl dtlData = new GEDtl(dtl.getNo());
GEDtls dtlsFromData = new GEDtls(dtl.getNo());
dtlsFromData.Retrieve(GEDtlAttr.RefPK, workID, null);
for (GEDtl geDtlFromData : dtlsFromData.ToJavaList())
{
//是否启用多附件
FrmAttachmentDBs dbs = null;
if (dtl.getIsEnableAthM() == true)
{
//根据从表的OID 获取附件信息
dbs = new FrmAttachmentDBs();
dbs.Retrieve(FrmAttachmentDBAttr.RefPKVal, geDtlFromData.getOID(), null);
}
dtlData.Copy(geDtlFromData);
dtlData.setRefPK(String.valueOf(rpt.getOID()));
dtlData.InsertAsNew();
if (dbs != null && !dbs.isEmpty())
{
//复制附件信息
FrmAttachmentDB newDB = new FrmAttachmentDB();
for (FrmAttachmentDB db : dbs.ToJavaList())
{
newDB.Copy(db);
newDB.setRefPKVal(String.valueOf(dtlData.getOID()));
newDB.setFID(dtlData.getOID());
newDB.setMyPK(DBAccess.GenerGUID(0, null, null));
newDB.Insert();
}
}
}
}
}
//获取附件组件、
FrmAttachments athDecs = new FrmAttachments(frmID);
//复制附件数据。
if (!athDecs.isEmpty())
{
for (FrmAttachment athDec : athDecs.ToJavaList())
{
FrmAttachmentDBs aths = new FrmAttachmentDBs();
aths.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, athDec.getMyPK(), FrmAttachmentDBAttr.RefPKVal, workID, null);
for (FrmAttachmentDB athDB : aths.ToJavaList())
{
FrmAttachmentDB athDB_N = new FrmAttachmentDB();
athDB_N.Copy(athDB);
athDB_N.setRefPKVal ( String.valueOf(rpt.getOID()));
athDB_N.setMyPK(DBAccess.GenerGUID(0, null, null));
athDB_N.Insert();
}
}
}
///#endregion 复制表单其他数据.
bp.ccbill.Dev2Interface.Dict_AddTrack(frmID, String.valueOf(workID), "复制", "执行复制");
return "复制成功.";
}
/**
获得发起列表
param empID
@return
*/
public static DataSet DB_StartBills(String empID) throws Exception {
//定义容器.
DataSet ds = new DataSet();
//单据类别.
FrmTrees ens = new FrmTrees();
ens.RetrieveAll();
DataTable dtSort = ens.ToDataTableField("Sort");
dtSort.TableName = "Sort";
ds.Tables.add(dtSort);
//查询出来单据运行模式的.
FrmBills bills = new FrmBills();
bills.RetrieveAll();
//bills.Retrieve(FrmBillAttr.EntityType, 0); //实体类型.
DataTable dtStart = bills.ToDataTableField("dt");
dtStart.TableName = "Start";
ds.Tables.add(dtStart);
return ds;
}
/**
获得待办列表
param empID
@return
*/
public static DataTable DB_Todolist(String empID)
{
return new DataTable();
}
/**
草稿列表
param frmID 单据ID
param empID 操作员
@return
*/
public static DataTable DB_Draft(String frmID, String empID) throws Exception {
if (DataType.IsNullOrEmpty(empID) == true)
{
empID = WebUser.getNo();
}
GenerBills bills = new GenerBills();
bills.Retrieve(GenerBillAttr.FrmID, frmID, GenerBillAttr.Starter, empID, null);
return bills.ToDataTableField("dt");
}
public static String GenerTitle(String titleRole, Entity wk)
{
if (DataType.IsNullOrEmpty(titleRole))
{
// 为了保持与ccflow4.5的兼容,从开始节点属性里获取.
Attr myattr = wk.getEnMap().getAttrs().GetAttrByKey("Title");
if (myattr == null)
{
myattr = wk.getEnMap().getAttrs().GetAttrByKey("Title");
}
if (myattr != null)
{
titleRole = myattr.getDefaultVal().toString();
}
if (DataType.IsNullOrEmpty(titleRole) || titleRole.contains("@") == false)
{
titleRole = "@WebUser.FK_DeptName-@WebUser.No,@WebUser.Name在@RDT发起.";
}
}
if (titleRole.equals("@OutPara") || DataType.IsNullOrEmpty(titleRole) == true)
{
titleRole = "@WebUser.FK_DeptName-@WebUser.No,@WebUser.Name在@RDT发起.";
}
titleRole = titleRole.replace("@WebUser.No", WebUser.getNo());
titleRole = titleRole.replace("@WebUser.Name", WebUser.getName());
titleRole = titleRole.replace("@WebUser.FK_DeptNameOfFull", WebUser.getFK_DeptNameOfFull());
titleRole = titleRole.replace("@WebUser.FK_DeptName", WebUser.getFK_DeptName());
titleRole = titleRole.replace("@WebUser.FK_Dept", WebUser.getFK_Dept());
titleRole = titleRole.replace("@RDT", DataType.getCurrentDateByFormart("yy年MM月dd日HH时mm分"));
if (titleRole.contains("@"))
{
Attrs attrs = wk.getEnMap().getAttrs();
// 优先考虑外键的替换,因为外键文本的字段的长度相对较长。
for (Attr attr : attrs.ToJavaList())
{
if (titleRole.contains("@") == false)
{
break;
}
if (attr.getIsRefAttr() == false)
{
continue;
}
titleRole = titleRole.replace("@" + attr.getKey(), wk.GetValStrByKey(attr.getKey()));
}
//在考虑其它的字段替换.
for (Attr attr : attrs.ToJavaList())
{
if (titleRole.contains("@") == false)
{
break;
}
if (attr.getIsRefAttr() == true)
{
continue;
}
titleRole = titleRole.replace("@" + attr.getKey(), wk.GetValStrByKey(attr.getKey()));
}
}
titleRole = titleRole.replace('~', '-');
titleRole = titleRole.replace("'", "”");
// 为当前的工作设置title.
wk.SetValByKey("Title", titleRole);
return titleRole;
}
/**
生成单据编号
param billNo 单据编号规则
param workid 工作ID
param en 实体类
param frmID 表单ID
@return 生成的单据编号
*/
public static String GenerBillNo(String billNo, long workid, Entity en, String frmID) throws Exception {
if (DataType.IsNullOrEmpty(billNo))
{
billNo = "3";
}
if (billNo.contains("@"))
{
billNo = bp.wf.Glo.DealExp(billNo, en, null);
}
/*如果,Bill 有规则 */
billNo = billNo.replace("{YYYY}", DataType.getCurrentDateByFormart("yyyy"));
billNo = billNo.replace("{yyyy}", DataType.getCurrentDateByFormart("yyyy"));
billNo = billNo.replace("{yy}", DataType.getCurrentDateByFormart("yy"));
billNo = billNo.replace("{YY}", DataType.getCurrentDateByFormart("yy"));
billNo = billNo.replace("{MM}", DataType.getCurrentDateByFormart("MM"));
billNo = billNo.replace("{mm}", DataType.getCurrentDateByFormart("MM"));
billNo = billNo.replace("{DD}", DateUtils.format(new Date(), "dd"));
billNo = billNo.replace("{dd}", DateUtils.format(new Date(), "dd"));
billNo = billNo.replace("{HH}", DateUtils.format(new Date(),"HH"));
billNo = billNo.replace("{hh}", DateUtils.format(new Date(),"HH"));
billNo = billNo.replace("{LSH}", String.valueOf(workid));
billNo = billNo.replace("{WorkID}", String.valueOf(workid));
billNo = billNo.replace("{OID}", String.valueOf(workid));
if (billNo.contains("@WebUser.DeptZi"))
{
String val = DBAccess.RunSQLReturnStringIsNull("SELECT Zi FROM Port_Dept WHERE No='" + WebUser.getFK_Dept() + "'", "");
billNo = billNo.replace("@WebUser.DeptZi", val.toString());
}
String sql = "";
int num = 0;
String supposeBillNo = billNo; //假设单据号,长度与真实单据号一致
ArrayList<java.util.Map.Entry<Integer, Integer>> loc = new java.util.ArrayList<java.util.Map.Entry<Integer, Integer>>(); //流水号位置,流水号位数
String lsh; //流水号设置码
int lshIdx = -1; //流水号设置码所在位置
java.util.Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 2; i < 9; i++)
{
lsh = "{LSH" + i + "}";
if (!supposeBillNo.contains(lsh))
{
continue;
}
while (supposeBillNo.contains(lsh))
{
//查找流水号所在位置
lshIdx = supposeBillNo.indexOf(lsh);
//将找到的流水号码替换成假设的流水号
supposeBillNo = (lshIdx == 0 ? "" : supposeBillNo.substring(0, lshIdx)) + StringHelper.padLeft("", i, '_') + (lshIdx + 6 < supposeBillNo.length() ? supposeBillNo.substring(lshIdx + 6) : "");
//保存当前流程号所处位置,及流程号长度,以便之后使用替换成正确的流水号
map.put(lshIdx, i);
}
}
Iterator<Map.Entry<Integer, Integer>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, Integer> entry = iterator.next();
loc.add(entry);
}
//数据库中查找符合的单据号集合,NOTE:此处需要注意,在LIKE中带有左广方括号时,要使用一对广播号将其转义
sql = "SELECT BillNo FROM Frm_GenerBill WHERE BillNo LIKE '" + supposeBillNo.replace("[", "[[]") + "'" + " AND WorkID <> " + workid + " AND FrmID ='" + frmID + "' " + " ORDER BY BillNo DESC ";
String maxBillNo = DBAccess.RunSQLReturnString(sql);
int ilsh = 0;
if (DataType.IsNullOrEmpty(maxBillNo))
{
//没有数据,则所有流水号都从1开始
for (java.util.Map.Entry<Integer, Integer> kv : loc)
{
supposeBillNo = (kv.getKey() == 0 ? "" : supposeBillNo.substring(0, kv.getKey())) + StringHelper.padLeft("1", kv.getValue(), '0') + (kv.getKey() + kv.getValue() < supposeBillNo.length() ? supposeBillNo.substring(kv.getKey() + kv.getValue()) : "");
}
}
else
{
//有数据,则从右向左开始判断流水号,当右侧的流水号达到最大值,则左侧的流水号自动加1
HashMap<Integer, Integer> mlsh = new HashMap<Integer, Integer>();
int plus1idx = -1;
for (int i = loc.size() - 1; i >= 0; i--)
{
//获取单据号中当前位的流水码数
ilsh = Integer.parseInt(StringHelper.substring(maxBillNo, loc.get(i).getKey(), loc.get(i).getValue()));
if (plus1idx >= 0)
{
//如果当前码位被置为+1,则+1,同时将标识置为-1
ilsh++;
plus1idx = -1;
}
else
{
mlsh.put(loc.get(i).getKey(), i == loc.size() - 1 ? ilsh + 1 : ilsh);
continue;
}
if (ilsh >= Integer.parseInt(StringHelper.padLeft("", loc.get(i).getValue(), '9')))
{
//右侧已经达到最大值
if (i > 0)
{
//记录前位的码
mlsh.put(loc.get(i).getKey(), 1);
}
else
{
supposeBillNo = "单据号超出范围";
break;
}
//则将前一个流水码位,标记为+1
plus1idx = i - 1;
}
else
{
mlsh.put(loc.get(i).getKey(), ilsh + 1);
}
}
if (supposeBillNo.equals("单据号超出范围"))
{
return supposeBillNo;
}
//拼接单据号
for (Map.Entry<Integer, Integer> kv : loc)
{
supposeBillNo = (kv.getKey() == 0 ? "" : supposeBillNo.substring(0, kv.getKey())) + StringHelper.padLeft(mlsh.get(kv.getKey()).toString(), kv.getValue(), '0') + (kv.getKey() + kv.getValue() < supposeBillNo.length() ? supposeBillNo.substring(kv.getKey() + kv.getValue()) : "");
}
}
billNo = supposeBillNo;
return billNo;
}
}
# 参考资料和推荐阅读
1. 暂无
>欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~