?? configaction.java
字號:
int objectId = value1.getFieldList().getConfigTree().getParentId();
logger.debug("所屬模塊實體ID=" + objectId);
String tableName = configTreeMgr.getById(objectId).getTableName();
logger.debug("要修改的實體表 " + tableName);
logger.debug("這個字段名所屬模塊實體表 " + tableName + " 字段為 " + fieldName
+ " 值為 '" + deleteValue + "' 都將被修改為 '" + value1.getListValue()
+ "'");
// 更新對應實表內容
configTreeMgr.updateTable(tableName, fieldName, deleteValue, value1
.getListValue());
logger.debug("刪除成功了");
// 修改選項值表
delevalue.setListValue(value1.getListValue());
delevalue.setFlag(2);// 把被刪除的值設為無效值
delevalue.setInterrelater(value1.getInterrelater());// 修改對應的相關值
valueListMgr.update(delevalue);
// valueListMgr.update(value1);
List valueList = valueListMgr.getByField(value1.getFieldList());
request.setAttribute("fields", value1.getFieldList());
request.setAttribute("valueList", valueList);
return mapping.findForward("editField");
}
public ActionForward newValueList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
User user = SessionMgr.getCustSession(request);
String fieldId = request.getParameter("id");// 字段ID
String isMoreValue = request.getParameter("isMoreValue");// 是否有多值
String values = request.getParameter("values");// 新建選項值
String[] value = values.split("\n");// 新建的選項值以回車符隔開
for (int i = 0; i < value.length; i++) {
ValueList valueList = new ValueList();
logger.debug("新建選項值value=" + value[i]);
if (!isMoreValue.equals("1")) {
valueList.setListValue(value[i].trim());
valueList.setFieldList(fieldListMgr.getById(Integer
.parseInt(fieldId)));
valueList.setOperation(12);// 設置操作類型 1編輯2刪除3替換
valueList.setCreateTime(new Date());
valueList.setLastModifyTime(new Date());
valueList
.setOrderNO(valueListMgr
.getByField(
fieldListMgr.getById(Integer
.parseInt(fieldId))).size() + 1);// 設置排序序列號
logger.debug("orderNO===" + valueList.getOrderNO());
valueList.setCreater(user);
valueList.setLastModifier(user);
logger.debug("creater=" + user.getUserName());
valueListMgr.save(valueList);
} else {
valueList.setListValue(values);
valueList.setFieldList(fieldListMgr.getById(Integer
.parseInt(fieldId)));
valueList.setOperation(12);// 設置操作類型 1編輯2刪除3替換
valueList.setCreateTime(new Date());
valueList.setLastModifyTime(new Date());
// 設置排序
valueList
.setOrderNO(valueListMgr
.getByField(
fieldListMgr.getById(Integer
.parseInt(fieldId))).size() + 1);
logger.debug("orderNO===" + valueList.getOrderNO());
valueList.setListValueState(request
.getParameter("listValueState"));
valueList.setCreater(user);
valueList.setLastModifier(user);
logger.debug("creater=" + user.getUserName());
// 新建的相關值并與之字段對應
Interrelater interrelater = new Interrelater();
interrelater.setInterrelaterValue(request
.getParameter("interrelaterValue"));
// interrelater.setFieldList(fieldListMgr.getById(Integer.parseInt(fieldId)));
interrelater.setFieldList(fieldListMgr.getById(55));// 相關值對應字段ID(可能性)
interrelater.setValues(valueList);
interrelaterMgr.save(interrelater);
}
}
request.setAttribute("fields", fieldListMgr.getById(Integer
.parseInt(fieldId)));
request.setAttribute("valueList", valueListMgr.getByField(fieldListMgr
.getById(Integer.parseInt(fieldId))));
// return gotoEditField(mapping,form,request,response);
return mapping.findForward("editField");
}
// 獲得選項列表值進行排序
public ActionForward getListValue(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String forward = "orderValueList";
String id = request.getParameter("id");// 字段ID
FieldList fieldList = fieldListMgr.getById(Integer.parseInt(id));
request.setAttribute("fields", fieldList);
List valueList = valueListMgr.getByField(fieldList);
request.setAttribute("valueList", valueList);
return mapping.findForward(forward);
}
// 排序
public ActionForward orderValueList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String items = request.getParameter("items");
String[] item = items.split(" ");
String ids = request.getParameter("ids");// 排序后對應的ID組
String[] valueListId = ids.split(" ");// 每個選項值ID
logger.debug("" + valueListId.length + " ===== " + item.length);
for (int i = 0; i < valueListId.length; i++) {
ValueList values1 = valueListMgr.getById(Integer
.parseInt(valueListId[i]));
values1.setOrderNO(i + 1);
valueListMgr.update(values1);
}
return view(mapping, form, request, response);
}
// 封裝所需選項值,進入選項值替換
public ActionForward replaceValue(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String id = request.getParameter("id");// 字段ID
FieldList fields = fieldListMgr.getById(Integer.parseInt(id));
List valueList = valueListMgr.getByField(fields);
request.setAttribute("valueList", valueList);
request.setAttribute("fields", fields);
return mapping.findForward("replaceValue");
}
public ActionForward replace(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String id = request.getParameter("id");// 字段ID
String replaceValue = request.getParameter("replaceValue");// 將被替換的值
String value = request.getParameter("value");// 替換的目標值
FieldList fields = fieldListMgr.getById(Integer.parseInt(id));
String fieldName = fields.getFieldName();
List fieldList = fieldListMgr.getByConfigTree(fields.getConfigTree());
// 判斷該字段是否為標準字段
if (fields.getIsStandardField() != 2) {// 2為不是標準字段
int parentId = fields.getConfigTree().getParentId();
if (fields.getIsMoreValue() == 1) {
ValueList FormerlyValueList = valueListMgr
.getByListValue(replaceValue);
if (FormerlyValueList == null) {
request.setAttribute("fieldList", fieldList);
request.setAttribute("configTree", configTreeMgr
.getById(fields.getConfigTree().getParentId()));
request.setAttribute("message", "已有0條數據 " + replaceValue
+ " 被替換為 " + value + " !");
return mapping.findForward("fieldList");
}
String FormerlyInterrelaterValue = FormerlyValueList
.getInterrelater().getInterrelaterValue();
ValueList valueList = valueListMgr.getByListValue(value);
String InterrelaterValue = valueList.getInterrelater()
.getInterrelaterValue();
String InterrelaterTableName = configTreeMgr.getById(parentId)
.getTableName();
logger.debug("可能性"
+ valueList.getInterrelater().getFieldList()
.getFieldName());
configTreeMgr.updateTable(InterrelaterTableName, valueList
.getInterrelater().getFieldList().getFieldName(),
FormerlyInterrelaterValue, InterrelaterValue);
logger.debug("有沒有到這里了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
}
String tableName = configTreeMgr.getById(parentId).getTableName();
logger.debug("被修改的表格tableName==" + tableName);
int i = configTreeMgr.lockUpTableDate(tableName, fieldName,
replaceValue);
if (i != 0) {
logger.debug("這個字段名所屬模塊實體表 " + tableName + " 字段為 " + fieldName
+ " 值為 '" + replaceValue + "' 都將被替換為 '" + value + "'");
configTreeMgr.updateTable(tableName, fieldName, replaceValue,
value);
logger.debug("數據庫替換成功");
}
request.setAttribute("fieldList", fieldList);
request.setAttribute("configTree", configTreeMgr.getById(fields
.getConfigTree().getParentId()));
request.setAttribute("message", "已有" + i + "條數據 " + replaceValue
+ " 被替換為 " + value + " !");
} else {
ValueList valueList = valueListMgr.getByListValue(replaceValue);
if (valueList != null) {
valueList.setListValue(value);
valueListMgr.update(valueList);
}
request.setAttribute("fieldList", fieldListMgr
.getByConfigTree(fields.getConfigTree()));
request.setAttribute("configTree", configTreeMgr.getById(fields
.getConfigTree().getParentId()));
request.setAttribute("message", "數據 " + replaceValue + " 被替換為 "
+ value + " !");
}
return mapping.findForward("fieldList");
}
// newField新建字段
public ActionForward newField(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String id = request.getParameter("id");// 實例模塊ID
String dataType = request.getParameter("dataType");
String fieldLable = request.getParameter("fieldLable");
String fieldName = request.getParameter("fieldName");
String remark = request.getParameter("remark");
String helpText = request.getParameter("helpText");
String values = request.getParameter("values");
logger.debug(values);
logger.debug("開始增加…………………………");
User user = SessionMgr.getCustSession(request);
ConfigTree configTree = configTreeMgr.getById(Integer.parseInt(id));
FieldList fieldList = new FieldList();
fieldList.setConfigTree(configTree);
fieldList.setDataType(dataType);
fieldList.setFieldLable(fieldLable);
fieldList.setFieldName(fieldName);
fieldList.setRemark(remark);
fieldList.setHelpText(helpText);
fieldList.setCreater(user);
fieldList.setCreateTime(new Date());
fieldList.setIsStandardField(2);// 注釋此字段為自定義字段
fieldList.setIsMoreValue(2);// 設置該字段沒有多值
fieldList.setLastModifier(user);
fieldList.setLastModifyTime(new Date());
logger.debug("第二階段安全");
if ("1".equals(dataType)) {
fieldList.setOperation(123);// 自定義字段類型為選項列表可以進行編輯刪除替換
fieldListMgr.save(fieldList);
logger.debug("這個最關鍵");
String[] value = values.split("\n");
for (int i = 0; i < value.length; i++) {
ValueList valueList = new ValueList();
valueList.setCreater(user);
valueList.setCreateTime(new Date());
valueList.setLastModifier(user);
valueList.setLastModifyTime(new Date());
valueList.setFieldList(fieldList);
valueList.setListValue(value[i].trim());
valueList.setOrderNO(i + 1);// 新建字段所以排序1開始
valueList.setOperation(12);// 自定義列表值可以進行編輯刪除替換
valueListMgr.save(valueList);
}
} else {
fieldList.setOperation(12);// 自定義字段類型不是選項列表可以進行編輯刪除
logger.debug("類型不是選項列表");
fieldListMgr.save(fieldList);
}
return getField(mapping, form, request, response);
}
// 接口類
public ActionForward getCustomerField(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ApplicationException {
List bizType = valueListMgr.getByField(fieldListMgr.getBizType());
List industryType = valueListMgr.getByField(fieldListMgr
.getIndustryType());
List employee_Num = valueListMgr.getByField(fieldListMgr
.getEmployee_Num());
List regionOf = valueListMgr.getByField(fieldListMgr.getRegionOf());
List province = valueListMgr.getByField(fieldListMgr.getProvince());
List city = valueListMgr.getByField(fieldListMgr.getCity());
List county = valueListMgr.getByField(fieldListMgr.getCounty());
List manger_Level = valueListMgr.getByField(fieldListMgr
.getManager_Level());
List customerState = valueListMgr.getByField(fieldListMgr
.getCustomerState());
List honestGrade = valueListMgr.getByField(fieldListMgr
.getHonestGrade());
List cuscomerSource = valueListMgr.getByField(fieldListMgr
.getCustomerSource());
request.setAttribute("bizType", bizType);
request.setAttribute("industryType", industryType);
request.setAttribute("employee_Num", employee_Num);
request.setAttribute("regionOf", regionOf);
request.setAttribute("province", province);
request.setAttribute("city", city);
request.setAttribute("county", county);
request.setAttribute("manger_Level", manger_Level);
request.setAttribute("customerState", customerState);
request.setAttribute("honestGrade", honestGrade);
request.setAttribute("cuscomerSource", cuscomerSource);
return mapping.findForward("newCustomer");
}
public ActionForward getContactField(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ApplicationException {
List satulation = valueListMgr.getByField(fieldListMgr.getSatulation());
List education = valueListMgr.getByField(fieldListMgr.getEducation());
request.setAttribute("satulation", satulation);
request.setAttribute("education", education);
return mapping.findForward("newContact");
}
public ActionForward getBusiOpportField(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ApplicationException {
List stageOf = valueListMgr.getByField(fieldListMgr.getStageOf());
request.setAttribute("stageOf", stageOf);
return mapping.findForward("busiOpport");
}
// dwr
public String getInterrelaterValue(String idStr, HttpServletRequest request) {
int id = Integer.parseInt(idStr);
if (id == 0) {
return "0.0";
}
Interrelater interrelater = interrelaterMgr.getByValue(valueListMgr
.getById(id));
String interralaterValue = interrelater.getInterrelaterValue();
return interralaterValue;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -