This commit is contained in:
AlanGao 2018-04-07 12:41:53 +08:00
parent 35e9301b5e
commit 546aa7ec40
10 changed files with 294 additions and 357 deletions

3
.gitignore vendored
View File

@ -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 @@
hs_err_pid* hs_err_pid*
.idea .idea
/target
**/*.iml

View File

@ -1,41 +1,30 @@
package com.jsh.action.asset; package com.jsh.action.asset;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
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.util.AssetConstants; import com.jsh.model.po.*;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.Assetname;
import com.jsh.model.po.Basicuser;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Supplier;
import com.jsh.model.vo.asset.AssetModel; import com.jsh.model.vo.asset.AssetModel;
import com.jsh.service.asset.AssetIService; import com.jsh.service.asset.AssetIService;
import com.jsh.service.basic.AssetNameIService; import com.jsh.service.basic.AssetNameIService;
import com.jsh.service.basic.CategoryIService; import com.jsh.service.basic.CategoryIService;
import com.jsh.service.basic.SupplierIService; import com.jsh.service.basic.SupplierIService;
import com.jsh.service.basic.UserIService; import com.jsh.service.basic.UserIService;
import com.jsh.util.AssetConstants;
import com.jsh.util.JshException;
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.io.InputStream;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.*;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class AssetAction extends BaseAction<AssetModel> public class AssetAction extends BaseAction<AssetModel> {
{
private AssetModel model = new AssetModel(); private AssetModel model = new AssetModel();
private AssetIService assetService; private AssetIService assetService;
private CategoryIService categoryService; private CategoryIService categoryService;
@ -43,87 +32,78 @@ public class AssetAction extends BaseAction<AssetModel>
private UserIService userService; private UserIService userService;
private AssetNameIService assetnameService; private AssetNameIService assetnameService;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public String getBasicData() public String getBasicData() {
{ Map<String, List> mapData = model.getShowModel().getMap();
Map<String,List> mapData = model.getShowModel().getMap(); PageUtil pageUtil = new PageUtil();
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.put("id_s_order", "desc"); condition.put("id_s_order", "desc");
categoryService.find(pageUtil); categoryService.find(pageUtil);
mapData.put("categoryList", pageUtil.getPageList()); mapData.put("categoryList", pageUtil.getPageList());
supplierService.find(pageUtil); supplierService.find(pageUtil);
mapData.put("supplierList", pageUtil.getPageList()); mapData.put("supplierList", pageUtil.getPageList());
condition.put("isystem_n_eq", 1); condition.put("isystem_n_eq", 1);
condition.put("id_s_order", "desc"); condition.put("id_s_order", "desc");
userService.find(pageUtil); userService.find(pageUtil);
mapData.put("userList", pageUtil.getPageList()); mapData.put("userList", pageUtil.getPageList());
//清除搜索条件 防止对查询有影响 //清除搜索条件 防止对查询有影响
condition.remove("isystem_n_eq"); condition.remove("isystem_n_eq");
assetnameService.find(pageUtil); assetnameService.find(pageUtil);
mapData.put("assetnameList", pageUtil.getPageList()); mapData.put("assetnameList", 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 void create() public void create() {
{
Log.infoFileSync("==================开始调用增加资产方法==================="); Log.infoFileSync("==================开始调用增加资产方法===================");
Boolean flag = false; Boolean flag = false;
try try {
{
Asset asset = new Asset(); Asset asset = new Asset();
//添加设置 //添加设置
asset.setAssetname(new Assetname(model.getAssetNameID())); asset.setAssetname(new Assetname(model.getAssetNameID()));
asset.setLocation(model.getLocation()); asset.setLocation(model.getLocation());
asset.setStatus(model.getStatus()); asset.setStatus(model.getStatus());
asset.setPrice(model.getPrice()); asset.setPrice(model.getPrice());
if(null != model.getUserID()) if (null != model.getUserID()) {
{ asset.setUser(new Basicuser(model.getUserID()));
asset.setUser( new Basicuser(model.getUserID()));
} }
try try {
{
//购买日期 //购买日期
asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime()));
//有效日期 //有效日期
asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime()));
//保修日期 //保修日期
asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime()));
} } catch (ParseException e) {
catch (ParseException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
} }
asset.setAssetnum(model.getAssetnum()); asset.setAssetnum(model.getAssetnum());
asset.setSerialnum(model.getSerialnum()); asset.setSerialnum(model.getSerialnum());
asset.setLabels(model.getLabels()); asset.setLabels(model.getLabels());
asset.setSupplier( new Supplier(model.getSupplierID())); asset.setSupplier(new Supplier(model.getSupplierID()));
asset.setDescription(model.getDescription()); asset.setDescription(model.getDescription());
asset.setCreatetime(new Timestamp(new Date().getTime())); asset.setCreatetime(new Timestamp(System.currentTimeMillis()));
asset.setCreator(getUser()); asset.setCreator(getUser());
asset.setUpdatetime(new Timestamp(new Date().getTime())); asset.setUpdatetime(new Timestamp(System.currentTimeMillis()));
asset.setUpdator(getUser()); asset.setUpdator(getUser());
asset.setAddMonth(Tools.getCurrentMonth()); asset.setAddMonth(Tools.getCurrentMonth());
assetService.create(asset); assetService.create(asset);
@ -132,47 +112,37 @@ public class AssetAction extends BaseAction<AssetModel>
//记录操作日志使用 //记录操作日志使用
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, "增加资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "", "增加资产" + tipMsg)); , tipType, "增加资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "", "增加资产" + tipMsg));
Log.infoFileSync("==================结束调用增加资产方法==================="); Log.infoFileSync("==================结束调用增加资产方法===================");
} }
/** /**
* 删除资产 * 删除资产
*
* @return * @return
*/ */
public String delete() public String delete() {
{
Log.infoFileSync("====================开始调用删除资产信息方法delete()================"); Log.infoFileSync("====================开始调用删除资产信息方法delete()================");
try try {
{
assetService.delete(model.getAssetID()); assetService.delete(model.getAssetID());
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e); Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e);
tipMsg = "失败"; tipMsg = "失败";
tipType = 1; tipType = 1;
@ -180,128 +150,114 @@ public class AssetAction extends BaseAction<AssetModel>
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.getAssetID() + " " + tipMsg + "", "删除资产" + tipMsg)); , tipType, "删除资产ID为 " + model.getAssetID() + " " + 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 {
{
Asset asset = assetService.get(model.getAssetID()); Asset asset = assetService.get(model.getAssetID());
//设置要更新的熟悉值 //设置要更新的熟悉值
asset.setAssetname(new Assetname(model.getAssetNameID())); asset.setAssetname(new Assetname(model.getAssetNameID()));
asset.setLocation(model.getLocation()); asset.setLocation(model.getLocation());
asset.setStatus(model.getStatus()); asset.setStatus(model.getStatus());
asset.setPrice(model.getPrice()); asset.setPrice(model.getPrice());
if(null != model.getUserID()) if (null != model.getUserID()) {
asset.setUser(new Basicuser(model.getUserID())); asset.setUser(new Basicuser(model.getUserID()));
else } else {
asset.setUser(null); asset.setUser(null);
try }
{ try {
//购买日期 //购买日期
asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime()));
//有效日期 //有效日期
asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime()));
//保修日期 //保修日期
asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime()));
} } catch (ParseException e) {
catch (ParseException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
} }
asset.setAssetnum(model.getAssetnum()); asset.setAssetnum(model.getAssetnum());
asset.setSerialnum(model.getSerialnum()); asset.setSerialnum(model.getSerialnum());
asset.setLabels(model.getLabels()); asset.setLabels(model.getLabels());
asset.setSupplier(new Supplier(model.getSupplierID())); asset.setSupplier(new Supplier(model.getSupplierID()));
asset.setDescription(model.getDescription()); asset.setDescription(model.getDescription());
asset.setUpdatetime(new Timestamp(new Date().getTime())); asset.setUpdatetime(new Timestamp(System.currentTimeMillis()));
asset.setUpdator(getUser()); asset.setUpdator(getUser());
assetService.update(asset); assetService.update(asset);
flag = true; flag = true;
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 " + model.getAssetID() + "信息失败", e); Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 " + model.getAssetID() + "信息失败", 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.getAssetID() + " " + tipMsg + "", "更新资产" + tipMsg)); , tipType, "更新资产ID为 " + model.getAssetID() + " " + tipMsg + "", "更新资产" + tipMsg));
} }
/** /**
* 批量删除指定ID资产 * 批量删除指定ID资产
*
* @return * @return
*/ */
public String batchDelete() public String batchDelete() {
{ try {
try
{
assetService.batchDelete(model.getAssetIDs()); assetService.batchDelete(model.getAssetIDs());
model.getShowModel().setMsgTip("成功"); model.getShowModel().setMsgTip("成功");
//记录操作日志使用 //记录操作日志使用
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除资产ID为" + model.getAssetIDs() + "信息异常", e); Log.errorFileSync(">>>>>>>>>>>批量删除资产ID为" + model.getAssetIDs() + "信息异常", 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.getAssetIDs() + " " + tipMsg + "", "批量删除资产" + tipMsg)); , tipType, "批量删除资产ID为 " + model.getAssetIDs() + " " + tipMsg + "", "批量删除资产" + tipMsg));
return SUCCESS; return SUCCESS;
} }
/** /**
* 查找资产信息 * 查找资产信息
*
* @return * @return
*/ */
public void findBy() public void findBy() {
{ try {
try PageUtil<Asset> pageUtil = new PageUtil<Asset>();
{
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
pageUtil.setPageSize(model.getPageSize()); pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo()); pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition()); pageUtil.setAdvSearch(getCondition());
assetService.find(pageUtil); assetService.find(pageUtil);
getSession().put("pageUtil", pageUtil); getSession().put("pageUtil", pageUtil);
List<Asset> dataList = pageUtil.getPageList(); List<Asset> 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"}
@ -310,10 +266,8 @@ public class AssetAction extends BaseAction<AssetModel>
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 (Asset asset : dataList) {
for(Asset asset:dataList)
{
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("id", asset.getId()); item.put("id", asset.getId());
//添加资产属性 //添加资产属性
@ -328,25 +282,25 @@ public class AssetAction extends BaseAction<AssetModel>
item.put("status", getStatusInfo(asset.getStatus())); item.put("status", getStatusInfo(asset.getStatus()));
item.put("statushort", asset.getStatus()); item.put("statushort", asset.getStatus());
//在用用户名称 //在用用户名称
item.put("username", asset.getUser()==null?"":asset.getUser().getUsername()); item.put("username", asset.getUser() == null ? "" : asset.getUser().getUsername());
item.put("userID", asset.getUser()==null?"":asset.getUser().getId()); item.put("userID", asset.getUser() == null ? "" : asset.getUser().getId());
//位置 //位置
item.put("location", Tools.dealNullStr(asset.getLocation())); item.put("location", Tools.dealNullStr(asset.getLocation()));
//购买日期 //购买日期
item.put("purchasedate", asset.getPurchasedate()==null?"":Tools.getCurrentMonth(asset.getPurchasedate())); item.put("purchasedate", asset.getPurchasedate() == null ? "" : Tools.getCurrentMonth(asset.getPurchasedate()));
//有效日期 //有效日期
item.put("periodofvalidity", asset.getPeriodofvalidity()==null?"":Tools.getCurrentMonth(asset.getPeriodofvalidity())); item.put("periodofvalidity", asset.getPeriodofvalidity() == null ? "" : Tools.getCurrentMonth(asset.getPeriodofvalidity()));
//保修日期 //保修日期
item.put("warrantydate", asset.getWarrantydate()==null?"":Tools.getCurrentMonth(asset.getWarrantydate())); item.put("warrantydate", asset.getWarrantydate() == null ? "" : Tools.getCurrentMonth(asset.getWarrantydate()));
//资产编号 //资产编号
item.put("assetnum", Tools.dealNullStr(asset.getAssetnum())); item.put("assetnum", Tools.dealNullStr(asset.getAssetnum()));
//资产序列号 //资产序列号
item.put("serialnum", Tools.dealNullStr(asset.getSerialnum())); item.put("serialnum", Tools.dealNullStr(asset.getSerialnum()));
//供应商 //供应商
item.put("supplier", asset.getSupplier()==null?"":asset.getSupplier().getSupplier()); item.put("supplier", asset.getSupplier() == null ? "" : asset.getSupplier().getSupplier());
//供应商 //供应商
item.put("supplierID", asset.getSupplier()==null?"":asset.getSupplier().getId()); item.put("supplierID", asset.getSupplier() == null ? "" : asset.getSupplier().getId());
//标签 //标签
item.put("labels", Tools.dealNullStr(asset.getLabels())); item.put("labels", Tools.dealNullStr(asset.getLabels()));
item.put("description", Tools.dealNullStr(asset.getDescription())); item.put("description", Tools.dealNullStr(asset.getDescription()));
@ -357,97 +311,80 @@ public class AssetAction extends BaseAction<AssetModel>
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);
} }
} }
/** /**
* 导出excel表格 * 导出excel表格
* @return *
*/ * @return
@SuppressWarnings("unchecked") */
public String exportExcel() @SuppressWarnings("unchecked")
{ public String exportExcel() {
Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始======================="); Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始=======================");
try try {
{ PageUtil<Asset> pageUtil = (PageUtil<Asset>) getSession().get("pageUtil");
PageUtil<Asset> pageUtil = (PageUtil<Asset>)getSession().get("pageUtil");
pageUtil.setPageSize(model.getPageSize()); pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo()); pageUtil.setCurPage(model.getPageNo());
//pageUtil.setAdvSearch(getCondition()); //pageUtil.setAdvSearch(getCondition());
String isCurrentPage = model.getIsAllData(); String isCurrentPage = model.getIsAllData();
model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls",model.getBrowserType())); model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls", model.getBrowserType()));
model.setExcelStream(assetService.exmportExcel(isCurrentPage,pageUtil)); model.setExcelStream(assetService.exmportExcel(isCurrentPage, pageUtil));
} } catch (Exception e) {
catch (Exception e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常", e);
{ model.getShowModel().setMsgTip("export excel exception");
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常",e); }
model.getShowModel().setMsgTip("export excel exception"); Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束==================");
} return AssetConstants.BusinessForExcel.EXCEL;
Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束=================="); }
return AssetConstants.BusinessForExcel.EXCEL;
}
/**
* 导入资产excel表格内容
/** */
* 导入资产excel表格内容 public String importExcel() {
*/ //资产excel表格file
public String importExcel() Boolean result = false;
{ String returnStr = "";
//资产excel表格file try {
Boolean result = false; InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck());
String returnStr = "";
try if (null != in) {
{ model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck()); model.setExcelStream(in);
returnStr = AssetConstants.BusinessForExcel.EXCEL;
if(null != in) } else {
{ result = true;
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls"); try {
model.setExcelStream(in); toClient(result.toString());
returnStr = AssetConstants.BusinessForExcel.EXCEL; } catch (IOException e) {
} Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e);
else }
{ //导入数据成功
result = true; returnStr = SUCCESS;
try }
{
toClient(result.toString()); } catch (JshException e) {
} Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e);
catch (IOException e) }
{ return returnStr;
Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e); }
}
//导入数据成功
returnStr = SUCCESS;
}
}
catch (JshException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e);
}
return returnStr;
}
/** /**
* 拼接搜索条件 * 拼接搜索条件
*
* @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.getUserID()); condition.put("user.id_n_eq", model.getUserID());
@ -456,62 +393,57 @@ public class AssetAction extends BaseAction<AssetModel>
condition.put("createtime_s_order", "desc"); condition.put("createtime_s_order", "desc");
return condition; return condition;
} }
/** /**
* 根据状态码转化成说明字符串 * 根据状态码转化成说明字符串
* 资产的状态0==在库1==在用2==消费 * 资产的状态0==在库1==在用2==消费
*
* @param statusCode * @param statusCode
* @return * @return
*/ */
private String getStatusInfo(short statusCode) private String getStatusInfo(short statusCode) {
{
String statusInfo = ""; String statusInfo = "";
switch(statusCode) switch (statusCode) {
{
case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU: case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU:
statusInfo = "在库"; statusInfo = "在库";
break; break;
case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE: case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE:
statusInfo = "在用"; statusInfo = "在用";
break; break;
case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME: case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME:
statusInfo = "消费"; statusInfo = "消费";
break; break;
default:
break;
} }
return statusInfo; return statusInfo;
} }
//=========Spring注入以及model驱动公共方法=========== //=========Spring注入以及model驱动公共方法===========
public void setAssetService(AssetIService assetService) public void setAssetService(AssetIService assetService) {
{
this.assetService = assetService; this.assetService = assetService;
} }
public void setCategoryService(CategoryIService categoryService) public void setCategoryService(CategoryIService categoryService) {
{
this.categoryService = categoryService; this.categoryService = categoryService;
} }
public void setSupplierService(SupplierIService supplierService) public void setSupplierService(SupplierIService supplierService) {
{
this.supplierService = supplierService; this.supplierService = supplierService;
} }
public void setUserService(UserIService userService) public void setUserService(UserIService userService) {
{
this.userService = userService; this.userService = userService;
} }
public void setAssetnameService(AssetNameIService assetnameService) public void setAssetnameService(AssetNameIService assetnameService) {
{
this.assetnameService = assetnameService; this.assetnameService = assetnameService;
} }
@Override @Override
public AssetModel getModel() public AssetModel getModel() {
{ return model;
return model; }
}
} }

View File

@ -1,73 +1,69 @@
package com.jsh.action.asset; package com.jsh.action.asset;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
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.HashMap;
import java.util.Map; 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.PageUtil;
@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>
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>
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; }
}
} }

View File

@ -86,7 +86,7 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
depotHead.setDefaultNumber(allNewNumber); //初始编号一直都从后台取值 depotHead.setDefaultNumber(allNewNumber); //初始编号一直都从后台取值
depotHead.setOperPersonName(getUser().getUsername()); depotHead.setOperPersonName(getUser().getUsername());
depotHead.setCreateTime(new Timestamp(new Date().getTime())); depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
try{ try{
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime())); depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
} }

View File

@ -20,6 +20,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override
public void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException public void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException
{ {
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
@ -28,6 +29,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override
public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException
{ {
Query query; Query query;
@ -51,6 +53,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
query.executeUpdate(); query.executeUpdate();
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException { public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException {
StringBuffer queryString = new StringBuffer(); StringBuffer queryString = new StringBuffer();
@ -87,6 +90,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
pageUtil.setPageList(query.list()); pageUtil.setPageList(query.list());
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException { public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException {
StringBuffer queryString = new StringBuffer(); StringBuffer queryString = new StringBuffer();
@ -185,6 +189,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
pageUtil.setPageList(query.list()); pageUtil.setPageList(query.list());
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException { public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException {
StringBuffer queryString = new StringBuffer(); StringBuffer queryString = new StringBuffer();

View File

@ -1,30 +1,28 @@
package com.jsh.dao.materials; package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.DepotHead; import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness; import com.jsh.util.JshException;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
public interface DepotHeadIDAO extends BaseIDAO<DepotHead> public interface DepotHeadIDAO extends BaseIDAO<DepotHead> {
{ /*
/* * 获取MaxId
* 获取MaxId */
*/ void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException;
void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException;
void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException; void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException;
public void batchSetStatus(Boolean status,String depotHeadIDs); void batchSetStatus(Boolean status, String depotHeadIDs);
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException; void findInDetail(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException;
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids, Long oId) throws JshException; void findInOutMaterialCount(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException;
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId) throws JshException; void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) throws JshException;
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId, String supType) throws JshException; void findStatementAccount(PageUtil pageUtil, String beginTime, String endTime, Long organId, String supType) throws JshException;
void getHeaderIdByMaterial(PageUtil pageUtil, String materialParam, String depotIds) throws JshException;
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException;
} }

View File

@ -15,15 +15,15 @@ public interface DepotHeadIService extends BaseIService<DepotHead>
void findAllMoney(PageUtil<DepotHead> depotHead, Integer supplierId, String type, String subType, String mode)throws JshException; void findAllMoney(PageUtil<DepotHead> depotHead, Integer supplierId, String type, String subType, String mode)throws JshException;
public void batchSetStatus(Boolean status,String depotHeadIDs); void batchSetStatus(Boolean status,String depotHeadIDs);
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids,Long oId)throws JshException; void findInDetail(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids,Long oId)throws JshException;
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids,Long oId)throws JshException; void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids,Long oId)throws JshException;
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId)throws JshException; void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId)throws JshException;
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime, Long organId, String supType)throws JshException; void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime, Long organId, String supType)throws JshException;
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds)throws JshException; void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds)throws JshException;
} }

View File

@ -2,59 +2,62 @@ package com.jsh.service.materials;
import com.jsh.base.BaseService; import com.jsh.base.BaseService;
import com.jsh.dao.materials.DepotHeadIDAO; import com.jsh.dao.materials.DepotHeadIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.DepotHead; import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness; import com.jsh.util.JshException;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
public class DepotHeadService extends BaseService<DepotHead> implements DepotHeadIService public class DepotHeadService extends BaseService<DepotHead> implements DepotHeadIService {
{ @SuppressWarnings("unused")
@SuppressWarnings("unused") private DepotHeadIDAO depotHeadDao;
private DepotHeadIDAO depotHeadDao;
public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) {
this.depotHeadDao = depotHeadDao;
}
@Override public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) {
protected Class<DepotHead> getEntityClass() this.depotHeadDao = depotHeadDao;
{
return DepotHead.class;
}
public void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException
{
depotHeadDao.find(pageUtil, maxid);
}
public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException
{
depotHeadDao.findAllMoney(pageUtil, supplierId, type, subType, mode);
} }
public void batchSetStatus(Boolean status,String depotHeadIDs){
depotHeadDao.batchSetStatus(status, depotHeadIDs);
}
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException { @Override
depotHeadDao.findInDetail(pageUtil,beginTime,endTime,type,pid,dids,oId); protected Class<DepotHead> getEntityClass() {
} return DepotHead.class;
}
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException { @Override
depotHeadDao.findInOutMaterialCount(pageUtil,beginTime,endTime,type,pid,dids,oId); public void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException {
} depotHeadDao.find(pageUtil, maxid);
}
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId) throws JshException { @Override
depotHeadDao.findMaterialsListByHeaderId(pageUtil, headerId); public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException {
} depotHeadDao.findAllMoney(pageUtil, supplierId, type, subType, mode);
}
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId, String supType) throws JshException { @Override
depotHeadDao.findStatementAccount(pageUtil, beginTime, endTime, organId, supType); public void batchSetStatus(Boolean status, String depotHeadIDs) {
} depotHeadDao.batchSetStatus(status, depotHeadIDs);
}
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException { @Override
depotHeadDao.getHeaderIdByMaterial(pageUtil, materialParam, depotIds); public void findInDetail(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException {
} depotHeadDao.findInDetail(pageUtil, beginTime, endTime, type, pid, dids, oId);
}
@Override
public void findInOutMaterialCount(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException {
depotHeadDao.findInOutMaterialCount(pageUtil, beginTime, endTime, type, pid, dids, oId);
}
@Override
public void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) throws JshException {
depotHeadDao.findMaterialsListByHeaderId(pageUtil, headerId);
}
@Override
public void findStatementAccount(PageUtil pageUtil, String beginTime, String endTime, Long organId, String supType) throws JshException {
depotHeadDao.findStatementAccount(pageUtil, beginTime, endTime, organId, supType);
}
@Override
public void getHeaderIdByMaterial(PageUtil pageUtil, String materialParam, String depotIds) throws JshException {
depotHeadDao.getHeaderIdByMaterial(pageUtil, materialParam, depotIds);
}
} }

View File

@ -1,3 +1,3 @@
stmp=smtp.126.com stmp=smtp.gaodonghua.com
emailname=accountnms@126.com emailname=alan@gaodonghua.com
password=public password=1QAZ2wsx

View File

@ -1,4 +1,4 @@
jdbcUrl= jdbc\:mysql\://localhost\:3306/jsh_erp?useUnicode\=true&characterEncoding\=UTF-8 jdbcUrl= jdbc\:mysql\://mysql.gaodonghua.com\:13306/jsh_erp?useUnicode\=true&characterEncoding\=UTF-8
driverClass= com.mysql.jdbc.Driver driverClass= com.mysql.jdbc.Driver
user= root user= root
password=1234 password=Alan!@#