update
This commit is contained in:
parent
35e9301b5e
commit
546aa7ec40
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
*.iml
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
@ -12,5 +13,7 @@
|
||||
hs_err_pid*
|
||||
|
||||
.idea
|
||||
/target
|
||||
|
||||
**/*.iml
|
||||
|
||||
|
||||
@ -1,41 +1,30 @@
|
||||
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.Log;
|
||||
import com.jsh.util.AssetConstants;
|
||||
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.po.*;
|
||||
import com.jsh.model.vo.asset.AssetModel;
|
||||
import com.jsh.service.asset.AssetIService;
|
||||
import com.jsh.service.basic.AssetNameIService;
|
||||
import com.jsh.service.basic.CategoryIService;
|
||||
import com.jsh.service.basic.SupplierIService;
|
||||
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.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")
|
||||
public class AssetAction extends BaseAction<AssetModel>
|
||||
{
|
||||
public class AssetAction extends BaseAction<AssetModel> {
|
||||
private AssetModel model = new AssetModel();
|
||||
private AssetIService assetService;
|
||||
private CategoryIService categoryService;
|
||||
@ -43,87 +32,78 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
private UserIService userService;
|
||||
private AssetNameIService assetnameService;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public String getBasicData()
|
||||
{
|
||||
Map<String,List> mapData = model.getShowModel().getMap();
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public String getBasicData() {
|
||||
Map<String, List> mapData = model.getShowModel().getMap();
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
try
|
||||
{
|
||||
Map<String,Object> condition = pageUtil.getAdvSearch();
|
||||
try {
|
||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
||||
condition.put("id_s_order", "desc");
|
||||
categoryService.find(pageUtil);
|
||||
mapData.put("categoryList", pageUtil.getPageList());
|
||||
supplierService.find(pageUtil);
|
||||
mapData.put("supplierList", pageUtil.getPageList());
|
||||
|
||||
|
||||
condition.put("isystem_n_eq", 1);
|
||||
condition.put("id_s_order", "desc");
|
||||
userService.find(pageUtil);
|
||||
mapData.put("userList", pageUtil.getPageList());
|
||||
|
||||
|
||||
//清除搜索条件 防止对查询有影响
|
||||
condition.remove("isystem_n_eq");
|
||||
|
||||
|
||||
assetnameService.find(pageUtil);
|
||||
mapData.put("assetnameList", pageUtil.getPageList());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
||||
model.getShowModel().setMsgTip("exceptoin");
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加资产
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void create()
|
||||
{
|
||||
public void create() {
|
||||
Log.infoFileSync("==================开始调用增加资产方法===================");
|
||||
Boolean flag = false;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Asset asset = new Asset();
|
||||
//添加设置
|
||||
asset.setAssetname(new Assetname(model.getAssetNameID()));
|
||||
|
||||
|
||||
asset.setLocation(model.getLocation());
|
||||
asset.setStatus(model.getStatus());
|
||||
asset.setPrice(model.getPrice());
|
||||
|
||||
if(null != model.getUserID())
|
||||
{
|
||||
asset.setUser( new Basicuser(model.getUserID()));
|
||||
|
||||
if (null != model.getUserID()) {
|
||||
asset.setUser(new Basicuser(model.getUserID()));
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
//购买日期
|
||||
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.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
} catch (ParseException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
||||
}
|
||||
|
||||
|
||||
asset.setAssetnum(model.getAssetnum());
|
||||
asset.setSerialnum(model.getSerialnum());
|
||||
asset.setLabels(model.getLabels());
|
||||
|
||||
asset.setSupplier( new Supplier(model.getSupplierID()));
|
||||
|
||||
asset.setSupplier(new Supplier(model.getSupplierID()));
|
||||
asset.setDescription(model.getDescription());
|
||||
|
||||
asset.setCreatetime(new Timestamp(new Date().getTime()));
|
||||
|
||||
asset.setCreatetime(new Timestamp(System.currentTimeMillis()));
|
||||
asset.setCreator(getUser());
|
||||
asset.setUpdatetime(new Timestamp(new Date().getTime()));
|
||||
asset.setUpdatetime(new Timestamp(System.currentTimeMillis()));
|
||||
asset.setUpdator(getUser());
|
||||
asset.setAddMonth(Tools.getCurrentMonth());
|
||||
assetService.create(asset);
|
||||
@ -132,47 +112,37 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
//记录操作日志使用
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
} catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产异常", e);
|
||||
flag = false;
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
} finally {
|
||||
try {
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>增加资产回写客户端结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logService.create(new Logdetails(getUser(), "增加资产", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "增加资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "!", "增加资产" + tipMsg));
|
||||
, tipType, "增加资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "增加资产" + tipMsg));
|
||||
Log.infoFileSync("==================结束调用增加资产方法===================");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除资产
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String delete()
|
||||
{
|
||||
public String delete() {
|
||||
Log.infoFileSync("====================开始调用删除资产信息方法delete()================");
|
||||
try
|
||||
{
|
||||
try {
|
||||
assetService.delete(model.getAssetID());
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
} catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e);
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
@ -180,128 +150,114 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
model.getShowModel().setMsgTip(tipMsg);
|
||||
logService.create(new Logdetails(getUser(), "删除资产", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "删除资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "删除资产" + tipMsg));
|
||||
, tipType, "删除资产ID为 " + model.getAssetID() + " " + tipMsg + "!", "删除资产" + tipMsg));
|
||||
Log.infoFileSync("====================结束调用删除资产信息方法delete()================");
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新资产
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
Boolean flag = false;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Asset asset = assetService.get(model.getAssetID());
|
||||
|
||||
|
||||
//设置要更新的熟悉值
|
||||
asset.setAssetname(new Assetname(model.getAssetNameID()));
|
||||
|
||||
|
||||
asset.setLocation(model.getLocation());
|
||||
asset.setStatus(model.getStatus());
|
||||
asset.setPrice(model.getPrice());
|
||||
|
||||
if(null != model.getUserID())
|
||||
|
||||
if (null != model.getUserID()) {
|
||||
asset.setUser(new Basicuser(model.getUserID()));
|
||||
else
|
||||
asset.setUser(null);
|
||||
try
|
||||
{
|
||||
} else {
|
||||
asset.setUser(null);
|
||||
}
|
||||
try {
|
||||
//购买日期
|
||||
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.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
} catch (ParseException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
||||
}
|
||||
|
||||
|
||||
asset.setAssetnum(model.getAssetnum());
|
||||
asset.setSerialnum(model.getSerialnum());
|
||||
asset.setLabels(model.getLabels());
|
||||
|
||||
|
||||
asset.setSupplier(new Supplier(model.getSupplierID()));
|
||||
asset.setDescription(model.getDescription());
|
||||
|
||||
asset.setUpdatetime(new Timestamp(new Date().getTime()));
|
||||
|
||||
asset.setUpdatetime(new Timestamp(System.currentTimeMillis()));
|
||||
asset.setUpdator(getUser());
|
||||
assetService.update(asset);
|
||||
flag = true;
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
} catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 : " + model.getAssetID() + "信息失败", e);
|
||||
flag = false;
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
} finally {
|
||||
try {
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>修改资产回写客户端结果异常", e);
|
||||
}
|
||||
}
|
||||
logService.create(new Logdetails(getUser(), "更新资产", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "更新资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "更新资产" + tipMsg));
|
||||
, tipType, "更新资产ID为 " + model.getAssetID() + " " + tipMsg + "!", "更新资产" + tipMsg));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除指定ID资产
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String batchDelete()
|
||||
{
|
||||
try
|
||||
{
|
||||
public String batchDelete() {
|
||||
try {
|
||||
assetService.batchDelete(model.getAssetIDs());
|
||||
model.getShowModel().setMsgTip("成功");
|
||||
//记录操作日志使用
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
} catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>批量删除资产ID为:" + model.getAssetIDs() + "信息异常", e);
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
|
||||
|
||||
logService.create(new Logdetails(getUser(), "批量删除资产", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "批量删除资产ID为 "+ model.getAssetIDs() + " " + tipMsg + "!", "批量删除资产" + tipMsg));
|
||||
, tipType, "批量删除资产ID为 " + model.getAssetIDs() + " " + tipMsg + "!", "批量删除资产" + tipMsg));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找资产信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void findBy()
|
||||
{
|
||||
try
|
||||
{
|
||||
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
|
||||
public void findBy() {
|
||||
try {
|
||||
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
pageUtil.setAdvSearch(getCondition());
|
||||
assetService.find(pageUtil);
|
||||
|
||||
|
||||
getSession().put("pageUtil", pageUtil);
|
||||
List<Asset> dataList = pageUtil.getPageList();
|
||||
|
||||
|
||||
//开始拼接json数据
|
||||
// {"total":28,"rows":[
|
||||
// {"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());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(Asset asset:dataList)
|
||||
{
|
||||
if (null != dataList) {
|
||||
for (Asset asset : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", asset.getId());
|
||||
//添加资产属性
|
||||
@ -328,25 +282,25 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
item.put("status", getStatusInfo(asset.getStatus()));
|
||||
item.put("statushort", asset.getStatus());
|
||||
//在用用户名称
|
||||
item.put("username", asset.getUser()==null?"":asset.getUser().getUsername());
|
||||
item.put("userID", asset.getUser()==null?"":asset.getUser().getId());
|
||||
item.put("username", asset.getUser() == null ? "" : asset.getUser().getUsername());
|
||||
item.put("userID", asset.getUser() == null ? "" : asset.getUser().getId());
|
||||
//位置
|
||||
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("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("description", Tools.dealNullStr(asset.getDescription()));
|
||||
@ -357,97 +311,80 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
} catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>回写查询资产信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel表格
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String exportExcel()
|
||||
{
|
||||
Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始=======================");
|
||||
try
|
||||
{
|
||||
PageUtil<Asset> pageUtil = (PageUtil<Asset>)getSession().get("pageUtil");
|
||||
|
||||
* 导出excel表格
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String exportExcel() {
|
||||
Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始=======================");
|
||||
try {
|
||||
PageUtil<Asset> pageUtil = (PageUtil<Asset>) getSession().get("pageUtil");
|
||||
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
//pageUtil.setAdvSearch(getCondition());
|
||||
String isCurrentPage = model.getIsAllData();
|
||||
model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls",model.getBrowserType()));
|
||||
model.setExcelStream(assetService.exmportExcel(isCurrentPage,pageUtil));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常",e);
|
||||
model.getShowModel().setMsgTip("export excel exception");
|
||||
}
|
||||
Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束==================");
|
||||
return AssetConstants.BusinessForExcel.EXCEL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入资产excel表格内容
|
||||
*/
|
||||
public String importExcel()
|
||||
{
|
||||
//资产excel表格file
|
||||
Boolean result = false;
|
||||
String returnStr = "";
|
||||
try
|
||||
{
|
||||
InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck());
|
||||
|
||||
if(null != in)
|
||||
{
|
||||
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
|
||||
model.setExcelStream(in);
|
||||
returnStr = AssetConstants.BusinessForExcel.EXCEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
try
|
||||
{
|
||||
toClient(result.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e);
|
||||
}
|
||||
//导入数据成功
|
||||
returnStr = SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
catch (JshException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e);
|
||||
}
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
String isCurrentPage = model.getIsAllData();
|
||||
model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls", model.getBrowserType()));
|
||||
model.setExcelStream(assetService.exmportExcel(isCurrentPage, pageUtil));
|
||||
} catch (Exception e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常", e);
|
||||
model.getShowModel().setMsgTip("export excel exception");
|
||||
}
|
||||
Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束==================");
|
||||
return AssetConstants.BusinessForExcel.EXCEL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入资产excel表格内容
|
||||
*/
|
||||
public String importExcel() {
|
||||
//资产excel表格file
|
||||
Boolean result = false;
|
||||
String returnStr = "";
|
||||
try {
|
||||
InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck());
|
||||
|
||||
if (null != in) {
|
||||
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
|
||||
model.setExcelStream(in);
|
||||
returnStr = AssetConstants.BusinessForExcel.EXCEL;
|
||||
} else {
|
||||
result = true;
|
||||
try {
|
||||
toClient(result.toString());
|
||||
} catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e);
|
||||
}
|
||||
//导入数据成功
|
||||
returnStr = SUCCESS;
|
||||
}
|
||||
|
||||
} catch (JshException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e);
|
||||
}
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Map<String,Object> getCondition()
|
||||
{
|
||||
private Map<String, Object> getCondition() {
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*/
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
Map<String, Object> condition = new HashMap<String, Object>();
|
||||
condition.put("assetname.id_n_eq", model.getAssetNameID());
|
||||
condition.put("assetname.category.id_n_eq", model.getAssetCategoryID());
|
||||
condition.put("user.id_n_eq", model.getUserID());
|
||||
@ -456,62 +393,57 @@ public class AssetAction extends BaseAction<AssetModel>
|
||||
condition.put("createtime_s_order", "desc");
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据状态码转化成说明字符串
|
||||
* 资产的状态:0==在库,1==在用,2==消费
|
||||
*
|
||||
* @param statusCode
|
||||
* @return
|
||||
*/
|
||||
private String getStatusInfo(short statusCode)
|
||||
{
|
||||
private String getStatusInfo(short statusCode) {
|
||||
String statusInfo = "";
|
||||
switch(statusCode)
|
||||
{
|
||||
switch (statusCode) {
|
||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU:
|
||||
statusInfo = "在库";
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE:
|
||||
statusInfo = "在用";
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME:
|
||||
statusInfo = "消费";
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return statusInfo;
|
||||
}
|
||||
|
||||
|
||||
//=========Spring注入以及model驱动公共方法===========
|
||||
public void setAssetService(AssetIService assetService)
|
||||
{
|
||||
public void setAssetService(AssetIService assetService) {
|
||||
this.assetService = assetService;
|
||||
}
|
||||
|
||||
public void setCategoryService(CategoryIService categoryService)
|
||||
{
|
||||
|
||||
public void setCategoryService(CategoryIService categoryService) {
|
||||
this.categoryService = categoryService;
|
||||
}
|
||||
|
||||
public void setSupplierService(SupplierIService supplierService)
|
||||
{
|
||||
public void setSupplierService(SupplierIService supplierService) {
|
||||
this.supplierService = supplierService;
|
||||
}
|
||||
|
||||
public void setUserService(UserIService userService)
|
||||
{
|
||||
public void setUserService(UserIService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public void setAssetnameService(AssetNameIService assetnameService)
|
||||
{
|
||||
|
||||
public void setAssetnameService(AssetNameIService assetnameService) {
|
||||
this.assetnameService = assetnameService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetModel getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
@Override
|
||||
public AssetModel getModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,73 +1,69 @@
|
||||
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.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")
|
||||
public class ReportAction extends BaseAction<ReportModel>
|
||||
{
|
||||
public class ReportAction extends BaseAction<ReportModel> {
|
||||
private ReportModel model = new ReportModel();
|
||||
private ReportIService reportService;
|
||||
|
||||
|
||||
/**
|
||||
* 查找资产信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String find()
|
||||
{
|
||||
try
|
||||
{
|
||||
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
|
||||
public String find() {
|
||||
try {
|
||||
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
pageUtil.setAdvSearch(getCondition());
|
||||
String reportType = getReportType(new HashMap<String,Object>());
|
||||
reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]);
|
||||
String reportType = getReportType(new HashMap<String, Object>());
|
||||
reportService.find(pageUtil, reportType.split("_")[0], reportType.split("_")[1]);
|
||||
model.getShowModel().setReportData(pageUtil.getPageList());
|
||||
}
|
||||
catch (JshException e)
|
||||
{
|
||||
} catch (JshException e) {
|
||||
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
|
||||
model.getShowModel().setMsgTip("get report data exception");
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Map<String,Object> getCondition()
|
||||
{
|
||||
private Map<String, Object> getCondition() {
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*/
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
Map<String, Object> condition = new HashMap<String, Object>();
|
||||
condition.put("assetname.id_n_eq", model.getAssetNameID());
|
||||
condition.put("assetname.category.id_n_eq", model.getAssetCategoryID());
|
||||
condition.put("user.id_n_eq", model.getUsernameID());
|
||||
condition.put("status_n_eq", model.getStatus());
|
||||
condition.put("supplier.id_n_eq", model.getSupplierID());
|
||||
condition.put("dataSum_s_order","desc");
|
||||
condition.put("dataSum_s_order", "desc");
|
||||
//拼接统计数据条件
|
||||
getReportType(condition);
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取统计条件
|
||||
*
|
||||
* @param condition
|
||||
*/
|
||||
private String getReportType(Map<String,Object> condition)
|
||||
{
|
||||
private String getReportType(Map<String, Object> condition) {
|
||||
// <option value="0">资产状态</option>
|
||||
// <option value="1">资产类型</option>
|
||||
// <option value="2">供应商</option>
|
||||
@ -76,8 +72,7 @@ public class ReportAction extends BaseAction<ReportModel>
|
||||
int reportType = model.getReportType();
|
||||
String reportTypeInfo = "";
|
||||
String reportTypeName = "";
|
||||
switch(reportType)
|
||||
{
|
||||
switch (reportType) {
|
||||
case 0:
|
||||
condition.put("status_s_gb", "group");
|
||||
reportTypeInfo = "status";
|
||||
@ -103,18 +98,19 @@ public class ReportAction extends BaseAction<ReportModel>
|
||||
reportTypeInfo = "user.id";
|
||||
reportTypeName = "user.username";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return reportTypeInfo + "_" + reportTypeName;
|
||||
}
|
||||
|
||||
//=========Spring注入以及model驱动公共方法===========
|
||||
public void setReportService(ReportIService reportService)
|
||||
{
|
||||
public void setReportService(ReportIService reportService) {
|
||||
this.reportService = reportService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportModel getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
@Override
|
||||
public ReportModel getModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
depotHead.setDefaultNumber(allNewNumber); //初始编号,一直都从后台取值
|
||||
|
||||
depotHead.setOperPersonName(getUser().getUsername());
|
||||
depotHead.setCreateTime(new Timestamp(new Date().getTime()));
|
||||
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
try{
|
||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
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()));
|
||||
@ -28,6 +29,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException
|
||||
{
|
||||
Query query;
|
||||
@ -51,6 +53,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
query.executeUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
@ -87,6 +90,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids,Long oId) throws JshException {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
@ -185,6 +189,7 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
|
||||
@ -1,30 +1,28 @@
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.util.PageUtil;
|
||||
|
||||
public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
|
||||
{
|
||||
/*
|
||||
* 获取MaxId
|
||||
*/
|
||||
void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException;
|
||||
|
||||
public interface DepotHeadIDAO extends BaseIDAO<DepotHead> {
|
||||
/*
|
||||
* 获取MaxId
|
||||
*/
|
||||
void find(PageUtil<DepotHead> pageUtil, String maxid) 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;
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2,59 +2,62 @@ package com.jsh.service.materials;
|
||||
|
||||
import com.jsh.base.BaseService;
|
||||
import com.jsh.dao.materials.DepotHeadIDAO;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.util.PageUtil;
|
||||
|
||||
public class DepotHeadService extends BaseService<DepotHead> implements DepotHeadIService
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private DepotHeadIDAO depotHeadDao;
|
||||
|
||||
|
||||
public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) {
|
||||
this.depotHeadDao = depotHeadDao;
|
||||
}
|
||||
public class DepotHeadService extends BaseService<DepotHead> implements DepotHeadIService {
|
||||
@SuppressWarnings("unused")
|
||||
private DepotHeadIDAO depotHeadDao;
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<DepotHead> getEntityClass()
|
||||
{
|
||||
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 setDepotHeadDao(DepotHeadIDAO depotHeadDao) {
|
||||
this.depotHeadDao = depotHeadDao;
|
||||
}
|
||||
|
||||
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 {
|
||||
depotHeadDao.findInDetail(pageUtil,beginTime,endTime,type,pid,dids,oId);
|
||||
}
|
||||
@Override
|
||||
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 {
|
||||
depotHeadDao.findInOutMaterialCount(pageUtil,beginTime,endTime,type,pid,dids,oId);
|
||||
}
|
||||
@Override
|
||||
public void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException {
|
||||
depotHeadDao.find(pageUtil, maxid);
|
||||
}
|
||||
|
||||
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId) throws JshException {
|
||||
depotHeadDao.findMaterialsListByHeaderId(pageUtil, headerId);
|
||||
}
|
||||
@Override
|
||||
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 {
|
||||
depotHeadDao.findStatementAccount(pageUtil, beginTime, endTime, organId, supType);
|
||||
}
|
||||
@Override
|
||||
public void batchSetStatus(Boolean status, String depotHeadIDs) {
|
||||
depotHeadDao.batchSetStatus(status, depotHeadIDs);
|
||||
}
|
||||
|
||||
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam,String depotIds) throws JshException {
|
||||
depotHeadDao.getHeaderIdByMaterial(pageUtil, materialParam, depotIds);
|
||||
}
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
stmp=smtp.126.com
|
||||
emailname=accountnms@126.com
|
||||
password=public
|
||||
stmp=smtp.gaodonghua.com
|
||||
emailname=alan@gaodonghua.com
|
||||
password=1QAZ2wsx
|
||||
@ -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
|
||||
user= root
|
||||
password=1234
|
||||
password=Alan!@#
|
||||
Loading…
Reference in New Issue
Block a user