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

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

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