Commit 7a436d1c authored by 季圣华's avatar 季圣华
Browse files

!14 格式化代码,看着有点别扭

Merge pull request !14 from SmkfGao/master
parents 8f304964 6bc92ec9
......@@ -3,6 +3,7 @@
# Mobile Tools for Java (J2ME)
.mtj.tmp/
*.iml
# Package Files #
*.jar
*.war
......@@ -12,5 +13,7 @@
hs_err_pid*
.idea
/target
**/*.iml
package com.jsh.action.asset;
import java.util.HashMap;
import java.util.Map;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.vo.asset.ReportModel;
import com.jsh.service.asset.ReportIService;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("serial")
public class ReportAction extends BaseAction<ReportModel>
{
public class ReportAction extends BaseAction<ReportModel> {
private ReportModel model = new ReportModel();
private ReportIService reportService;
/**
* 查找资产信息
*
* @return
*/
public String find()
{
try
{
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
public String find() {
try {
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition());
String reportType = getReportType(new HashMap<String,Object>());
reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]);
String reportType = getReportType(new HashMap<String, Object>());
reportService.find(pageUtil, reportType.split("_")[0], reportType.split("_")[1]);
model.getShowModel().setReportData(pageUtil.getPageList());
}
catch (JshException e)
{
} catch (JshException e) {
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
model.getShowModel().setMsgTip("get report data exception");
}
}
return SUCCESS;
}
/**
* 拼接搜索条件
*
* @return
*/
private Map<String,Object> getCondition()
{
private Map<String, Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("assetname.id_n_eq", model.getAssetNameID());
condition.put("assetname.category.id_n_eq", model.getAssetCategoryID());
condition.put("user.id_n_eq", model.getUsernameID());
condition.put("status_n_eq", model.getStatus());
condition.put("supplier.id_n_eq", model.getSupplierID());
condition.put("dataSum_s_order","desc");
condition.put("dataSum_s_order", "desc");
//拼接统计数据条件
getReportType(condition);
return condition;
}
/**
* 获取统计条件
*
* @param condition
*/
private String getReportType(Map<String,Object> condition)
{
private String getReportType(Map<String, Object> condition) {
// <option value="0">资产状态</option>
// <option value="1">资产类型</option>
// <option value="2">供应商</option>
......@@ -76,8 +72,7 @@ public class ReportAction extends BaseAction<ReportModel>
int reportType = model.getReportType();
String reportTypeInfo = "";
String reportTypeName = "";
switch(reportType)
{
switch (reportType) {
case 0:
condition.put("status_s_gb", "group");
reportTypeInfo = "status";
......@@ -103,18 +98,19 @@ public class ReportAction extends BaseAction<ReportModel>
reportTypeInfo = "user.id";
reportTypeName = "user.username";
break;
default:
break;
}
return reportTypeInfo + "_" + reportTypeName;
}
//=========Spring注入以及model驱动公共方法===========
public void setReportService(ReportIService reportService)
{
public void setReportService(ReportIService reportService) {
this.reportService = reportService;
}
@Override
public ReportModel getModel()
{
return model;
}
@Override
public ReportModel getModel() {
return model;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Assetname;
......@@ -16,79 +8,77 @@ import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.AssetNameModel;
import com.jsh.service.basic.AssetNameIService;
import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SuppressWarnings("serial")
public class AssetNameAction extends BaseAction<AssetNameModel>
{
public class AssetNameAction extends BaseAction<AssetNameModel> {
private AssetNameModel model = new AssetNameModel();
private AssetNameIService assetnameService;
/**
* 增加资产名称
*
* @return
*/
public void create()
{
public void create() {
Log.infoFileSync("==================开始调用增加资产名称方法create()===================");
Boolean flag = false;
try
{
try {
Assetname assetname = new Assetname();
assetname.setAssetname(model.getAssetName());
//增加资产类型
assetname.setCategory(new Category(model.getCategoryID()));
assetname.setIsystem((short)1);
assetname.setIsystem((short) 1);
assetname.setIsconsumables(model.getConsumable());
assetname.setDescription(model.getDescription());
assetnameService.create(assetname);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产名称异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>增加资产名称回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加资产名称", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加资产名称名称为 "+ model.getAssetName() + " " + tipMsg + "!", "增加资产名称" + tipMsg));
, tipType, "增加资产名称名称为 " + model.getAssetName() + " " + tipMsg + "!", "增加资产名称" + tipMsg));
Log.infoFileSync("==================结束调用增加资产名称方法create()===================");
}
/**
* 删除资产名称
*
* @return
*/
public String delete()
{
public String delete() {
Log.infoFileSync("====================开始调用删除资产名称信息方法delete()================");
try
{
try {
assetnameService.delete(model.getAssetNameID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetNameID() + " 的资产名称异常", e);
tipMsg = "失败";
tipType = 1;
......@@ -96,20 +86,19 @@ public class AssetNameAction extends BaseAction<AssetNameModel>
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除资产名称", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "!", "删除资产名称" + tipMsg));
, tipType, "删除资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "删除资产名称" + tipMsg));
Log.infoFileSync("====================结束调用删除资产名称信息方法delete()================");
return SUCCESS;
}
/**
* 更新资产名称
*
* @return
*/
public void update()
{
public void update() {
Boolean flag = false;
try
{
try {
Assetname assetname = assetnameService.get(model.getAssetNameID());
//增加资产类型
assetname.setCategory(new Category(model.getCategoryID()));
......@@ -117,103 +106,83 @@ public class AssetNameAction extends BaseAction<AssetNameModel>
assetname.setIsconsumables(model.getConsumable());
assetname.setDescription(model.getDescription());
assetnameService.update(assetname);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改资产名称ID为 : " + model.getAssetNameID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>修改资产名称回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新资产名称", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "!", "更新资产名称" + tipMsg));
, tipType, "更新资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "更新资产名称" + tipMsg));
}
/**
* 批量删除指定ID资产名称
*
* @return
*/
public String batchDelete()
{
try
{
public String batchDelete() {
try {
assetnameService.batchDelete(model.getAssetNameIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>批量删除资产名称ID为:" + model.getAssetNameIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除资产名称", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除资产名称ID为 "+ model.getAssetNameIDs() + " " + tipMsg + "!", "批量删除资产名称" + tipMsg));
, tipType, "批量删除资产名称ID为 " + model.getAssetNameIDs() + " " + tipMsg + "!", "批量删除资产名称" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
public void checkIsNameExist() {
Boolean flag = false;
try
{
flag = assetnameService.checkIsNameExist("assetname",model.getAssetName(),"id", model.getAssetNameID());
}
catch (DataAccessException e)
{
try {
flag = assetnameService.checkIsNameExist("assetname", model.getAssetName(), "id", model.getAssetNameID());
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查资产名称名称为:" + model.getAssetName() + " ID为: " + model.getAssetNameID() + " 是否存在异常!");
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查资产名称名称为:" + model.getAssetName() + " ID为: " + model.getAssetNameID() + " 是否存在异常!",e);
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>回写检查资产名称名称为:" + model.getAssetName() + " ID为: " + model.getAssetNameID() + " 是否存在异常!", e);
}
}
}
/**
* 查找供应商信息
*
* @return
*/
public void findBy()
{
try
{
PageUtil<Assetname> pageUtil = new PageUtil<Assetname>();
public void findBy() {
try {
PageUtil<Assetname> pageUtil = new PageUtil<Assetname>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
assetnameService.find(pageUtil);
List<Assetname> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
......@@ -222,16 +191,14 @@ public class AssetNameAction extends BaseAction<AssetNameModel>
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Assetname assetname:dataList)
{
if (null != dataList) {
for (Assetname assetname : dataList) {
JSONObject item = new JSONObject();
item.put("id", assetname.getId());
//供应商名称
item.put("assetname", assetname.getAssetname());
item.put("isystem", assetname.getIsystem() == (short)0?"是":"否");
item.put("consumable", assetname.getIsconsumables() == (short)0?"是":"否");
item.put("isystem", assetname.getIsystem() == (short) 0 ? "是" : "否");
item.put("consumable", assetname.getIsconsumables() == (short) 0 ? "是" : "否");
item.put("consumableStatus", assetname.getIsconsumables());
item.put("description", assetname.getDescription());
item.put("categoryID", assetname.getCategory().getId());
......@@ -243,27 +210,23 @@ public class AssetNameAction extends BaseAction<AssetNameModel>
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找资产名称信息异常", e);
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询资产名称信息结果异常", e);
}
}
/**
* 拼接搜索条件
*
* @return
*/
private Map<String,Object> getCondition()
{
private Map<String, Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("assetname_s_like", model.getAssetName());
condition.put("isconsumables_n_eq", model.getConsumable());
condition.put("description_s_like", model.getDescription());
......@@ -271,16 +234,14 @@ public class AssetNameAction extends BaseAction<AssetNameModel>
condition.put("id_s_order", "desc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public AssetNameModel getModel()
{
public AssetNameModel getModel() {
return model;
}
public void setAssetnameService(AssetNameIService assetnameService)
{
public void setAssetnameService(AssetNameIService assetnameService) {
this.assetnameService = assetnameService;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Category;
......@@ -15,198 +7,176 @@ import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.CategoryModel;
import com.jsh.service.basic.CategoryIService;
import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
*/
*/
@SuppressWarnings("serial")
public class CategoryAction extends BaseAction<CategoryModel>
{
public class CategoryAction extends BaseAction<CategoryModel> {
private CategoryIService categoryService;
private CategoryModel model = new CategoryModel();
/**
* 增加资产类型
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加资产类型方法create()===================");
Boolean flag = false;
try
{
Category category = new Category();
category.setAssetname(model.getCategoryName());
category.setIsystem((short)1);
category.setDescription(model.getDescription());
categoryService.create(category);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
/**
* 增加资产类型
*
* @return
*/
public void create() {
Log.infoFileSync("==================开始调用增加资产类型方法create()===================");
Boolean flag = false;
try {
Category category = new Category();
category.setAssetname(model.getCategoryName());
category.setIsystem((short) 1);
category.setDescription(model.getDescription());
categoryService.create(category);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产类型异常", e);
flag = false;
tipMsg = "失败";
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产类型异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>增加资产类型回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加资产类型", model.getClientIp(),
}
logService.create(new Logdetails(getUser(), "增加资产类型", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加资产类型名称为 "+ model.getCategoryName() + " " + tipMsg + "!", "增加资产类型" + tipMsg));
Log.infoFileSync("==================结束调用增加资产类型方法create()===================");
}
/**
* 删除资产类型
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除资产类型信息方法delete()================");
try
{
categoryService.delete(model.getCategoryID());
, tipType, "增加资产类型名称为 " + model.getCategoryName() + " " + tipMsg + "!", "增加资产类型" + tipMsg));
Log.infoFileSync("==================结束调用增加资产类型方法create()===================");
}
/**
* 删除资产类型
*
* @return
*/
public String delete() {
Log.infoFileSync("====================开始调用删除资产类型信息方法delete()================");
try {
categoryService.delete(model.getCategoryID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getCategoryID() + " 的资产类型异常", e);
tipMsg = "失败";
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getCategoryID() + " 的资产类型异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除资产类型", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除资产类型ID为 "+ model.getCategoryID() + " " + tipMsg + "!", "删除资产类型" + tipMsg));
Log.infoFileSync("====================结束调用删除资产类型信息方法delete()================");
return SUCCESS;
}
/**
* 更新资产类型
* @return
*/
public void update()
{
Boolean flag = false;
try
{
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除资产类型", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除资产类型ID为 " + model.getCategoryID() + " " + tipMsg + "!", "删除资产类型" + tipMsg));
Log.infoFileSync("====================结束调用删除资产类型信息方法delete()================");
return SUCCESS;
}
/**
* 更新资产类型
*
* @return
*/
public void update() {
Boolean flag = false;
try {
Category category = categoryService.get(model.getCategoryID());
category.setAssetname(model.getCategoryName());
category.setDescription(model.getDescription());
categoryService.update(category);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改资产类型ID为 : " + model.getCategoryID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>修改资产类型回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新资产类型", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新资产类型ID为 "+ model.getCategoryID() + " " + tipMsg + "!", "更新资产类型" + tipMsg));
}
/**
* 批量删除指定ID资产类型
* @return
*/
public String batchDelete()
{
try
{
categoryService.batchDelete(model.getCategoryIDs());
, tipType, "更新资产类型ID为 " + model.getCategoryID() + " " + tipMsg + "!", "更新资产类型" + tipMsg));
}
/**
* 批量删除指定ID资产类型
*
* @return
*/
public String batchDelete() {
try {
categoryService.batchDelete(model.getCategoryIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除资产类型ID为:" + model.getCategoryIDs() + "信息异常", e);
tipMsg = "失败";
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>批量删除资产类型ID为:" + model.getCategoryIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除资产类型", model.getClientIp(),
logService.create(new Logdetails(getUser(), "批量删除资产类型", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除资产类型ID为 "+ model.getCategoryIDs() + " " + tipMsg + "!", "批量删除资产类型" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = categoryService.checkIsNameExist("assetname",model.getCategoryName(),"id", model.getCategoryID());
}
catch (DataAccessException e)
{
, tipType, "批量删除资产类型ID为 " + model.getCategoryIDs() + " " + tipMsg + "!", "批量删除资产类型" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist() {
Boolean flag = false;
try {
flag = categoryService.checkIsNameExist("assetname", model.getCategoryName(), "id", model.getCategoryID());
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查资产类型名称为:" + model.getCategoryName() + " ID为: " + model.getCategoryID() + " 是否存在异常!");
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>回写检查资产类型名称为:" + model.getCategoryName() + " ID为: " + model.getCategoryID() + " 是否存在异常!", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查资产类型名称为:" + model.getCategoryName() + " ID为: " + model.getCategoryID() + " 是否存在异常!",e);
}
}
}
/**
* 查找供应商信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Category> pageUtil = new PageUtil<Category>();
}
}
/**
* 查找供应商信息
*
* @return
*/
public void findBy() {
try {
PageUtil<Category> pageUtil = new PageUtil<Category>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
categoryService.find(pageUtil);
List<Category> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
......@@ -215,15 +185,13 @@ public class CategoryAction extends BaseAction<CategoryModel>
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Category category:dataList)
{
if (null != dataList) {
for (Category category : dataList) {
JSONObject item = new JSONObject();
item.put("id", category.getId());
//供应商名称
item.put("categoryname", category.getAssetname());
item.put("isystem", category.getIsystem() == (short)0?"是":"否");
item.put("isystem", category.getIsystem() == (short) 0 ? "是" : "否");
item.put("description", category.getDescription());
item.put("op", category.getIsystem());
dataArray.add(item);
......@@ -232,41 +200,36 @@ public class CategoryAction extends BaseAction<CategoryModel>
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找资产类型信息异常", e);
}
catch (IOException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找资产类型信息异常", e);
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询资产类型信息结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
}
/**
* 拼接搜索条件
*
* @return
*/
private Map<String, Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("assetname_s_like", model.getCategoryName());
condition.put("description_s_like", model.getDescription());
condition.put("id_s_order", "desc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public CategoryModel getModel()
{
return model;
}
public void setCategoryService(CategoryIService categoryService)
{
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public CategoryModel getModel() {
return model;
}
public void setCategoryService(CategoryIService categoryService) {
this.categoryService = categoryService;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.InOutItem;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.InOutItemModel;
import com.jsh.service.basic.InOutItemIService;
import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 收支项目
*
* @author ji*sheng*hua qq 7.5.2.7.1.8.9.2.0
*/
@SuppressWarnings("serial")
public class InOutItemAction extends BaseAction<InOutItemModel>
{
public class InOutItemAction extends BaseAction<InOutItemModel> {
private InOutItemIService inOutItemService;
private InOutItemModel model = new InOutItemModel();
/**
* 增加收支项目
*
* @return
*/
public void create()
{
public void create() {
Log.infoFileSync("==================开始调用增加收支项目方法===================");
Boolean flag = false;
try
{
try {
InOutItem inOutItem = new InOutItem();
inOutItem.setName(model.getName());
inOutItem.setType(model.getType());
......@@ -46,68 +47,57 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加收支项目异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>增加收支项目回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加收支项目", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加收支项目名称为 "+ model.getName() + " " + tipMsg + "!", "增加收支项目" + tipMsg));
new Timestamp(System.currentTimeMillis())
, tipType, "增加收支项目名称为 " + model.getName() + " " + tipMsg + "!", "增加收支项目" + tipMsg));
Log.infoFileSync("==================结束调用增加收支项目方法===================");
}
/**
* 删除收支项目
*
* @return
*/
public String delete()
{
public String delete() {
Log.infoFileSync("====================开始调用删除收支项目信息方法delete()================");
try
{
try {
inOutItemService.delete(model.getInOutItemID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getInOutItemID() + " 的收支项目异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除收支项目", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除收支项目ID为 "+ model.getInOutItemID() + ",名称为 " + model.getName() + tipMsg + "!", "删除收支项目" + tipMsg));
new Timestamp(System.currentTimeMillis())
, tipType, "删除收支项目ID为 " + model.getInOutItemID() + ",名称为 " + model.getName() + tipMsg + "!", "删除收支项目" + tipMsg));
Log.infoFileSync("====================结束调用删除收支项目信息方法delete()================");
return SUCCESS;
}
/**
* 更新收支项目
*
* @return
*/
public void update()
{
public void update() {
Boolean flag = false;
try
{
try {
InOutItem inOutItem = inOutItemService.get(model.getInOutItemID());
inOutItem.setName(model.getName());
inOutItem.setType(model.getType());
......@@ -117,93 +107,73 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改收支项目ID为 : " + model.getInOutItemID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>修改收支项目回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新收支项目", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新收支项目ID为 "+ model.getInOutItemID() + " " + tipMsg + "!", "更新收支项目" + tipMsg));
new Timestamp(System.currentTimeMillis())
, tipType, "更新收支项目ID为 " + model.getInOutItemID() + " " + tipMsg + "!", "更新收支项目" + tipMsg));
}
/**
* 批量删除指定ID收支项目
*
* @return
*/
public String batchDelete()
{
try
{
public String batchDelete() {
try {
inOutItemService.batchDelete(model.getInOutItemIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>批量删除收支项目ID为:" + model.getInOutItemIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除收支项目", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除收支项目ID为 "+ model.getInOutItemIDs() + " " + tipMsg + "!", "批量删除收支项目" + tipMsg));
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除收支项目ID为 " + model.getInOutItemIDs() + " " + tipMsg + "!", "批量删除收支项目" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
public void checkIsNameExist() {
Boolean flag = false;
try
{
flag = inOutItemService.checkIsNameExist("name",model.getName(),"id", model.getInOutItemID());
}
catch (DataAccessException e)
{
try {
flag = inOutItemService.checkIsNameExist("name", model.getName(), "id", model.getInOutItemID());
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查收支项目名称为:" + model.getName() + " ID为: " + model.getInOutItemID() + " 是否存在异常!");
}
finally
{
try
{
} finally {
try {
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查收支项目名称为:" + model.getName() + " ID为: " + model.getInOutItemID() + " 是否存在异常!",e);
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>回写检查收支项目名称为:" + model.getName() + " ID为: " + model.getInOutItemID() + " 是否存在异常!", e);
}
}
}
/**
* 查找收支项目信息
*
* @return
*/
public void findBy()
{
try
{
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
public void findBy() {
try {
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
......@@ -214,10 +184,8 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(InOutItem inOutItem:dataList)
{
if (null != dataList) {
for (InOutItem inOutItem : dataList) {
JSONObject item = new JSONObject();
item.put("id", inOutItem.getId());
//收支项目名称
......@@ -231,26 +199,21 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找收支项目信息异常", e);
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询收支项目信息结果异常", e);
}
}
/**
* 查找收支项目信息-下拉框
*
* @return
*/
public void findBySelect()
{
try
{
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
public void findBySelect() {
try {
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition_select());
......@@ -258,10 +221,8 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
List<InOutItem> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(InOutItem inOutItem:dataList)
{
if (null != dataList) {
for (InOutItem inOutItem : dataList) {
JSONObject item = new JSONObject();
item.put("Id", inOutItem.getId());
//收支项目名称
......@@ -271,27 +232,23 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
}
//回写查询结果
toClient(dataArray.toString());
}
catch (DataAccessException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找收支项目信息异常", e);
}
catch (IOException e)
{
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询收支项目信息结果异常", e);
}
}
/**
* 拼接搜索条件
*
* @return
*/
private Map<String,Object> getCondition()
{
private Map<String, Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("name_s_like", model.getName());
condition.put("remark_s_like", model.getRemark());
condition.put("id_s_order", "desc");
......@@ -300,32 +257,30 @@ public class InOutItemAction extends BaseAction<InOutItemModel>
/**
* 拼接搜索条件-下拉框-收支项目
*
* @return
*/
private Map<String,Object> getCondition_select()
{
private Map<String, Object> getCondition_select() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
if(model.getType().equals("in")) {
condition.put("type_s_eq", "收入");
Map<String, Object> condition = new HashMap<String, Object>();
if (model.getType().equals("in")) {
condition.put("type_s_eq", "收入");
} else if (model.getType().equals("out")) {
condition.put("type_s_eq", "支出");
}
else if(model.getType().equals("out")) {
condition.put("type_s_eq", "支出");
}
condition.put("id_s_order", "desc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public InOutItemModel getModel()
{
public InOutItemModel getModel() {
return model;
}
public void setInOutItemService(InOutItemIService inOutItemService)
{
public void setInOutItemService(InOutItemIService inOutItemService) {
this.inOutItemService = inOutItemService;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Logdetails;
......@@ -15,109 +7,106 @@ import com.jsh.model.vo.basic.LogModel;
import com.jsh.service.basic.UserIService;
import com.jsh.util.PageUtil;
import com.jsh.util.Tools;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
*日志管理
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
*/
*/
@SuppressWarnings("serial")
public class LogAction extends BaseAction<LogModel>
{
private LogModel model = new LogModel();
private UserIService userService;
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
public class LogAction extends BaseAction<LogModel> {
private LogModel model = new LogModel();
private UserIService userService;
@SuppressWarnings({"rawtypes", "unchecked"})
public String getBasicData() {
Map<String, List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.clear();
try {
Map<String, Object> condition = pageUtil.getAdvSearch();
condition.clear();
condition.put("ismanager_n_eq", 0);
userService.find(pageUtil);
mapData.put("userList", pageUtil.getPageList());
}
catch (Exception e)
{
} catch (Exception e) {
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 删除日志
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除日志信息方法delete()================");
try
{
/**
* 删除日志
*
* @return
*/
public String delete() {
Log.infoFileSync("====================开始调用删除日志信息方法delete()================");
try {
logService.delete(model.getLogID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getLogID() + " 的日志异常", e);
tipMsg = "失败";
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getLogID() + " 的日志异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除日志", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除日志ID为 "+ model.getLogID() + " " + tipMsg + "!", "删除日志" + tipMsg));
Log.infoFileSync("====================结束调用删除日志信息方法delete()================");
return SUCCESS;
}
/**
* 批量删除指定ID日志
* @return
*/
public String batchDelete()
{
try
{
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除日志", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除日志ID为 " + model.getLogID() + " " + tipMsg + "!", "删除日志" + tipMsg));
Log.infoFileSync("====================结束调用删除日志信息方法delete()================");
return SUCCESS;
}
/**
* 批量删除指定ID日志
*
* @return
*/
public String batchDelete() {
try {
logService.batchDelete(model.getLogIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除日志ID为:" + model.getLogIDs() + "信息异常", e);
tipMsg = "失败";
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>批量删除日志ID为:" + model.getLogIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除日志", model.getClientIp(),
logService.create(new Logdetails(getUser(), "批量删除日志", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除日志ID为 "+ model.getLogIDs() + " " + tipMsg + "!", "批量删除日志" + tipMsg));
return SUCCESS;
}
/**
* 查找日志信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Logdetails> pageUtil = new PageUtil<Logdetails>();
, tipType, "批量删除日志ID为 " + model.getLogIDs() + " " + tipMsg + "!", "批量删除日志" + tipMsg));
return SUCCESS;
}
/**
* 查找日志信息
*
* @return
*/
public void findBy() {
try {
PageUtil<Logdetails> pageUtil = new PageUtil<Logdetails>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
logService.find(pageUtil);
List<Logdetails> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
......@@ -126,10 +115,8 @@ public class LogAction extends BaseAction<LogModel>
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Logdetails log:dataList)
{
if (null != dataList) {
for (Logdetails log : dataList) {
JSONObject item = new JSONObject();
item.put("id", log.getId());
item.put("clientIP", log.getClientIp());
......@@ -137,36 +124,32 @@ public class LogAction extends BaseAction<LogModel>
item.put("createTime", Tools.getCenternTime(log.getCreatetime()));
item.put("operation", log.getOperation());
item.put("remark", log.getRemark());
item.put("status", log.getStatus() == 0 ?"成功":"失败");
item.put("status", log.getStatus() == 0 ? "成功" : "失败");
item.put("statusShort", log.getStatus());
item.put("username", log.getUser()==null?"":log.getUser().getUsername());
item.put("username", log.getUser() == null ? "" : log.getUser().getUsername());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>查找日志信息异常", e);
}
catch (IOException e)
{
} catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找日志信息异常", e);
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询日志信息结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
}
/**
* 拼接搜索条件
*
* @return
*/
private Map<String, Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("user.id_n_eq", model.getUsernameID());
condition.put("createtime_s_gteq", model.getBeginTime());
condition.put("createtime_s_lteq", model.getEndTime());
......@@ -178,16 +161,14 @@ public class LogAction extends BaseAction<LogModel>
condition.put("createtime_s_order", "desc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
public void setUserService(UserIService userService)
{
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
public void setUserService(UserIService userService) {
this.userService = userService;
}
@Override
public LogModel getModel()
{
return model;
}
@Override
public LogModel getModel() {
return model;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment