更新后端,采用Springboot+mybatis
This commit is contained in:
40
src/main/assembly/package.xml
Normal file
40
src/main/assembly/package.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
|
||||||
|
http://maven.apache.org/xsd/assembly-1.1.0.xsd
|
||||||
|
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 ">
|
||||||
|
<id>package</id>
|
||||||
|
<formats>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<moduleSets>
|
||||||
|
<moduleSet>
|
||||||
|
<includes>
|
||||||
|
</includes>
|
||||||
|
</moduleSet>
|
||||||
|
</moduleSets>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<directory>src/main/conf</directory>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>erp_web</directory>
|
||||||
|
<outputDirectory>/erp_web</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
<files>
|
||||||
|
<file>
|
||||||
|
<source>src/main/resources/application.yml</source>
|
||||||
|
<outputDirectory>/conf</outputDirectory>
|
||||||
|
</file>
|
||||||
|
</files>
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<outputDirectory>lib</outputDirectory>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
</assembly>
|
||||||
6
src/main/conf/jshERPStart.bat
Normal file
6
src/main/conf/jshERPStart.bat
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
title jshERP
|
||||||
|
|
||||||
|
java -Xms1000m -Xmx2000m -cp .\conf;.\lib\*; -XX:+CreateMinidumpOnCrash com.jsh.erp.ErpApplication
|
||||||
|
pause over
|
||||||
1
src/main/conf/jshERPStart.sh
Normal file
1
src/main/conf/jshERPStart.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
java -XX:+CreateMinidumpOnCrash -cp ./conf:./lib/*: com.jsh.erp.ErpApplication
|
||||||
@@ -1,452 +0,0 @@
|
|||||||
package com.jsh.action.asset;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
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.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AssetAction extends BaseAction<AssetModel> {
|
|
||||||
private AssetModel model = new AssetModel();
|
|
||||||
private AssetIService assetService;
|
|
||||||
private CategoryIService categoryService;
|
|
||||||
private SupplierIService supplierService;
|
|
||||||
private UserIService userService;
|
|
||||||
private AssetNameIService assetnameService;
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.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) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加资产
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加资产方法===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
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.setCreatetime(new Timestamp(System.currentTimeMillis()));
|
|
||||||
asset.setCreator(getUser());
|
|
||||||
asset.setUpdatetime(new Timestamp(System.currentTimeMillis()));
|
|
||||||
asset.setUpdator(getUser());
|
|
||||||
asset.setAddMonth(Tools.getCurrentMonth());
|
|
||||||
assetService.create(asset);
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加资产回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加资产", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "增加资产" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加资产方法===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除资产
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除资产信息方法delete()================");
|
|
||||||
try {
|
|
||||||
assetService.delete(model.getAssetID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除资产", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除资产ID为 " + model.getAssetID() + " " + tipMsg + "!", "删除资产" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除资产信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新资产
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
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()) {
|
|
||||||
asset.setUser(new Basicuser(model.getUserID()));
|
|
||||||
} 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) {
|
|
||||||
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(System.currentTimeMillis()));
|
|
||||||
asset.setUpdator(getUser());
|
|
||||||
assetService.update(asset);
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 : " + model.getAssetID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改资产回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新资产", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新资产ID为 " + model.getAssetID() + " " + tipMsg + "!", "更新资产" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID资产
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
assetService.batchDelete(model.getAssetIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} 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));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找资产信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
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"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Asset asset : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", asset.getId());
|
|
||||||
//添加资产属性
|
|
||||||
item.put("assetname", asset.getAssetname().getAssetname());
|
|
||||||
item.put("assetnameID", asset.getAssetname().getId());
|
|
||||||
//单价
|
|
||||||
item.put("price", Tools.dealNullStr(asset.getPrice() + ""));
|
|
||||||
//分类
|
|
||||||
item.put("category", asset.getAssetname().getCategory().getAssetname());
|
|
||||||
item.put("categoryID", asset.getAssetname().getCategory().getId());
|
|
||||||
//资产的状态:0==在库,1==在用,2==消费
|
|
||||||
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("location", Tools.dealNullStr(asset.getLocation()));
|
|
||||||
|
|
||||||
//购买日期
|
|
||||||
item.put("purchasedate", asset.getPurchasedate() == null ? "" : Tools.getCurrentMonth(asset.getPurchasedate()));
|
|
||||||
//有效日期
|
|
||||||
item.put("periodofvalidity", asset.getPeriodofvalidity() == null ? "" : Tools.getCurrentMonth(asset.getPeriodofvalidity()));
|
|
||||||
//保修日期
|
|
||||||
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("supplierID", asset.getSupplier() == null ? "" : asset.getSupplier().getId());
|
|
||||||
//标签
|
|
||||||
item.put("labels", Tools.dealNullStr(asset.getLabels()));
|
|
||||||
item.put("description", Tools.dealNullStr(asset.getDescription()));
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找资产信息异常", 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");
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
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());
|
|
||||||
condition.put("status_n_eq", model.getStatus());
|
|
||||||
condition.put("supplier.id_n_eq", model.getSupplierID());
|
|
||||||
condition.put("createtime_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据状态码转化成说明字符串
|
|
||||||
* 资产的状态:0==在库,1==在用,2==消费
|
|
||||||
*
|
|
||||||
* @param statusCode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getStatusInfo(short statusCode) {
|
|
||||||
String statusInfo = "";
|
|
||||||
switch (statusCode) {
|
|
||||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU:
|
|
||||||
statusInfo = "在库";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE:
|
|
||||||
statusInfo = "在用";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME:
|
|
||||||
statusInfo = "消费";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return statusInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========Spring注入以及model驱动公共方法===========
|
|
||||||
public void setAssetService(AssetIService assetService) {
|
|
||||||
this.assetService = assetService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCategoryService(CategoryIService categoryService) {
|
|
||||||
this.categoryService = categoryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupplierService(SupplierIService supplierService) {
|
|
||||||
this.supplierService = supplierService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserService(UserIService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssetnameService(AssetNameIService assetnameService) {
|
|
||||||
this.assetnameService = assetnameService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AssetModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
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>();
|
|
||||||
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]);
|
|
||||||
model.getShowModel().setReportData(pageUtil.getPageList());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("get report data exception");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
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");
|
|
||||||
//拼接统计数据条件
|
|
||||||
getReportType(condition);
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取统计条件
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
*/
|
|
||||||
private String getReportType(Map<String, Object> condition) {
|
|
||||||
// <option value="0">资产状态</option>
|
|
||||||
// <option value="1">资产类型</option>
|
|
||||||
// <option value="2">供应商</option>
|
|
||||||
// <option value="3">资产名称</option>
|
|
||||||
// <option value="4">所属用户</option>
|
|
||||||
int reportType = model.getReportType();
|
|
||||||
String reportTypeInfo = "";
|
|
||||||
String reportTypeName = "";
|
|
||||||
switch (reportType) {
|
|
||||||
case 0:
|
|
||||||
condition.put("status_s_gb", "group");
|
|
||||||
reportTypeInfo = "status";
|
|
||||||
reportTypeName = "status";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
condition.put("assetname.category.id_s_gb", "group");
|
|
||||||
reportTypeInfo = "assetname.category.id";
|
|
||||||
reportTypeName = "assetname.category.assetname";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
condition.put("supplier.id_s_gb", "group");
|
|
||||||
reportTypeInfo = "supplier.id";
|
|
||||||
reportTypeName = "supplier.supplier";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
condition.put("assetname.id_s_gb", "group");
|
|
||||||
reportTypeInfo = "assetname.id";
|
|
||||||
reportTypeName = "assetname.assetname";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
condition.put("user.id_s_gb", "group");
|
|
||||||
reportTypeInfo = "user.id";
|
|
||||||
reportTypeName = "user.username";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return reportTypeInfo + "_" + reportTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========Spring注入以及model驱动公共方法===========
|
|
||||||
public void setReportService(ReportIService reportService) {
|
|
||||||
this.reportService = reportService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReportModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,683 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.*;
|
|
||||||
import com.jsh.model.vo.basic.AccountModel;
|
|
||||||
import com.jsh.service.basic.AccountIService;
|
|
||||||
import com.jsh.service.materials.AccountHeadIService;
|
|
||||||
import com.jsh.service.materials.AccountItemIService;
|
|
||||||
import com.jsh.service.materials.DepotHeadIService;
|
|
||||||
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.sql.Timestamp;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 结算账户
|
|
||||||
*
|
|
||||||
* @author ji sheng hua qq7527-18920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AccountAction extends BaseAction<AccountModel> {
|
|
||||||
private AccountIService accountService;
|
|
||||||
private DepotHeadIService depotHeadService;
|
|
||||||
private AccountHeadIService accountHeadService;
|
|
||||||
private AccountItemIService accountItemService;
|
|
||||||
private AccountModel model = new AccountModel();
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getAccount() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
accountService.find(pageUtil);
|
|
||||||
mapData.put("accountList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找账户信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exception");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加结算账户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加结算账户方法===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Account Account = new Account();
|
|
||||||
Account.setName(model.getName());
|
|
||||||
Account.setSerialNo(model.getSerialNo());
|
|
||||||
Account.setInitialAmount(model.getInitialAmount() != null ? model.getInitialAmount() : 0);
|
|
||||||
Account.setCurrentAmount(model.getCurrentAmount());
|
|
||||||
Account.setRemark(model.getRemark());
|
|
||||||
accountService.create(Account);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加结算账户异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加结算账户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加结算账户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加结算账户名称为 " + model.getName() + " " + tipMsg + "!", "增加结算账户" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加结算账户方法===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除结算账户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除结算账户信息方法delete()================");
|
|
||||||
try {
|
|
||||||
accountService.delete(model.getAccountID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAccountID() + " 的结算账户异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除结算账户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除结算账户ID为 " + model.getAccountID() + ",名称为 " + model.getName() + tipMsg + "!", "删除结算账户" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除结算账户信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新结算账户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Account Account = accountService.get(model.getAccountID());
|
|
||||||
Account.setName(model.getName());
|
|
||||||
Account.setSerialNo(model.getSerialNo());
|
|
||||||
Account.setInitialAmount(model.getInitialAmount() != null ? model.getInitialAmount() : 0);
|
|
||||||
Account.setCurrentAmount(model.getCurrentAmount());
|
|
||||||
Account.setRemark(model.getRemark());
|
|
||||||
accountService.update(Account);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改结算账户ID为 : " + model.getAccountID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改结算账户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新结算账户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新结算账户ID为 " + model.getAccountID() + " " + tipMsg + "!", "更新结算账户" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新结算账户金额
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void updateAmount() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Account Account = accountService.get(model.getAccountID());
|
|
||||||
Account.setCurrentAmount(model.getCurrentAmount());
|
|
||||||
accountService.update(Account);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改结算账户ID为 : " + model.getAccountID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改结算账户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新结算账户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新结算账户ID为 " + model.getAccountID() + " " + tipMsg + "!", "更新结算账户" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新结算账户-设置是否默认
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void updateAmountIsDefault() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Account Account = accountService.get(model.getAccountID());
|
|
||||||
Account.setIsDefault(model.getIsDefault());
|
|
||||||
accountService.update(Account);
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改结算账户ID为 : " + model.getAccountID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改结算账户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如果改为默认账户时记录日志
|
|
||||||
if (model.getIsDefault()) {
|
|
||||||
logService.create(new Logdetails(getUser(), "更新默认账户", model.getClientIp(), new Timestamp(System.currentTimeMillis()),
|
|
||||||
tipType, "更新账户ID" + model.getAccountID() + "为默认账户" + tipMsg + "!", "更新默认账户" + tipMsg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID结算账户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
accountService.batchDelete(model.getAccountIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除结算账户ID为:" + model.getAccountIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除结算账户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除结算账户ID为 " + model.getAccountIDs() + " " + tipMsg + "!", "批量删除结算账户" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = accountService.checkIsNameExist("name", model.getName(), "id", model.getAccountID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查结算账户名称为:" + model.getName() + " ID为: " + model.getAccountID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查结算账户名称为:" + model.getName() + " ID为: " + model.getAccountID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找结算账户信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Account> pageUtil = new PageUtil<Account>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
accountService.find(pageUtil);
|
|
||||||
List<Account> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Account account : dataList) {
|
|
||||||
DecimalFormat df = new DecimalFormat(".##");
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", account.getId());
|
|
||||||
//结算账户名称
|
|
||||||
item.put("name", account.getName());
|
|
||||||
item.put("serialNo", account.getSerialNo());
|
|
||||||
item.put("initialAmount", account.getInitialAmount());
|
|
||||||
String timeStr = Tools.getCurrentMonth();
|
|
||||||
Double thisMonthAmount = getAccountSum(account.getId(), timeStr, "month") + getAccountSumByHead(account.getId(), timeStr, "month") + getAccountSumByDetail(account.getId(), timeStr, "month") + getManyAccountSum(account.getId(), timeStr, "month");
|
|
||||||
String thisMonthAmountFmt = "0";
|
|
||||||
if (thisMonthAmount != 0) {
|
|
||||||
thisMonthAmountFmt = df.format(thisMonthAmount);
|
|
||||||
}
|
|
||||||
item.put("thisMonthAmount", thisMonthAmountFmt); //本月发生额
|
|
||||||
Double currentAmount = getAccountSum(account.getId(), "", "month") + getAccountSumByHead(account.getId(), "", "month") + getAccountSumByDetail(account.getId(), "", "month") + getManyAccountSum(account.getId(), "", "month") + account.getInitialAmount();
|
|
||||||
String currentAmountFmt = df.format(currentAmount);
|
|
||||||
item.put("currentAmount", currentAmountFmt); //当前余额
|
|
||||||
item.put("isDefault", account.getIsDefault()); //是否默认
|
|
||||||
item.put("remark", account.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找结算账户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询结算账户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个账户的金额求和-入库和出库
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Double getAccountSum(Long id, String timeStr, String type) {
|
|
||||||
Double accountSum = 0.0;
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_getSum(id, timeStr, type));
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (DepotHead depotHead : dataList) {
|
|
||||||
accountSum = accountSum + depotHead.getChangeAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找进销存信息异常", e);
|
|
||||||
}
|
|
||||||
return accountSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个账户的金额求和-收入、支出、转账的单据表头的合计
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Double getAccountSumByHead(Long id, String timeStr, String type) {
|
|
||||||
Double accountSum = 0.0;
|
|
||||||
try {
|
|
||||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_getSumByHead(id, timeStr, type));
|
|
||||||
accountHeadService.find(pageUtil);
|
|
||||||
List<AccountHead> dataList = pageUtil.getPageList();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (AccountHead accountHead : dataList) {
|
|
||||||
accountSum = accountSum + accountHead.getChangeAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找进销存信息异常", e);
|
|
||||||
}
|
|
||||||
return accountSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个账户的金额求和-收款、付款、转账、收预付款的单据明细的合计
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Double getAccountSumByDetail(Long id, String timeStr, String type) {
|
|
||||||
Double accountSum = 0.0;
|
|
||||||
try {
|
|
||||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_getSumByHead(timeStr, type));
|
|
||||||
accountHeadService.find(pageUtil);
|
|
||||||
List<AccountHead> dataList = pageUtil.getPageList();
|
|
||||||
if (dataList != null) {
|
|
||||||
String ids = "";
|
|
||||||
for (AccountHead accountHead : dataList) {
|
|
||||||
ids = ids + accountHead.getId() + ",";
|
|
||||||
}
|
|
||||||
if (!ids.equals("")) {
|
|
||||||
ids = ids.substring(0, ids.length() - 1);
|
|
||||||
}
|
|
||||||
PageUtil<AccountItem> pageUtilOne = new PageUtil<AccountItem>();
|
|
||||||
pageUtilOne.setPageSize(0);
|
|
||||||
pageUtilOne.setCurPage(0);
|
|
||||||
pageUtilOne.setAdvSearch(getCondition_getSumByDetail(id, ids));
|
|
||||||
accountItemService.find(pageUtilOne);
|
|
||||||
List<AccountItem> dataListOne = pageUtilOne.getPageList();
|
|
||||||
if (dataListOne != null) {
|
|
||||||
for (AccountItem accountItem : dataListOne) {
|
|
||||||
accountSum = accountSum + accountItem.getEachAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找进销存信息异常", e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>异常信息:", e);
|
|
||||||
}
|
|
||||||
return accountSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个账户的金额求和-多账户的明细合计
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Double getManyAccountSum(Long id, String timeStr, String type) {
|
|
||||||
Double accountSum = 0.0;
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_getManyAccountSum(id, timeStr, type));
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (DepotHead depotHead : dataList) {
|
|
||||||
String accountIdList = depotHead.getAccountIdList();
|
|
||||||
String accountMoneyList = depotHead.getAccountMoneyList();
|
|
||||||
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
|
|
||||||
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
|
|
||||||
String[] aList = accountIdList.split(",");
|
|
||||||
String[] amList = accountMoneyList.split(",");
|
|
||||||
for (int i = 0; i < aList.length; i++) {
|
|
||||||
if (aList[i].toString().equals(id.toString())) {
|
|
||||||
accountSum = accountSum + Double.parseDouble(amList[i].toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
|
|
||||||
}
|
|
||||||
return accountSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找结算账户信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect() {
|
|
||||||
try {
|
|
||||||
PageUtil<Account> pageUtil = new PageUtil<Account>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_select());
|
|
||||||
accountService.find(pageUtil);
|
|
||||||
List<Account> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Account account : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", account.getId());
|
|
||||||
//结算账户名称
|
|
||||||
item.put("AccountName", account.getName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找结算账户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询结算账户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 账户流水信息
|
|
||||||
*/
|
|
||||||
public void findAccountInOutList() {
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
Long accountId = model.getAccountID();
|
|
||||||
Double initialAmount = model.getInitialAmount();
|
|
||||||
try {
|
|
||||||
accountService.findAccountInOutList(pageUtil, accountId);
|
|
||||||
List dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (Integer i = 0; i < dataList.size(); i++) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
Object dl = dataList.get(i); //获取对象
|
|
||||||
Object[] arr = (Object[]) dl; //转为数组
|
|
||||||
item.put("number", arr[0]); //单据编号
|
|
||||||
item.put("type", arr[1]); //类型
|
|
||||||
item.put("supplierName", arr[2]); //单位信息
|
|
||||||
item.put("changeAmount", arr[3]); //金额
|
|
||||||
String timeStr = arr[4].toString();
|
|
||||||
Double balance = getAccountSum(accountId, timeStr, "date") + getAccountSumByHead(accountId, timeStr, "date")
|
|
||||||
+ getAccountSumByDetail(accountId, timeStr, "date") + getManyAccountSum(accountId, timeStr, "date") + initialAmount;
|
|
||||||
item.put("balance", balance); //余额
|
|
||||||
item.put("operTime", arr[4]); //入库出库日期
|
|
||||||
item.put("aList", arr[5]); //多账户的id列表
|
|
||||||
item.put("amList", arr[6]); //多账户的金额列表
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("name_s_like", model.getName());
|
|
||||||
condition.put("serialNo_s_like", model.getSerialNo());
|
|
||||||
condition.put("remark_s_like", model.getRemark());
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框-结算账户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_select() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_getSum(Long id, String timeStr, String type) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("AccountId_n_eq", id);
|
|
||||||
condition.put("PayType_s_neq", "预付款");
|
|
||||||
if (!timeStr.equals("")) {
|
|
||||||
if (type.equals("month")) {
|
|
||||||
condition.put("OperTime_s_gteq", timeStr + "-01 00:00:00");
|
|
||||||
condition.put("OperTime_s_lteq", timeStr + "-31 00:00:00");
|
|
||||||
} else if (type.equals("date")) {
|
|
||||||
condition.put("OperTime_s_lteq", timeStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_getManyAccountSum(Long id, String timeStr, String type) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("AccountIdList_s_like", "\"" + id.toString() + "\"");
|
|
||||||
if (!timeStr.equals("")) {
|
|
||||||
if (type.equals("month")) {
|
|
||||||
condition.put("OperTime_s_gteq", timeStr + "-01 00:00:00");
|
|
||||||
condition.put("OperTime_s_lteq", timeStr + "-31 00:00:00");
|
|
||||||
} else if (type.equals("date")) {
|
|
||||||
condition.put("OperTime_s_lteq", timeStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_getSumByHead(Long id, String timeStr, String type) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("AccountId_n_eq", id);
|
|
||||||
if (!timeStr.equals("")) {
|
|
||||||
if (type.equals("month")) {
|
|
||||||
condition.put("BillTime_s_gteq", timeStr + "-01 00:00:00");
|
|
||||||
condition.put("BillTime_s_lteq", timeStr + "-31 00:00:00");
|
|
||||||
} else if (type.equals("date")) {
|
|
||||||
condition.put("BillTime_s_lteq", timeStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_getSumByHead(String timeStr, String type) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
if (!timeStr.equals("")) {
|
|
||||||
if (type.equals("month")) {
|
|
||||||
condition.put("BillTime_s_gteq", timeStr + "-01 00:00:00");
|
|
||||||
condition.put("BillTime_s_lteq", timeStr + "-31 00:00:00");
|
|
||||||
} else if (type.equals("date")) {
|
|
||||||
condition.put("BillTime_s_lteq", timeStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_getSumByDetail(Long id, String ids) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("AccountId_n_eq", id);
|
|
||||||
if (!ids.equals("")) {
|
|
||||||
condition.put("HeaderId_s_in", ids);
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public AccountModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountService(AccountIService accountService) {
|
|
||||||
this.accountService = accountService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDepotHeadService(DepotHeadIService depotHeadService) {
|
|
||||||
this.depotHeadService = depotHeadService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountHeadService(AccountHeadIService accountHeadService) {
|
|
||||||
this.accountHeadService = accountHeadService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountItemService(AccountItemIService accountItemService) {
|
|
||||||
this.accountItemService = accountItemService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,482 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.App;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.AppModel;
|
|
||||||
import com.jsh.service.basic.AppIService;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.apache.struts2.ServletActionContext;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用
|
|
||||||
*
|
|
||||||
* @author ji_sheng_hua qq752 718 920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AppAction extends BaseAction<AppModel> {
|
|
||||||
private AppIService appService;
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private AppModel model = new AppModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传图片
|
|
||||||
*/
|
|
||||||
public void uploadImg() {
|
|
||||||
Log.infoFileSync("==================开始调用上传图片方法uploadImg()===================");
|
|
||||||
File fileInfo = model.getFileInfo();
|
|
||||||
String fileName = model.getFileInfoName(); //获取文件名
|
|
||||||
try {
|
|
||||||
if (fileInfo != null) {
|
|
||||||
String path = ServletActionContext.getServletContext().getRealPath("/upload/images/deskIcon");
|
|
||||||
InputStream is = new FileInputStream(fileInfo);
|
|
||||||
File file = new File(path, fileName);
|
|
||||||
OutputStream os = new FileOutputStream(file);
|
|
||||||
byte[] b = new byte[1024];
|
|
||||||
int bs = 0;
|
|
||||||
while ((bs = is.read(b)) > 0) {
|
|
||||||
os.write(b, 0, bs);
|
|
||||||
}
|
|
||||||
is.close();
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
Log.infoFileSync("==================结束调用上传图片方法uploadImg()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加应用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加应用方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
App app = new App();
|
|
||||||
app.setNumber(model.getNumber());
|
|
||||||
app.setName(model.getName());
|
|
||||||
app.setType(model.getType());
|
|
||||||
app.setIcon(model.getIcon()); //设置图片Icon
|
|
||||||
app.setURL(model.getURL());
|
|
||||||
app.setWidth(model.getWidth());
|
|
||||||
app.setHeight(model.getHeight());
|
|
||||||
app.setReSize(model.getReSize());
|
|
||||||
app.setOpenMax(model.getOpenMax());
|
|
||||||
app.setFlash(model.getFlash());
|
|
||||||
app.setZL(model.getZL());
|
|
||||||
app.setSort(model.getSort());
|
|
||||||
app.setRemark(model.getRemark());
|
|
||||||
app.setEnabled(model.getEnabled());
|
|
||||||
appService.create(app);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加应用异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加应用回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加应用", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加应用名称为 " + model.getName() + " " + tipMsg + "!", "增加应用" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加应用方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除应用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除应用方法delete()================");
|
|
||||||
try {
|
|
||||||
appService.delete(model.getAppID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAppID() + " 的应用异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除应用", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除应用ID为 " + model.getAppID() + " " + tipMsg + "!", "删除应用" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除应用方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
App app = appService.get(model.getAppID());
|
|
||||||
app.setNumber(model.getNumber());
|
|
||||||
app.setName(model.getName());
|
|
||||||
app.setType(model.getType());
|
|
||||||
//app.setIcon(model.getIcon());
|
|
||||||
app.setURL(model.getURL());
|
|
||||||
app.setWidth(model.getWidth());
|
|
||||||
app.setHeight(model.getHeight());
|
|
||||||
app.setReSize(model.getReSize());
|
|
||||||
app.setOpenMax(model.getOpenMax());
|
|
||||||
app.setFlash(model.getFlash());
|
|
||||||
app.setZL(model.getZL());
|
|
||||||
app.setSort(model.getSort());
|
|
||||||
app.setRemark(model.getRemark());
|
|
||||||
app.setEnabled(model.getEnabled());
|
|
||||||
appService.update(app);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改应用ID为 : " + model.getAppID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改应用回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新应用", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新应用ID为 " + model.getAppID() + " " + tipMsg + "!", "更新应用" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID应用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
appService.batchDelete(model.getAppIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除应用ID为:" + model.getAppIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除应用", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除应用ID为 " + model.getAppIDs() + " " + tipMsg + "!", "批量删除应用" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = appService.checkIsNameExist("name", model.getName(), "Id", model.getAppID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找应用信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<App> pageUtil = new PageUtil<App>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
appService.find(pageUtil);
|
|
||||||
List<App> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (App app : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", app.getId());
|
|
||||||
//应用名称
|
|
||||||
item.put("Number", app.getNumber());
|
|
||||||
item.put("Name", app.getName());
|
|
||||||
item.put("Type", app.getType());
|
|
||||||
item.put("Icon", app.getIcon());
|
|
||||||
item.put("URL", app.getURL());
|
|
||||||
item.put("Width", app.getWidth());
|
|
||||||
item.put("Height", app.getHeight());
|
|
||||||
item.put("ReSize", app.getReSize());
|
|
||||||
item.put("OpenMax", app.getOpenMax());
|
|
||||||
item.put("Flash", app.getFlash());
|
|
||||||
item.put("ZL", app.getZL());
|
|
||||||
item.put("Sort", app.getSort());
|
|
||||||
item.put("Remark", app.getRemark());
|
|
||||||
item.put("Enabled", app.getEnabled());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 桌面应用显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findDesk() {
|
|
||||||
try {
|
|
||||||
PageUtil<App> pageUtil = new PageUtil<App>();
|
|
||||||
pageUtil.setPageSize(100);
|
|
||||||
//pageUtil.setCurPage(model.getPageNo());
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
|
|
||||||
//下面是dock
|
|
||||||
pageUtil.setAdvSearch(getCondition_dock());
|
|
||||||
appService.find(pageUtil);
|
|
||||||
List<App> dataList1 = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray1 = new JSONArray();
|
|
||||||
if (null != dataList1) {
|
|
||||||
for (App app : dataList1) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", app.getId());
|
|
||||||
item.put("title", app.getName());
|
|
||||||
item.put("type", app.getType());
|
|
||||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
|
||||||
item.put("url", app.getURL());
|
|
||||||
item.put("width", app.getWidth());
|
|
||||||
item.put("height", app.getHeight());
|
|
||||||
item.put("isresize", app.getReSize());
|
|
||||||
item.put("isopenmax", app.getOpenMax());
|
|
||||||
item.put("isflash", app.getFlash());
|
|
||||||
dataArray1.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("dock", dataArray1);
|
|
||||||
|
|
||||||
//下面是desk
|
|
||||||
pageUtil.setAdvSearch(getCondition_desk());
|
|
||||||
appService.find(pageUtil);
|
|
||||||
List<App> dataList2 = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray2 = new JSONArray();
|
|
||||||
if (null != dataList2) {
|
|
||||||
for (App app : dataList2) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", app.getId());
|
|
||||||
item.put("title", app.getName());
|
|
||||||
item.put("type", app.getType());
|
|
||||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
|
||||||
item.put("url", "../../pages/common/menu.jsp?appID=" + app.getNumber() + "&id=" + app.getId());
|
|
||||||
item.put("width", app.getWidth());
|
|
||||||
item.put("height", app.getHeight());
|
|
||||||
item.put("isresize", app.getReSize());
|
|
||||||
item.put("isopenmax", app.getOpenMax());
|
|
||||||
item.put("isflash", app.getFlash());
|
|
||||||
dataArray2.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("desk", dataArray2);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色对应应用显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findRoleAPP() {
|
|
||||||
try {
|
|
||||||
PageUtil<App> pageUtil = new PageUtil<App>();
|
|
||||||
pageUtil.setPageSize(100);
|
|
||||||
//pageUtil.setCurPage(model.getPageNo());
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleAPP());
|
|
||||||
appService.find(pageUtil);
|
|
||||||
List<App> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("id", 1);
|
|
||||||
outer.put("text", "应用列表");
|
|
||||||
outer.put("state", "open");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (App app : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", app.getId());
|
|
||||||
item.put("text", app.getName());
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + app.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("children", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient("[" + outer.toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Type_s_like", model.getType());
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-桌面dock
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_dock() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("ZL_s_eq", "dock");
|
|
||||||
condition.put("Enabled_n_eq", 1);
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-桌面desk
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_desk() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("ZL_s_eq", "desk");
|
|
||||||
condition.put("Enabled_n_eq", 1);
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-角色对应应用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_RoleAPP() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Enabled_n_eq", 1);
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public AppModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppService(AppIService appService) {
|
|
||||||
this.appService = appService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Assetname;
|
|
||||||
import com.jsh.model.po.Category;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.AssetNameModel;
|
|
||||||
import com.jsh.service.basic.AssetNameIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AssetNameAction extends BaseAction<AssetNameModel> {
|
|
||||||
private AssetNameModel model = new AssetNameModel();
|
|
||||||
|
|
||||||
private AssetNameIService assetnameService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加资产名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加资产名称方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Assetname assetname = new Assetname();
|
|
||||||
assetname.setAssetname(model.getAssetName());
|
|
||||||
//增加资产类型
|
|
||||||
assetname.setCategory(new Category(model.getCategoryID()));
|
|
||||||
|
|
||||||
assetname.setIsystem((short) 1);
|
|
||||||
assetname.setIsconsumables(model.getConsumable());
|
|
||||||
assetname.setDescription(model.getDescription());
|
|
||||||
assetnameService.create(assetname);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产名称异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加资产名称回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加资产名称", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加资产名称名称为 " + model.getAssetName() + " " + tipMsg + "!", "增加资产名称" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加资产名称方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除资产名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除资产名称信息方法delete()================");
|
|
||||||
try {
|
|
||||||
assetnameService.delete(model.getAssetNameID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetNameID() + " 的资产名称异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除资产名称", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "删除资产名称" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除资产名称信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新资产名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Assetname assetname = assetnameService.get(model.getAssetNameID());
|
|
||||||
//增加资产类型
|
|
||||||
assetname.setCategory(new Category(model.getCategoryID()));
|
|
||||||
assetname.setAssetname(model.getAssetName());
|
|
||||||
assetname.setIsconsumables(model.getConsumable());
|
|
||||||
assetname.setDescription(model.getDescription());
|
|
||||||
assetnameService.update(assetname);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改资产名称ID为 : " + model.getAssetNameID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改资产名称回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新资产名称", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新资产名称ID为 " + model.getAssetNameID() + " " + tipMsg + "!", "更新资产名称" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID资产名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
assetnameService.batchDelete(model.getAssetNameIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除资产名称ID为:" + model.getAssetNameIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除资产名称", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除资产名称ID为 " + model.getAssetNameIDs() + " " + tipMsg + "!", "批量删除资产名称" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = assetnameService.checkIsNameExist("assetname", model.getAssetName(), "id", model.getAssetNameID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查资产名称名称为:" + model.getAssetName() + " ID为: " + model.getAssetNameID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查资产名称名称为:" + model.getAssetName() + " ID为: " + model.getAssetNameID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找供应商信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Assetname> pageUtil = new PageUtil<Assetname>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
assetnameService.find(pageUtil);
|
|
||||||
List<Assetname> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Assetname assetname : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", assetname.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("assetname", assetname.getAssetname());
|
|
||||||
item.put("isystem", assetname.getIsystem() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("consumable", assetname.getIsconsumables() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("consumableStatus", assetname.getIsconsumables());
|
|
||||||
item.put("description", assetname.getDescription());
|
|
||||||
item.put("categoryID", assetname.getCategory().getId());
|
|
||||||
item.put("category", assetname.getCategory().getAssetname());
|
|
||||||
item.put("op", assetname.getIsystem());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找资产名称信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询资产名称信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("assetname_s_like", model.getAssetName());
|
|
||||||
condition.put("isconsumables_n_eq", model.getConsumable());
|
|
||||||
condition.put("description_s_like", model.getDescription());
|
|
||||||
condition.put("category.id_n_eq", model.getCategoryID());
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public AssetNameModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssetnameService(AssetNameIService assetnameService) {
|
|
||||||
this.assetnameService = assetnameService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Category;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.CategoryModel;
|
|
||||||
import com.jsh.service.basic.CategoryIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class CategoryAction extends BaseAction<CategoryModel> {
|
|
||||||
private CategoryIService categoryService;
|
|
||||||
private CategoryModel model = new CategoryModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加资产类型
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加资产类型方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Category category = new Category();
|
|
||||||
category.setAssetname(model.getCategoryName());
|
|
||||||
category.setIsystem((short) 1);
|
|
||||||
category.setDescription(model.getDescription());
|
|
||||||
categoryService.create(category);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产类型异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加资产类型回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加资产类型", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加资产类型名称为 " + model.getCategoryName() + " " + tipMsg + "!", "增加资产类型" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加资产类型方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除资产类型
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除资产类型信息方法delete()================");
|
|
||||||
try {
|
|
||||||
categoryService.delete(model.getCategoryID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getCategoryID() + " 的资产类型异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除资产类型", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除资产类型ID为 " + model.getCategoryID() + " " + tipMsg + "!", "删除资产类型" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除资产类型信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新资产类型
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Category category = categoryService.get(model.getCategoryID());
|
|
||||||
category.setAssetname(model.getCategoryName());
|
|
||||||
category.setDescription(model.getDescription());
|
|
||||||
categoryService.update(category);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改资产类型ID为 : " + model.getCategoryID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改资产类型回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新资产类型", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新资产类型ID为 " + model.getCategoryID() + " " + tipMsg + "!", "更新资产类型" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID资产类型
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
categoryService.batchDelete(model.getCategoryIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除资产类型ID为:" + model.getCategoryIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除资产类型", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除资产类型ID为 " + model.getCategoryIDs() + " " + tipMsg + "!", "批量删除资产类型" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = categoryService.checkIsNameExist("assetname", model.getCategoryName(), "id", model.getCategoryID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查资产类型名称为:" + model.getCategoryName() + " ID为: " + model.getCategoryID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查资产类型名称为:" + model.getCategoryName() + " ID为: " + model.getCategoryID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找供应商信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Category> pageUtil = new PageUtil<Category>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
categoryService.find(pageUtil);
|
|
||||||
List<Category> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Category category : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", category.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("categoryname", category.getAssetname());
|
|
||||||
item.put("isystem", category.getIsystem() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("description", category.getDescription());
|
|
||||||
item.put("op", category.getIsystem());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找资产类型信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询资产类型信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("assetname_s_like", model.getCategoryName());
|
|
||||||
condition.put("description_s_like", model.getDescription());
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public CategoryModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCategoryService(CategoryIService categoryService) {
|
|
||||||
this.categoryService = categoryService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,429 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Depot;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.DepotModel;
|
|
||||||
import com.jsh.service.basic.DepotIService;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仓库管理
|
|
||||||
*
|
|
||||||
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class DepotAction extends BaseAction<DepotModel> {
|
|
||||||
private DepotIService depotService;
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private DepotModel model = new DepotModel();
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("sort_s_order", "asc");
|
|
||||||
depotService.find(pageUtil);
|
|
||||||
mapData.put("depotList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加仓库信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Depot depot = new Depot();
|
|
||||||
depot.setName(model.getName());
|
|
||||||
depot.setAddress(model.getAddress());
|
|
||||||
depot.setWarehousing(model.getWarehousing());
|
|
||||||
depot.setTruckage(model.getTruckage());
|
|
||||||
depot.setType(model.getType());
|
|
||||||
depot.setSort(model.getSort());
|
|
||||||
depot.setRemark(model.getRemark());
|
|
||||||
depotService.create(depot);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加仓库名称为 " + model.getName() + " " + tipMsg + "!", "增加仓库" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加仓库方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除仓库信息方法delete()================");
|
|
||||||
try {
|
|
||||||
depotService.delete(model.getDepotID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除仓库ID为 " + model.getDepotID() + " " + tipMsg + "!", "删除仓库" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除仓库信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Depot depot = depotService.get(model.getDepotID());
|
|
||||||
depot.setName(model.getName());
|
|
||||||
depot.setAddress(model.getAddress());
|
|
||||||
depot.setWarehousing(model.getWarehousing());
|
|
||||||
depot.setTruckage(model.getTruckage());
|
|
||||||
depot.setType(model.getType());
|
|
||||||
depot.setSort(model.getSort());
|
|
||||||
depot.setRemark(model.getRemark());
|
|
||||||
depotService.update(depot);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 : " + model.getDepotID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新仓库ID为 " + model.getDepotID() + " " + tipMsg + "!", "更新仓库" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
depotService.batchDelete(model.getDepotIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为:" + model.getDepotIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除仓库ID为 " + model.getDepotIDs() + " " + tipMsg + "!", "批量删除仓库" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = depotService.checkIsNameExist("name", model.getName(), "id", model.getDepotID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找仓库信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
depotService.find(pageUtil);
|
|
||||||
List<Depot> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Depot depot : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", depot.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("name", depot.getName());
|
|
||||||
item.put("address", depot.getAddress());
|
|
||||||
item.put("warehousing", depot.getWarehousing());
|
|
||||||
item.put("truckage", depot.getTruckage());
|
|
||||||
item.put("type", depot.getType());
|
|
||||||
item.put("sort", depot.getSort());
|
|
||||||
item.put("remark", depot.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找礼品卡-虚拟仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findGiftByType() {
|
|
||||||
try {
|
|
||||||
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionByType());
|
|
||||||
depotService.find(pageUtil);
|
|
||||||
List<Depot> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Depot depot : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", depot.getId());
|
|
||||||
//仓库名称
|
|
||||||
item.put("name", depot.getName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找仓库信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询仓库信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户对应仓库显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findUserDepot() {
|
|
||||||
try {
|
|
||||||
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
|
|
||||||
pageUtil.setPageSize(100);
|
|
||||||
//pageUtil.setCurPage(model.getPageNo());
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_UserDepot());
|
|
||||||
depotService.find(pageUtil);
|
|
||||||
List<Depot> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("id", 1);
|
|
||||||
outer.put("text", "仓库列表");
|
|
||||||
outer.put("state", "open");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Depot depot : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", depot.getId());
|
|
||||||
item.put("text", depot.getName());
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + depot.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("children", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient("[" + outer.toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户查找对应仓库列表-仅显示有权限的
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findDepotByUserId() {
|
|
||||||
try {
|
|
||||||
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_UserDepot());
|
|
||||||
depotService.find(pageUtil);
|
|
||||||
List<Depot> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Depot depot : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + depot.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("id", depot.getId());
|
|
||||||
item.put("depotName", depot.getName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("name_s_like", model.getName());
|
|
||||||
condition.put("remark_s_like", model.getRemark());
|
|
||||||
condition.put("type_n_eq", model.getType()); //0-仓库,1-礼品卡
|
|
||||||
condition.put("sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getConditionByType() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_n_eq", model.getType()); //0-仓库,1-礼品卡
|
|
||||||
condition.put("sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-用户对应仓库
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_UserDepot() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_n_eq", 0);
|
|
||||||
condition.put("sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public DepotModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDepotService(DepotIService depotService) {
|
|
||||||
this.depotService = depotService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,566 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Functions;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.FunctionsModel;
|
|
||||||
import com.jsh.service.basic.FunctionsIService;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 功能管理
|
|
||||||
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class FunctionsAction extends BaseAction<FunctionsModel> {
|
|
||||||
private FunctionsIService functionsService;
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private FunctionsModel model = new FunctionsModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加功能信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Functions functions = new Functions();
|
|
||||||
functions.setNumber(model.getNumber());
|
|
||||||
functions.setName(model.getName());
|
|
||||||
functions.setPNumber(model.getPNumber());
|
|
||||||
functions.setURL(model.getURL());
|
|
||||||
functions.setState(model.getState());
|
|
||||||
functions.setSort(model.getSort());
|
|
||||||
functions.setEnabled(model.getEnabled());
|
|
||||||
functions.setType(model.getType());
|
|
||||||
functions.setPushBtn(model.getPushBtn());
|
|
||||||
functionsService.create(functions);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加功能信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加功能信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加功能", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加功能名称为 " + model.getName() + " " + tipMsg + "!", "增加功能" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加功能方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除功能信息方法delete()================");
|
|
||||||
try {
|
|
||||||
functionsService.delete(model.getFunctionsID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getFunctionsID() + " 的功能异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除功能", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除功能ID为 " + model.getFunctionsID() + " " + tipMsg + "!", "删除功能" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除功能信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Functions functions = functionsService.get(model.getFunctionsID());
|
|
||||||
functions.setNumber(model.getNumber());
|
|
||||||
functions.setName(model.getName());
|
|
||||||
functions.setPNumber(model.getPNumber());
|
|
||||||
functions.setURL(model.getURL());
|
|
||||||
functions.setState(model.getState());
|
|
||||||
functions.setSort(model.getSort());
|
|
||||||
functions.setEnabled(model.getEnabled());
|
|
||||||
functions.setType(model.getType());
|
|
||||||
functions.setPushBtn(model.getPushBtn());
|
|
||||||
functionsService.update(functions);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改功能ID为 : " + model.getFunctionsID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改功能回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新功能", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新功能ID为 " + model.getFunctionsID() + " " + tipMsg + "!", "更新功能" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
functionsService.batchDelete(model.getFunctionsIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除功能ID为:" + model.getFunctionsIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除功能", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除功能ID为 " + model.getFunctionsIDs() + " " + tipMsg + "!", "批量删除功能" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = functionsService.checkIsNameExist("Name", model.getName(), "Id", model.getFunctionsID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找功能信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Functions> pageUtil = new PageUtil<Functions>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Functions functions : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", functions.getId());
|
|
||||||
item.put("Number", functions.getNumber());
|
|
||||||
item.put("Name", functions.getName());
|
|
||||||
item.put("PNumber", functions.getPNumber());
|
|
||||||
item.put("URL", functions.getURL());
|
|
||||||
item.put("State", functions.getState());
|
|
||||||
item.put("Sort", functions.getSort());
|
|
||||||
item.put("Enabled", functions.getEnabled());
|
|
||||||
item.put("Type", functions.getType());
|
|
||||||
item.put("PushBtn", functions.getPushBtn());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id列表查找功能信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findByIds() {
|
|
||||||
try {
|
|
||||||
PageUtil<Functions> pageUtil = new PageUtil<Functions>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionByIds());
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Functions functions : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", functions.getId());
|
|
||||||
item.put("Name", functions.getName());
|
|
||||||
item.put("PushBtn", functions.getPushBtn());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色对应功能显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findRoleFunctions() {
|
|
||||||
try {
|
|
||||||
PageUtil<Functions> pageUtil = new PageUtil<Functions>();
|
|
||||||
pageUtil.setPageSize(200);
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions("0"));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("id", 1);
|
|
||||||
outer.put("text", "功能列表");
|
|
||||||
outer.put("state", "open");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Functions functions : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", functions.getId());
|
|
||||||
item.put("text", functions.getName());
|
|
||||||
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + functions.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList1 = pageUtil.getPageList();
|
|
||||||
JSONArray dataArray1 = new JSONArray();
|
|
||||||
if (null != dataList1) {
|
|
||||||
|
|
||||||
for (Functions functions1 : dataList1) {
|
|
||||||
item.put("state", "open"); //如果不为空,节点不展开
|
|
||||||
JSONObject item1 = new JSONObject();
|
|
||||||
item1.put("id", functions1.getId());
|
|
||||||
item1.put("text", functions1.getName());
|
|
||||||
|
|
||||||
//勾选判断2
|
|
||||||
//Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + functions1.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item1.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList2 = pageUtil.getPageList();
|
|
||||||
JSONArray dataArray2 = new JSONArray();
|
|
||||||
if (null != dataList2) {
|
|
||||||
|
|
||||||
for (Functions functions2 : dataList2) {
|
|
||||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
|
||||||
JSONObject item2 = new JSONObject();
|
|
||||||
item2.put("id", functions2.getId());
|
|
||||||
item2.put("text", functions2.getName());
|
|
||||||
|
|
||||||
//勾选判断3
|
|
||||||
//Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + functions2.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item2.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList3 = pageUtil.getPageList();
|
|
||||||
JSONArray dataArray3 = new JSONArray();
|
|
||||||
if (null != dataList3) {
|
|
||||||
|
|
||||||
for (Functions functions3 : dataList3) {
|
|
||||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
|
||||||
JSONObject item3 = new JSONObject();
|
|
||||||
item3.put("id", functions3.getId());
|
|
||||||
item3.put("text", functions3.getName());
|
|
||||||
|
|
||||||
//勾选判断4
|
|
||||||
//Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + functions3.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item3.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
dataArray3.add(item3);
|
|
||||||
item2.put("children", dataArray3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dataArray2.add(item2);
|
|
||||||
item1.put("children", dataArray2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dataArray1.add(item1);
|
|
||||||
item.put("children", dataArray1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
outer.put("children", dataArray);
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient("[" + outer.toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面显示菜单
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findMenu() {
|
|
||||||
try {
|
|
||||||
String fc = model.getHasFunctions(); //当前用户所拥有的功能列表,格式如:[1][2][5]
|
|
||||||
PageUtil<Functions> pageUtil = new PageUtil<Functions>();
|
|
||||||
pageUtil.setPageSize(200);
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(model.getPNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Functions functions : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
|
|
||||||
item.put("id", functions.getId());
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList1 = pageUtil.getPageList();
|
|
||||||
JSONArray dataArray1 = new JSONArray();
|
|
||||||
if (dataList1.size() != 0) {
|
|
||||||
item.put("text", functions.getName()); //是目录就没链接
|
|
||||||
for (Functions functions1 : dataList1) {
|
|
||||||
item.put("state", "open"); //如果不为空,节点展开
|
|
||||||
JSONObject item1 = new JSONObject();
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList2 = pageUtil.getPageList();
|
|
||||||
if (fc.indexOf("[" + functions1.getId().toString() + "]") != -1 || dataList2.size() != 0) {
|
|
||||||
item1.put("id", functions1.getId());
|
|
||||||
JSONArray dataArray2 = new JSONArray();
|
|
||||||
if (dataList2.size() != 0) {
|
|
||||||
item1.put("text", functions1.getName());//是目录就没链接
|
|
||||||
for (Functions functions2 : dataList2) {
|
|
||||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
|
||||||
JSONObject item2 = new JSONObject();
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber()));
|
|
||||||
functionsService.find(pageUtil);
|
|
||||||
List<Functions> dataList3 = pageUtil.getPageList();
|
|
||||||
if (fc.indexOf("[" + functions2.getId().toString() + "]") != -1 || dataList3.size() != 0) {
|
|
||||||
item2.put("id", functions2.getId());
|
|
||||||
JSONArray dataArray3 = new JSONArray();
|
|
||||||
if (dataList3.size() != 0) {
|
|
||||||
item2.put("text", functions2.getName());//是目录就没链接
|
|
||||||
for (Functions functions3 : dataList3) {
|
|
||||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
|
||||||
JSONObject item3 = new JSONObject();
|
|
||||||
item3.put("id", functions3.getId());
|
|
||||||
item3.put("text", functions3.getName());
|
|
||||||
//
|
|
||||||
dataArray3.add(item3);
|
|
||||||
item2.put("children", dataArray3);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不是目录,有链接
|
|
||||||
item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getURL() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不是目录,有链接
|
|
||||||
item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getURL() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
|
||||||
}
|
|
||||||
dataArray2.add(item2);
|
|
||||||
item1.put("children", dataArray2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不是目录,有链接
|
|
||||||
item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getURL() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不是目录,有链接
|
|
||||||
item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getURL() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
|
||||||
}
|
|
||||||
dataArray1.add(item1);
|
|
||||||
item.put("children", dataArray1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不是目录,有链接
|
|
||||||
item.put("text", "<a onclick=\"NewTab('" + functions.getName() + "','" + functions.getURL() + "','" + functions.getId() + "')\">" + functions.getName() + "</a>");
|
|
||||||
}
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-角色对应功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_RoleFunctions(String num) {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Enabled_n_eq", 1);
|
|
||||||
condition.put("PNumber_s_eq", num);
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-角色对应功能
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getConditionByIds() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Enabled_n_eq", 1);
|
|
||||||
condition.put("Id_s_in", model.getFunctionsIDs());
|
|
||||||
condition.put("Sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public FunctionsModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFunctionsService(FunctionsIService functionsService) {
|
|
||||||
this.functionsService = functionsService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.InOutItem;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.InOutItemModel;
|
|
||||||
import com.jsh.service.basic.InOutItemIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收支项目
|
|
||||||
*
|
|
||||||
* @author ji*sheng*hua qq 7.5.2.7.1.8.9.2.0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class InOutItemAction extends BaseAction<InOutItemModel> {
|
|
||||||
private InOutItemIService inOutItemService;
|
|
||||||
private InOutItemModel model = new InOutItemModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加收支项目
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加收支项目方法===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
InOutItem inOutItem = new InOutItem();
|
|
||||||
inOutItem.setName(model.getName());
|
|
||||||
inOutItem.setType(model.getType());
|
|
||||||
inOutItem.setRemark(model.getRemark());
|
|
||||||
inOutItemService.create(inOutItem);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加收支项目异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加收支项目回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加收支项目", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加收支项目名称为 " + model.getName() + " " + tipMsg + "!", "增加收支项目" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加收支项目方法===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除收支项目
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除收支项目信息方法delete()================");
|
|
||||||
try {
|
|
||||||
inOutItemService.delete(model.getInOutItemID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getInOutItemID() + " 的收支项目异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除收支项目", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除收支项目ID为 " + model.getInOutItemID() + ",名称为 " + model.getName() + tipMsg + "!", "删除收支项目" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除收支项目信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新收支项目
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
InOutItem inOutItem = inOutItemService.get(model.getInOutItemID());
|
|
||||||
inOutItem.setName(model.getName());
|
|
||||||
inOutItem.setType(model.getType());
|
|
||||||
inOutItem.setRemark(model.getRemark());
|
|
||||||
inOutItemService.update(inOutItem);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改收支项目ID为 : " + model.getInOutItemID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改收支项目回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新收支项目", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新收支项目ID为 " + model.getInOutItemID() + " " + tipMsg + "!", "更新收支项目" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID收支项目
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
inOutItemService.batchDelete(model.getInOutItemIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除收支项目ID为:" + model.getInOutItemIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除收支项目", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除收支项目ID为 " + model.getInOutItemIDs() + " " + tipMsg + "!", "批量删除收支项目" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = inOutItemService.checkIsNameExist("name", model.getName(), "id", model.getInOutItemID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查收支项目名称为:" + model.getName() + " ID为: " + model.getInOutItemID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查收支项目名称为:" + model.getName() + " ID为: " + model.getInOutItemID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找收支项目信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
inOutItemService.find(pageUtil);
|
|
||||||
List<InOutItem> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (InOutItem inOutItem : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", inOutItem.getId());
|
|
||||||
//收支项目名称
|
|
||||||
item.put("name", inOutItem.getName());
|
|
||||||
item.put("type", inOutItem.getType());
|
|
||||||
item.put("remark", inOutItem.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找收支项目信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询收支项目信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找收支项目信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect() {
|
|
||||||
try {
|
|
||||||
PageUtil<InOutItem> pageUtil = new PageUtil<InOutItem>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_select());
|
|
||||||
inOutItemService.find(pageUtil);
|
|
||||||
List<InOutItem> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (InOutItem inOutItem : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", inOutItem.getId());
|
|
||||||
//收支项目名称
|
|
||||||
item.put("InOutItemName", inOutItem.getName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找收支项目信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询收支项目信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("name_s_like", model.getName());
|
|
||||||
condition.put("remark_s_like", model.getRemark());
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框-收支项目
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_select() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
if (model.getType().equals("in")) {
|
|
||||||
condition.put("type_s_eq", "收入");
|
|
||||||
} else if (model.getType().equals("out")) {
|
|
||||||
condition.put("type_s_eq", "支出");
|
|
||||||
}
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public InOutItemModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInOutItemService(InOutItemIService inOutItemService) {
|
|
||||||
this.inOutItemService = inOutItemService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.LogModel;
|
|
||||||
import com.jsh.service.basic.UserIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.Tools;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*日志管理
|
|
||||||
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class LogAction extends BaseAction<LogModel> {
|
|
||||||
private LogModel model = new LogModel();
|
|
||||||
private UserIService userService;
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.clear();
|
|
||||||
condition.put("ismanager_n_eq", 0);
|
|
||||||
userService.find(pageUtil);
|
|
||||||
mapData.put("userList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除日志
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除日志信息方法delete()================");
|
|
||||||
try {
|
|
||||||
logService.delete(model.getLogID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getLogID() + " 的日志异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除日志", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除日志ID为 " + model.getLogID() + " " + tipMsg + "!", "删除日志" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除日志信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID日志
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
logService.batchDelete(model.getLogIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除日志ID为:" + model.getLogIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除日志", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除日志ID为 " + model.getLogIDs() + " " + tipMsg + "!", "批量删除日志" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找日志信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Logdetails> pageUtil = new PageUtil<Logdetails>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
logService.find(pageUtil);
|
|
||||||
List<Logdetails> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Logdetails log : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", log.getId());
|
|
||||||
item.put("clientIP", log.getClientIp());
|
|
||||||
item.put("details", log.getContentdetails());
|
|
||||||
item.put("createTime", Tools.getCenternTime(log.getCreatetime()));
|
|
||||||
item.put("operation", log.getOperation());
|
|
||||||
item.put("remark", log.getRemark());
|
|
||||||
item.put("status", log.getStatus() == 0 ? "成功" : "失败");
|
|
||||||
item.put("statusShort", log.getStatus());
|
|
||||||
item.put("username", log.getUser() == null ? "" : log.getUser().getUsername());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找日志信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询日志信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("user.id_n_eq", model.getUsernameID());
|
|
||||||
condition.put("createtime_s_gteq", model.getBeginTime());
|
|
||||||
condition.put("createtime_s_lteq", model.getEndTime());
|
|
||||||
condition.put("operation_s_like", model.getOperation());
|
|
||||||
condition.put("clientIp_s_like", model.getClientIp());
|
|
||||||
condition.put("status_n_eq", model.getStatus());
|
|
||||||
condition.put("contentdetails_s_like", model.getContentdetails());
|
|
||||||
condition.put("remark_s_like", model.getRemark());
|
|
||||||
condition.put("createtime_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
public void setUserService(UserIService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LogModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,301 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.Role;
|
|
||||||
import com.jsh.model.vo.basic.RoleModel;
|
|
||||||
import com.jsh.service.basic.RoleIService;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 角色管理
|
|
||||||
* @author jishenghua qq:7-5-2-7-1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class RoleAction extends BaseAction<RoleModel> {
|
|
||||||
private RoleIService roleService;
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private RoleModel model = new RoleModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加角色
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加角色信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Role role = new Role();
|
|
||||||
role.setName(model.getName());
|
|
||||||
roleService.create(role);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加角色信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加角色信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加角色", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加角色名称为 " + model.getName() + " " + tipMsg + "!", "增加角色" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加角色方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除角色
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除角色信息方法delete()================");
|
|
||||||
try {
|
|
||||||
roleService.delete(model.getRoleID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getRoleID() + " 的角色异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除角色", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除角色ID为 " + model.getRoleID() + " " + tipMsg + "!", "删除角色" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除角色信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新角色
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Role role = roleService.get(model.getRoleID());
|
|
||||||
role.setName(model.getName());
|
|
||||||
roleService.update(role);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改角色ID为 : " + model.getRoleID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改角色回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新角色", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新角色ID为 " + model.getRoleID() + " " + tipMsg + "!", "更新角色" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID角色
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
roleService.batchDelete(model.getRoleIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除角色ID为:" + model.getRoleIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除角色", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除角色ID为 " + model.getRoleIDs() + " " + tipMsg + "!", "批量删除角色" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = roleService.checkIsNameExist("name", model.getName(), "Id", model.getRoleID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找角色信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Role> pageUtil = new PageUtil<Role>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
roleService.find(pageUtil);
|
|
||||||
List<Role> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Role role : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", role.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("Name", role.getName());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户对应角色显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findUserRole() {
|
|
||||||
try {
|
|
||||||
PageUtil<Role> pageUtil = new PageUtil<Role>();
|
|
||||||
pageUtil.setPageSize(100);
|
|
||||||
//pageUtil.setCurPage(model.getPageNo());
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(getCondition_UserRole());
|
|
||||||
roleService.find(pageUtil);
|
|
||||||
List<Role> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("id", 1);
|
|
||||||
outer.put("text", "角色列表");
|
|
||||||
outer.put("state", "open");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Role role : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", role.getId());
|
|
||||||
item.put("text", role.getName());
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + role.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("children", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient("[" + outer.toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-用户对应角色
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_UserRole() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public RoleModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoleService(RoleIService roleService) {
|
|
||||||
this.roleService = roleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,795 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.Supplier;
|
|
||||||
import com.jsh.model.vo.basic.SupplierModel;
|
|
||||||
import com.jsh.service.basic.SupplierIService;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SupplierConstants;
|
|
||||||
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.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 单位管理
|
|
||||||
* @author ji-sheng-hua qq:7 5 2 7 1 8 9 2 0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class SupplierAction extends BaseAction<SupplierModel> {
|
|
||||||
public static final String EXCEL = "excel"; //action返回excel结果
|
|
||||||
private final static Integer ISYSTEM = 1;
|
|
||||||
private SupplierIService supplierService;
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private SupplierModel model = new SupplierModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加供应商方法===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Supplier supplier = new Supplier();
|
|
||||||
supplier.setContacts(model.getContacts());
|
|
||||||
supplier.setType(model.getType());
|
|
||||||
supplier.setDescription(model.getDescription());
|
|
||||||
supplier.setEmail(model.getEmail());
|
|
||||||
supplier.setAdvanceIn(0.0);
|
|
||||||
supplier.setBeginNeedGet(model.getBeginNeedGet());
|
|
||||||
supplier.setBeginNeedPay(model.getBeginNeedPay());
|
|
||||||
supplier.setIsystem((short) 1);
|
|
||||||
supplier.setEnabled(true);
|
|
||||||
supplier.setPhonenum(model.getPhonenum());
|
|
||||||
supplier.setSupplier(model.getSupplier());
|
|
||||||
|
|
||||||
supplier.setFax(model.getFax());
|
|
||||||
supplier.setTelephone(model.getTelephone());
|
|
||||||
supplier.setAddress(model.getAddress());
|
|
||||||
supplier.setTaxNum(model.getTaxNum());
|
|
||||||
supplier.setBankName(model.getBankName());
|
|
||||||
supplier.setAccountNumber(model.getAccountNumber());
|
|
||||||
supplier.setTaxRate(model.getTaxRate());
|
|
||||||
|
|
||||||
supplierService.create(supplier);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加供应商异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加供应商回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加供应商", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加供应商名称为 " + model.getSupplier() + " " + tipMsg + "!", "增加供应商" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加供应商方法===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除供应商信息方法delete()================");
|
|
||||||
try {
|
|
||||||
supplierService.delete(model.getSupplierID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getSupplierID() + " 的供应商异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除供应商", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除供应商ID为 " + model.getSupplierID() + ",名称为 " + model.getSupplier() + tipMsg + "!", "删除供应商" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除供应商信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Supplier supplier = supplierService.get(model.getSupplierID());
|
|
||||||
supplier.setContacts(model.getContacts());
|
|
||||||
supplier.setType(model.getType());
|
|
||||||
supplier.setDescription(model.getDescription());
|
|
||||||
supplier.setEmail(model.getEmail());
|
|
||||||
supplier.setAdvanceIn(supplier.getAdvanceIn());
|
|
||||||
supplier.setBeginNeedGet(model.getBeginNeedGet());
|
|
||||||
supplier.setBeginNeedPay(model.getBeginNeedPay());
|
|
||||||
supplier.setIsystem((short) 1);
|
|
||||||
supplier.setPhonenum(model.getPhonenum());
|
|
||||||
supplier.setSupplier(model.getSupplier());
|
|
||||||
|
|
||||||
supplier.setFax(model.getFax());
|
|
||||||
supplier.setTelephone(model.getTelephone());
|
|
||||||
supplier.setAddress(model.getAddress());
|
|
||||||
supplier.setTaxNum(model.getTaxNum());
|
|
||||||
supplier.setBankName(model.getBankName());
|
|
||||||
supplier.setAccountNumber(model.getAccountNumber());
|
|
||||||
supplier.setTaxRate(model.getTaxRate());
|
|
||||||
|
|
||||||
supplier.setEnabled(supplier.getEnabled());
|
|
||||||
supplierService.update(supplier);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改供应商ID为 : " + model.getSupplierID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改供应商回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新供应商", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新供应商ID为 " + model.getSupplierID() + " " + tipMsg + "!", "更新供应商" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新供应商-只更新预付款,其余用原来的值
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void updateAdvanceIn() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Supplier supplier = supplierService.get(model.getSupplierID());
|
|
||||||
supplier.setContacts(supplier.getContacts());
|
|
||||||
supplier.setType(supplier.getType());
|
|
||||||
supplier.setDescription(supplier.getDescription());
|
|
||||||
supplier.setEmail(supplier.getEmail());
|
|
||||||
supplier.setAdvanceIn(supplier.getAdvanceIn() + model.getAdvanceIn()); //增加预收款的金额,可能增加的是负值
|
|
||||||
supplier.setBeginNeedGet(supplier.getBeginNeedGet());
|
|
||||||
supplier.setBeginNeedPay(supplier.getBeginNeedPay());
|
|
||||||
supplier.setIsystem((short) 1);
|
|
||||||
supplier.setPhonenum(supplier.getPhonenum());
|
|
||||||
supplier.setSupplier(supplier.getSupplier());
|
|
||||||
|
|
||||||
supplier.setFax(supplier.getFax());
|
|
||||||
supplier.setTelephone(supplier.getTelephone());
|
|
||||||
supplier.setAddress(supplier.getAddress());
|
|
||||||
supplier.setTaxNum(supplier.getTaxNum());
|
|
||||||
supplier.setBankName(supplier.getBankName());
|
|
||||||
supplier.setAccountNumber(supplier.getAccountNumber());
|
|
||||||
supplier.setTaxRate(supplier.getTaxRate());
|
|
||||||
|
|
||||||
supplier.setEnabled(supplier.getEnabled());
|
|
||||||
supplierService.update(supplier);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改供应商ID为 : " + model.getSupplierID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改供应商回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新供应商预付款", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新供应商ID为 " + model.getSupplierID() + " " + tipMsg + "!", "更新供应商" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
supplierService.batchDelete(model.getSupplierIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除供应商ID为:" + model.getSupplierIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除供应商", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除供应商ID为 " + model.getSupplierIDs() + " " + tipMsg + "!", "批量删除供应商" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量设置状态-启用或者禁用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchSetEnable() {
|
|
||||||
try {
|
|
||||||
supplierService.batchSetEnable(model.getEnabled(), model.getSupplierIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量修改状态,单位ID为:" + model.getSupplierIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量修改单位状态", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量修改状态,单位ID为 " + model.getSupplierIDs() + " " + tipMsg + "!", "批量修改单位状态" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = supplierService.checkIsNameExist("supplier", model.getSupplier(), "id", model.getSupplierID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查供应商名称为:" + model.getSupplier() + " ID为: " + model.getSupplierID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查供应商名称为:" + model.getSupplier() + " ID为: " + model.getSupplierID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找供应商信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
String sName = "";
|
|
||||||
if ((model.getType()).equals("供应商")) {
|
|
||||||
sName = "pageUtilVendor";
|
|
||||||
} else if ((model.getType()).equals("客户")) {
|
|
||||||
sName = "pageUtilCustomer";
|
|
||||||
} else if ((model.getType()).equals("会员")) {
|
|
||||||
sName = "pageUtilMember";
|
|
||||||
}
|
|
||||||
getSession().put(sName, pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("supplier", supplier.getSupplier());
|
|
||||||
item.put("type", supplier.getType());
|
|
||||||
item.put("contacts", supplier.getContacts());
|
|
||||||
item.put("phonenum", supplier.getPhonenum());
|
|
||||||
item.put("email", supplier.getEmail());
|
|
||||||
item.put("AdvanceIn", supplier.getAdvanceIn());
|
|
||||||
item.put("BeginNeedGet", supplier.getBeginNeedGet());
|
|
||||||
item.put("BeginNeedPay", supplier.getBeginNeedPay());
|
|
||||||
item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("description", supplier.getDescription());
|
|
||||||
|
|
||||||
item.put("fax", supplier.getFax());
|
|
||||||
item.put("telephone", supplier.getTelephone());
|
|
||||||
item.put("address", supplier.getAddress());
|
|
||||||
item.put("taxNum", supplier.getTaxNum());
|
|
||||||
item.put("bankName", supplier.getBankName());
|
|
||||||
item.put("accountNumber", supplier.getAccountNumber());
|
|
||||||
item.put("taxRate", supplier.getTaxRate());
|
|
||||||
|
|
||||||
item.put("enabled", supplier.getEnabled());
|
|
||||||
item.put("op", supplier.getIsystem());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id查找信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findById() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionById());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
//名称
|
|
||||||
item.put("supplier", supplier.getSupplier());
|
|
||||||
item.put("type", supplier.getType());
|
|
||||||
item.put("contacts", supplier.getContacts());
|
|
||||||
item.put("phonenum", supplier.getPhonenum());
|
|
||||||
item.put("email", supplier.getEmail());
|
|
||||||
item.put("AdvanceIn", supplier.getAdvanceIn());
|
|
||||||
item.put("BeginNeedGet", supplier.getBeginNeedGet());
|
|
||||||
item.put("BeginNeedPay", supplier.getBeginNeedPay());
|
|
||||||
item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("description", supplier.getDescription());
|
|
||||||
|
|
||||||
item.put("fax", supplier.getFax());
|
|
||||||
item.put("telephone", supplier.getTelephone());
|
|
||||||
item.put("address", supplier.getAddress());
|
|
||||||
item.put("taxNum", supplier.getTaxNum());
|
|
||||||
item.put("bankName", supplier.getBankName());
|
|
||||||
item.put("accountNumber", supplier.getAccountNumber());
|
|
||||||
item.put("taxRate", supplier.getTaxRate());
|
|
||||||
|
|
||||||
item.put("enabled", supplier.getEnabled());
|
|
||||||
item.put("op", supplier.getIsystem());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找供应商信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect_sup() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Select_sup());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
//供应商名称
|
|
||||||
item.put("supplier", supplier.getSupplier());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找客户信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect_cus() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Select_cus());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + supplier.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>查询用户对应的客户:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
item.put("supplier", supplier.getSupplier()); //客户名称
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找客户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询客户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找会员信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect_retail() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Select_retail());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
//客户名称
|
|
||||||
item.put("supplier", supplier.getSupplier());
|
|
||||||
item.put("advanceIn", supplier.getAdvanceIn()); //预付款金额
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找客户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询客户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找非会员的id
|
|
||||||
*/
|
|
||||||
public void findBySelectRetailNoPeople() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Select_retail_no_people());
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
//客户名称
|
|
||||||
item.put("supplier", supplier.getSupplier());
|
|
||||||
item.put("advanceIn", supplier.getAdvanceIn()); //预付款金额
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找客户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询客户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户对应客户显示
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findUserCustomer() {
|
|
||||||
try {
|
|
||||||
PageUtil<Supplier> pageUtil = new PageUtil<Supplier>();
|
|
||||||
pageUtil.setPageSize(500);
|
|
||||||
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_s_eq", "客户");
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
|
|
||||||
pageUtil.setAdvSearch(condition);
|
|
||||||
supplierService.find(pageUtil);
|
|
||||||
List<Supplier> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("id", 1);
|
|
||||||
outer.put("text", "客户列表");
|
|
||||||
outer.put("state", "open");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Supplier supplier : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", supplier.getId());
|
|
||||||
item.put("text", supplier.getSupplier());
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist("Type", model.getUBType(), "KeyId", model.getUBKeyId(), "Value", "[" + supplier.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("children", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient("[" + outer.toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找客户异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询客户结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String importFun() {
|
|
||||||
//excel表格file
|
|
||||||
Boolean result = false;
|
|
||||||
String returnStr = "";
|
|
||||||
try {
|
|
||||||
InputStream in = supplierService.importExcel(model.getSupplierFile());
|
|
||||||
|
|
||||||
if (null != in) {
|
|
||||||
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
|
|
||||||
model.setExcelStream(in);
|
|
||||||
returnStr = SupplierConstants.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入excel表格-供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String importExcelVendor() {
|
|
||||||
return importFun();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入excel表格-客户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String importExcelCustomer() {
|
|
||||||
return importFun();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入excel表格-会员
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String importExcelMember() {
|
|
||||||
return importFun();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出excel表格
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String exportExcel() {
|
|
||||||
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
|
|
||||||
try {
|
|
||||||
String sName = "pageUtil" + model.getType();
|
|
||||||
PageUtil<Supplier> pageUtil = (PageUtil<Supplier>) getSession().get(sName);
|
|
||||||
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
String isCurrentPage = "allPage";
|
|
||||||
model.setFileName(Tools.changeUnicode("report" + System.currentTimeMillis() + ".xls", model.getBrowserType()));
|
|
||||||
model.setExcelStream(supplierService.exmportExcel(isCurrentPage, pageUtil));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常", e);
|
|
||||||
model.getShowModel().setMsgTip("export excel exception");
|
|
||||||
}
|
|
||||||
Log.infoFileSync("===================调用导出信息action方法exportExcel结束==================");
|
|
||||||
return EXCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("supplier_s_like", model.getSupplier());
|
|
||||||
condition.put("type_s_like", model.getType());
|
|
||||||
condition.put("phonenum_s_like", model.getPhonenum());
|
|
||||||
condition.put("telephone_s_like", model.getTelephone());
|
|
||||||
condition.put("description_s_like", model.getDescription());
|
|
||||||
condition.put("isystem_n_eq", ISYSTEM);
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索条件
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getConditionById() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Id_n_eq", model.getSupplierID());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框-供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Select_sup() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_s_like", "供应商");
|
|
||||||
condition.put("enabled_s_eq", 1);
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框-客户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Select_cus() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_s_like", "客户");
|
|
||||||
condition.put("enabled_s_eq", 1);
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框-会员
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Select_retail() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_s_like", "会员");
|
|
||||||
condition.put("enabled_s_eq", 1);
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-非会员
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Select_retail_no_people() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("type_s_like", "会员");
|
|
||||||
condition.put("isystem_n_eq", 0);
|
|
||||||
condition.put("id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public SupplierModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupplierService(SupplierIService supplierService) {
|
|
||||||
this.supplierService = supplierService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.SystemConfig;
|
|
||||||
import com.jsh.model.vo.basic.SystemConfigModel;
|
|
||||||
import com.jsh.service.basic.SystemConfigIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 系统配置
|
|
||||||
* @author jishenghua qq:7-5-2-7 1-8-9-2-0
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class SystemConfigAction extends BaseAction<SystemConfigModel> {
|
|
||||||
private SystemConfigIService systemConfigService;
|
|
||||||
private SystemConfigModel model = new SystemConfigModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新系统配置
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
SystemConfig sysConfig = systemConfigService.get(model.getId());
|
|
||||||
sysConfig.setType(sysConfig.getType());
|
|
||||||
sysConfig.setName(sysConfig.getName());
|
|
||||||
sysConfig.setValue(model.getValue());
|
|
||||||
sysConfig.setDescription(sysConfig.getDescription());
|
|
||||||
systemConfigService.update(sysConfig);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改系统配置ID为 : " + model.getId() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改系统配置回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新系统配置", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新系统配置ID为 " + model.getId() + " " + tipMsg + "!", "更新系统配置" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找系统配置信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<SystemConfig> pageUtil = new PageUtil<SystemConfig>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
systemConfigService.find(pageUtil);
|
|
||||||
List<SystemConfig> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (SystemConfig sysConfig : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", sysConfig.getId());
|
|
||||||
item.put("type", sysConfig.getType());
|
|
||||||
item.put("name", sysConfig.getName());
|
|
||||||
item.put("value", sysConfig.getValue());
|
|
||||||
item.put("description", sysConfig.getDescription());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找系统配置信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询系统配置信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public SystemConfigModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSystemConfigService(SystemConfigIService systemConfigService) {
|
|
||||||
this.systemConfigService = systemConfigService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,262 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.Unit;
|
|
||||||
import com.jsh.model.vo.basic.UnitModel;
|
|
||||||
import com.jsh.service.basic.UnitIService;
|
|
||||||
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 shenghua qq:752 718 920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class UnitAction extends BaseAction<UnitModel> {
|
|
||||||
private UnitIService unitService;
|
|
||||||
private UnitModel model = new UnitModel();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加计量单位
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加计量单位方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Unit unit = new Unit();
|
|
||||||
unit.setUName(model.getUName());
|
|
||||||
unitService.create(unit);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加计量单位异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加计量单位回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加计量单位", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加计量单位名称为 " + model.getUName() + " " + tipMsg + "!", "增加计量单位" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加计量单位方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除计量单位
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除计量单位方法delete()================");
|
|
||||||
try {
|
|
||||||
unitService.delete(model.getUnitID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getUnitID() + " 的计量单位异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除计量单位", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除计量单位ID为 " + model.getUnitID() + " " + tipMsg + "!", "删除计量单位" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除计量单位方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新计量单位
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Unit unit = unitService.get(model.getUnitID());
|
|
||||||
unit.setUName(model.getUName());
|
|
||||||
unitService.update(unit);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改计量单位ID为 : " + model.getUnitID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改计量单位回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新计量单位", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新计量单位ID为 " + model.getUnitID() + " " + tipMsg + "!", "更新计量单位" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID计量单位
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
unitService.batchDelete(model.getUnitIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除计量单位ID为:" + model.getUnitIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除计量单位", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除计量单位ID为 " + model.getUnitIDs() + " " + tipMsg + "!", "批量删除计量单位" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = unitService.checkIsNameExist("UName", model.getUName(), "id", model.getUnitID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找计量单位信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Unit> pageUtil = new PageUtil<Unit>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
unitService.find(pageUtil);
|
|
||||||
List<Unit> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Unit unit : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", unit.getId());
|
|
||||||
//名称
|
|
||||||
item.put("UName", unit.getUName());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找计量单位异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询计量单位结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找计量单位信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findUnitDownList() {
|
|
||||||
try {
|
|
||||||
PageUtil<Unit> pageUtil = new PageUtil<Unit>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
unitService.find(pageUtil);
|
|
||||||
List<Unit> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Unit unit : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", unit.getId());
|
|
||||||
//名称
|
|
||||||
item.put("UName", unit.getUName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找计量单位异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询计量单位结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("UName_s_like", model.getUName());
|
|
||||||
condition.put("id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public UnitModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnitService(UnitIService unitService) {
|
|
||||||
this.unitService = unitService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,446 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Basicuser;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.vo.basic.UserModel;
|
|
||||||
import com.jsh.service.basic.UserIService;
|
|
||||||
import com.jsh.util.ExceptionCodeConstants;
|
|
||||||
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.security.NoSuchAlgorithmException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 用户管理
|
|
||||||
* @author jishenghua qq:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class UserAction extends BaseAction<UserModel> {
|
|
||||||
private UserModel model = new UserModel();
|
|
||||||
private UserIService userService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要判断用户状态,用户名密码错误不能登录 ,黑名单用户不能登录,如果已经登录过,不再进行处理,直接进入管理页面
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String login() {
|
|
||||||
Log.infoFileSync("============用户登录 login 方法调用开始==============");
|
|
||||||
String username = model.getLoginame().trim();
|
|
||||||
String password = model.getPassword().trim();
|
|
||||||
//因密码用MD5加密,需要对密码进行转化
|
|
||||||
try {
|
|
||||||
password = Tools.md5Encryp(password);
|
|
||||||
System.out.println(password);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断用户是否已经登录过,登录过不再处理
|
|
||||||
Basicuser sessionUser = (Basicuser) getSession().get("user");
|
|
||||||
if (null != sessionUser && username.equalsIgnoreCase(sessionUser.getLoginame())
|
|
||||||
&& sessionUser.getPassword().equals(password)) {
|
|
||||||
Log.infoFileSync("====用户 " + username + "已经登录过, login 方法调用结束====");
|
|
||||||
model.getShowModel().setMsgTip("user already login");
|
|
||||||
/*return "login";*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取用户状态
|
|
||||||
int userStatus = -1;
|
|
||||||
try {
|
|
||||||
userStatus = userService.validateUser(username, password);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>用户 " + username + " 登录 login 方法 访问服务层异常====", e);
|
|
||||||
model.getShowModel().setMsgTip("access service exception");
|
|
||||||
}
|
|
||||||
switch (userStatus) {
|
|
||||||
case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
|
|
||||||
model.getShowModel().setMsgTip("user is not exist");
|
|
||||||
break;
|
|
||||||
case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
|
|
||||||
model.getShowModel().setMsgTip("user password error");
|
|
||||||
break;
|
|
||||||
case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
|
|
||||||
model.getShowModel().setMsgTip("user is black");
|
|
||||||
break;
|
|
||||||
case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
|
|
||||||
model.getShowModel().setMsgTip("access service error");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
try {
|
|
||||||
//验证通过 ,可以登录,放入session,记录登录日志
|
|
||||||
Basicuser user = userService.getUser(username);
|
|
||||||
logService.create(new Logdetails(user, "登录系统", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis()), (short) 0, "管理用户:" + username + " 登录系统", username + " 登录系统"));
|
|
||||||
model.getShowModel().setMsgTip("user can login");
|
|
||||||
getSession().put("user", user);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>查询用户名为:" + username + " ,用户信息异常", e);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/*if(ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT == userStatus)
|
|
||||||
return "login";*/
|
|
||||||
Log.infoFileSync("===============用户登录 login 方法调用结束===============");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户退出登录
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String logout() {
|
|
||||||
logService.create(new Logdetails(getUser(), "退出系统", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis()), (short) 0,
|
|
||||||
"管理用户:" + getUser().getLoginame() + " 退出系统", getUser().getLoginame() + " 退出系统"));
|
|
||||||
getSession().remove("user");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加用户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加用户方法===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Basicuser user = new Basicuser();
|
|
||||||
user.setDepartment(model.getDepartment());
|
|
||||||
user.setDescription(model.getDescription());
|
|
||||||
user.setEmail(model.getEmail());
|
|
||||||
user.setIsmanager((short) 1);
|
|
||||||
user.setIsystem((short) 0);
|
|
||||||
user.setLoginame(model.getLoginame());
|
|
||||||
String password = "123456";
|
|
||||||
//因密码用MD5加密,需要对密码进行转化
|
|
||||||
try {
|
|
||||||
password = Tools.md5Encryp(password);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
user.setPassword(password);
|
|
||||||
|
|
||||||
user.setPhonenum(model.getPhonenum());
|
|
||||||
user.setPosition(model.getPosition());
|
|
||||||
user.setUsername(model.getUsername());
|
|
||||||
|
|
||||||
userService.create(user);
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加用户异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加用户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加用户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加用户名称为 " + model.getUsername() + " " + tipMsg + "!", "增加用户" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加用户方法===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除用户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除用户信息方法delete()================");
|
|
||||||
try {
|
|
||||||
userService.delete(model.getUserID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getUserID() + " 的用户异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除用户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除用户ID为 " + model.getUserID() + " " + tipMsg + "!", "删除用户" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除用户信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Basicuser user = userService.get(model.getUserID());
|
|
||||||
user.setDepartment(model.getDepartment());
|
|
||||||
user.setDescription(model.getDescription());
|
|
||||||
user.setEmail(model.getEmail());
|
|
||||||
//user.setIsmanager(model.getIsmanager());
|
|
||||||
user.setLoginame(model.getLoginame());
|
|
||||||
//user.setPassword(model.getPassword());
|
|
||||||
user.setPhonenum(model.getPhonenum());
|
|
||||||
user.setPosition(model.getPosition());
|
|
||||||
user.setUsername(model.getUsername());
|
|
||||||
userService.update(user);
|
|
||||||
|
|
||||||
//看是否需要更新seesion中user
|
|
||||||
if (getUser().getId() == model.getUserID()) {
|
|
||||||
getSession().put("user", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改用户ID为 : " + model.getUserID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改用户回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新用户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新用户ID为 " + model.getUserID() + " " + tipMsg + "!", "更新用户" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改密码
|
|
||||||
*/
|
|
||||||
public void updatePwd() {
|
|
||||||
Integer flag = 0;
|
|
||||||
try {
|
|
||||||
Basicuser user = getUser();
|
|
||||||
String orgPassword = Tools.md5Encryp(model.getOrgpwd());
|
|
||||||
String md5Pwd = Tools.md5Encryp(model.getPassword());
|
|
||||||
//必须和原始密码一致才可以更新密码
|
|
||||||
if(user.getLoginame().equals("jsh")){
|
|
||||||
flag = 3;
|
|
||||||
tipMsg = "管理员jsh不能修改密码";
|
|
||||||
tipType = 1;
|
|
||||||
} else if (orgPassword.equalsIgnoreCase(user.getPassword())) {
|
|
||||||
|
|
||||||
user.setPassword(md5Pwd);
|
|
||||||
userService.update(user);
|
|
||||||
|
|
||||||
//看是否需要更新seesion中user
|
|
||||||
// if(getUser().getId() == model.getUserID())
|
|
||||||
// {
|
|
||||||
// getSession().put("user", user);
|
|
||||||
// }
|
|
||||||
|
|
||||||
flag = 1;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} else {
|
|
||||||
flag = 2;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改用户ID为 : " + model.getUserID() + "密码信息失败", e);
|
|
||||||
flag = 3;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改用户密码回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新用户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新用户ID为 " + model.getUserID() + "密码信息 " + tipMsg + "!", "更新用户" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重置用户的密码
|
|
||||||
*/
|
|
||||||
public void resetPwd() {
|
|
||||||
Integer flag = 0;
|
|
||||||
try {
|
|
||||||
Basicuser user = userService.get(model.getUserID());
|
|
||||||
String password = "123456";
|
|
||||||
String md5Pwd = Tools.md5Encryp(password);
|
|
||||||
user.setPassword(md5Pwd);
|
|
||||||
userService.update(user);
|
|
||||||
flag = 1;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改用户ID为 : " + model.getUserID() + "密码信息失败", e);
|
|
||||||
flag = 0;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改用户密码回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "重置用户密码", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis()), tipType, "重置用户ID为 " + model.getUserID() + "密码信息 " + tipMsg + "!", "重置用户密码" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID用户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
userService.batchDelete(model.getUserIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除用户ID为:" + model.getUserIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除用户", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除用户ID为 " + model.getUserIDs() + " " + tipMsg + "!", "批量删除用户" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入名称是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNameExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
String fieldName = "";
|
|
||||||
String fieldValue = "";
|
|
||||||
try {
|
|
||||||
if (0 == model.getCheckFlag()) {
|
|
||||||
fieldName = "username";
|
|
||||||
fieldValue = model.getUsername();
|
|
||||||
} else {
|
|
||||||
fieldName = "loginame";
|
|
||||||
fieldValue = model.getLoginame();
|
|
||||||
}
|
|
||||||
flag = userService.checkIsNameExist(fieldName, fieldValue, model.getUserID());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查用户名称为:" + fieldValue + " ID为: " + model.getUserID() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查用户名称为:" + fieldValue + " ID为: " + model.getUserID() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找用户信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Basicuser> pageUtil = new PageUtil<Basicuser>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
userService.find(pageUtil);
|
|
||||||
List<Basicuser> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Basicuser user : dataList) {
|
|
||||||
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", user.getId());
|
|
||||||
item.put("username", user.getUsername());
|
|
||||||
item.put("loginame", Tools.dealNullStr(user.getLoginame()));
|
|
||||||
item.put("password", Tools.dealNullStr(user.getPassword()));
|
|
||||||
item.put("position", Tools.dealNullStr(user.getPosition()));
|
|
||||||
item.put("department", Tools.dealNullStr(user.getDepartment()));
|
|
||||||
item.put("email", Tools.dealNullStr(user.getEmail()));
|
|
||||||
item.put("phonenum", Tools.dealNullStr(user.getPhonenum()));
|
|
||||||
item.put("ismanager", user.getIsmanager() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("isystem", user.getIsystem() == (short) 0 ? "是" : "否");
|
|
||||||
item.put("status", user.getStatus());
|
|
||||||
item.put("description", Tools.dealNullStr(user.getDescription()));
|
|
||||||
item.put("remark", user.getRemark());
|
|
||||||
item.put("op", user.getIsmanager());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找用户信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询用户信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return 拼接后的条件
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("username_s_like", model.getUsername());
|
|
||||||
condition.put("loginame_s_like", model.getLoginame());
|
|
||||||
condition.put("id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public UserModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserService(UserIService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
package com.jsh.action.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.UserBusiness;
|
|
||||||
import com.jsh.model.vo.basic.UserBusinessModel;
|
|
||||||
import com.jsh.service.basic.UserBusinessIService;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
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:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class UserBusinessAction extends BaseAction<UserBusinessModel> {
|
|
||||||
private UserBusinessIService userBusinessService;
|
|
||||||
private UserBusinessModel model = new UserBusinessModel();
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("KeyId_s_eq", model.getKeyId());
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
userBusinessService.find(pageUtil);
|
|
||||||
mapData.put("userBusinessList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找UserBusiness信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 测试hql语句的写法
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getceshi() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
userBusinessService.find(pageUtil, "ceshi");
|
|
||||||
mapData.put("userBusinessList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找UserBusiness信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加UserBusiness
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加UserBusiness信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
UserBusiness userBusiness = new UserBusiness();
|
|
||||||
userBusiness.setType(model.getType());
|
|
||||||
userBusiness.setKeyId(model.getKeyId());
|
|
||||||
userBusiness.setValue(model.getValue());
|
|
||||||
userBusinessService.create(userBusiness);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加UserBusiness信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加UserBusiness信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加UserBusiness", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加UserBusiness为 " + model.getType() + " " + tipMsg + "!", "增加UserBusiness" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加UserBusiness方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新UserBusiness
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
Long id = 0l;
|
|
||||||
try {
|
|
||||||
PageUtil<UserBusiness> pageUtil = new PageUtil<UserBusiness>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition_RoleAPP());
|
|
||||||
userBusinessService.find(pageUtil);
|
|
||||||
List<UserBusiness> dataList = pageUtil.getPageList();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (UserBusiness userBusiness : dataList) {
|
|
||||||
id = userBusiness.getId();
|
|
||||||
}
|
|
||||||
UserBusiness userBusiness = userBusinessService.get(id);
|
|
||||||
userBusiness.setType(model.getType());
|
|
||||||
userBusiness.setKeyId(model.getKeyId());
|
|
||||||
userBusiness.setValue(model.getValue());
|
|
||||||
userBusinessService.update(userBusiness);
|
|
||||||
}
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改UserBusiness的ID为 : " + id + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改UserBusiness回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新UserBusiness", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新UserBusiness的ID为 " + id + " " + tipMsg + "!", "更新UserBusiness" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新角色的按钮权限
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void updateBtnStr() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
UserBusiness userBusiness = userBusinessService.get(model.getUserBusinessID());
|
|
||||||
userBusiness.setType(userBusiness.getType());
|
|
||||||
userBusiness.setKeyId(userBusiness.getKeyId());
|
|
||||||
userBusiness.setValue(userBusiness.getValue());
|
|
||||||
userBusiness.setBtnStr(model.getBtnStr());
|
|
||||||
userBusinessService.update(userBusiness);
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改角色按钮权限的ID为 : " + model.getUserBusinessID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改功能回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新角色按钮权限", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis()), tipType,
|
|
||||||
"角色按钮权限的ID为 " + model.getUserBusinessID() + " " + tipMsg + "!", "更新角色按钮权限" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-RoleAPP
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_RoleAPP() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
condition.put("KeyId_s_eq", model.getKeyId());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查角色对应应用/功能是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsValueExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsValueExist("Type", model.getType(), "KeyId", model.getKeyId());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色对应应用/功能的类型为:" + model.getType() + " KeyId为: " + model.getKeyId() + " 是否存在异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查角色对应应用/功能的类型为:" + model.getType() + " KeyId为: " + model.getKeyId() + " 是否存在异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public UserBusinessModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserBusinessService(UserBusinessIService userBusinessService) {
|
|
||||||
this.userBusinessService = userBusinessService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,393 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.*;
|
|
||||||
import com.jsh.model.vo.materials.AccountHeadModel;
|
|
||||||
import com.jsh.service.materials.AccountHeadIService;
|
|
||||||
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.sql.Timestamp;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 财务表头管理
|
|
||||||
* @author jishenghua qq:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AccountHeadAction extends BaseAction<AccountHeadModel> {
|
|
||||||
private AccountHeadIService accountHeadService;
|
|
||||||
private AccountHeadModel model = new AccountHeadModel();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 获取MaxId
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getMaxId() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
accountHeadService.find(pageUtil, "maxId");
|
|
||||||
mapData.put("accountHeadMax", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找最大的Id信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加财务
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加财务信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
AccountHead accountHead = new AccountHead();
|
|
||||||
accountHead.setType(model.getType());
|
|
||||||
if (model.getOrganId() != null) {
|
|
||||||
accountHead.setOrganId(new Supplier(model.getOrganId()));
|
|
||||||
}
|
|
||||||
if (model.getHandsPersonId() != null) {
|
|
||||||
accountHead.setHandsPersonId(new Person(model.getHandsPersonId()));
|
|
||||||
}
|
|
||||||
accountHead.setChangeAmount(model.getChangeAmount() == null ? 0 : model.getChangeAmount());
|
|
||||||
accountHead.setTotalPrice(model.getTotalPrice());
|
|
||||||
if (model.getAccountId() != null) {
|
|
||||||
accountHead.setAccountId(new Account(model.getAccountId()));
|
|
||||||
}
|
|
||||||
accountHead.setBillNo(model.getBillNo());
|
|
||||||
try {
|
|
||||||
accountHead.setBillTime(new Timestamp(Tools.parse(model.getBillTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
|
||||||
}
|
|
||||||
accountHead.setRemark(model.getRemark());
|
|
||||||
accountHeadService.create(accountHead);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加财务信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加财务信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加财务", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加财务编号为 " + model.getBillNo() + " " + tipMsg + "!", "增加财务" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加财务方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除财务
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除财务信息方法delete()================");
|
|
||||||
try {
|
|
||||||
accountHeadService.delete(model.getAccountHeadID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAccountHeadID() + " 的财务异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除财务", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除财务ID为 " + model.getAccountHeadID() + " " + tipMsg + "!", "删除财务" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除财务信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新财务
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
AccountHead accountHead = accountHeadService.get(model.getAccountHeadID());
|
|
||||||
accountHead.setType(model.getType());
|
|
||||||
if (model.getOrganId() != null) {
|
|
||||||
accountHead.setOrganId(new Supplier(model.getOrganId()));
|
|
||||||
}
|
|
||||||
if (model.getHandsPersonId() != null) {
|
|
||||||
accountHead.setHandsPersonId(new Person(model.getHandsPersonId()));
|
|
||||||
}
|
|
||||||
accountHead.setChangeAmount(model.getChangeAmount() == null ? 0 : model.getChangeAmount());
|
|
||||||
accountHead.setTotalPrice(model.getTotalPrice());
|
|
||||||
if (model.getAccountId() != null) {
|
|
||||||
accountHead.setAccountId(new Account(model.getAccountId()));
|
|
||||||
}
|
|
||||||
accountHead.setBillNo(model.getBillNo());
|
|
||||||
try {
|
|
||||||
accountHead.setBillTime(new Timestamp(Tools.parse(model.getBillTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
|
||||||
}
|
|
||||||
accountHead.setRemark(model.getRemark());
|
|
||||||
accountHeadService.update(accountHead);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改财务ID为 : " + model.getAccountHeadID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改财务回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新财务", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新财务ID为 " + model.getAccountHeadID() + " " + tipMsg + "!", "更新财务" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID财务
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
accountHeadService.batchDelete(model.getAccountHeadIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除财务ID为:" + model.getAccountHeadIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除财务", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除财务ID为 " + model.getAccountHeadIDs() + " " + tipMsg + "!", "批量删除财务" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找财务信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
accountHeadService.find(pageUtil);
|
|
||||||
List<AccountHead> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (AccountHead accountHead : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", accountHead.getId());
|
|
||||||
item.put("OrganId", accountHead.getOrganId() == null ? "" : accountHead.getOrganId().getId());
|
|
||||||
item.put("OrganName", accountHead.getOrganId() == null ? "" : accountHead.getOrganId().getSupplier());
|
|
||||||
item.put("HandsPersonId", accountHead.getHandsPersonId() == null ? "" : accountHead.getHandsPersonId().getId());
|
|
||||||
item.put("HandsPersonName", accountHead.getHandsPersonId() == null ? "" : accountHead.getHandsPersonId().getName());
|
|
||||||
item.put("AccountId", accountHead.getAccountId() == null ? "" : accountHead.getAccountId().getId());
|
|
||||||
item.put("AccountName", accountHead.getAccountId() == null ? "" : accountHead.getAccountId().getName());
|
|
||||||
item.put("BillNo", accountHead.getBillNo());
|
|
||||||
item.put("BillTime", Tools.getCenternTime(accountHead.getBillTime()));
|
|
||||||
item.put("ChangeAmount", accountHead.getChangeAmount() == null ? "" : Math.abs(accountHead.getChangeAmount()));
|
|
||||||
item.put("TotalPrice", accountHead.getTotalPrice() == null ? "" : Math.abs(accountHead.getTotalPrice()));
|
|
||||||
item.put("Remark", accountHead.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找财务信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询财务信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据编号查询单据信息
|
|
||||||
*/
|
|
||||||
public void getDetailByNumber() {
|
|
||||||
try {
|
|
||||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionByNumber());
|
|
||||||
accountHeadService.find(pageUtil);
|
|
||||||
List<AccountHead> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
if (dataList != null && dataList.get(0) != null) {
|
|
||||||
AccountHead accountHead = dataList.get(0);
|
|
||||||
item.put("Id", accountHead.getId());
|
|
||||||
item.put("OrganId", accountHead.getOrganId() == null ? "" : accountHead.getOrganId().getId());
|
|
||||||
item.put("OrganName", accountHead.getOrganId() == null ? "" : accountHead.getOrganId().getSupplier());
|
|
||||||
item.put("HandsPersonId", accountHead.getHandsPersonId() == null ? "" : accountHead.getHandsPersonId().getId());
|
|
||||||
item.put("HandsPersonName", accountHead.getHandsPersonId() == null ? "" : accountHead.getHandsPersonId().getName());
|
|
||||||
item.put("AccountId", accountHead.getAccountId() == null ? "" : accountHead.getAccountId().getId());
|
|
||||||
item.put("AccountName", accountHead.getAccountId() == null ? "" : accountHead.getAccountId().getName());
|
|
||||||
item.put("BillNo", accountHead.getBillNo());
|
|
||||||
item.put("BillTime", Tools.getCenternTime(accountHead.getBillTime()));
|
|
||||||
item.put("ChangeAmount", accountHead.getChangeAmount() == null ? "" : Math.abs(accountHead.getChangeAmount()));
|
|
||||||
item.put("TotalPrice", accountHead.getTotalPrice() == null ? "" : Math.abs(accountHead.getTotalPrice()));
|
|
||||||
item.put("Remark", accountHead.getRemark());
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(item.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询单位的累计应收和累计应付,收预付款不计入此处
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findTotalPay() {
|
|
||||||
try {
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
Double sum = 0.0;
|
|
||||||
String getS = model.getSupplierId();
|
|
||||||
String supType = model.getSupType(); //单位类型:客户、供应商
|
|
||||||
int i = 1;
|
|
||||||
if (supType.equals("customer")) { //客户
|
|
||||||
i = 1;
|
|
||||||
} else if (supType.equals("vendor")) { //供应商
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
//收付款部分
|
|
||||||
sum = sum + (allMoney(getS, "付款", "合计") + allMoney(getS, "付款", "实际")) * i;
|
|
||||||
sum = sum - (allMoney(getS, "收款", "合计") + allMoney(getS, "收款", "实际")) * i;
|
|
||||||
sum = sum + (allMoney(getS, "收入", "合计") - allMoney(getS, "收入", "实际")) * i;
|
|
||||||
sum = sum - (allMoney(getS, "支出", "合计") - allMoney(getS, "支出", "实际")) * i;
|
|
||||||
outer.put("getAllMoney", sum);
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计总金额
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param mode 合计或者金额
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
||||||
public Double allMoney(String getS, String type, String mode) {
|
|
||||||
Log.infoFileSync("getS:" + getS);
|
|
||||||
Double allMoney = 0.0;
|
|
||||||
String allReturn = "";
|
|
||||||
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionHead_byEndTime());
|
|
||||||
try {
|
|
||||||
Integer supplierId = Integer.valueOf(getS);
|
|
||||||
accountHeadService.findAllMoney(pageUtil, supplierId, type, mode);
|
|
||||||
allReturn = pageUtil.getPageList().toString();
|
|
||||||
allReturn = allReturn.substring(1, allReturn.length() - 1);
|
|
||||||
if (allReturn.equals("null")) {
|
|
||||||
allReturn = "0";
|
|
||||||
}
|
|
||||||
} catch (JshException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
allMoney = Double.parseDouble(allReturn);
|
|
||||||
//返回正数,如果负数也转为正数
|
|
||||||
if (allMoney < 0) {
|
|
||||||
allMoney = -allMoney;
|
|
||||||
}
|
|
||||||
return allMoney;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionByNumber() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("BillNo_s_eq", model.getBillNo());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
{
|
|
||||||
condition.put("BillNo_s_like", model.getBillNo());
|
|
||||||
}
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
condition.put("BillTime_s_gteq", model.getBeginTime());
|
|
||||||
condition.put("BillTime_s_lteq", model.getEndTime());
|
|
||||||
condition.put("Id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionHead_byEndTime() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("BillTime_s_lteq", model.getEndTime());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
public AccountHeadModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountHeadService(AccountHeadIService accountHeadService) {
|
|
||||||
this.accountHeadService = accountHeadService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.*;
|
|
||||||
import com.jsh.model.vo.materials.AccountItemModel;
|
|
||||||
import com.jsh.service.materials.AccountItemIService;
|
|
||||||
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:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class AccountItemAction extends BaseAction<AccountItemModel> {
|
|
||||||
private AccountItemIService accountItemService;
|
|
||||||
private AccountItemModel model = new AccountItemModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存明细
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void saveDetials() {
|
|
||||||
Log.infoFileSync("==================开始调用保存财务明细信息方法saveDetials()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Long headerId = model.getHeaderId();
|
|
||||||
String listType = model.getListType(); //单据类型
|
|
||||||
String inserted = model.getInserted();
|
|
||||||
String deleted = model.getDeleted();
|
|
||||||
String updated = model.getUpdated();
|
|
||||||
//转为json
|
|
||||||
JSONArray insertedJson = JSONArray.fromObject(inserted);
|
|
||||||
JSONArray deletedJson = JSONArray.fromObject(deleted);
|
|
||||||
JSONArray updatedJson = JSONArray.fromObject(updated);
|
|
||||||
if (null != insertedJson) {
|
|
||||||
for (int i = 0; i < insertedJson.size(); i++) {
|
|
||||||
AccountItem accountItem = new AccountItem();
|
|
||||||
JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i));
|
|
||||||
accountItem.setHeaderId(new AccountHead(headerId));
|
|
||||||
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
|
|
||||||
accountItem.setAccountId(new Account(tempInsertedJson.getLong("AccountId")));
|
|
||||||
}
|
|
||||||
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
|
|
||||||
accountItem.setInOutItemId(new InOutItem(tempInsertedJson.getLong("InOutItemId")));
|
|
||||||
}
|
|
||||||
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
|
|
||||||
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
|
|
||||||
if (listType.equals("付款")) {
|
|
||||||
eachAmount = 0 - eachAmount;
|
|
||||||
}
|
|
||||||
accountItem.setEachAmount(eachAmount);
|
|
||||||
} else {
|
|
||||||
accountItem.setEachAmount(0.0);
|
|
||||||
}
|
|
||||||
accountItem.setRemark(tempInsertedJson.getString("Remark"));
|
|
||||||
accountItemService.create(accountItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (null != deletedJson) {
|
|
||||||
for (int i = 0; i < deletedJson.size(); i++) {
|
|
||||||
JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i));
|
|
||||||
accountItemService.delete(tempDeletedJson.getLong("Id"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (null != updatedJson) {
|
|
||||||
for (int i = 0; i < updatedJson.size(); i++) {
|
|
||||||
JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i));
|
|
||||||
AccountItem accountItem = accountItemService.get(tempUpdatedJson.getLong("Id"));
|
|
||||||
accountItem.setHeaderId(new AccountHead(headerId));
|
|
||||||
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
|
|
||||||
accountItem.setAccountId(new Account(tempUpdatedJson.getLong("AccountId")));
|
|
||||||
}
|
|
||||||
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
|
|
||||||
accountItem.setInOutItemId(new InOutItem(tempUpdatedJson.getLong("InOutItemId")));
|
|
||||||
}
|
|
||||||
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
|
|
||||||
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
|
|
||||||
if (listType.equals("付款")) {
|
|
||||||
eachAmount = 0 - eachAmount;
|
|
||||||
}
|
|
||||||
accountItem.setEachAmount(eachAmount);
|
|
||||||
} else {
|
|
||||||
accountItem.setEachAmount(0.0);
|
|
||||||
}
|
|
||||||
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
|
|
||||||
accountItemService.create(accountItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存财务明细信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>保存财务明细信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "保存财务明细", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "保存财务明细对应主表编号为 " + model.getHeaderId() + " " + tipMsg + "!", "保存财务明细" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用保存财务明细方法saveDetials()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找财务信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<AccountItem> pageUtil = new PageUtil<AccountItem>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
accountItemService.find(pageUtil);
|
|
||||||
List<AccountItem> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (AccountItem accountItem : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", accountItem.getId());
|
|
||||||
item.put("AccountId", accountItem.getAccountId() == null ? "" : accountItem.getAccountId().getId());
|
|
||||||
item.put("AccountName", accountItem.getAccountId() == null ? "" : accountItem.getAccountId().getName());
|
|
||||||
item.put("InOutItemId", accountItem.getInOutItemId() == null ? "" : accountItem.getInOutItemId().getId());
|
|
||||||
item.put("InOutItemName", accountItem.getInOutItemId() == null ? "" : accountItem.getInOutItemId().getName());
|
|
||||||
Double eachAmount = accountItem.getEachAmount();
|
|
||||||
item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
|
|
||||||
item.put("Remark", accountItem.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找财务信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询财务信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("HeaderId_n_eq", model.getHeaderId());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public AccountItemModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountItemService(AccountItemIService accountItemService) {
|
|
||||||
this.accountItemService = accountItemService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,920 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.*;
|
|
||||||
import com.jsh.model.vo.materials.DepotHeadModel;
|
|
||||||
import com.jsh.service.materials.DepotHeadIService;
|
|
||||||
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.sql.Timestamp;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 单据表头管理
|
|
||||||
* @author jishenghua qq:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class DepotHeadAction extends BaseAction<DepotHeadModel> {
|
|
||||||
private DepotHeadIService depotHeadService;
|
|
||||||
private DepotHeadModel model = new DepotHeadModel();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 获取MaxId
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getMaxId() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
depotHeadService.find(pageUtil, "maxId");
|
|
||||||
mapData.put("depotHeadMax", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找最大的Id信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加单据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加单据信息信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
DepotHead depotHead = new DepotHead();
|
|
||||||
depotHead.setType(model.getType());
|
|
||||||
depotHead.setSubType(model.getSubType());
|
|
||||||
if (model.getProjectId() != null) {
|
|
||||||
depotHead.setProjectId(new Depot(model.getProjectId()));
|
|
||||||
}
|
|
||||||
//构造新的编号
|
|
||||||
String dNumber = model.getDefaultNumber();
|
|
||||||
String number = dNumber.substring(0, 12); //截取前缀
|
|
||||||
String beginTime = Tools.getNow() + " 00:00:00";
|
|
||||||
String endTime = Tools.getNow() + " 23:59:59";
|
|
||||||
String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime); //从数据库查询最新的编号+1,这样能防止重复
|
|
||||||
String allNewNumber = number + newNumber;
|
|
||||||
depotHead.setNumber(model.getNumber()); //一直从前端文本框里面获取
|
|
||||||
depotHead.setDefaultNumber(allNewNumber); //初始编号,一直都从后台取值
|
|
||||||
|
|
||||||
depotHead.setOperPersonName(getUser().getUsername());
|
|
||||||
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
||||||
try {
|
|
||||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
|
||||||
}
|
|
||||||
if (model.getOrganId() != null) {
|
|
||||||
depotHead.setOrganId(new Supplier(model.getOrganId()));
|
|
||||||
}
|
|
||||||
if (model.getHandsPersonId() != null) {
|
|
||||||
depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));
|
|
||||||
}
|
|
||||||
if (model.getSalesman() != null) {
|
|
||||||
depotHead.setSalesman(model.getSalesman().toString());
|
|
||||||
}
|
|
||||||
if (model.getAccountId() != null) {
|
|
||||||
depotHead.setAccountId(new Account(model.getAccountId()));
|
|
||||||
}
|
|
||||||
depotHead.setChangeAmount(model.getChangeAmount());
|
|
||||||
depotHead.setAccountIdList(model.getAccountIdList());
|
|
||||||
depotHead.setAccountMoneyList(model.getAccountMoneyList());
|
|
||||||
depotHead.setDiscount(model.getDiscount());
|
|
||||||
depotHead.setDiscountMoney(model.getDiscountMoney());
|
|
||||||
depotHead.setDiscountLastMoney(model.getDiscountLastMoney());
|
|
||||||
depotHead.setOtherMoney(model.getOtherMoney());
|
|
||||||
depotHead.setOtherMoneyList(model.getOtherMoneyList());
|
|
||||||
depotHead.setOtherMoneyItem(model.getOtherMoneyItem());
|
|
||||||
depotHead.setAccountDay(model.getAccountDay());
|
|
||||||
if (model.getAllocationProjectId() != null) {
|
|
||||||
depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));
|
|
||||||
}
|
|
||||||
depotHead.setTotalPrice(model.getTotalPrice());
|
|
||||||
depotHead.setPayType(model.getPayType());
|
|
||||||
depotHead.setStatus(false);
|
|
||||||
depotHead.setRemark(model.getRemark());
|
|
||||||
depotHeadService.create(depotHead);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单据信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加单据信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加单据", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加单据编号为 " + model.getNumber() + " " + tipMsg + "!", "增加单据" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加单据方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除单据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除单据信息方法delete()================");
|
|
||||||
try {
|
|
||||||
depotHeadService.delete(model.getDepotHeadID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + " 的单据异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除单据", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除单据ID为 " + model.getDepotHeadID() + " " + tipMsg + "!", "删除单据" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除单据信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新单据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
DepotHead depotHead = depotHeadService.get(model.getDepotHeadID());
|
|
||||||
depotHead.setType(model.getType());
|
|
||||||
depotHead.setSubType(model.getSubType());
|
|
||||||
if (model.getProjectId() != null) {
|
|
||||||
depotHead.setProjectId(new Depot(model.getProjectId()));
|
|
||||||
}
|
|
||||||
depotHead.setNumber(model.getNumber());
|
|
||||||
depotHead.setOperPersonName(getUser().getUsername());
|
|
||||||
try {
|
|
||||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析入库时间格式异常", e);
|
|
||||||
}
|
|
||||||
if (model.getOrganId() != null) {
|
|
||||||
depotHead.setOrganId(new Supplier(model.getOrganId()));
|
|
||||||
}
|
|
||||||
if (model.getHandsPersonId() != null) {
|
|
||||||
depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));
|
|
||||||
}
|
|
||||||
depotHead.setSalesman(model.getSalesman());
|
|
||||||
if (model.getAccountId() != null) {
|
|
||||||
depotHead.setAccountId(new Account(model.getAccountId()));
|
|
||||||
} else {
|
|
||||||
depotHead.setAccountId(null);
|
|
||||||
}
|
|
||||||
depotHead.setChangeAmount(model.getChangeAmount());
|
|
||||||
depotHead.setAccountIdList(model.getAccountIdList());
|
|
||||||
depotHead.setAccountMoneyList(model.getAccountMoneyList());
|
|
||||||
depotHead.setDiscount(model.getDiscount());
|
|
||||||
depotHead.setDiscountMoney(model.getDiscountMoney());
|
|
||||||
depotHead.setDiscountLastMoney(model.getDiscountLastMoney());
|
|
||||||
depotHead.setOtherMoney(model.getOtherMoney());
|
|
||||||
depotHead.setOtherMoneyList(model.getOtherMoneyList());
|
|
||||||
depotHead.setOtherMoneyItem(model.getOtherMoneyItem());
|
|
||||||
depotHead.setAccountDay(model.getAccountDay());
|
|
||||||
if (model.getAllocationProjectId() != null) {
|
|
||||||
depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));
|
|
||||||
}
|
|
||||||
depotHead.setTotalPrice(model.getTotalPrice());
|
|
||||||
depotHead.setPayType(model.getPayType());
|
|
||||||
depotHead.setStatus(false);
|
|
||||||
depotHead.setRemark(model.getRemark());
|
|
||||||
depotHeadService.update(depotHead);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改单据ID为 : " + model.getDepotHeadID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改单据回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新单据", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新单据ID为 " + model.getDepotHeadID() + " " + tipMsg + "!", "更新单据" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID单据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
depotHeadService.batchDelete(model.getDepotHeadIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除单据ID为:" + model.getDepotHeadIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除单据", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除单据ID为 " + model.getDepotHeadIDs() + " " + tipMsg + "!", "批量删除单据" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量设置状态-审核或者反审核
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchSetStatus() {
|
|
||||||
try {
|
|
||||||
depotHeadService.batchSetStatus(model.getStatus(), model.getDepotHeadIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量修改状态,单据ID为:" + model.getDepotHeadIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量修改单据状态", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量修改状态,单据ID为 " + model.getDepotHeadIDs() + " " + tipMsg + "!", "批量修改单据状态" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查单据编号是否存在
|
|
||||||
*/
|
|
||||||
public void checkIsNumberExist() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = depotHeadService.checkIsNameExist("Number", model.getNumber(), "Id", model.getDepotHeadID());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!");
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>回写检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单据编号生成接口,规则:查找当前类型单据下的当天最大的单据号,并加1
|
|
||||||
*/
|
|
||||||
public void buildNumber() {
|
|
||||||
try {
|
|
||||||
String beginTime = model.getBeginTime();
|
|
||||||
String endTime = model.getEndTime();
|
|
||||||
String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime);
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("DefaultNumber", newNumber);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写单据编号生成接口异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找单据编号
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String buildNumberFun(String type, String subType, String beginTime, String endTime) {
|
|
||||||
String newNumber = "0001"; //新编号
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(buildNumberCondition(type, subType, beginTime, endTime));
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
if (null != dataList && dataList.size() > 0) {
|
|
||||||
DepotHead depotHead = dataList.get(0);
|
|
||||||
if (depotHead != null) {
|
|
||||||
String number = depotHead.getDefaultNumber(); //最大的单据编号
|
|
||||||
if (number != null) {
|
|
||||||
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
|
|
||||||
lastNumber = lastNumber + 1;
|
|
||||||
Integer nLen = lastNumber.toString().length();
|
|
||||||
if (nLen == 1) {
|
|
||||||
newNumber = "000" + lastNumber.toString();
|
|
||||||
} else if (nLen == 2) {
|
|
||||||
newNumber = "00" + lastNumber.toString();
|
|
||||||
} else if (nLen == 3) {
|
|
||||||
newNumber = "0" + lastNumber.toString();
|
|
||||||
} else if (nLen == 4) {
|
|
||||||
newNumber = lastNumber.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
|
|
||||||
}
|
|
||||||
return newNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据材料信息获取
|
|
||||||
*/
|
|
||||||
public void getHeaderIdByMaterial() {
|
|
||||||
try {
|
|
||||||
String materialParam = model.getMaterialParam(); //商品参数
|
|
||||||
String depotIds = model.getDepotIds(); //拥有的仓库信息
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
depotHeadService.getHeaderIdByMaterial(pageUtil, materialParam, depotIds);
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
String allReturn = "";
|
|
||||||
List dataList = pageUtil.getPageList();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (Integer i = 0; i < dataList.size(); i++) {
|
|
||||||
Object dl = dataList.get(i); //获取对象
|
|
||||||
allReturn = allReturn + dl.toString() + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allReturn = allReturn.substring(0, allReturn.length() - 1);
|
|
||||||
if (allReturn.equals("null")) {
|
|
||||||
allReturn = "";
|
|
||||||
}
|
|
||||||
outer.put("ret", allReturn);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找单据信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (DepotHead depotHead : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", depotHead.getId());
|
|
||||||
item.put("ProjectId", depotHead.getProjectId() == null ? "" : depotHead.getProjectId().getId());
|
|
||||||
item.put("ProjectName", depotHead.getProjectId() == null ? "" : depotHead.getProjectId().getName());
|
|
||||||
item.put("Number", depotHead.getNumber());
|
|
||||||
item.put("OperPersonName", depotHead.getOperPersonName());
|
|
||||||
item.put("CreateTime", Tools.getCenternTime(depotHead.getCreateTime()));
|
|
||||||
item.put("OperTime", Tools.getCenternTime(depotHead.getOperTime()));
|
|
||||||
item.put("OrganId", depotHead.getOrganId() == null ? "" : depotHead.getOrganId().getId());
|
|
||||||
item.put("OrganName", depotHead.getOrganId() == null ? "" : depotHead.getOrganId().getSupplier());
|
|
||||||
item.put("HandsPersonId", depotHead.getHandsPersonId() == null ? "" : depotHead.getHandsPersonId().getId());
|
|
||||||
item.put("Salesman", depotHead.getSalesman().toString());
|
|
||||||
item.put("HandsPersonName", depotHead.getHandsPersonId() == null ? "" : depotHead.getHandsPersonId().getName());
|
|
||||||
item.put("AccountId", depotHead.getAccountId() == null ? "" : depotHead.getAccountId().getId());
|
|
||||||
item.put("AccountName", depotHead.getAccountId() == null ? "" : depotHead.getAccountId().getName());
|
|
||||||
item.put("ChangeAmount", depotHead.getChangeAmount() == null ? "" : Math.abs(depotHead.getChangeAmount()));
|
|
||||||
item.put("AccountIdList", depotHead.getAccountIdList());
|
|
||||||
item.put("AccountMoneyList", depotHead.getAccountMoneyList());
|
|
||||||
item.put("Discount", depotHead.getDiscount());
|
|
||||||
item.put("DiscountMoney", depotHead.getDiscountMoney());
|
|
||||||
item.put("DiscountLastMoney", depotHead.getDiscountLastMoney());
|
|
||||||
item.put("OtherMoney", depotHead.getOtherMoney());
|
|
||||||
item.put("OtherMoneyList", depotHead.getOtherMoneyList()); //id列表
|
|
||||||
item.put("OtherMoneyItem", depotHead.getOtherMoneyItem()); //money列表
|
|
||||||
item.put("AccountDay", depotHead.getAccountDay()); //结算天数
|
|
||||||
item.put("AllocationProjectId", depotHead.getAllocationProjectId() == null ? "" : depotHead.getAllocationProjectId().getId());
|
|
||||||
item.put("AllocationProjectName", depotHead.getAllocationProjectId() == null ? "" : depotHead.getAllocationProjectId().getName());
|
|
||||||
item.put("TotalPrice", depotHead.getTotalPrice() == null ? "" : Math.abs(depotHead.getTotalPrice()));
|
|
||||||
item.put("payType", depotHead.getPayType() == null ? "" : depotHead.getPayType());
|
|
||||||
item.put("Status", depotHead.getStatus());
|
|
||||||
item.put("Remark", depotHead.getRemark());
|
|
||||||
item.put("MaterialsList", findMaterialsListByHeaderId(depotHead.getId()));
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据编号查询单据信息
|
|
||||||
*/
|
|
||||||
public void getDetailByNumber() {
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionByNumber());
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
if (dataList != null && dataList.get(0) != null) {
|
|
||||||
DepotHead depotHead = dataList.get(0);
|
|
||||||
item.put("Id", depotHead.getId());
|
|
||||||
item.put("ProjectId", depotHead.getProjectId() == null ? "" : depotHead.getProjectId().getId());
|
|
||||||
item.put("ProjectName", depotHead.getProjectId() == null ? "" : depotHead.getProjectId().getName());
|
|
||||||
item.put("Number", depotHead.getNumber());
|
|
||||||
item.put("OperPersonName", depotHead.getOperPersonName());
|
|
||||||
item.put("CreateTime", Tools.getCenternTime(depotHead.getCreateTime()));
|
|
||||||
item.put("OperTime", Tools.getCenternTime(depotHead.getOperTime()));
|
|
||||||
item.put("OrganId", depotHead.getOrganId() == null ? "" : depotHead.getOrganId().getId());
|
|
||||||
item.put("OrganName", depotHead.getOrganId() == null ? "" : depotHead.getOrganId().getSupplier());
|
|
||||||
item.put("HandsPersonId", depotHead.getHandsPersonId() == null ? "" : depotHead.getHandsPersonId().getId());
|
|
||||||
item.put("Salesman", depotHead.getSalesman().toString());
|
|
||||||
item.put("HandsPersonName", depotHead.getHandsPersonId() == null ? "" : depotHead.getHandsPersonId().getName());
|
|
||||||
item.put("AccountId", depotHead.getAccountId() == null ? "" : depotHead.getAccountId().getId());
|
|
||||||
item.put("AccountName", depotHead.getAccountId() == null ? "" : depotHead.getAccountId().getName());
|
|
||||||
item.put("ChangeAmount", depotHead.getChangeAmount() == null ? "" : Math.abs(depotHead.getChangeAmount()));
|
|
||||||
item.put("AccountIdList", depotHead.getAccountIdList());
|
|
||||||
item.put("AccountMoneyList", depotHead.getAccountMoneyList());
|
|
||||||
item.put("Discount", depotHead.getDiscount());
|
|
||||||
item.put("DiscountMoney", depotHead.getDiscountMoney());
|
|
||||||
item.put("DiscountLastMoney", depotHead.getDiscountLastMoney());
|
|
||||||
item.put("OtherMoney", depotHead.getOtherMoney());
|
|
||||||
item.put("OtherMoneyList", depotHead.getOtherMoneyList()); //id列表
|
|
||||||
item.put("OtherMoneyItem", depotHead.getOtherMoneyItem()); //money列表
|
|
||||||
item.put("AccountDay", depotHead.getAccountDay()); //结算天数
|
|
||||||
item.put("AllocationProjectId", depotHead.getAllocationProjectId() == null ? "" : depotHead.getAllocationProjectId().getId());
|
|
||||||
item.put("AllocationProjectName", depotHead.getAllocationProjectId() == null ? "" : depotHead.getAllocationProjectId().getName());
|
|
||||||
item.put("TotalPrice", depotHead.getTotalPrice() == null ? "" : Math.abs(depotHead.getTotalPrice()));
|
|
||||||
item.put("payType", depotHead.getPayType() == null ? "" : depotHead.getPayType());
|
|
||||||
item.put("Status", depotHead.getStatus());
|
|
||||||
item.put("Remark", depotHead.getRemark());
|
|
||||||
item.put("MaterialsList", findMaterialsListByHeaderId(depotHead.getId()));
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(item.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找单据_根据月份(报表)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findByMonth() {
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(1000);
|
|
||||||
pageUtil.setCurPage(1);
|
|
||||||
pageUtil.setAdvSearch(getConditionHead());
|
|
||||||
depotHeadService.find(pageUtil);
|
|
||||||
List<DepotHead> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
String headId = "";
|
|
||||||
if (null != dataList) {
|
|
||||||
for (DepotHead depotHead : dataList) {
|
|
||||||
headId = headId + depotHead.getId() + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (headId != "") {
|
|
||||||
headId = headId.substring(0, headId.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
outer.put("HeadIds", headId);
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找统计信息_根据礼品卡(报表)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findGiftReport() {
|
|
||||||
try {
|
|
||||||
PageUtil<DepotHead> pageUtil_in = new PageUtil<DepotHead>();
|
|
||||||
pageUtil_in.setPageSize(0);
|
|
||||||
pageUtil_in.setCurPage(0);
|
|
||||||
pageUtil_in.setAdvSearch(getConditionHead_Gift_In());
|
|
||||||
depotHeadService.find(pageUtil_in);
|
|
||||||
List<DepotHead> dataList_in = pageUtil_in.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
String headId = "";
|
|
||||||
if (null != dataList_in) {
|
|
||||||
for (DepotHead depotHead : dataList_in) {
|
|
||||||
headId = headId + depotHead.getId() + ",";
|
|
||||||
}
|
|
||||||
PageUtil<DepotHead> pageUtil_out = new PageUtil<DepotHead>();
|
|
||||||
pageUtil_out.setPageSize(0);
|
|
||||||
pageUtil_out.setCurPage(0);
|
|
||||||
pageUtil_out.setAdvSearch(getConditionHead_Gift_Out());
|
|
||||||
depotHeadService.find(pageUtil_out);
|
|
||||||
List<DepotHead> dataList_out = pageUtil_out.getPageList();
|
|
||||||
if (null != dataList_out) {
|
|
||||||
for (DepotHead depotHead : dataList_out) {
|
|
||||||
headId = headId + depotHead.getId() + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (headId != "") {
|
|
||||||
headId = headId.substring(0, headId.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
outer.put("HeadIds", headId);
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询单位的累计应收和累计应付,零售不能计入
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findTotalPay() {
|
|
||||||
try {
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
Double sum = 0.0;
|
|
||||||
String getS = model.getSupplierId();
|
|
||||||
String supType = model.getSupType(); //单位类型:客户、供应商
|
|
||||||
int i = 1;
|
|
||||||
if (supType.equals("customer")) { //客户
|
|
||||||
i = 1;
|
|
||||||
} else if (supType.equals("vendor")) { //供应商
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
//进销部分
|
|
||||||
sum = sum - (allMoney(getS, "入库", "采购", "合计") - allMoney(getS, "入库", "采购", "实际")) * i;
|
|
||||||
sum = sum - (allMoney(getS, "入库", "销售退货", "合计") - allMoney(getS, "入库", "销售退货", "实际")) * i;
|
|
||||||
sum = sum + (allMoney(getS, "出库", "销售", "合计") - allMoney(getS, "出库", "销售", "实际")) * i;
|
|
||||||
sum = sum + (allMoney(getS, "出库", "采购退货", "合计") - allMoney(getS, "出库", "采购退货", "实际")) * i;
|
|
||||||
outer.put("getAllMoney", sum);
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计总金额
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param subType
|
|
||||||
* @param mode 合计或者金额
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
||||||
public Double allMoney(String getS, String type, String subType, String mode) {
|
|
||||||
Log.infoFileSync("getS:" + getS);
|
|
||||||
Double allMoney = 0.0;
|
|
||||||
String allReturn = "";
|
|
||||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionHead_byEndTime());
|
|
||||||
try {
|
|
||||||
Integer supplierId = Integer.valueOf(getS);
|
|
||||||
depotHeadService.findAllMoney(pageUtil, supplierId, type, subType, mode);
|
|
||||||
allReturn = pageUtil.getPageList().toString();
|
|
||||||
allReturn = allReturn.substring(1, allReturn.length() - 1);
|
|
||||||
if (allReturn.equals("null")) {
|
|
||||||
allReturn = "0";
|
|
||||||
}
|
|
||||||
} catch (JshException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
allMoney = Double.parseDouble(allReturn);
|
|
||||||
//返回正数,如果负数也转为正数
|
|
||||||
if (allMoney < 0) {
|
|
||||||
allMoney = -allMoney;
|
|
||||||
}
|
|
||||||
return allMoney;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 入库出库明细接口
|
|
||||||
*/
|
|
||||||
public void findInDetail() {
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
Long pid = model.getProjectId();
|
|
||||||
String dids = model.getDepotIds();
|
|
||||||
Long oId = model.getOrganId();
|
|
||||||
String beginTime = model.getBeginTime();
|
|
||||||
String endTime = model.getEndTime();
|
|
||||||
String type = model.getType();
|
|
||||||
try {
|
|
||||||
depotHeadService.findInDetail(pageUtil, beginTime, endTime, type, pid, dids, oId);
|
|
||||||
List dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (Integer i = 0; i < dataList.size(); i++) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
Object dl = dataList.get(i); //获取对象
|
|
||||||
Object[] arr = (Object[]) dl; //转为数组
|
|
||||||
item.put("number", arr[0]); //单据编号
|
|
||||||
item.put("materialName", arr[1]); //商品名称
|
|
||||||
item.put("materialModel", arr[2]); //商品型号
|
|
||||||
item.put("unitPrice", arr[3]); //单价
|
|
||||||
item.put("operNumber", arr[4]); //入库出库数量
|
|
||||||
item.put("allPrice", arr[5]); //金额
|
|
||||||
item.put("supplierName", arr[6]); //供应商
|
|
||||||
item.put("depotName", arr[7]); //仓库
|
|
||||||
item.put("operTime", arr[8]); //入库出库日期
|
|
||||||
item.put("type", arr[9]); //入库出库日期
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 入库出库统计接口
|
|
||||||
*/
|
|
||||||
public void findInOutMaterialCount() {
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
Long pid = model.getProjectId();
|
|
||||||
String dids = model.getDepotIds();
|
|
||||||
Long oId = model.getOrganId();
|
|
||||||
String beginTime = model.getBeginTime();
|
|
||||||
String endTime = model.getEndTime();
|
|
||||||
String type = model.getType();
|
|
||||||
try {
|
|
||||||
depotHeadService.findInOutMaterialCount(pageUtil, beginTime, endTime, type, pid, dids, oId);
|
|
||||||
List dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (Integer i = 0; i < dataList.size(); i++) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
Object dl = dataList.get(i); //获取对象
|
|
||||||
Object[] arr = (Object[]) dl; //转为数组
|
|
||||||
item.put("MaterialId", arr[0]); //商品Id
|
|
||||||
item.put("mName", arr[1]); //商品名称
|
|
||||||
item.put("Model", arr[2]); //商品型号
|
|
||||||
item.put("categoryName", arr[3]); //商品类型
|
|
||||||
item.put("numSum", arr[4]); //数量
|
|
||||||
item.put("priceSum", arr[5]); //金额
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String findMaterialsListByHeaderId(Long headerId) {
|
|
||||||
String allReturn = "";
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
depotHeadService.findMaterialsListByHeaderId(pageUtil, headerId);
|
|
||||||
allReturn = pageUtil.getPageList().toString();
|
|
||||||
allReturn = allReturn.substring(1, allReturn.length() - 1);
|
|
||||||
if (allReturn.equals("null")) {
|
|
||||||
allReturn = "";
|
|
||||||
}
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
}
|
|
||||||
return allReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对账单接口
|
|
||||||
*/
|
|
||||||
public void findStatementAccount() {
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
String beginTime = model.getBeginTime();
|
|
||||||
String endTime = model.getEndTime();
|
|
||||||
Long organId = model.getOrganId();
|
|
||||||
String supType = model.getSupType(); //单位类型:客户、供应商
|
|
||||||
int j = 1;
|
|
||||||
if (supType.equals("客户")) { //客户
|
|
||||||
j = 1;
|
|
||||||
} else if (supType.equals("供应商")) { //供应商
|
|
||||||
j = -1;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
depotHeadService.findStatementAccount(pageUtil, beginTime, endTime, organId, supType);
|
|
||||||
List dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (dataList != null) {
|
|
||||||
for (Integer i = 0; i < dataList.size(); i++) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
Object dl = dataList.get(i); //获取对象
|
|
||||||
Object[] arr = (Object[]) dl; //转为数组
|
|
||||||
item.put("number", arr[0]); //单据编号
|
|
||||||
item.put("type", arr[1]); //类型
|
|
||||||
String type = arr[1].toString();
|
|
||||||
Double p1 = 0.0;
|
|
||||||
Double p2 = 0.0;
|
|
||||||
if (arr[2] != null) {
|
|
||||||
p1 = Double.parseDouble(arr[2].toString());
|
|
||||||
}
|
|
||||||
if (arr[3] != null) {
|
|
||||||
p2 = Double.parseDouble(arr[3].toString());
|
|
||||||
}
|
|
||||||
Double allPrice = 0.0;
|
|
||||||
if (p1 < 0) {
|
|
||||||
p1 = -p1;
|
|
||||||
}
|
|
||||||
if (p2 < 0) {
|
|
||||||
p2 = -p2;
|
|
||||||
}
|
|
||||||
if (type.equals("采购入库")) {
|
|
||||||
allPrice = -(p1 - p2);
|
|
||||||
} else if (type.equals("销售退货入库")) {
|
|
||||||
allPrice = -(p1 - p2);
|
|
||||||
} else if (type.equals("销售出库")) {
|
|
||||||
allPrice = p1 - p2;
|
|
||||||
} else if (type.equals("采购退货出库")) {
|
|
||||||
allPrice = p1 - p2;
|
|
||||||
} else if (type.equals("付款")) {
|
|
||||||
allPrice = p1 + p2;
|
|
||||||
} else if (type.equals("收款")) {
|
|
||||||
allPrice = -(p1 + p2);
|
|
||||||
} else if (type.equals("收入")) {
|
|
||||||
allPrice = p1 - p2;
|
|
||||||
} else if (type.equals("支出")) {
|
|
||||||
allPrice = -(p1 - p2);
|
|
||||||
}
|
|
||||||
item.put("discountLastMoney", p1); //金额
|
|
||||||
item.put("changeAmount", p2); //金额
|
|
||||||
item.put("allPrice", String.format("%.2f", allPrice * j)); //计算后的金额
|
|
||||||
item.put("supplierName", arr[4]); //供应商
|
|
||||||
item.put("operTime", arr[5]); //入库出库日期
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (JshException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionByNumber() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Number_s_eq", model.getNumber());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
condition.put("SubType_s_eq", model.getSubType());
|
|
||||||
condition.put("Number_s_like", model.getNumber());
|
|
||||||
condition.put("Id_s_in", model.getDhIds());
|
|
||||||
condition.put("OperTime_s_gteq", model.getBeginTime());
|
|
||||||
condition.put("OperTime_s_lteq", model.getEndTime());
|
|
||||||
condition.put("Id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> buildNumberCondition(String type, String subType, String beginTime, String endTime) {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Type_s_eq", type);
|
|
||||||
condition.put("SubType_s_eq", subType);
|
|
||||||
condition.put("OperTime_s_gteq", beginTime);
|
|
||||||
condition.put("OperTime_s_lteq", endTime);
|
|
||||||
condition.put("Id_s_order", "desc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionHead() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("OperTime_s_lteq", model.getMonthTime() + "-31 00:00:00");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionHead_Gift_In() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionHead_Gift_Out() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
if (model.getProjectId() != null) {
|
|
||||||
condition.put("ProjectId_n_eq", model.getProjectId());
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionHead_byEndTime() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("OperTime_s_lteq", model.getEndTime());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
public DepotHeadModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDepotHeadService(DepotHeadIService depotHeadService) {
|
|
||||||
this.depotHeadService = depotHeadService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,666 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.Material;
|
|
||||||
import com.jsh.model.po.MaterialCategory;
|
|
||||||
import com.jsh.model.po.Unit;
|
|
||||||
import com.jsh.model.vo.materials.MaterialModel;
|
|
||||||
import com.jsh.service.materials.MaterialIService;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.MaterialConstants;
|
|
||||||
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.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 商品管理
|
|
||||||
* @author jishenghua qq:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class MaterialAction extends BaseAction<MaterialModel> {
|
|
||||||
public static final String EXCEL = "excel"; //action返回excel结果
|
|
||||||
private MaterialIService materialService;
|
|
||||||
private MaterialModel model = new MaterialModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加商品
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加商品信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Material material = new Material();
|
|
||||||
material.setMaterialCategory(new MaterialCategory(model.getCategoryId()));
|
|
||||||
|
|
||||||
material.setName(model.getName());
|
|
||||||
material.setMfrs(model.getMfrs());
|
|
||||||
material.setPacking(model.getPacking());
|
|
||||||
material.setSafetyStock(model.getSafetyStock());
|
|
||||||
material.setModel(model.getModel());
|
|
||||||
material.setStandard(model.getStandard());
|
|
||||||
material.setColor(model.getColor());
|
|
||||||
material.setUnit(model.getUnit());
|
|
||||||
material.setRetailPrice(model.getRetailPrice());
|
|
||||||
material.setLowPrice(model.getLowPrice());
|
|
||||||
material.setPresetPriceOne(model.getPresetPriceOne());
|
|
||||||
material.setPresetPriceTwo(model.getPresetPriceTwo());
|
|
||||||
if (model.getUnitId() != null) {
|
|
||||||
material.setUnitId(new Unit(model.getUnitId()));
|
|
||||||
} else {
|
|
||||||
material.setUnitId(null);
|
|
||||||
}
|
|
||||||
material.setFirstOutUnit(model.getFirstOutUnit());
|
|
||||||
material.setFirstInUnit(model.getFirstInUnit());
|
|
||||||
material.setPriceStrategy(model.getPriceStrategy());
|
|
||||||
material.setRemark(model.getRemark());
|
|
||||||
material.setEnabled(model.getEnabled());
|
|
||||||
material.setOtherField1(model.getOtherField1());
|
|
||||||
material.setOtherField2(model.getOtherField2());
|
|
||||||
material.setOtherField3(model.getOtherField3());
|
|
||||||
materialService.create(material);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加商品信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加商品信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加商品", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加商品名称为 " + model.getName() + " " + tipMsg + "!", "增加商品" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加商品方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除商品
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除商品信息方法delete()================");
|
|
||||||
try {
|
|
||||||
materialService.delete(model.getMaterialID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialID() + " 的商品异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除商品", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除商品ID为 " + model.getMaterialID() + " " + tipMsg + "!", "删除商品" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除商品信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新商品
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Material material = materialService.get(model.getMaterialID());
|
|
||||||
material.setMaterialCategory(new MaterialCategory(model.getCategoryId()));
|
|
||||||
|
|
||||||
material.setName(model.getName());
|
|
||||||
material.setMfrs(model.getMfrs());
|
|
||||||
material.setPacking(model.getPacking());
|
|
||||||
material.setSafetyStock(model.getSafetyStock());
|
|
||||||
material.setModel(model.getModel());
|
|
||||||
material.setStandard(model.getStandard());
|
|
||||||
material.setColor(model.getColor());
|
|
||||||
material.setUnit(model.getUnit());
|
|
||||||
material.setRetailPrice(model.getRetailPrice());
|
|
||||||
material.setLowPrice(model.getLowPrice());
|
|
||||||
material.setPresetPriceOne(model.getPresetPriceOne());
|
|
||||||
material.setPresetPriceTwo(model.getPresetPriceTwo());
|
|
||||||
if (model.getUnitId() != null) {
|
|
||||||
material.setUnitId(new Unit(model.getUnitId()));
|
|
||||||
} else {
|
|
||||||
material.setUnitId(null);
|
|
||||||
}
|
|
||||||
material.setFirstOutUnit(model.getFirstOutUnit());
|
|
||||||
material.setFirstInUnit(model.getFirstInUnit());
|
|
||||||
material.setPriceStrategy(model.getPriceStrategy());
|
|
||||||
material.setRemark(model.getRemark());
|
|
||||||
material.setOtherField1(model.getOtherField1());
|
|
||||||
material.setOtherField2(model.getOtherField2());
|
|
||||||
material.setOtherField3(model.getOtherField3());
|
|
||||||
materialService.update(material);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改商品ID为 : " + model.getMaterialID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改商品回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新商品", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新商品ID为 " + model.getMaterialID() + " " + tipMsg + "!", "更新商品" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID商品
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
materialService.batchDelete(model.getMaterialIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除商品ID为:" + model.getMaterialIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除商品", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除商品ID为 " + model.getMaterialIDs() + " " + tipMsg + "!", "批量删除商品" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量设置状态-启用或者禁用
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchSetEnable() {
|
|
||||||
try {
|
|
||||||
materialService.batchSetEnable(model.getEnabled(), model.getMaterialIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量修改状态,商品ID为:" + model.getMaterialIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量修改商品状态", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量修改状态,商品ID为 " + model.getMaterialIDs() + " " + tipMsg + "!", "批量修改商品状态" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找该商品是否存在
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void checkIsExist() {
|
|
||||||
try {
|
|
||||||
Boolean flag = false;
|
|
||||||
PageUtil<Material> pageUtil = new PageUtil<Material>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getConditionCheckIsExist());
|
|
||||||
materialService.find(pageUtil);
|
|
||||||
List<Material> dataList = pageUtil.getPageList();
|
|
||||||
if (null != dataList && dataList.size() > 0) {
|
|
||||||
flag = true;
|
|
||||||
} else {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找商品信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Material> pageUtil = new PageUtil<Material>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
Long lei = model.getCategoryId();
|
|
||||||
if (1 == lei) //判断值还真不能用String类型的判断
|
|
||||||
{
|
|
||||||
pageUtil.setAdvSearch(getCondition_all());
|
|
||||||
} else if (1 != lei) {
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
}
|
|
||||||
materialService.find(pageUtil);
|
|
||||||
getSession().put("pageUtilMaterial", pageUtil);
|
|
||||||
List<Material> dataList = pageUtil.getPageList();
|
|
||||||
String mpList = model.getMpList(); //商品属性
|
|
||||||
String[] mpArr = mpList.split(",");
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Material material : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", material.getId());
|
|
||||||
item.put("Name", material.getName());
|
|
||||||
item.put("CategoryId", material.getMaterialCategory().getId()); //类型Id
|
|
||||||
item.put("CategoryName", material.getMaterialCategory().getName()); //类型名称
|
|
||||||
item.put("Packing", material.getPacking() == null ? "" : material.getPacking());
|
|
||||||
item.put("SafetyStock", material.getSafetyStock() == null ? "" : material.getSafetyStock());
|
|
||||||
item.put("Model", material.getModel() == null ? "" : material.getModel());
|
|
||||||
//扩展信息
|
|
||||||
String materialOther = "";
|
|
||||||
for (int i = 0; i < mpArr.length; i++) {
|
|
||||||
if (mpArr[i].equals("颜色")) {
|
|
||||||
materialOther = materialOther + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("规格")) {
|
|
||||||
materialOther = materialOther + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("制造商")) {
|
|
||||||
materialOther = materialOther + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义1")) {
|
|
||||||
materialOther = materialOther + ((material.getOtherField1() == null || material.getOtherField1().equals("")) ? "" : "(" + material.getOtherField1() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义2")) {
|
|
||||||
materialOther = materialOther + ((material.getOtherField2() == null || material.getOtherField2().equals("")) ? "" : "(" + material.getOtherField2() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义3")) {
|
|
||||||
materialOther = materialOther + ((material.getOtherField3() == null || material.getOtherField3().equals("")) ? "" : "(" + material.getOtherField3() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item.put("MaterialOther", materialOther);
|
|
||||||
item.put("Unit", material.getUnit() == null ? "" : material.getUnit());
|
|
||||||
item.put("RetailPrice", material.getRetailPrice());
|
|
||||||
item.put("LowPrice", material.getLowPrice());
|
|
||||||
item.put("PresetPriceOne", material.getPresetPriceOne() == null ? "" : material.getPresetPriceOne());
|
|
||||||
item.put("PresetPriceTwo", material.getPresetPriceTwo() == null ? "" : material.getPresetPriceTwo());
|
|
||||||
item.put("UnitId", material.getUnitId() == null ? "" : material.getUnitId().getId()); //计量单位Id
|
|
||||||
item.put("UnitName", material.getUnitId() == null ? "" : material.getUnitId().getUName()); //计量单位名称
|
|
||||||
item.put("FirstOutUnit", material.getFirstOutUnit());
|
|
||||||
item.put("FirstInUnit", material.getFirstInUnit());
|
|
||||||
item.put("PriceStrategy", material.getPriceStrategy());
|
|
||||||
item.put("Enabled", material.getEnabled());
|
|
||||||
item.put("Remark", material.getRemark());
|
|
||||||
item.put("Color", material.getColor() == null ? "" : material.getColor());
|
|
||||||
item.put("Standard", material.getStandard() == null ? "" : material.getStandard());
|
|
||||||
item.put("Mfrs", material.getMfrs() == null ? "" : material.getMfrs());
|
|
||||||
item.put("OtherField1", material.getOtherField1() == null ? "" : material.getOtherField1());
|
|
||||||
item.put("OtherField2", material.getOtherField2() == null ? "" : material.getOtherField2());
|
|
||||||
item.put("OtherField3", material.getOtherField3() == null ? "" : material.getOtherField3());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id来查询商品名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findById() {
|
|
||||||
try {
|
|
||||||
PageUtil<Material> pageUtil = new PageUtil<Material>();
|
|
||||||
pageUtil.setAdvSearch(getConditionById());
|
|
||||||
materialService.find(pageUtil);
|
|
||||||
List<Material> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Material material : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", material.getId());
|
|
||||||
item.put("Name", material.getName());
|
|
||||||
item.put("Mfrs", material.getMfrs() == null ? "" : material.getMfrs());
|
|
||||||
item.put("Packing", material.getPacking() == null ? "" : material.getPacking());
|
|
||||||
item.put("SafetyStock", material.getSafetyStock() == null ? "" : material.getSafetyStock());
|
|
||||||
item.put("Model", material.getModel());
|
|
||||||
item.put("Standard", material.getStandard());
|
|
||||||
item.put("Color", material.getColor() == null ? "" : material.getColor());
|
|
||||||
item.put("Unit", material.getUnit());
|
|
||||||
item.put("RetailPrice", material.getRetailPrice());
|
|
||||||
item.put("LowPrice", material.getLowPrice());
|
|
||||||
item.put("PresetPriceOne", material.getPresetPriceOne());
|
|
||||||
item.put("PresetPriceTwo", material.getPresetPriceTwo());
|
|
||||||
item.put("UnitId", material.getUnitId() == null ? "" : material.getUnitId().getId()); //计量单位Id
|
|
||||||
item.put("UnitName", material.getUnitId() == null ? "" : material.getUnitId().getUName()); //计量单位名称
|
|
||||||
item.put("FirstOutUnit", material.getFirstOutUnit());
|
|
||||||
item.put("FirstInUnit", material.getFirstInUnit());
|
|
||||||
item.put("PriceStrategy", material.getPriceStrategy());
|
|
||||||
item.put("Remark", material.getRemark());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找商品信息-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBySelect() {
|
|
||||||
try {
|
|
||||||
PageUtil<Material> pageUtil = new PageUtil<Material>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Select());
|
|
||||||
materialService.find(pageUtil);
|
|
||||||
List<Material> dataList = pageUtil.getPageList();
|
|
||||||
String mpList = model.getMpList(); //商品属性
|
|
||||||
String[] mpArr = mpList.split(",");
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Material material : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", material.getId());
|
|
||||||
String ratio; //比例
|
|
||||||
if (material.getUnitId() == null || material.getUnitId().equals("")) {
|
|
||||||
ratio = "";
|
|
||||||
} else {
|
|
||||||
ratio = material.getUnitId().getUName();
|
|
||||||
ratio = ratio.substring(ratio.indexOf("("));
|
|
||||||
}
|
|
||||||
//品名/型号/扩展信息/包装
|
|
||||||
String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
|
|
||||||
for (int i = 0; i < mpArr.length; i++) {
|
|
||||||
if (mpArr[i].equals("颜色")) {
|
|
||||||
MaterialName = MaterialName + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("规格")) {
|
|
||||||
MaterialName = MaterialName + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("制造商")) {
|
|
||||||
MaterialName = MaterialName + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义1")) {
|
|
||||||
MaterialName = MaterialName + ((material.getOtherField1() == null || material.getOtherField1().equals("")) ? "" : "(" + material.getOtherField1() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义2")) {
|
|
||||||
MaterialName = MaterialName + ((material.getOtherField2() == null || material.getOtherField2().equals("")) ? "" : "(" + material.getOtherField2() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义3")) {
|
|
||||||
MaterialName = MaterialName + ((material.getOtherField3() == null || material.getOtherField3().equals("")) ? "" : "(" + material.getOtherField3() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MaterialName = MaterialName + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
|
|
||||||
item.put("MaterialName", MaterialName);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找商品信息-统计排序
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findByOrder() {
|
|
||||||
try {
|
|
||||||
PageUtil<Material> pageUtil = new PageUtil<Material>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition_Order());
|
|
||||||
materialService.find(pageUtil);
|
|
||||||
List<Material> dataList = pageUtil.getPageList();
|
|
||||||
//存放数据json数组
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
String mId = "";
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Material material : dataList) {
|
|
||||||
mId = mId + material.getId() + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mId != "") {
|
|
||||||
mId = mId.substring(0, mId.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
outer.put("mIds", mId);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入excel表格-供应商
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String importExcel() {
|
|
||||||
//excel表格file
|
|
||||||
Boolean result = false;
|
|
||||||
String returnStr = "";
|
|
||||||
try {
|
|
||||||
InputStream in = materialService.importExcel(model.getMaterialFile());
|
|
||||||
|
|
||||||
if (null != in) {
|
|
||||||
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
|
|
||||||
model.setExcelStream(in);
|
|
||||||
returnStr = MaterialConstants.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出excel表格
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String exportExcel() {
|
|
||||||
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
|
|
||||||
try {
|
|
||||||
String sName = "pageUtilMaterial";
|
|
||||||
PageUtil<Material> pageUtil = (PageUtil<Material>) getSession().get(sName);
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
String isCurrentPage = "allPage";
|
|
||||||
model.setFileName(Tools.changeUnicode("goods" + System.currentTimeMillis() + ".xls", model.getBrowserType()));
|
|
||||||
model.setExcelStream(materialService.exmportExcel(isCurrentPage, pageUtil));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常", e);
|
|
||||||
model.getShowModel().setMsgTip("export excel exception");
|
|
||||||
}
|
|
||||||
Log.infoFileSync("===================调用导出信息action方法exportExcel结束==================");
|
|
||||||
return EXCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件(查全部)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_all() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Model_s_like", model.getModel());
|
|
||||||
condition.put("Color_s_like", model.getColor());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Model_s_like", model.getModel());
|
|
||||||
condition.put("Color_s_like", model.getColor());
|
|
||||||
condition.put("CategoryId_s_in", model.getCategoryIds());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> getConditionCheckIsExist() {
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
if (model.getMaterialID() > 0) {
|
|
||||||
condition.put("ID_n_neq", model.getMaterialID());
|
|
||||||
}
|
|
||||||
condition.put("Name_s_eq", model.getName());
|
|
||||||
condition.put("Model_s_eq", model.getModel());
|
|
||||||
condition.put("Color_s_eq", model.getColor());
|
|
||||||
condition.put("Standard_s_eq", model.getStandard());
|
|
||||||
condition.put("Mfrs_s_eq", model.getMfrs());
|
|
||||||
condition.put("OtherField1_s_eq", model.getOtherField1());
|
|
||||||
condition.put("OtherField2_s_eq", model.getOtherField2());
|
|
||||||
condition.put("OtherField3_s_eq", model.getOtherField3());
|
|
||||||
if (model.getUnit() != null) {
|
|
||||||
condition.put("Unit_s_eq", model.getUnit());
|
|
||||||
}
|
|
||||||
if (model.getUnitId() != null) {
|
|
||||||
condition.put("UnitId_n_eq", model.getUnitId());
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getConditionById() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Id_n_eq", model.getMaterialID());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Select() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("enabled_s_eq", 1);
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件-下拉框
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition_Order() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name,Model_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public MaterialModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaterialService(MaterialIService materialService) {
|
|
||||||
this.materialService = materialService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.MaterialCategory;
|
|
||||||
import com.jsh.model.vo.materials.MaterialCategoryModel;
|
|
||||||
import com.jsh.service.materials.MaterialCategoryIService;
|
|
||||||
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:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> {
|
|
||||||
private MaterialCategoryIService materialCategoryService;
|
|
||||||
private MaterialCategoryModel model = new MaterialCategoryModel();
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("ParentId_n_eq", model.getParentId());
|
|
||||||
condition.put("Id_n_neq", 1);
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
materialCategoryService.find(pageUtil);
|
|
||||||
mapData.put("materialCategoryList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找商品类别信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加商品类别
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加商品类别信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
MaterialCategory materialCategory = new MaterialCategory();
|
|
||||||
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
|
|
||||||
|
|
||||||
materialCategory.setCategoryLevel(model.getCategoryLevel());
|
|
||||||
materialCategory.setName(model.getName());
|
|
||||||
materialCategoryService.create(materialCategory);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加商品类别信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加商品类别信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加商品类别", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加商品类别名称为 " + model.getName() + " " + tipMsg + "!", "增加商品类别" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加商品类别方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除商品类别
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除商品类别信息方法delete()================");
|
|
||||||
try {
|
|
||||||
materialCategoryService.delete(model.getMaterialCategoryID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除商品类别", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除商品类别ID为 " + model.getMaterialCategoryID() + " " + tipMsg + "!", "删除商品类别" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除商品类别信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新商品类别
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
MaterialCategory materialCategory = materialCategoryService.get(model.getMaterialCategoryID());
|
|
||||||
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
|
|
||||||
|
|
||||||
materialCategory.setCategoryLevel(model.getCategoryLevel());
|
|
||||||
materialCategory.setName(model.getName());
|
|
||||||
materialCategoryService.update(materialCategory);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改商品类别ID为 : " + model.getMaterialCategoryID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改商品类别回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新商品类别", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新商品类别ID为 " + model.getMaterialCategoryID() + " " + tipMsg + "!", "更新商品类别" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID商品类别
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
materialCategoryService.batchDelete(model.getMaterialCategoryIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除商品类别", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除商品类别ID为 " + model.getMaterialCategoryIDs() + " " + tipMsg + "!", "批量删除商品类别" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找商品类别信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
materialCategoryService.find(pageUtil);
|
|
||||||
List<MaterialCategory> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
//开始拼接json数据
|
|
||||||
// {"total":28,"rows":[
|
|
||||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
|
||||||
// ]}
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (MaterialCategory materialCategory : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", materialCategory.getId());
|
|
||||||
item.put("ParentId", materialCategory.getMaterialCategory().getId());
|
|
||||||
item.put("ParentName", materialCategory.getMaterialCategory().getName());
|
|
||||||
item.put("CategoryLevel", materialCategory.getCategoryLevel());
|
|
||||||
item.put("Name", materialCategory.getName());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id来查询商品名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findById() {
|
|
||||||
try {
|
|
||||||
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
|
|
||||||
pageUtil.setAdvSearch(getConditionById());
|
|
||||||
materialCategoryService.find(pageUtil);
|
|
||||||
List<MaterialCategory> dataList = pageUtil.getPageList();
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (MaterialCategory materialCategory : dataList) {
|
|
||||||
outer.put("name", materialCategory.getName());
|
|
||||||
outer.put("parentId", materialCategory.getMaterialCategory().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("ParentId_n_eq", model.getParentId());
|
|
||||||
condition.put("Id_n_neq", 1);
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getConditionById() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Id_n_eq", model.getMaterialCategoryID());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public MaterialCategoryModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaterialCategoryService(MaterialCategoryIService materialCategoryService) {
|
|
||||||
this.materialCategoryService = materialCategoryService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.MaterialProperty;
|
|
||||||
import com.jsh.model.vo.materials.MaterialPropertyModel;
|
|
||||||
import com.jsh.service.materials.MaterialPropertyIService;
|
|
||||||
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 s h e n g hua qq:75 27 18 920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> {
|
|
||||||
private MaterialPropertyIService materialPropertyService;
|
|
||||||
private MaterialPropertyModel model = new MaterialPropertyModel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新商品属性
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
MaterialProperty materialProperty = materialPropertyService.get(model.getId());
|
|
||||||
materialProperty.setNativeName(model.getNativeName());
|
|
||||||
materialProperty.setEnabled(model.getEnabled());
|
|
||||||
materialProperty.setSort(model.getSort());
|
|
||||||
materialProperty.setAnotherName(model.getAnotherName());
|
|
||||||
materialPropertyService.update(materialProperty);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改商品属性ID为 : " + model.getId() + "失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改商品属性回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新商品属性", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新商品属性ID为 " + model.getId() + " " + tipMsg + "!", "更新商品属性" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找商品属性
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<MaterialProperty> pageUtil = new PageUtil<MaterialProperty>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
materialPropertyService.find(pageUtil);
|
|
||||||
List<MaterialProperty> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (MaterialProperty materialProperty : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", materialProperty.getId());
|
|
||||||
item.put("nativeName", materialProperty.getNativeName());
|
|
||||||
item.put("enabled", materialProperty.getEnabled());
|
|
||||||
item.put("sort", materialProperty.getSort());
|
|
||||||
item.put("anotherName", materialProperty.getAnotherName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品属性异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品属性结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("nativeName_s_like", model.getNativeName());
|
|
||||||
condition.put("sort_s_order", "asc");
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public MaterialPropertyModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaterialPropertyService(MaterialPropertyIService materialPropertyService) {
|
|
||||||
this.materialPropertyService = materialPropertyService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,320 +0,0 @@
|
|||||||
package com.jsh.action.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseAction;
|
|
||||||
import com.jsh.base.Log;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
import com.jsh.model.po.Person;
|
|
||||||
import com.jsh.model.vo.materials.PersonModel;
|
|
||||||
import com.jsh.service.materials.PersonIService;
|
|
||||||
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:752718920
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class PersonAction extends BaseAction<PersonModel> {
|
|
||||||
private PersonIService personService;
|
|
||||||
private PersonModel model = new PersonModel();
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getBasicData() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
personService.find(pageUtil);
|
|
||||||
mapData.put("personList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
public String getPersonByType() {
|
|
||||||
Map<String, List> mapData = model.getShowModel().getMap();
|
|
||||||
PageUtil pageUtil = new PageUtil();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
try {
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
personService.find(pageUtil);
|
|
||||||
mapData.put("personList", pageUtil.getPageList());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
|
|
||||||
model.getShowModel().setMsgTip("exceptoin");
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void getPersonByNumType() {
|
|
||||||
try {
|
|
||||||
PageUtil<Person> pageUtil = new PageUtil<Person>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
String type = "";
|
|
||||||
if (model.getType().equals("1")) {
|
|
||||||
type = "业务员";
|
|
||||||
} else if (model.getType().equals("2")) {
|
|
||||||
type = "仓管员";
|
|
||||||
} else if (model.getType().equals("3")) {
|
|
||||||
type = "财务员";
|
|
||||||
}
|
|
||||||
condition.put("Type_s_eq", type);
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
personService.find(pageUtil);
|
|
||||||
List<Person> dataList = pageUtil.getPageList();
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Person person : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("id", person.getId());
|
|
||||||
item.put("name", person.getName());
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(dataArray.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据Id获取经手人信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void getPersonByIds() {
|
|
||||||
try {
|
|
||||||
PageUtil<Person> pageUtil = new PageUtil<Person>();
|
|
||||||
pageUtil.setPageSize(0);
|
|
||||||
pageUtil.setCurPage(0);
|
|
||||||
Map<String, Object> condition = pageUtil.getAdvSearch();
|
|
||||||
condition.put("Id_s_in", model.getPersonIDs());
|
|
||||||
condition.put("Id_s_order", "asc");
|
|
||||||
personService.find(pageUtil);
|
|
||||||
List<Person> dataList = pageUtil.getPageList();
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Person person : dataList) {
|
|
||||||
sb.append(person.getName() + " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//回写查询结果
|
|
||||||
toClient(sb.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加经手人
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void create() {
|
|
||||||
Log.infoFileSync("==================开始调用增加经手人信息方法create()===================");
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Person person = new Person();
|
|
||||||
|
|
||||||
person.setType(model.getType());
|
|
||||||
person.setName(model.getName());
|
|
||||||
personService.create(person);
|
|
||||||
|
|
||||||
//========标识位===========
|
|
||||||
flag = true;
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加经手人信息异常", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>增加经手人信息回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "增加经手人", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "增加经手人名称为 " + model.getName() + " " + tipMsg + "!", "增加经手人" + tipMsg));
|
|
||||||
Log.infoFileSync("==================结束调用增加经手人方法create()===================");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除经手人
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String delete() {
|
|
||||||
Log.infoFileSync("====================开始调用删除经手人信息方法delete()================");
|
|
||||||
try {
|
|
||||||
personService.delete(model.getPersonID());
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
model.getShowModel().setMsgTip(tipMsg);
|
|
||||||
logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "删除经手人ID为 " + model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
|
|
||||||
Log.infoFileSync("====================结束调用删除经手人信息方法delete()================");
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新经手人
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
Person person = personService.get(model.getPersonID());
|
|
||||||
|
|
||||||
person.setType(model.getType());
|
|
||||||
person.setName(model.getName());
|
|
||||||
personService.update(person);
|
|
||||||
|
|
||||||
flag = true;
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", e);
|
|
||||||
flag = false;
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
toClient(flag.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>修改经手人回写客户端结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logService.create(new Logdetails(getUser(), "更新经手人", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "更新经手人ID为 " + model.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除指定ID经手人
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String batchDelete() {
|
|
||||||
try {
|
|
||||||
personService.batchDelete(model.getPersonIDs());
|
|
||||||
model.getShowModel().setMsgTip("成功");
|
|
||||||
//记录操作日志使用
|
|
||||||
tipMsg = "成功";
|
|
||||||
tipType = 0;
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
|
|
||||||
tipMsg = "失败";
|
|
||||||
tipType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(),
|
|
||||||
new Timestamp(System.currentTimeMillis())
|
|
||||||
, tipType, "批量删除经手人ID为 " + model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg));
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找经手人信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void findBy() {
|
|
||||||
try {
|
|
||||||
PageUtil<Person> pageUtil = new PageUtil<Person>();
|
|
||||||
pageUtil.setPageSize(model.getPageSize());
|
|
||||||
pageUtil.setCurPage(model.getPageNo());
|
|
||||||
pageUtil.setAdvSearch(getCondition());
|
|
||||||
personService.find(pageUtil);
|
|
||||||
List<Person> dataList = pageUtil.getPageList();
|
|
||||||
|
|
||||||
JSONObject outer = new JSONObject();
|
|
||||||
outer.put("total", pageUtil.getTotalCount());
|
|
||||||
//存放数据json数组
|
|
||||||
JSONArray dataArray = new JSONArray();
|
|
||||||
if (null != dataList) {
|
|
||||||
for (Person person : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
item.put("Id", person.getId());
|
|
||||||
item.put("Type", person.getType());
|
|
||||||
item.put("Name", person.getName());
|
|
||||||
item.put("op", 1);
|
|
||||||
dataArray.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.put("rows", dataArray);
|
|
||||||
//回写查询结果
|
|
||||||
toClient(outer.toString());
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找经手人信息异常", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询经手人信息结果异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Object> getCondition() {
|
|
||||||
/**
|
|
||||||
* 拼接搜索条件
|
|
||||||
*/
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put("Name_s_like", model.getName());
|
|
||||||
condition.put("Type_s_eq", model.getType());
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
|
||||||
@Override
|
|
||||||
public PersonModel getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPersonService(PersonIService personService) {
|
|
||||||
this.personService = personService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import com.jsh.model.po.Basicuser;
|
|
||||||
import com.jsh.service.basic.LogIService;
|
|
||||||
import com.opensymphony.xwork2.ActionContext;
|
|
||||||
import com.opensymphony.xwork2.ActionSupport;
|
|
||||||
import com.opensymphony.xwork2.ModelDriven;
|
|
||||||
import org.apache.struts2.ServletActionContext;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* struts2工具类
|
|
||||||
*
|
|
||||||
* @author jishenghua qq752718920
|
|
||||||
* struts2 base action 一些常用方法获取
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T> {
|
|
||||||
public LogIService logService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志使用 是否成功表示
|
|
||||||
*/
|
|
||||||
public String tipMsg = "成功";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志使用 是否成功表示 0 ==成功 1==失败
|
|
||||||
*/
|
|
||||||
public short tipType = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取session
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> getSession() {
|
|
||||||
return ActionContext.getContext().getSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取request
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static HttpServletRequest getRequest() {
|
|
||||||
return ServletActionContext.getRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取response
|
|
||||||
*
|
|
||||||
* @return response
|
|
||||||
*/
|
|
||||||
public static HttpServletResponse getResponse() {
|
|
||||||
return ServletActionContext.getResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogService(LogIService logService) {
|
|
||||||
this.logService = logService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加错误信息
|
|
||||||
*
|
|
||||||
* @param anErrorMessage
|
|
||||||
*/
|
|
||||||
public void addActionError(String anErrorMessage) {
|
|
||||||
super.addActionError(anErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加消息
|
|
||||||
*
|
|
||||||
* @param aMessage
|
|
||||||
*/
|
|
||||||
public void addActionMessage(String aMessage) {
|
|
||||||
clearErrorsAndMessages();
|
|
||||||
super.addActionMessage(aMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加字段错误
|
|
||||||
*
|
|
||||||
* @param fieldName
|
|
||||||
* @param errorMessage
|
|
||||||
*/
|
|
||||||
public void addFieldError(String fieldName, String errorMessage) {
|
|
||||||
clearErrorsAndMessages();
|
|
||||||
super.addFieldError(fieldName, errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户信息
|
|
||||||
*
|
|
||||||
* @return 登录用户对象
|
|
||||||
*/
|
|
||||||
public Basicuser getUser() {
|
|
||||||
return (Basicuser) getSession().get("user");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 回写客户端数据
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public void toClient(String jsonData) throws IOException {
|
|
||||||
HttpServletResponse response = ServletActionContext.getResponse();
|
|
||||||
response.setContentType("text/html;charset=utf-8");
|
|
||||||
response.getWriter().print(jsonData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础dao
|
|
||||||
*
|
|
||||||
* @author ji_sheng_hua qq:752718920
|
|
||||||
*/
|
|
||||||
public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T> {
|
|
||||||
protected Class<T> entityClass;
|
|
||||||
|
|
||||||
public void setPoJoClass(Class<T> c) {
|
|
||||||
this.entityClass = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Class<T> getEntityClass() {
|
|
||||||
return this.entityClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable create(T t) throws DataAccessException {
|
|
||||||
return this.getHibernateTemplate().save(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(T t) throws DataAccessException {
|
|
||||||
this.getHibernateTemplate().delete(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T get(Long objID) throws DataAccessException {
|
|
||||||
return (T) this.getHibernateTemplate().get(getEntityClass(), objID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(T t) throws DataAccessException {
|
|
||||||
this.getHibernateTemplate().update(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void batchDelete(String objIDs) throws DataAccessException {
|
|
||||||
this.getHibernateTemplate().bulkUpdate("delete from " + getEntityClass().getName() + " where id in (" + objIDs + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void find(PageUtil<T> pageUtil) throws DataAccessException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
|
|
||||||
.createQuery(" from " + getEntityClass().getName() + " where 1=1 " +
|
|
||||||
SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// @Override
|
|
||||||
// public List<T> find(Map<String, Object> conditon)throws DataAccessException
|
|
||||||
// {
|
|
||||||
// return this.getHibernateTemplate().find(" from " + getEntityClass().getName() + " where 1=1 "+ SearchConditionUtil.getCondition(conditon));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// @Override
|
|
||||||
// public List<T> find(String hql) throws DataAccessException
|
|
||||||
// {
|
|
||||||
// return this.getHibernateTemplate().find(" from " + getEntityClass().getName() + " where 1=1 "+ hql);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public List<T> find(Map<String, Object> conditon, int pageSize, int pageNo) throws DataAccessException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
|
|
||||||
.createQuery(" from " + getEntityClass().getName() + " where 1=1 " + SearchConditionUtil.getCondition(conditon));
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
return query.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public List<T> find(String hql, int pageSize, int pageNo) throws DataAccessException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
|
|
||||||
.createQuery(" from " + getEntityClass().getName() + " where 1=1 " + hql);
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
return query.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public Integer countSum(Map<String, Object> conditon) throws DataAccessException {
|
|
||||||
List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
|
|
||||||
.createQuery(" from " + getEntityClass().getName() + " where 1=1 " + SearchConditionUtil.getCondition(conditon)).list();
|
|
||||||
return dataList == null ? 0 : dataList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public Integer countSum(String hql) throws DataAccessException {
|
|
||||||
List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
|
|
||||||
.createQuery(" from " + getEntityClass().getName() + " where 1=1 " + hql).list();
|
|
||||||
return dataList == null ? 0 : dataList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(T t) throws DataAccessException {
|
|
||||||
this.getHibernateTemplate().save(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 常用增删改查操作
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* @author ji-sheng-hua qq752718920
|
|
||||||
*/
|
|
||||||
public interface BaseIDAO<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置操作类对象
|
|
||||||
*
|
|
||||||
* @param paramClass
|
|
||||||
*/
|
|
||||||
void setPoJoClass(Class<T> paramClass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Serializable create(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void save(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void delete(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取
|
|
||||||
*
|
|
||||||
* @param objID ID
|
|
||||||
* @return 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
T get(Long objID) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改信息
|
|
||||||
*
|
|
||||||
* @param t 要修改的对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void update(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除信息
|
|
||||||
*
|
|
||||||
* @param 以逗号分割的ID
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void batchDelete(String objIDs) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找列表
|
|
||||||
*
|
|
||||||
* @param pageUtil 分页工具类
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void find(PageUtil<T> pageUtil) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据条件查询列表--没有分页信息
|
|
||||||
* @param conditon 查询条件
|
|
||||||
* @return 查询列表数据
|
|
||||||
*/
|
|
||||||
// List<T> find(Map<String,Object> conditon)throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据hql查询 --没有分页信息
|
|
||||||
* @param hql hibernate查询
|
|
||||||
* @return 查询列表数据
|
|
||||||
*/
|
|
||||||
// List<T> find(String hql)throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据搜索条件查询--分页
|
|
||||||
*
|
|
||||||
* @param conditon 查询条件
|
|
||||||
* @param pageSize 每页个数
|
|
||||||
* @param pageNo 页码
|
|
||||||
* @return 查询列表数据
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
List<T> find(Map<String, Object> conditon, int pageSize, int pageNo) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据hql查询--分页
|
|
||||||
*
|
|
||||||
* @param hql hibernate查询语句
|
|
||||||
* @param pageSize 每页个数
|
|
||||||
* @param pageNo 页码
|
|
||||||
* @return 查询列表数据
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
List<T> find(String hql, int pageSize, int pageNo) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找符合条件的总数
|
|
||||||
*
|
|
||||||
* @param conditon
|
|
||||||
* @return
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Integer countSum(Map<String, Object> conditon) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找符合条件的总数
|
|
||||||
*
|
|
||||||
* @param hql
|
|
||||||
* @return
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Integer countSum(String hql) throws DataAccessException;
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务层底层接口
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* @author ji-sheng-hua qq752718920
|
|
||||||
*/
|
|
||||||
public interface BaseIService<T> {
|
|
||||||
/**
|
|
||||||
* 增加
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Serializable create(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void save(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*
|
|
||||||
* @param t 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void delete(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*
|
|
||||||
* @param id 对象ID
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void delete(Long id) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取
|
|
||||||
*
|
|
||||||
* @param objID ID
|
|
||||||
* @return 对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
T get(Long objID) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改信息
|
|
||||||
*
|
|
||||||
* @param t 要修改的对象
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void update(T t) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除信息
|
|
||||||
*
|
|
||||||
* @param 以逗号分割的ID
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void batchDelete(String objIDs) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找列表
|
|
||||||
*
|
|
||||||
* @param pageUtil 分页工具类
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
void find(PageUtil<T> pageUtil) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查名称是否存在,页面唯一性效验使用
|
|
||||||
*
|
|
||||||
* @param filedName 效验的字段名称
|
|
||||||
* @param filedVale 校验值
|
|
||||||
* @param idFiled ID字段名称
|
|
||||||
* @param objectID 修改时对象ID
|
|
||||||
* @return true==存在 false==不存在
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Boolean checkIsNameExist(String filedName, String filedVale, String idFiled, Long objectID) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查UserBusiness是否存在,页面唯一性效验使用
|
|
||||||
*
|
|
||||||
* @param TypeName 类型名称
|
|
||||||
* @param TypeVale 类型值
|
|
||||||
* @param KeyIdName 关键id
|
|
||||||
* @param KeyIdValue 关键值
|
|
||||||
* @param UBName 关系名称
|
|
||||||
* @param UBValue 关系值
|
|
||||||
* @return true==存在 false==不存在
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Boolean checkIsUserBusinessExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue, String UBName, String UBValue) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查UserBusiness是否存在,页面唯一性效验使用
|
|
||||||
*
|
|
||||||
* @param TypeName 类型名称
|
|
||||||
* @param TypeVale 类型值
|
|
||||||
* @param KeyIdName 关键id
|
|
||||||
* @param KeyIdValue 关键值
|
|
||||||
* @return true==存在 false==不存在
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 底层服务层
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* @author ji-sheng-hua qq752718920
|
|
||||||
*/
|
|
||||||
public abstract class BaseService<T> implements BaseIService<T> {
|
|
||||||
protected Class<T> entityClass;
|
|
||||||
/**
|
|
||||||
* Dao对象
|
|
||||||
*/
|
|
||||||
private BaseIDAO<T> baseDao;
|
|
||||||
|
|
||||||
protected BaseIDAO<T> getBaseDao() {
|
|
||||||
return this.baseDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBaseDao(BaseIDAO<T> baseDao) {
|
|
||||||
this.baseDao = baseDao;
|
|
||||||
setPoJoClass(getEntityClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPoJoClass(Class<T> c) {
|
|
||||||
this.baseDao.setPoJoClass(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Class<T> getEntityClass();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Serializable create(T t) throws DataAccessException {
|
|
||||||
return baseDao.create(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(T t) throws DataAccessException {
|
|
||||||
baseDao.save(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(T t) throws DataAccessException {
|
|
||||||
baseDao.delete(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Long id) throws DataAccessException {
|
|
||||||
baseDao.batchDelete(id.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T get(Long objID) throws DataAccessException {
|
|
||||||
return baseDao.get(objID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(T t) throws DataAccessException {
|
|
||||||
baseDao.update(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void batchDelete(String objIDs) throws DataAccessException {
|
|
||||||
baseDao.batchDelete(objIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void find(PageUtil<T> pageUtil) throws DataAccessException {
|
|
||||||
baseDao.find(pageUtil);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean checkIsNameExist(String filedName, String filedVale, String idFiled, Long objectID) throws DataAccessException {
|
|
||||||
PageUtil<T> pageUtil = new PageUtil<T>();
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put(filedName + "_s_eq", filedVale);
|
|
||||||
condition.put(idFiled + "_n_neq", objectID);
|
|
||||||
pageUtil.setAdvSearch(condition);
|
|
||||||
baseDao.find(pageUtil);
|
|
||||||
|
|
||||||
List<T> dataList = pageUtil.getPageList();
|
|
||||||
if (null != dataList && dataList.size() > 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean checkIsUserBusinessExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue, String UBName, String UBValue) throws DataAccessException {
|
|
||||||
PageUtil<T> pageUtil = new PageUtil<T>();
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put(TypeName + "_s_eq", TypeVale);
|
|
||||||
condition.put(KeyIdName + "_s_eq", KeyIdValue);
|
|
||||||
condition.put(UBName + "_s_like", UBValue);
|
|
||||||
pageUtil.setAdvSearch(condition);
|
|
||||||
baseDao.find(pageUtil);
|
|
||||||
|
|
||||||
List<T> dataList = pageUtil.getPageList();
|
|
||||||
if (null != dataList && dataList.size() > 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException {
|
|
||||||
PageUtil<T> pageUtil = new PageUtil<T>();
|
|
||||||
Map<String, Object> condition = new HashMap<String, Object>();
|
|
||||||
condition.put(TypeName + "_s_eq", TypeVale);
|
|
||||||
condition.put(KeyIdName + "_s_eq", KeyIdValue);
|
|
||||||
pageUtil.setAdvSearch(condition);
|
|
||||||
baseDao.find(pageUtil);
|
|
||||||
|
|
||||||
List<T> dataList = pageUtil.getPageList();
|
|
||||||
if (null != dataList && dataList.size() > 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
package com.jsh.base;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 封装log4j日志信息,打印日志信息类
|
|
||||||
*
|
|
||||||
* @author ji/sheng/hua qq_7527.18920
|
|
||||||
* @since 2014-01-22
|
|
||||||
*/
|
|
||||||
public class Log {
|
|
||||||
/**
|
|
||||||
* Info级别日志前缀
|
|
||||||
*/
|
|
||||||
public static final String LOG_INFO_PREFIX = "==========";
|
|
||||||
/**
|
|
||||||
* error级别日志前缀
|
|
||||||
*/
|
|
||||||
public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>";
|
|
||||||
/**
|
|
||||||
* debug级别日志前缀
|
|
||||||
*/
|
|
||||||
public static final String LOG_DEBUG_PREFIX = "-----------";
|
|
||||||
/**
|
|
||||||
* fatal级别日志前缀
|
|
||||||
*/
|
|
||||||
public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$";
|
|
||||||
/**
|
|
||||||
* warn级别日志前缀
|
|
||||||
*/
|
|
||||||
public static final String LOG_WARN_PREFIX = "##########";
|
|
||||||
/**
|
|
||||||
* 根据异常信息获取调用类的信息
|
|
||||||
*/
|
|
||||||
private static final Exception ex = new Exception();
|
|
||||||
/**
|
|
||||||
* 获取Log4j实例
|
|
||||||
*/
|
|
||||||
private static final Logger log = Logger.getLogger("jsh");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印deug日期信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
*/
|
|
||||||
public static void debugFileSync(Object msg) {
|
|
||||||
log.debug(getLogDetail(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印debug异常信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
* @param e 异常堆栈
|
|
||||||
*/
|
|
||||||
public static void debugFileSync(Object msg, Throwable e) {
|
|
||||||
log.debug(getLogDetail(msg), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印info日志信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
*/
|
|
||||||
public static void infoFileSync(Object msg) {
|
|
||||||
log.info(getLogDetail(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印 info日志带异常信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
* @param e 异常堆栈
|
|
||||||
*/
|
|
||||||
public static void infoFileSync(Object msg, Throwable e) {
|
|
||||||
log.info(getLogDetail(msg), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印warn日期信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
*/
|
|
||||||
public static void warnFileSync(Object msg) {
|
|
||||||
log.warn(getLogDetail(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印warn日志信息带异常
|
|
||||||
*
|
|
||||||
* @param msg日志信息
|
|
||||||
* @param e 异常堆栈
|
|
||||||
*/
|
|
||||||
public static void warnFileSync(Object msg, Throwable e) {
|
|
||||||
log.warn(getLogDetail(msg), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印error日志信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
*/
|
|
||||||
public static void errorFileSync(Object msg) {
|
|
||||||
log.error(getLogDetail(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印error日志信息带异常
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
* @param e 异常堆栈
|
|
||||||
*/
|
|
||||||
public static void errorFileSync(Object msg, Throwable e) {
|
|
||||||
log.error(getLogDetail(msg), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印fatal日志信息
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
*/
|
|
||||||
public static void fatalFileSync(Object msg) {
|
|
||||||
log.fatal(getLogDetail(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印fatal日志信息带异常
|
|
||||||
*
|
|
||||||
* @param msg 日志信息
|
|
||||||
* @param e 异常堆栈
|
|
||||||
*/
|
|
||||||
public static void fatalFileSync(Object msg, Throwable e) {
|
|
||||||
log.fatal(getLogDetail(msg), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼装日志详细信息
|
|
||||||
*
|
|
||||||
* @param message 要打印的日志信息
|
|
||||||
* @return 封装后的日志详细信息
|
|
||||||
*/
|
|
||||||
private static synchronized String getLogDetail(Object message) {
|
|
||||||
String msg = "";
|
|
||||||
if (null != message)
|
|
||||||
msg = message.toString();
|
|
||||||
StringBuffer bf = new StringBuffer();
|
|
||||||
try {
|
|
||||||
ex.fillInStackTrace();
|
|
||||||
throw ex;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
StackTraceElement[] trace = ex.getStackTrace();
|
|
||||||
//获取异常堆栈中的调用类信息
|
|
||||||
final int pos = 2;
|
|
||||||
bf.append(msg);
|
|
||||||
bf.append(" [class:");
|
|
||||||
bf.append(trace[pos].getClassName());
|
|
||||||
bf.append(" method:");
|
|
||||||
bf.append(trace[pos].getMethodName());
|
|
||||||
bf.append(" line:");
|
|
||||||
bf.append(trace[pos].getLineNumber());
|
|
||||||
bf.append("]");
|
|
||||||
}
|
|
||||||
return bf.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.asset;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Asset;
|
|
||||||
|
|
||||||
public class AssetDAO extends BaseDAO<Asset> implements AssetIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Asset> getEntityClass() {
|
|
||||||
return Asset.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.asset;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Asset;
|
|
||||||
|
|
||||||
public interface AssetIDAO extends BaseIDAO<Asset> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.jsh.dao.asset;
|
|
||||||
|
|
||||||
import com.jsh.model.po.Asset;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|
||||||
|
|
||||||
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void find(PageUtil<Asset> pageUtil, String reportType, String reportName) throws JshException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType + ") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.asset;
|
|
||||||
|
|
||||||
import com.jsh.model.po.Asset;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface ReportIDAO {
|
|
||||||
/**
|
|
||||||
* 查找资产列表
|
|
||||||
*
|
|
||||||
* @param pageUtil 分页工具类
|
|
||||||
* @param reportType 报表统计字段
|
|
||||||
* @throws JshException
|
|
||||||
*/
|
|
||||||
void find(PageUtil<Asset> pageUtil, String reportType, String reportName) throws JshException;
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Account;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class AccountDAO extends BaseDAO<Account> implements AccountIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Account> getEntityClass() {
|
|
||||||
return Account.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void findAccountInOutList(PageUtil<Account> pageUtil, Long accountId) throws JshException {
|
|
||||||
StringBuffer queryString = new StringBuffer();
|
|
||||||
//主表出入库涉及的账户
|
|
||||||
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
|
|
||||||
" from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and dh.AccountId='" + accountId + "' ");
|
|
||||||
}
|
|
||||||
//主表收入和支出涉及的账户
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select ah.BillNo,ah.Type as newType,s.supplier,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
|
|
||||||
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id where 1=1 ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and ah.AccountId='" + accountId + "' ");
|
|
||||||
}
|
|
||||||
//明细中涉及的账户(收款,付款,收预付款)
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select ah.BillNo,ah.Type as newType,s.supplier,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
|
|
||||||
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id " +
|
|
||||||
" inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
|
|
||||||
" where ah.Type in ('收款','付款','收预付款') ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and ai.AccountId='" + accountId + "' ");
|
|
||||||
}
|
|
||||||
//主表中转出的账户
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select ah.BillNo,ah.Type as newType, '' as sName,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
|
|
||||||
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
|
|
||||||
" where ah.Type='转账' ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and ah.AccountId='" + accountId + "' ");
|
|
||||||
}
|
|
||||||
//明细中被转入的账户
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select ah.BillNo,ah.Type as newType, '' as sName,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
|
|
||||||
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
|
|
||||||
" where ah.Type='转账' ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and ai.AccountId='" + accountId + "' ");
|
|
||||||
}
|
|
||||||
//多账户的情况
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,dh.AccountIdList,dh.AccountMoneyList" +
|
|
||||||
" from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 ");
|
|
||||||
if (accountId != null && !accountId.equals("")) {
|
|
||||||
queryString.append(" and dh.AccountIdList like '%\"" + accountId + "\"%' ");
|
|
||||||
}
|
|
||||||
queryString.append(" ORDER BY oTime desc");
|
|
||||||
Query query;
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Account;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface AccountIDAO extends BaseIDAO<Account> {
|
|
||||||
|
|
||||||
public void findAccountInOutList(PageUtil<Account> pageUtil, Long accountId) throws JshException;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.App;
|
|
||||||
|
|
||||||
public class AppDAO extends BaseDAO<App> implements AppIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<App> getEntityClass() {
|
|
||||||
return App.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.App;
|
|
||||||
|
|
||||||
public interface AppIDAO extends BaseIDAO<App> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Assetname;
|
|
||||||
|
|
||||||
public class AssetNameDAO extends BaseDAO<Assetname> implements AssetNameIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Assetname> getEntityClass() {
|
|
||||||
return Assetname.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Assetname;
|
|
||||||
|
|
||||||
public interface AssetNameIDAO extends BaseIDAO<Assetname> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Category;
|
|
||||||
|
|
||||||
public class CategoryDAO extends BaseDAO<Category> implements CategoryIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Category> getEntityClass() {
|
|
||||||
return Category.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Category;
|
|
||||||
|
|
||||||
public interface CategoryIDAO extends BaseIDAO<Category> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Depot;
|
|
||||||
|
|
||||||
public class DepotDAO extends BaseDAO<Depot> implements DepotIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Depot> getEntityClass() {
|
|
||||||
return Depot.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Depot;
|
|
||||||
|
|
||||||
public interface DepotIDAO extends BaseIDAO<Depot> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Functions;
|
|
||||||
|
|
||||||
public class FunctionsDAO extends BaseDAO<Functions> implements FunctionsIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Functions> getEntityClass() {
|
|
||||||
return Functions.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Functions;
|
|
||||||
|
|
||||||
public interface FunctionsIDAO extends BaseIDAO<Functions> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.InOutItem;
|
|
||||||
|
|
||||||
public class InOutItemDAO extends BaseDAO<InOutItem> implements InOutItemIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<InOutItem> getEntityClass() {
|
|
||||||
return InOutItem.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.InOutItem;
|
|
||||||
|
|
||||||
public interface InOutItemIDAO extends BaseIDAO<InOutItem> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
|
|
||||||
public class LogDAO extends BaseDAO<Logdetails> implements LogIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Logdetails> getEntityClass() {
|
|
||||||
return Logdetails.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Logdetails;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志相关处理接口
|
|
||||||
*
|
|
||||||
* @author angel
|
|
||||||
*/
|
|
||||||
public interface LogIDAO extends BaseIDAO<Logdetails> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Role;
|
|
||||||
|
|
||||||
public class RoleDAO extends BaseDAO<Role> implements RoleIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Role> getEntityClass() {
|
|
||||||
return Role.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Role;
|
|
||||||
|
|
||||||
public interface RoleIDAO extends BaseIDAO<Role> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Supplier;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class SupplierDAO extends BaseDAO<Supplier> implements SupplierIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Supplier> getEntityClass() {
|
|
||||||
return Supplier.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void batchSetEnable(Boolean enable, String supplierIDs) {
|
|
||||||
String sql = "update jsh_supplier s set s.enabled=" + enable + " where s.id in (" + supplierIDs + ")";
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
|
|
||||||
query.executeUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Supplier;
|
|
||||||
|
|
||||||
public interface SupplierIDAO extends BaseIDAO<Supplier> {
|
|
||||||
public void batchSetEnable(Boolean enable, String supplierIDs);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.SystemConfig;
|
|
||||||
|
|
||||||
public class SystemConfigDAO extends BaseDAO<SystemConfig> implements SystemConfigIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<SystemConfig> getEntityClass() {
|
|
||||||
return SystemConfig.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.SystemConfig;
|
|
||||||
|
|
||||||
public interface SystemConfigIDAO extends BaseIDAO<SystemConfig> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Unit;
|
|
||||||
|
|
||||||
public class UnitDAO extends BaseDAO<Unit> implements UnitIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Unit> getEntityClass() {
|
|
||||||
return Unit.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Unit;
|
|
||||||
|
|
||||||
public interface UnitIDAO extends BaseIDAO<Unit> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.UserBusiness;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<UserBusiness> getEntityClass() {
|
|
||||||
return UserBusiness.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void find(PageUtil<UserBusiness> pageUtil, String ceshi) throws JshException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.UserBusiness;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness> {
|
|
||||||
/*
|
|
||||||
* 测试hql语句
|
|
||||||
*/
|
|
||||||
void find(PageUtil<UserBusiness> pageUtil, String ceshi) throws JshException;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Basicuser;
|
|
||||||
|
|
||||||
public class UserDAO extends BaseDAO<Basicuser> implements UserIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Basicuser> getEntityClass() {
|
|
||||||
return Basicuser.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.basic;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Basicuser;
|
|
||||||
|
|
||||||
public interface UserIDAO extends BaseIDAO<Basicuser> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.AccountHead;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author alan
|
|
||||||
*/
|
|
||||||
public class AccountHeadDAO extends BaseDAO<AccountHead> implements AccountHeadIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<AccountHead> getEntityClass() {
|
|
||||||
return AccountHead.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void find(PageUtil<AccountHead> pageUtil, String maxid) throws JshException {
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from AccountHead accountHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findAllMoney(PageUtil<AccountHead> pageUtil, Integer supplierId, String type, String mode) throws JshException {
|
|
||||||
Query query;
|
|
||||||
String modeName = "";
|
|
||||||
if (mode.equals("实际")) {
|
|
||||||
modeName = "ChangeAmount";
|
|
||||||
} else if (mode.equals("合计")) {
|
|
||||||
modeName = "TotalPrice";
|
|
||||||
}
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select sum(" + modeName + ") as allMoney from AccountHead accountHead where Type='" + type + "' and OrganId =" + supplierId + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.AccountHead;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface AccountHeadIDAO extends BaseIDAO<AccountHead> {
|
|
||||||
/*
|
|
||||||
* 获取MaxId
|
|
||||||
*/
|
|
||||||
void find(PageUtil<AccountHead> pageUtil, String maxid) throws JshException;
|
|
||||||
|
|
||||||
void findAllMoney(PageUtil<AccountHead> pageUtil, Integer supplierId, String type, String mode) throws JshException;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.AccountItem;
|
|
||||||
|
|
||||||
public class AccountItemDAO extends BaseDAO<AccountItem> implements AccountItemIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<AccountItem> getEntityClass() {
|
|
||||||
return AccountItem.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.AccountItem;
|
|
||||||
|
|
||||||
public interface AccountItemIDAO extends BaseIDAO<AccountItem> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.DepotHead;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<DepotHead> getEntityClass() {
|
|
||||||
return DepotHead.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException {
|
|
||||||
Query query;
|
|
||||||
String modeName = "";
|
|
||||||
if (mode.equals("实际")) {
|
|
||||||
modeName = "ChangeAmount";
|
|
||||||
} else if (mode.equals("合计")) {
|
|
||||||
modeName = "DiscountLastMoney";
|
|
||||||
}
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select sum(" + modeName + ") as allMoney from DepotHead depotHead where Type='" + type + "' and SubType = '" + subType + "' and OrganId =" + supplierId + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void batchSetStatus(Boolean status, String depotHeadIDs) {
|
|
||||||
String sql = "update jsh_depothead d set d.Status=" + status + " where d.id in (" + depotHeadIDs + ")";
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
|
|
||||||
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();
|
|
||||||
queryString.append("select dh.Number,m.`name`,m.Model,di.UnitPrice,di.OperNumber,di.AllPrice,s.supplier,d.dName," +
|
|
||||||
"date_format(dh.OperTime, '%Y-%m-%d'), concat(dh.SubType,dh.Type) as newType " +
|
|
||||||
"from jsh_depothead dh inner join jsh_depotitem di on di.HeaderId=dh.id " +
|
|
||||||
"inner join jsh_material m on m.id=di.MaterialId " +
|
|
||||||
"inner join jsh_supplier s on s.id=dh.OrganId " +
|
|
||||||
"inner join (select id,name as dName from jsh_depot) d on d.id=di.DepotId " +
|
|
||||||
"where dh.OperTime >='" + beginTime + "' and dh.OperTime <='" + endTime + "' ");
|
|
||||||
if (oId != null) {
|
|
||||||
queryString.append(" and dh.OrganId = " + oId);
|
|
||||||
}
|
|
||||||
if (pid != null) {
|
|
||||||
queryString.append(" and di.DepotId=" + pid);
|
|
||||||
} else {
|
|
||||||
queryString.append(" and di.DepotId in (" + dids + ")");
|
|
||||||
}
|
|
||||||
if (type != null && !type.equals("")) {
|
|
||||||
queryString.append(" and dh.Type='" + type + "'");
|
|
||||||
}
|
|
||||||
queryString.append(" ORDER BY OperTime DESC,Number desc");
|
|
||||||
Query query;
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
queryString.append("select di.MaterialId, m.mName,m.Model,m.categoryName, ");
|
|
||||||
//数量汇总
|
|
||||||
queryString.append(" (select sum(jdi.BasicNumber) numSum from jsh_depothead jdh INNER JOIN jsh_depotitem jdi " +
|
|
||||||
"on jdh.id=jdi.HeaderId where jdi.MaterialId=di.MaterialId " +
|
|
||||||
" and jdh.type='" + type + "' and jdh.OperTime >='" + beginTime + "' and jdh.OperTime <='" + endTime + "'");
|
|
||||||
if (oId != null) {
|
|
||||||
queryString.append(" and jdh.OrganId = " + oId);
|
|
||||||
}
|
|
||||||
if (pid != null) {
|
|
||||||
queryString.append(" and jdi.DepotId=" + pid);
|
|
||||||
} else {
|
|
||||||
queryString.append(" and jdi.DepotId in (" + dids + ")");
|
|
||||||
}
|
|
||||||
queryString.append(" ) numSum, ");
|
|
||||||
//金额汇总
|
|
||||||
queryString.append(" (select sum(jdi.AllPrice) priceSum from jsh_depothead jdh INNER JOIN jsh_depotitem jdi " +
|
|
||||||
"on jdh.id=jdi.HeaderId where jdi.MaterialId=di.MaterialId " +
|
|
||||||
" and jdh.type='" + type + "' and jdh.OperTime >='" + beginTime + "' and jdh.OperTime <='" + endTime + "'");
|
|
||||||
if (oId != null) {
|
|
||||||
queryString.append(" and jdh.OrganId = " + oId);
|
|
||||||
}
|
|
||||||
if (pid != null) {
|
|
||||||
queryString.append(" and jdi.DepotId=" + pid);
|
|
||||||
} else {
|
|
||||||
queryString.append(" and jdi.DepotId in (" + dids + ")");
|
|
||||||
}
|
|
||||||
queryString.append(" ) priceSum ");
|
|
||||||
|
|
||||||
queryString.append(" from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId " +
|
|
||||||
" INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model,jsh_materialcategory.`Name` categoryName from jsh_material INNER JOIN jsh_materialcategory on jsh_material.CategoryId=jsh_materialcategory.Id) m " +
|
|
||||||
" on m.Id=di.MaterialId where dh.type='" + type + "' and dh.OperTime >='" + beginTime + "' and dh.OperTime <='" + endTime + "' ");
|
|
||||||
if (oId != null) {
|
|
||||||
queryString.append(" and dh.OrganId = " + oId);
|
|
||||||
}
|
|
||||||
if (pid != null) {
|
|
||||||
queryString.append(" and di.DepotId=" + pid);
|
|
||||||
} else {
|
|
||||||
queryString.append(" and di.DepotId in (" + dids + ")");
|
|
||||||
}
|
|
||||||
queryString.append(" GROUP BY di.MaterialId,m.mName,m.Model,m.categoryName ");
|
|
||||||
Query query;
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) throws JshException {
|
|
||||||
StringBuffer queryString = new StringBuffer();
|
|
||||||
queryString.append("select group_concat(concat(jsh_material.`Name`,' ',jsh_material.Model)) as mName from jsh_depotitem inner join jsh_material " +
|
|
||||||
" on jsh_depotitem.MaterialId = jsh_material.Id where jsh_depotitem.HeaderId =" + headerId);
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void findStatementAccount(PageUtil pageUtil, String beginTime, String endTime, Long organId, String supType) throws JshException {
|
|
||||||
StringBuffer queryString = new StringBuffer();
|
|
||||||
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,dh.DiscountLastMoney,dh.ChangeAmount,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
|
|
||||||
"inner join jsh_supplier s on s.id=dh.OrganId where s.type='" + supType + "' and dh.SubType!='其它' " +
|
|
||||||
"and dh.OperTime >='" + beginTime + "' and dh.OperTime<='" + endTime + "' ");
|
|
||||||
if (organId != null && !organId.equals("")) {
|
|
||||||
queryString.append(" and dh.OrganId='" + organId + "' ");
|
|
||||||
}
|
|
||||||
queryString.append("UNION ALL " +
|
|
||||||
"select ah.BillNo,ah.Type as newType,ah.TotalPrice,ah.ChangeAmount,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
|
|
||||||
"inner join jsh_supplier s on s.id=ah.OrganId where s.type='" + supType + "' " +
|
|
||||||
"and ah.BillTime >='" + beginTime + "' and ah.BillTime<='" + endTime + "' ");
|
|
||||||
if (organId != null && !organId.equals("")) {
|
|
||||||
queryString.append(" and ah.OrganId='" + organId + "' ");
|
|
||||||
}
|
|
||||||
queryString.append(" ORDER BY oTime");
|
|
||||||
Query query;
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void getHeaderIdByMaterial(PageUtil pageUtil, String materialParam, String depotIds) throws JshException {
|
|
||||||
StringBuffer queryString = new StringBuffer();
|
|
||||||
queryString.append("select dt.HeaderId from jsh_depotitem dt INNER JOIN jsh_material m on dt.MaterialId = m.Id where ( m.`Name` " +
|
|
||||||
" like '%" + materialParam + "%' or m.Model like '%" + materialParam + "%') ");
|
|
||||||
if (!depotIds.equals("")) {
|
|
||||||
queryString.append(" and dt.DepotId in (" + depotIds + ") ");
|
|
||||||
}
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.DepotHead;
|
|
||||||
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;
|
|
||||||
|
|
||||||
void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException;
|
|
||||||
|
|
||||||
void batchSetStatus(Boolean status, String depotHeadIDs);
|
|
||||||
|
|
||||||
void findInDetail(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;
|
|
||||||
|
|
||||||
void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) 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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.DepotItem;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO {
|
|
||||||
private final static String TYPE = "入库";
|
|
||||||
private final static String SUM_TYPE = "Number";
|
|
||||||
private final static String IN = "in";
|
|
||||||
private final static String OUT = "out";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<DepotItem> getEntityClass() {
|
|
||||||
return DepotItem.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findByType(PageUtil<DepotItem> pageUtil, String type, Integer dId, Long MId, String MonthTime, Boolean isPrev) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
StringBuilder queryString = new StringBuilder();
|
|
||||||
if (TYPE.equals(type)) {
|
|
||||||
if (isPrev) {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
|
|
||||||
queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) ");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime <'").append(MonthTime).append("-01 00:00:00' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
|
|
||||||
queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) ");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime >='").append(MonthTime).append("-01 00:00:00' and dh.OperTime <='").append(MonthTime).append("-31 59:59:59' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isPrev) {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
|
|
||||||
queryString.append(" and DepotId='").append(dId).append("'");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime <'").append(MonthTime).append("-01 00:00:00' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
|
|
||||||
queryString.append(" and DepotId='").append(dId).append("'");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime >='").append(MonthTime).append("-01 00:00:00' and jsh_depothead.OperTime <='").append(MonthTime).append("-31 59:59:59' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findPriceByType(PageUtil<DepotItem> pageUtil, String type, Integer dId, Long MId, String MonthTime, Boolean isPrev) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
StringBuilder queryString = new StringBuilder();
|
|
||||||
if (TYPE.equals(type)) {
|
|
||||||
if (isPrev) {
|
|
||||||
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
|
|
||||||
queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) ");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime <'").append(MonthTime).append("-01 00:00:00' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
|
|
||||||
queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) ");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime >='").append(MonthTime).append("-01 00:00:00' and dh.OperTime <='").append(MonthTime).append("-31 59:59:59' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isPrev) {
|
|
||||||
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
|
|
||||||
queryString.append(" and DepotId='").append(dId).append("'");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime <'").append(MonthTime).append("-01 00:00:00' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
|
|
||||||
queryString.append(" and DepotId='").append(dId).append("'");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime >='").append(MonthTime).append("-01 00:00:00' and jsh_depothead.OperTime <='").append(MonthTime).append("-31 59:59:59' ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, String type, Long MId) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
StringBuilder queryString = new StringBuilder();
|
|
||||||
if (TYPE.equals(type)) {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='入库'");
|
|
||||||
queryString.append(" and MaterialId =").append(MId);
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='出库'");
|
|
||||||
queryString.append(" and SubType!='调拨' and SubType!='礼品充值' and MaterialId =").append(MId);
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, Long MId) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
StringBuilder queryString = new StringBuilder();
|
|
||||||
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType, " +
|
|
||||||
"case when type='入库' then di.BasicNumber when type='出库' then 0-di.BasicNumber else 0 end as b_num, " +
|
|
||||||
"date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime " +
|
|
||||||
"from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type!='其它' " +
|
|
||||||
"and SubType!='调拨' and SubType!='礼品充值' ");
|
|
||||||
queryString.append(" and MaterialId =").append(MId).append(" ORDER BY oTime desc ");
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
// 分页查询
|
|
||||||
int pageNo = pageUtil.getCurPage();
|
|
||||||
int pageSize = pageUtil.getPageSize();
|
|
||||||
if (0 != pageNo && 0 != pageSize) {
|
|
||||||
query.setFirstResult((pageNo - 1) * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void buyOrSale(PageUtil<DepotItem> pageUtil, String type, String subType, Long MId, String MonthTime, String sumType) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
if (SUM_TYPE.equals(sumType)) {
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "' and subType='" + subType + "' and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
} else {
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "' and subType='" + subType + "' and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
}
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findGiftByType(PageUtil<DepotItem> pageUtil, String subType, Integer ProjectId, Long MId, String type) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
|
||||||
Query query;
|
|
||||||
StringBuilder queryString = new StringBuilder();
|
|
||||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and jsh_depothead.SubType='").append(subType).append("'");
|
|
||||||
if (ProjectId != null) {
|
|
||||||
if (IN.equals(type)) {
|
|
||||||
queryString.append(" and jsh_depotitem.AnotherDepotId='").append(ProjectId).append("'"); //礼品充值时
|
|
||||||
} else if (OUT.equals(type)) {
|
|
||||||
queryString.append(" and jsh_depotitem.DepotId='").append(ProjectId).append("'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
queryString.append(" and jsh_depotitem.MaterialId =").append(MId);
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.DepotItem;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface DepotItemIDAO extends BaseIDAO<DepotItem> {
|
|
||||||
public void findByType(PageUtil<DepotItem> pageUtil, String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws JshException;
|
|
||||||
|
|
||||||
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, String type, Long MId) throws JshException;
|
|
||||||
|
|
||||||
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, Long MId) throws JshException;
|
|
||||||
|
|
||||||
public void findPriceByType(PageUtil<DepotItem> pageUtil, String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws JshException;
|
|
||||||
|
|
||||||
public void buyOrSale(PageUtil<DepotItem> pageUtil, String type, String subType, Long MId, String MonthTime, String sumType) throws JshException;
|
|
||||||
|
|
||||||
public void findGiftByType(PageUtil<DepotItem> pageUtil, String subType, Integer ProjectId, Long MId, String type) throws JshException;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.MaterialCategory;
|
|
||||||
|
|
||||||
public class MaterialCategoryDAO extends BaseDAO<MaterialCategory> implements MaterialCategoryIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<MaterialCategory> getEntityClass() {
|
|
||||||
return MaterialCategory.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.MaterialCategory;
|
|
||||||
|
|
||||||
public interface MaterialCategoryIDAO extends BaseIDAO<MaterialCategory> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Material;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
import com.jsh.util.SearchConditionUtil;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
|
|
||||||
public class MaterialDAO extends BaseDAO<Material> implements MaterialIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Material> getEntityClass() {
|
|
||||||
return Material.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void batchSetEnable(Boolean enable, String supplierIDs) {
|
|
||||||
String sql = "update jsh_material m set m.enabled=" + enable + " where m.id in (" + supplierIDs + ")";
|
|
||||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
|
|
||||||
query.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void findUnitName(PageUtil<Material> pageUtil, Long mId) throws JshException {
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便,
|
|
||||||
StringBuffer queryString = new StringBuffer();
|
|
||||||
queryString.append("select jsh_unit.UName from jsh_unit inner join jsh_material on UnitId=jsh_unit.id where jsh_material.id=" + mId);
|
|
||||||
Query query;
|
|
||||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
|
||||||
pageUtil.setTotalCount(query.list().size());
|
|
||||||
pageUtil.setPageList(query.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Material;
|
|
||||||
import com.jsh.util.JshException;
|
|
||||||
import com.jsh.util.PageUtil;
|
|
||||||
|
|
||||||
public interface MaterialIDAO extends BaseIDAO<Material> {
|
|
||||||
public void batchSetEnable(Boolean enable, String supplierIDs);
|
|
||||||
|
|
||||||
public void findUnitName(PageUtil<Material> pageUtil, Long mId) throws JshException;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.MaterialProperty;
|
|
||||||
|
|
||||||
public class MaterialPropertyDAO extends BaseDAO<MaterialProperty> implements MaterialPropertyIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<MaterialProperty> getEntityClass() {
|
|
||||||
return MaterialProperty.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.MaterialProperty;
|
|
||||||
|
|
||||||
public interface MaterialPropertyIDAO extends BaseIDAO<MaterialProperty> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseDAO;
|
|
||||||
import com.jsh.model.po.Person;
|
|
||||||
|
|
||||||
public class PersonDAO extends BaseDAO<Person> implements PersonIDAO {
|
|
||||||
/**
|
|
||||||
* 设置dao映射基类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Class<Person> getEntityClass() {
|
|
||||||
return Person.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.jsh.dao.materials;
|
|
||||||
|
|
||||||
import com.jsh.base.BaseIDAO;
|
|
||||||
import com.jsh.model.po.Person;
|
|
||||||
|
|
||||||
public interface PersonIDAO extends BaseIDAO<Person> {
|
|
||||||
|
|
||||||
}
|
|
||||||
15
src/main/java/com/jsh/erp/ErpApplication.java
Normal file
15
src/main/java/com/jsh/erp/ErpApplication.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.jsh.erp;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"})
|
||||||
|
@EnableScheduling
|
||||||
|
public class ErpApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ErpApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
src/main/java/com/jsh/erp/config/DbConfig.java
Normal file
97
src/main/java/com/jsh/erp/config/DbConfig.java
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package com.jsh.erp.config;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableTransactionManagement(proxyTargetClass = true)
|
||||||
|
public class DbConfig {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DbConfig.class);
|
||||||
|
|
||||||
|
@Bean(name = "erpDatasource")
|
||||||
|
@Primary
|
||||||
|
public DataSource erpDatasource(ErpDatasourceProperties properties){
|
||||||
|
try {
|
||||||
|
DruidDataSource datasource = new DruidDataSource();
|
||||||
|
datasource.setDriverClassName(properties.driverClassName);
|
||||||
|
datasource.setUrl(properties.url);
|
||||||
|
datasource.setUsername(properties.username);
|
||||||
|
datasource.setPassword(properties.password);
|
||||||
|
datasource.setInitialSize(1);
|
||||||
|
datasource.setMinIdle(1);
|
||||||
|
datasource.setMaxWait(60000);
|
||||||
|
datasource.setMaxActive(5);
|
||||||
|
datasource.setTimeBetweenEvictionRunsMillis(60000);
|
||||||
|
datasource.setValidationQuery("select '1'");
|
||||||
|
datasource.setTestOnBorrow(false);
|
||||||
|
datasource.setTestOnReturn(false);
|
||||||
|
datasource.setTestWhileIdle(true);
|
||||||
|
datasource.setPoolPreparedStatements(true);
|
||||||
|
datasource.setMaxOpenPreparedStatements(20);
|
||||||
|
datasource.setMinEvictableIdleTimeMillis(300000);
|
||||||
|
datasource.init();
|
||||||
|
return datasource;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("服务启动失败,jsh_erp数据库Datasource初始化失败:"+e.getMessage());
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public JdbcTemplate jdbcTemplate(@Qualifier("erpDatasource") DataSource dataSource) {
|
||||||
|
return new JdbcTemplate(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "erpDatasource")
|
||||||
|
public static class ErpDatasourceProperties {
|
||||||
|
private String driverClassName;
|
||||||
|
private String url;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getDriverClassName() {
|
||||||
|
return driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDriverClassName(String driverClassName) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/main/java/com/jsh/erp/config/WebConfig.java
Normal file
40
src/main/java/com/jsh/erp/config/WebConfig.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.jsh.erp.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
||||||
|
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "web.front")
|
||||||
|
public static class FrontEnd implements EmbeddedServletContainerCustomizer {
|
||||||
|
private File baseDir;
|
||||||
|
|
||||||
|
public File getBaseDir() {
|
||||||
|
return baseDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseDir(File baseDir) {
|
||||||
|
this.baseDir = baseDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(ConfigurableEmbeddedServletContainer container) {
|
||||||
|
if (!baseDir.exists()) {
|
||||||
|
if (!baseDir.mkdir()) {
|
||||||
|
logger.info("create web.front base path:" + baseDir + " failed!already exists!");
|
||||||
|
} else {
|
||||||
|
logger.info("create web.front base path:" + baseDir + " success!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
container.setDocumentRoot(baseDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
124
src/main/java/com/jsh/erp/controller/AccountController.java
Normal file
124
src/main/java/com/jsh/erp/controller/AccountController.java
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Account;
|
||||||
|
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||||
|
import com.jsh.erp.service.account.AccountService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/account")
|
||||||
|
public class AccountController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(AccountController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountService accountService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找结算账户信息-下拉框
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findBySelect")
|
||||||
|
public String findBySelect(HttpServletRequest request) {
|
||||||
|
String res = null;
|
||||||
|
try {
|
||||||
|
List<Account> dataList = accountService.findBySelect();
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Account account : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Id", account.getId());
|
||||||
|
//结算账户名称
|
||||||
|
item.put("AccountName", account.getName());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = dataArray.toJSONString();
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有结算账户
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getAccount")
|
||||||
|
public BaseResponseInfo getAccount(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<Account> accountList = accountService.getAccount();
|
||||||
|
map.put("accountList", accountList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账户流水信息
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param accountId
|
||||||
|
* @param initialAmount
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findAccountInOutList")
|
||||||
|
public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("accountId") Long accountId,
|
||||||
|
@RequestParam("initialAmount") Double initialAmount,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<AccountVo4InOutList> dataList = accountService.findAccountInOutList(accountId, (currentPage-1)*pageSize, pageSize);
|
||||||
|
int total = accountService.findAccountInOutListCount(accountId);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (AccountVo4InOutList aEx : dataList) {
|
||||||
|
String timeStr = aEx.getOperTime().toString();
|
||||||
|
Double balance = accountService.getAccountSum(accountId, timeStr, "date") + accountService.getAccountSumByHead(accountId, timeStr, "date")
|
||||||
|
+ accountService.getAccountSumByDetail(accountId, timeStr, "date") + accountService.getManyAccountSum(accountId, timeStr, "date") + initialAmount;
|
||||||
|
aEx.setBalance(balance);
|
||||||
|
dataArray.add(aEx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
146
src/main/java/com/jsh/erp/controller/AccountHeadController.java
Normal file
146
src/main/java/com/jsh/erp/controller/AccountHeadController.java
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.AccountHead;
|
||||||
|
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
|
||||||
|
import com.jsh.erp.service.accountHead.AccountHeadService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/accountHead")
|
||||||
|
public class AccountHeadController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(AccountHeadController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountHeadService accountHeadService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最大的id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getMaxId")
|
||||||
|
public BaseResponseInfo getMaxId(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
Long maxId = accountHeadService.getMaxId();
|
||||||
|
map.put("maxId", maxId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单位的累计应收和累计应付,收预付款不计入此处
|
||||||
|
* @param supplierId
|
||||||
|
* @param endTime
|
||||||
|
* @param supType
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findTotalPay")
|
||||||
|
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
@RequestParam("supType") String supType,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
Double sum = 0.0;
|
||||||
|
String getS = supplierId.toString();
|
||||||
|
int i = 1;
|
||||||
|
if (supType.equals("customer")) { //客户
|
||||||
|
i = 1;
|
||||||
|
} else if (supType.equals("vendor")) { //供应商
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
//收付款部分
|
||||||
|
sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i;
|
||||||
|
sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i;
|
||||||
|
sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i;
|
||||||
|
sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i;
|
||||||
|
outer.put("getAllMoney", sum);
|
||||||
|
map.put("rows", outer);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据编号查询单据信息
|
||||||
|
* @param number
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getDetailByNumber")
|
||||||
|
public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx();
|
||||||
|
try {
|
||||||
|
List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo);
|
||||||
|
if(list.size() == 1) {
|
||||||
|
ahl = list.get(0);
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = ahl;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计总金额
|
||||||
|
* @param getS
|
||||||
|
* @param type
|
||||||
|
* @param subType
|
||||||
|
* @param mode 合计或者金额
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double allMoney(String getS, String type, String mode, String endTime) {
|
||||||
|
Double allMoney = 0.0;
|
||||||
|
try {
|
||||||
|
Integer supplierId = Integer.valueOf(getS);
|
||||||
|
Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime);
|
||||||
|
if(sum != null) {
|
||||||
|
allMoney = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
//返回正数,如果负数也转为正数
|
||||||
|
if (allMoney < 0) {
|
||||||
|
allMoney = -allMoney;
|
||||||
|
}
|
||||||
|
return allMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
147
src/main/java/com/jsh/erp/controller/AccountItemController.java
Normal file
147
src/main/java/com/jsh/erp/controller/AccountItemController.java
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.AccountItem;
|
||||||
|
import com.jsh.erp.datasource.vo.AccountItemVo4List;
|
||||||
|
import com.jsh.erp.service.accountItem.AccountItemService;
|
||||||
|
import com.jsh.erp.utils.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/accountItem")
|
||||||
|
public class AccountItemController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(AccountItemController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountItemService accountItemService;
|
||||||
|
|
||||||
|
@PostMapping(value = "/saveDetials")
|
||||||
|
public String saveDetials(@RequestParam("inserted") String inserted,
|
||||||
|
@RequestParam("deleted") String deleted,
|
||||||
|
@RequestParam("updated") String updated,
|
||||||
|
@RequestParam("headerId") Long headerId,
|
||||||
|
@RequestParam("listType") String listType,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
//转为json
|
||||||
|
JSONArray insertedJson = JSONArray.parseArray(inserted);
|
||||||
|
JSONArray deletedJson = JSONArray.parseArray(deleted);
|
||||||
|
JSONArray updatedJson = JSONArray.parseArray(updated);
|
||||||
|
if (null != insertedJson) {
|
||||||
|
for (int i = 0; i < insertedJson.size(); i++) {
|
||||||
|
AccountItem accountItem = new AccountItem();
|
||||||
|
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
|
||||||
|
accountItem.setHeaderid(headerId);
|
||||||
|
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
|
||||||
|
accountItem.setAccountid(tempInsertedJson.getLong("AccountId"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
|
||||||
|
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
|
||||||
|
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
|
||||||
|
if (listType.equals("付款")) {
|
||||||
|
eachAmount = 0 - eachAmount;
|
||||||
|
}
|
||||||
|
accountItem.setEachamount(eachAmount);
|
||||||
|
} else {
|
||||||
|
accountItem.setEachamount(0.0);
|
||||||
|
}
|
||||||
|
accountItem.setRemark(tempInsertedJson.getString("Remark"));
|
||||||
|
accountItemService.insertAccountItemWithObj(accountItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != deletedJson) {
|
||||||
|
for (int i = 0; i < deletedJson.size(); i++) {
|
||||||
|
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
|
||||||
|
accountItemService.deleteAccountItem(tempDeletedJson.getLong("Id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != updatedJson) {
|
||||||
|
for (int i = 0; i < updatedJson.size(); i++) {
|
||||||
|
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
|
||||||
|
AccountItem accountItem = accountItemService.getAccountItem(tempUpdatedJson.getLong("Id"));
|
||||||
|
accountItem.setId(tempUpdatedJson.getLong("Id"));
|
||||||
|
accountItem.setHeaderid(headerId);
|
||||||
|
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
|
||||||
|
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId"));
|
||||||
|
}
|
||||||
|
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
|
||||||
|
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
|
||||||
|
}
|
||||||
|
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
|
||||||
|
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
|
||||||
|
if (listType.equals("付款")) {
|
||||||
|
eachAmount = 0 - eachAmount;
|
||||||
|
}
|
||||||
|
accountItem.setEachamount(eachAmount);
|
||||||
|
} else {
|
||||||
|
accountItem.setEachamount(0.0);
|
||||||
|
}
|
||||||
|
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
|
||||||
|
accountItemService.updateAccountItemWithObj(accountItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e);
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/getDetailList")
|
||||||
|
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<AccountItemVo4List> dataList = new ArrayList<AccountItemVo4List>();
|
||||||
|
if(headerId != 0) {
|
||||||
|
dataList = accountItemService.getDetailList(headerId);
|
||||||
|
}
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("total", dataList.size());
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (AccountItemVo4List ai : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Id", ai.getId());
|
||||||
|
item.put("AccountId", ai.getAccountid());
|
||||||
|
item.put("AccountName", ai.getAccountName());
|
||||||
|
item.put("InOutItemId", ai.getInoutitemid());
|
||||||
|
item.put("InOutItemName", ai.getInOutItemName());
|
||||||
|
Double eachAmount = ai.getEachamount();
|
||||||
|
item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
|
||||||
|
item.put("Remark", ai.getRemark());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = outer;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
116
src/main/java/com/jsh/erp/controller/AppController.java
Normal file
116
src/main/java/com/jsh/erp/controller/AppController.java
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.App;
|
||||||
|
import com.jsh.erp.service.app.AppService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/app")
|
||||||
|
public class AppController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(AppController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AppService appService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/findDesk")
|
||||||
|
public JSONObject findDesk(HttpServletRequest request) {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
List<App> dockList = appService.findDock();
|
||||||
|
JSONArray dockArray = new JSONArray();
|
||||||
|
if (null != dockList) {
|
||||||
|
for (App app : dockList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", app.getId());
|
||||||
|
item.put("title", app.getName());
|
||||||
|
item.put("type", app.getType());
|
||||||
|
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||||
|
item.put("url", app.getUrl());
|
||||||
|
item.put("width", app.getWidth());
|
||||||
|
item.put("height", app.getHeight());
|
||||||
|
item.put("isresize", app.getResize());
|
||||||
|
item.put("isopenmax", app.getOpenmax());
|
||||||
|
item.put("isflash", app.getFlash());
|
||||||
|
dockArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj.put("dock",dockArray);
|
||||||
|
|
||||||
|
List<App> deskList = appService.findDesk();
|
||||||
|
JSONArray deskArray = new JSONArray();
|
||||||
|
if (null != deskList) {
|
||||||
|
for (App app : deskList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", app.getId());
|
||||||
|
item.put("title", app.getName());
|
||||||
|
item.put("type", app.getType());
|
||||||
|
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||||
|
item.put("url", "../../pages/common/menu.html?appID=" + app.getNumber() + "&id=" + app.getId());
|
||||||
|
item.put("width", app.getWidth());
|
||||||
|
item.put("height", app.getHeight());
|
||||||
|
item.put("isresize", app.getResize());
|
||||||
|
item.put("isopenmax", app.getOpenmax());
|
||||||
|
item.put("isflash", app.getFlash());
|
||||||
|
deskArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj.put("desk",deskArray);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色对应应用显示
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findRoleAPP")
|
||||||
|
public JSONArray findRoleAPP(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<App> dataList = appService.findRoleAPP();
|
||||||
|
//开始拼接json数据
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("id", 1);
|
||||||
|
outer.put("text", "应用列表");
|
||||||
|
outer.put("state", "open");
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (App app : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", app.getId());
|
||||||
|
item.put("text", app.getName());
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + app.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("children", dataArray);
|
||||||
|
arr.add(outer);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
149
src/main/java/com/jsh/erp/controller/DepotController.java
Normal file
149
src/main/java/com/jsh/erp/controller/DepotController.java
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Depot;
|
||||||
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/depot")
|
||||||
|
public class DepotController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(DepotController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DepotService depotService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/getAllList")
|
||||||
|
public BaseResponseInfo getAllList(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<Depot> depotList = depotService.getAllList();
|
||||||
|
res.code = 200;
|
||||||
|
res.data = depotList;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户对应仓库显示
|
||||||
|
* @param type
|
||||||
|
* @param keyId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findUserDepot")
|
||||||
|
public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Depot> dataList = depotService.findUserDepot();
|
||||||
|
//开始拼接json数据
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("id", 1);
|
||||||
|
outer.put("text", "仓库列表");
|
||||||
|
outer.put("state", "open");
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Depot depot : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", depot.getId());
|
||||||
|
item.put("text", depot.getName());
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("children", dataArray);
|
||||||
|
arr.add(outer);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/findDepotByUserId")
|
||||||
|
public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Depot> dataList = depotService.findUserDepot();
|
||||||
|
//开始拼接json数据
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Depot depot : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("id", depot.getId());
|
||||||
|
item.put("depotName", depot.getName());
|
||||||
|
arr.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找礼品卡-虚拟仓库
|
||||||
|
* @param type
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findGiftByType")
|
||||||
|
public JSONArray findGiftByType(@RequestParam("type") Integer type,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Depot> dataList = depotService.findGiftByType(type);
|
||||||
|
//存放数据json数组
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Depot depot : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", depot.getId());
|
||||||
|
//仓库名称
|
||||||
|
item.put("name", depot.getName());
|
||||||
|
arr.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>查找仓库信息异常", e);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
458
src/main/java/com/jsh/erp/controller/DepotHeadController.java
Normal file
458
src/main/java/com/jsh/erp/controller/DepotHeadController.java
Normal file
@@ -0,0 +1,458 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.DepotHead;
|
||||||
|
import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
|
||||||
|
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
|
||||||
|
import com.jsh.erp.datasource.vo.DepotHeadVo4List;
|
||||||
|
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
||||||
|
import com.jsh.erp.service.depotHead.DepotHeadService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
|
import com.jsh.erp.utils.StringUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/depotHead")
|
||||||
|
public class DepotHeadController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(DepotHeadController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DepotHeadService depotHeadService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量设置状态-审核或者反审核
|
||||||
|
* @param status
|
||||||
|
* @param depotHeadIDs
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/batchSetStatus")
|
||||||
|
public String batchSetStatus(@RequestParam("status") Boolean status,
|
||||||
|
@RequestParam("depotHeadIDs") String depotHeadIDs,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int res = depotHeadService.batchSetStatus(status, depotHeadIDs);
|
||||||
|
if(res > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据编号生成接口,规则:查找当前类型单据下的当天最大的单据号,并加1
|
||||||
|
* @param type
|
||||||
|
* @param subType
|
||||||
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/buildNumber")
|
||||||
|
public BaseResponseInfo buildNumber(@RequestParam("type") String type,
|
||||||
|
@RequestParam("subType") String subType,
|
||||||
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
String number = depotHeadService.buildNumber(type, subType, beginTime, endTime);
|
||||||
|
map.put("DefaultNumber", number);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最大的id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getMaxId")
|
||||||
|
public BaseResponseInfo getMaxId(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
Long maxId = depotHeadService.getMaxId();
|
||||||
|
map.put("maxId", maxId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找单据_根据月份(报表)
|
||||||
|
* @param monthTime
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findByMonth")
|
||||||
|
public BaseResponseInfo findByMonth(@RequestParam("monthTime") String monthTime,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotHead> dataList = depotHeadService.findByMonth(monthTime);
|
||||||
|
String headId = "";
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotHead depotHead : dataList) {
|
||||||
|
headId = headId + depotHead.getId() + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (headId != "") {
|
||||||
|
headId = headId.substring(0, headId.lastIndexOf(","));
|
||||||
|
}
|
||||||
|
map.put("HeadIds", headId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找统计信息_根据礼品卡(报表)
|
||||||
|
* @param projectId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findGiftReport")
|
||||||
|
public BaseResponseInfo findGiftReport(@RequestParam("projectId") String projectId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotHead> dataList_in = depotHeadService.getDepotHead();
|
||||||
|
String headId = "";
|
||||||
|
if (null != dataList_in) {
|
||||||
|
for (DepotHead depotHead : dataList_in) {
|
||||||
|
headId = headId + depotHead.getId() + ",";
|
||||||
|
}
|
||||||
|
List<DepotHead> dataList_out = depotHeadService.getDepotHeadGiftOut(projectId);
|
||||||
|
if (null != dataList_out) {
|
||||||
|
for (DepotHead depotHead : dataList_out) {
|
||||||
|
headId = headId + depotHead.getId() + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (headId != "") {
|
||||||
|
headId = headId.substring(0, headId.lastIndexOf(","));
|
||||||
|
}
|
||||||
|
map.put("HeadIds", headId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库出库明细接口
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param oId
|
||||||
|
* @param pid
|
||||||
|
* @param dids
|
||||||
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
|
* @param type
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findInDetail")
|
||||||
|
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("organId") Integer oId,
|
||||||
|
@RequestParam("projectId") Integer pid,
|
||||||
|
@RequestParam("depotIds") String dids,
|
||||||
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
@RequestParam("type") String type,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotHeadVo4InDetail> resList = new ArrayList<DepotHeadVo4InDetail>();
|
||||||
|
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, pid, dids, oId, currentPage, pageSize);
|
||||||
|
int total = depotHeadService.findByAllCount(beginTime, endTime, type, pid, dids, oId);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
if (null != list) {
|
||||||
|
for (DepotHeadVo4InDetail dhd : list) {
|
||||||
|
resList.add(dhd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", resList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库出库统计接口
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param oId
|
||||||
|
* @param pid
|
||||||
|
* @param dids
|
||||||
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
|
* @param type
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findInOutMaterialCount")
|
||||||
|
public BaseResponseInfo findInOutMaterialCount(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("organId") Integer oId,
|
||||||
|
@RequestParam("projectId") Integer pid,
|
||||||
|
@RequestParam("depotIds") String dids,
|
||||||
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
@RequestParam("type") String type,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotHeadVo4InOutMCount> resList = new ArrayList<DepotHeadVo4InOutMCount>();
|
||||||
|
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, currentPage, pageSize);
|
||||||
|
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
if (null != list) {
|
||||||
|
for (DepotHeadVo4InOutMCount dhc : list) {
|
||||||
|
resList.add(dhc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", resList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对账单接口
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
|
* @param organId
|
||||||
|
* @param supType
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findStatementAccount")
|
||||||
|
public BaseResponseInfo findStatementAccount(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("beginTime") String beginTime,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
@RequestParam("organId") Integer organId,
|
||||||
|
@RequestParam("supType") String supType,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
int j = 1;
|
||||||
|
if (supType.equals("客户")) { //客户
|
||||||
|
j = 1;
|
||||||
|
} else if (supType.equals("供应商")) { //供应商
|
||||||
|
j = -1;
|
||||||
|
}
|
||||||
|
List<DepotHeadVo4StatementAccount> resList = new ArrayList<DepotHeadVo4StatementAccount>();
|
||||||
|
List<DepotHeadVo4StatementAccount> list = depotHeadService.findStatementAccount(beginTime, endTime, organId, supType, (currentPage-1)*pageSize, pageSize);
|
||||||
|
int total = depotHeadService.findStatementAccountCount(beginTime, endTime, organId, supType);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
if (null != list) {
|
||||||
|
for (DepotHeadVo4StatementAccount dha : list) {
|
||||||
|
dha.setNumber(dha.getNumber()); //单据编号
|
||||||
|
dha.setType(dha.getType()); //类型
|
||||||
|
String type = dha.getType();
|
||||||
|
Double p1 = 0.0;
|
||||||
|
Double p2 = 0.0;
|
||||||
|
if (dha.getDiscountLastMoney() != null) {
|
||||||
|
p1 = dha.getDiscountLastMoney();
|
||||||
|
}
|
||||||
|
if (dha.getChangeAmount() != null) {
|
||||||
|
p2 = dha.getChangeAmount();
|
||||||
|
}
|
||||||
|
Double allPrice = 0.0;
|
||||||
|
if (p1 < 0) {
|
||||||
|
p1 = -p1;
|
||||||
|
}
|
||||||
|
if (p2 < 0) {
|
||||||
|
p2 = -p2;
|
||||||
|
}
|
||||||
|
if (type.equals("采购入库")) {
|
||||||
|
allPrice = -(p1 - p2);
|
||||||
|
} else if (type.equals("销售退货入库")) {
|
||||||
|
allPrice = -(p1 - p2);
|
||||||
|
} else if (type.equals("销售出库")) {
|
||||||
|
allPrice = p1 - p2;
|
||||||
|
} else if (type.equals("采购退货出库")) {
|
||||||
|
allPrice = p1 - p2;
|
||||||
|
} else if (type.equals("付款")) {
|
||||||
|
allPrice = p1 + p2;
|
||||||
|
} else if (type.equals("收款")) {
|
||||||
|
allPrice = -(p1 + p2);
|
||||||
|
} else if (type.equals("收入")) {
|
||||||
|
allPrice = p1 - p2;
|
||||||
|
} else if (type.equals("支出")) {
|
||||||
|
allPrice = -(p1 - p2);
|
||||||
|
}
|
||||||
|
dha.setDiscountLastMoney(p1); //金额
|
||||||
|
dha.setChangeAmount(p2); //金额
|
||||||
|
dha.setAllPrice(Double.parseDouble(String.format("%.2f", allPrice * j))); //计算后的金额
|
||||||
|
dha.setSupplierName(dha.getSupplierName()); //供应商
|
||||||
|
dha.setoTime(dha.getoTime()); //入库出库日期
|
||||||
|
resList.add(dha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", resList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单位的累计应收和累计应付,零售不能计入
|
||||||
|
* @param supplierId
|
||||||
|
* @param endTime
|
||||||
|
* @param supType
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findTotalPay")
|
||||||
|
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
|
||||||
|
@RequestParam("endTime") String endTime,
|
||||||
|
@RequestParam("supType") String supType,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
Double sum = 0.0;
|
||||||
|
String getS = supplierId.toString();
|
||||||
|
int i = 1;
|
||||||
|
if (supType.equals("customer")) { //客户
|
||||||
|
i = 1;
|
||||||
|
} else if (supType.equals("vendor")) { //供应商
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
//进销部分
|
||||||
|
sum = sum - (allMoney(getS, "入库", "采购", "合计",endTime) - allMoney(getS, "入库", "采购", "实际",endTime)) * i;
|
||||||
|
sum = sum - (allMoney(getS, "入库", "销售退货", "合计",endTime) - allMoney(getS, "入库", "销售退货", "实际",endTime)) * i;
|
||||||
|
sum = sum + (allMoney(getS, "出库", "销售", "合计",endTime) - allMoney(getS, "出库", "销售", "实际",endTime)) * i;
|
||||||
|
sum = sum + (allMoney(getS, "出库", "采购退货", "合计",endTime) - allMoney(getS, "出库", "采购退货", "实际",endTime)) * i;
|
||||||
|
outer.put("getAllMoney", sum);
|
||||||
|
map.put("rows", outer);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据编号查询单据信息
|
||||||
|
* @param number
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getDetailByNumber")
|
||||||
|
public BaseResponseInfo getDetailByNumber(@RequestParam("number") String number,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
DepotHeadVo4List dhl = new DepotHeadVo4List();
|
||||||
|
try {
|
||||||
|
List<DepotHeadVo4List> list = depotHeadService.getDetailByNumber(number);
|
||||||
|
if(list.size() == 1) {
|
||||||
|
dhl = list.get(0);
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = dhl;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计总金额
|
||||||
|
* @param getS
|
||||||
|
* @param type
|
||||||
|
* @param subType
|
||||||
|
* @param mode 合计或者金额
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double allMoney(String getS, String type, String subType, String mode, String endTime) {
|
||||||
|
Double allMoney = 0.0;
|
||||||
|
try {
|
||||||
|
Integer supplierId = Integer.valueOf(getS);
|
||||||
|
Double sum = depotHeadService.findAllMoney(supplierId, type, subType, mode, endTime);
|
||||||
|
if(sum != null) {
|
||||||
|
allMoney = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
//返回正数,如果负数也转为正数
|
||||||
|
if (allMoney < 0) {
|
||||||
|
allMoney = -allMoney;
|
||||||
|
}
|
||||||
|
return allMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
936
src/main/java/com/jsh/erp/controller/DepotItemController.java
Normal file
936
src/main/java/com/jsh/erp/controller/DepotItemController.java
Normal file
@@ -0,0 +1,936 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.*;
|
||||||
|
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||||
|
import com.jsh.erp.service.material.MaterialService;
|
||||||
|
import com.jsh.erp.utils.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/depotItem")
|
||||||
|
public class DepotItemController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(DepotItemController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DepotItemService depotItemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialService materialService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据材料信息获取
|
||||||
|
* @param materialParam 商品参数
|
||||||
|
* @param depotIds 拥有的仓库信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getHeaderIdByMaterial")
|
||||||
|
public BaseResponseInfo getHeaderIdByMaterial(@RequestParam("materialParam") String materialParam,
|
||||||
|
@RequestParam("depotIds") String depotIds,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4HeaderId> depotItemList = depotItemService.getHeaderIdByMaterial(materialParam, depotIds);
|
||||||
|
String allReturn = "";
|
||||||
|
if (depotItemList != null) {
|
||||||
|
for (DepotItemVo4HeaderId d : depotItemList) {
|
||||||
|
Long dl = d.getHeaderid(); //获取对象
|
||||||
|
allReturn = allReturn + dl.toString() + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allReturn = allReturn.substring(0, allReturn.length() - 1);
|
||||||
|
if (allReturn.equals("null")) {
|
||||||
|
allReturn = "";
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = allReturn;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只根据商品id查询单据列表
|
||||||
|
* @param mId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findDetailByTypeAndMaterialId")
|
||||||
|
public String findDetailByTypeAndMaterialId(
|
||||||
|
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||||
|
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||||
|
@RequestParam("materialId") String mId, HttpServletRequest request) {
|
||||||
|
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||||
|
parameterMap.put("mId", mId);
|
||||||
|
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
if (pageSize != null && pageSize <= 0) {
|
||||||
|
pageSize = 10;
|
||||||
|
}
|
||||||
|
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||||
|
if (StringUtil.isNotEmpty(offset)) {
|
||||||
|
parameterMap.put(Constants.OFFSET, offset);
|
||||||
|
}
|
||||||
|
List<DepotItemVo4DetailByTypeAndMId> list = depotItemService.findDetailByTypeAndMaterialIdList(parameterMap);
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (list != null) {
|
||||||
|
for (DepotItemVo4DetailByTypeAndMId d: list) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Number", d.getNumber()); //商品编号
|
||||||
|
item.put("Type", d.getNewtype()); //进出类型
|
||||||
|
item.put("BasicNumber", d.getBnum()); //数量
|
||||||
|
item.put("OperTime", d.getOtime()); //时间
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
objectMap.put("page", dataArray);
|
||||||
|
if (list == null) {
|
||||||
|
queryInfo.setRows(new ArrayList<Object>());
|
||||||
|
queryInfo.setTotal(0);
|
||||||
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
queryInfo.setRows(list);
|
||||||
|
queryInfo.setTotal(depotItemService.findDetailByTypeAndMaterialIdCounts(parameterMap));
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品id和仓库id查询库存数量
|
||||||
|
* @param pageSize
|
||||||
|
* @param currentPage
|
||||||
|
* @param mId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findStockNumById")
|
||||||
|
public String findStockNumById(
|
||||||
|
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||||
|
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||||
|
@RequestParam("projectId") Integer pid,
|
||||||
|
@RequestParam("materialId") String mId,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||||
|
parameterMap.put("mId", mId);
|
||||||
|
parameterMap.put("monthTime", monthTime);
|
||||||
|
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
if (pageSize != null && pageSize <= 0) {
|
||||||
|
pageSize = 10;
|
||||||
|
}
|
||||||
|
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||||
|
if (StringUtil.isNotEmpty(offset)) {
|
||||||
|
parameterMap.put(Constants.OFFSET, offset);
|
||||||
|
}
|
||||||
|
List<DepotItemVo4Material> list = depotItemService.findStockNumByMaterialIdList(parameterMap);
|
||||||
|
//存放数据json数组
|
||||||
|
Long materialId = Long.parseLong(mId);
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != list) {
|
||||||
|
for (DepotItemVo4Material di : list) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
double prevSum = sumNumber("入库", pid, materialId, monthTime, true) - sumNumber("出库", pid, materialId, monthTime, true);
|
||||||
|
double InSum = sumNumber("入库", pid, materialId, monthTime, false);
|
||||||
|
double OutSum = sumNumber("出库", pid, materialId, monthTime, false);
|
||||||
|
item.put("MaterialId", di.getMaterialid() == null ? "" : di.getMaterialid());
|
||||||
|
item.put("MaterialName", di.getMname());
|
||||||
|
item.put("MaterialModel", di.getMmodel());
|
||||||
|
item.put("thisSum", prevSum + InSum - OutSum);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
objectMap.put("page", dataArray);
|
||||||
|
if (list == null) {
|
||||||
|
queryInfo.setRows(new ArrayList<Object>());
|
||||||
|
queryInfo.setTotal(0);
|
||||||
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
queryInfo.setRows(list);
|
||||||
|
queryInfo.setTotal(depotItemService.findStockNumByMaterialIdCounts(parameterMap));
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只根据商品id查询库存数量
|
||||||
|
* @param pageSize
|
||||||
|
* @param currentPage
|
||||||
|
* @param mId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findStockNumByMaterialId")
|
||||||
|
public String findStockNumByMaterialId(
|
||||||
|
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||||
|
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||||
|
@RequestParam("materialId") String mId,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||||
|
parameterMap.put("mId", mId);
|
||||||
|
parameterMap.put("monthTime", monthTime);
|
||||||
|
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
if (pageSize != null && pageSize <= 0) {
|
||||||
|
pageSize = 10;
|
||||||
|
}
|
||||||
|
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||||
|
if (StringUtil.isNotEmpty(offset)) {
|
||||||
|
parameterMap.put(Constants.OFFSET, offset);
|
||||||
|
}
|
||||||
|
List<DepotItemVo4Material> list = depotItemService.findStockNumByMaterialIdList(parameterMap);
|
||||||
|
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != list) {
|
||||||
|
for (DepotItemVo4Material di : list) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
int InSum = sumNumberByMaterialId("入库", di.getMaterialid());
|
||||||
|
int OutSum = sumNumberByMaterialId("出库", di.getMaterialid());
|
||||||
|
item.put("MaterialId", di.getMaterialid() == null ? "" : di.getMaterialid());
|
||||||
|
item.put("MaterialName", di.getMname());
|
||||||
|
item.put("MaterialModel", di.getMmodel());
|
||||||
|
item.put("thisSum", InSum - OutSum);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
objectMap.put("page", dataArray);
|
||||||
|
if (list == null) {
|
||||||
|
queryInfo.setRows(new ArrayList<Object>());
|
||||||
|
queryInfo.setTotal(0);
|
||||||
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
queryInfo.setRows(list);
|
||||||
|
queryInfo.setTotal(depotItemService.findStockNumByMaterialIdCounts(parameterMap));
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅根据商品Id进行数量合计
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param mId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int sumNumberByMaterialId(String type, Long mId) {
|
||||||
|
int allNumber = 0;
|
||||||
|
try {
|
||||||
|
allNumber = depotItemService.findByTypeAndMaterialId(type, mId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return allNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存明细
|
||||||
|
* @param inserted
|
||||||
|
* @param deleted
|
||||||
|
* @param updated
|
||||||
|
* @param headerId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/saveDetials")
|
||||||
|
public String saveDetials(@RequestParam("inserted") String inserted,
|
||||||
|
@RequestParam("deleted") String deleted,
|
||||||
|
@RequestParam("updated") String updated,
|
||||||
|
@RequestParam("headerId") Long headerId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
//转为json
|
||||||
|
JSONArray insertedJson = JSONArray.parseArray(inserted);
|
||||||
|
JSONArray deletedJson = JSONArray.parseArray(deleted);
|
||||||
|
JSONArray updatedJson = JSONArray.parseArray(updated);
|
||||||
|
if (null != insertedJson) {
|
||||||
|
for (int i = 0; i < insertedJson.size(); i++) {
|
||||||
|
DepotItem depotItem = new DepotItem();
|
||||||
|
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
|
||||||
|
depotItem.setHeaderid(headerId);
|
||||||
|
depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId"));
|
||||||
|
depotItem.setMunit(tempInsertedJson.getString("Unit"));
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) {
|
||||||
|
depotItem.setOpernumber(tempInsertedJson.getDouble("OperNumber"));
|
||||||
|
try {
|
||||||
|
String Unit = tempInsertedJson.get("Unit").toString();
|
||||||
|
Double oNumber = tempInsertedJson.getDouble("OperNumber");
|
||||||
|
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
|
||||||
|
//以下进行单位换算
|
||||||
|
String UnitName = findUnitName(mId); //查询计量单位名称
|
||||||
|
if (!UnitName.equals("")) {
|
||||||
|
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
|
||||||
|
String RatioList = UnitName.substring(UnitName.indexOf("("));
|
||||||
|
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
|
||||||
|
String otherUnit = UnitList.substring(UnitList.indexOf(",") + 1); //副单位
|
||||||
|
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")", "")); //比例
|
||||||
|
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
||||||
|
depotItem.setBasicnumber(oNumber); //数量一致
|
||||||
|
} else if (Unit.equals(otherUnit)) { //如果等于副单位
|
||||||
|
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
depotItem.setBasicnumber(oNumber); //其他情况
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
|
||||||
|
depotItem.setUnitprice(tempInsertedJson.getDouble("UnitPrice"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())) {
|
||||||
|
depotItem.setTaxunitprice(tempInsertedJson.getDouble("TaxUnitPrice"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("AllPrice").toString())) {
|
||||||
|
depotItem.setAllprice(tempInsertedJson.getDouble("AllPrice"));
|
||||||
|
}
|
||||||
|
depotItem.setRemark(tempInsertedJson.getString("Remark"));
|
||||||
|
if (tempInsertedJson.get("DepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("DepotId").toString())) {
|
||||||
|
depotItem.setDepotid(tempInsertedJson.getLong("DepotId"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())) {
|
||||||
|
depotItem.setAnotherdepotid(tempInsertedJson.getLong("AnotherDepotId"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxRate").toString())) {
|
||||||
|
depotItem.setTaxrate(tempInsertedJson.getDouble("TaxRate"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxMoney").toString())) {
|
||||||
|
depotItem.setTaxmoney(tempInsertedJson.getDouble("TaxMoney"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())) {
|
||||||
|
depotItem.setTaxlastmoney(tempInsertedJson.getDouble("TaxLastMoney"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("OtherField1") != null) {
|
||||||
|
depotItem.setOtherfield1(tempInsertedJson.getString("OtherField1"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("OtherField2") != null) {
|
||||||
|
depotItem.setOtherfield2(tempInsertedJson.getString("OtherField2"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("OtherField3") != null) {
|
||||||
|
depotItem.setOtherfield3(tempInsertedJson.getString("OtherField3"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("OtherField4") != null) {
|
||||||
|
depotItem.setOtherfield4(tempInsertedJson.getString("OtherField4"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("OtherField5") != null) {
|
||||||
|
depotItem.setOtherfield5(tempInsertedJson.getString("OtherField5"));
|
||||||
|
}
|
||||||
|
if (tempInsertedJson.get("MType") != null) {
|
||||||
|
depotItem.setMtype(tempInsertedJson.getString("MType"));
|
||||||
|
}
|
||||||
|
depotItemService.insertDepotItemWithObj(depotItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != deletedJson) {
|
||||||
|
for (int i = 0; i < deletedJson.size(); i++) {
|
||||||
|
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
|
||||||
|
depotItemService.deleteDepotItem(tempDeletedJson.getLong("Id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != updatedJson) {
|
||||||
|
for (int i = 0; i < updatedJson.size(); i++) {
|
||||||
|
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
|
||||||
|
DepotItem depotItem = depotItemService.getDepotItem(tempUpdatedJson.getLong("Id"));
|
||||||
|
depotItem.setId(tempUpdatedJson.getLong("Id"));
|
||||||
|
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
|
||||||
|
depotItem.setMunit(tempUpdatedJson.getString("Unit"));
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) {
|
||||||
|
depotItem.setOpernumber(tempUpdatedJson.getDouble("OperNumber"));
|
||||||
|
try {
|
||||||
|
String Unit = tempUpdatedJson.get("Unit").toString();
|
||||||
|
Double oNumber = tempUpdatedJson.getDouble("OperNumber");
|
||||||
|
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
|
||||||
|
//以下进行单位换算
|
||||||
|
String UnitName = findUnitName(mId); //查询计量单位名称
|
||||||
|
if (!UnitName.equals("")) {
|
||||||
|
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
|
||||||
|
String RatioList = UnitName.substring(UnitName.indexOf("("));
|
||||||
|
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
|
||||||
|
String otherUnit = UnitList.substring(UnitList.indexOf(",") + 1); //副单位
|
||||||
|
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")", "")); //比例
|
||||||
|
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
||||||
|
depotItem.setBasicnumber(oNumber); //数量一致
|
||||||
|
} else if (Unit.equals(otherUnit)) { //如果等于副单位
|
||||||
|
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
depotItem.setBasicnumber(oNumber); //其他情况
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
|
||||||
|
depotItem.setUnitprice(tempUpdatedJson.getDouble("UnitPrice"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
|
||||||
|
depotItem.setTaxunitprice(tempUpdatedJson.getDouble("TaxUnitPrice"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
|
||||||
|
depotItem.setAllprice(tempUpdatedJson.getDouble("AllPrice"));
|
||||||
|
}
|
||||||
|
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
|
||||||
|
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
|
||||||
|
depotItem.setDepotid(tempUpdatedJson.getLong("DepotId"));
|
||||||
|
}
|
||||||
|
if (tempUpdatedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())) {
|
||||||
|
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
|
||||||
|
depotItem.setTaxrate(tempUpdatedJson.getDouble("TaxRate"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
|
||||||
|
depotItem.setTaxmoney(tempUpdatedJson.getDouble("TaxMoney"));
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
|
||||||
|
depotItem.setTaxlastmoney(tempUpdatedJson.getDouble("TaxLastMoney"));
|
||||||
|
}
|
||||||
|
depotItem.setOtherfield1(tempUpdatedJson.getString("OtherField1"));
|
||||||
|
depotItem.setOtherfield2(tempUpdatedJson.getString("OtherField2"));
|
||||||
|
depotItem.setOtherfield3(tempUpdatedJson.getString("OtherField3"));
|
||||||
|
depotItem.setOtherfield4(tempUpdatedJson.getString("OtherField4"));
|
||||||
|
depotItem.setOtherfield5(tempUpdatedJson.getString("OtherField5"));
|
||||||
|
depotItem.setMtype(tempUpdatedJson.getString("MType"));
|
||||||
|
depotItemService.updateDepotItemWithObj(depotItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e);
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询计量单位信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String findUnitName(Long mId) {
|
||||||
|
String unitName = "";
|
||||||
|
try {
|
||||||
|
unitName = materialService.findUnitName(mId);
|
||||||
|
if (unitName != null) {
|
||||||
|
unitName = unitName.substring(1, unitName.length() - 1);
|
||||||
|
if (unitName.equals("null")) {
|
||||||
|
unitName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/getDetailList")
|
||||||
|
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = new ArrayList<DepotItemVo4WithInfoEx>();
|
||||||
|
if(headerId != 0) {
|
||||||
|
dataList = depotItemService.getDetailList(headerId);
|
||||||
|
}
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("total", dataList.size());
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Id", diEx.getId());
|
||||||
|
item.put("MaterialId", diEx.getMaterialid() == null ? "" : diEx.getMaterialid());
|
||||||
|
String ratio; //比例
|
||||||
|
if (diEx.getUnitId() == null || diEx.getUnitId().equals("")) {
|
||||||
|
ratio = "";
|
||||||
|
} else {
|
||||||
|
ratio = diEx.getUName();
|
||||||
|
ratio = ratio.substring(ratio.indexOf("("));
|
||||||
|
}
|
||||||
|
//品名/型号/扩展信息/包装
|
||||||
|
String MaterialName = diEx.getMName() + ((diEx.getMModel() == null || diEx.getMModel().equals("")) ? "" : "(" + diEx.getMModel() + ")");
|
||||||
|
String materialOther = getOtherInfo(mpArr, diEx);
|
||||||
|
MaterialName = MaterialName + materialOther + ((diEx.getUName() == null || diEx.getUName().equals("")) ? "" : "(" + diEx.getUName() + ")") + ratio;
|
||||||
|
item.put("MaterialName", MaterialName);
|
||||||
|
item.put("Unit", diEx.getMunit());
|
||||||
|
item.put("OperNumber", diEx.getOpernumber());
|
||||||
|
item.put("BasicNumber", diEx.getBasicnumber());
|
||||||
|
item.put("UnitPrice", diEx.getUnitprice());
|
||||||
|
item.put("TaxUnitPrice", diEx.getTaxunitprice());
|
||||||
|
item.put("AllPrice", diEx.getAllprice());
|
||||||
|
item.put("Remark", diEx.getRemark());
|
||||||
|
item.put("Img", diEx.getImg());
|
||||||
|
item.put("DepotId", diEx.getDepotid() == null ? "" : diEx.getDepotid());
|
||||||
|
item.put("DepotName", diEx.getDepotid() == null ? "" : diEx.getDepotName());
|
||||||
|
item.put("AnotherDepotId", diEx.getAnotherdepotid() == null ? "" : diEx.getAnotherdepotid());
|
||||||
|
item.put("AnotherDepotName", diEx.getAnotherdepotid() == null ? "" : diEx.getAnotherDepotName());
|
||||||
|
item.put("TaxRate", diEx.getTaxrate());
|
||||||
|
item.put("TaxMoney", diEx.getTaxmoney());
|
||||||
|
item.put("TaxLastMoney", diEx.getTaxlastmoney());
|
||||||
|
item.put("OtherField1", diEx.getOtherfield1());
|
||||||
|
item.put("OtherField2", diEx.getOtherfield2());
|
||||||
|
item.put("OtherField3", diEx.getOtherfield3());
|
||||||
|
item.put("OtherField4", diEx.getOtherfield4());
|
||||||
|
item.put("OtherField5", diEx.getOtherfield5());
|
||||||
|
item.put("MType", diEx.getMtype());
|
||||||
|
item.put("op", 1);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = outer;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取扩展信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx) {
|
||||||
|
String materialOther = "";
|
||||||
|
for (int i = 0; i < mpArr.length; i++) {
|
||||||
|
if (mpArr[i].equals("颜色")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMColor() == null || diEx.getMColor().equals("")) ? "" : "(" + diEx.getMColor() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("规格")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMStandard() == null || diEx.getMStandard().equals("")) ? "" : "(" + diEx.getMStandard() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("制造商")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义1")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField1() == null || diEx.getMOtherField1().equals("")) ? "" : "(" + diEx.getMOtherField1() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义2")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField2() == null || diEx.getMOtherField2().equals("")) ? "" : "(" + diEx.getMOtherField2() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义3")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField3() == null || diEx.getMOtherField3().equals("")) ? "" : "(" + diEx.getMOtherField3() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return materialOther;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找所有的明细
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param projectId
|
||||||
|
* @param monthTime
|
||||||
|
* @param headIds
|
||||||
|
* @param materialIds
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findByAll")
|
||||||
|
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("projectId") Integer projectId,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
@RequestParam("headIds") String headIds,
|
||||||
|
@RequestParam("materialIds") String materialIds,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize);
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
Integer pid = projectId;
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true);
|
||||||
|
Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true);
|
||||||
|
Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
item.put("Id", diEx.getId());
|
||||||
|
item.put("MaterialId", diEx.getMaterialid());
|
||||||
|
item.put("MaterialName", diEx.getMName());
|
||||||
|
item.put("MaterialModel", diEx.getMColor());
|
||||||
|
//扩展信息
|
||||||
|
String materialOther = getOtherInfo(mpArr, diEx);
|
||||||
|
item.put("MaterialOther", materialOther);
|
||||||
|
item.put("MaterialColor", diEx.getMColor());
|
||||||
|
item.put("MaterialUnit", diEx.getMaterialUnit());
|
||||||
|
Double unitPrice = 0.0;
|
||||||
|
if (prevSum + InSum - OutSum != 0.0) {
|
||||||
|
unitPrice = (prevPrice + InPrice - OutPrice) / (prevSum + InSum - OutSum);
|
||||||
|
}
|
||||||
|
item.put("UnitPrice", unitPrice);
|
||||||
|
item.put("prevSum", prevSum);
|
||||||
|
item.put("InSum", InSum);
|
||||||
|
item.put("OutSum", OutSum);
|
||||||
|
item.put("thisSum", prevSum + InSum - OutSum);
|
||||||
|
item.put("thisAllPrice", prevPrice + InPrice - OutPrice);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计总计金额
|
||||||
|
* @param pid
|
||||||
|
* @param monthTime
|
||||||
|
* @param headIds
|
||||||
|
* @param materialIds
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/totalCountMoney")
|
||||||
|
public BaseResponseInfo totalCountMoney(@RequestParam("projectId") Integer pid,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
@RequestParam("headIds") String headIds,
|
||||||
|
@RequestParam("materialIds") String materialIds,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, null, null);
|
||||||
|
Double thisAllPrice = 0.0;
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true);
|
||||||
|
Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false);
|
||||||
|
thisAllPrice = thisAllPrice + (prevPrice + InPrice - OutPrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("totalCount", thisAllPrice);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进货统计
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param monthTime
|
||||||
|
* @param headIds
|
||||||
|
* @param materialIds
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/buyIn")
|
||||||
|
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
@RequestParam("headIds") String headIds,
|
||||||
|
@RequestParam("materialIds") String materialIds,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize);
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Double InSum = sumNumberBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime);
|
||||||
|
Double OutSum = sumNumberBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime);
|
||||||
|
Double InSumPrice = sumPriceBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime);
|
||||||
|
Double OutSumPrice = sumPriceBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime);
|
||||||
|
item.put("Id", diEx.getId());
|
||||||
|
item.put("MaterialId", diEx.getMaterialid());
|
||||||
|
item.put("MaterialName", diEx.getMName());
|
||||||
|
item.put("MaterialModel", diEx.getMModel());
|
||||||
|
//扩展信息
|
||||||
|
String materialOther = getOtherInfo(mpArr, diEx);
|
||||||
|
item.put("MaterialOther", materialOther);
|
||||||
|
item.put("MaterialColor", diEx.getMColor());
|
||||||
|
item.put("MaterialUnit", diEx.getMaterialUnit());
|
||||||
|
item.put("InSum", InSum);
|
||||||
|
item.put("OutSum", OutSum);
|
||||||
|
item.put("InSumPrice", InSumPrice);
|
||||||
|
item.put("OutSumPrice", OutSumPrice);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售统计
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param monthTime
|
||||||
|
* @param headIds
|
||||||
|
* @param materialIds
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/saleOut")
|
||||||
|
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("monthTime") String monthTime,
|
||||||
|
@RequestParam("headIds") String headIds,
|
||||||
|
@RequestParam("materialIds") String materialIds,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize);
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||||
|
map.put("total", total);
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Double OutSumRetail = sumNumberBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime);
|
||||||
|
Double OutSum = sumNumberBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime);
|
||||||
|
Double InSumRetail = sumNumberBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime);
|
||||||
|
Double InSum = sumNumberBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime);
|
||||||
|
Double OutSumRetailPrice = sumPriceBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime);
|
||||||
|
Double OutSumPrice = sumPriceBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime);
|
||||||
|
Double InSumRetailPrice = sumPriceBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime);
|
||||||
|
Double InSumPrice = sumPriceBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime);
|
||||||
|
item.put("Id", diEx.getId());
|
||||||
|
item.put("MaterialId", diEx.getMaterialid());
|
||||||
|
item.put("MaterialName", diEx.getMName());
|
||||||
|
item.put("MaterialModel", diEx.getMModel());
|
||||||
|
//扩展信息
|
||||||
|
String materialOther = getOtherInfo(mpArr, diEx);
|
||||||
|
item.put("MaterialOther", materialOther);
|
||||||
|
item.put("MaterialColor", diEx.getMColor());
|
||||||
|
item.put("MaterialUnit", diEx.getMaterialUnit());
|
||||||
|
item.put("OutSum", OutSumRetail + OutSum);
|
||||||
|
item.put("InSum", InSumRetail + InSum);
|
||||||
|
item.put("OutSumPrice", OutSumRetailPrice + OutSumPrice);
|
||||||
|
item.put("InSumPrice", InSumRetailPrice + InSumPrice);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找礼品卡信息
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param projectId
|
||||||
|
* @param headIds
|
||||||
|
* @param materialIds
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findGiftByAll")
|
||||||
|
public BaseResponseInfo findGiftByAll(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("projectId") Integer projectId,
|
||||||
|
@RequestParam("headIds") String headIds,
|
||||||
|
@RequestParam("materialIds") String materialIds,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize);
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||||
|
map.put("total", total);
|
||||||
|
Integer pid = projectId;
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Double InSum = sumNumberGift("礼品充值", pid, diEx.getMaterialid(), "in");
|
||||||
|
Double OutSum = sumNumberGift("礼品销售", pid, diEx.getMaterialid(), "out");
|
||||||
|
item.put("Id", diEx.getId());
|
||||||
|
item.put("MaterialId", diEx.getMaterialid());
|
||||||
|
item.put("MaterialName", diEx.getMName());
|
||||||
|
item.put("MaterialModel", diEx.getMModel());
|
||||||
|
//扩展信息
|
||||||
|
String materialOther = getOtherInfo(mpArr, diEx);
|
||||||
|
item.put("MaterialOther", materialOther);
|
||||||
|
item.put("MaterialColor", diEx.getMColor());
|
||||||
|
item.put("MaterialUnit", diEx.getMaterialUnit());
|
||||||
|
item.put("thisSum", InSum - OutSum);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("rows", dataArray);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量合计
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param MId
|
||||||
|
* @param MonthTime
|
||||||
|
* @param isPrev
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
|
||||||
|
Double sumNumber = 0.0;
|
||||||
|
try {
|
||||||
|
Double sum = depotItemService.findByType(type, ProjectId, MId, MonthTime, isPrev);
|
||||||
|
if(sum != null) {
|
||||||
|
sumNumber = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sumNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格合计
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param MId
|
||||||
|
* @param MonthTime
|
||||||
|
* @param isPrev
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
|
||||||
|
Double sumPrice = 0.0;
|
||||||
|
try {
|
||||||
|
Double sum = depotItemService.findPriceByType(type, ProjectId, MId, MonthTime, isPrev);
|
||||||
|
if(sum != null) {
|
||||||
|
sumPrice = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sumPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime) {
|
||||||
|
Double sumNumber = 0.0;
|
||||||
|
String sumType = "Number";
|
||||||
|
try {
|
||||||
|
Double sum = depotItemService.buyOrSale(type, subType, MId, MonthTime, sumType);
|
||||||
|
if(sum != null) {
|
||||||
|
sumNumber = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sumNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double sumPriceBuyOrSale(String type, String subType, Long MId, String MonthTime) {
|
||||||
|
Double sumPrice = 0.0;
|
||||||
|
String sumType = "Price";
|
||||||
|
try {
|
||||||
|
Double sum = depotItemService.buyOrSale(type, subType, MId, MonthTime, sumType);
|
||||||
|
if(sum != null) {
|
||||||
|
sumPrice = sum;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sumPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量合计-礼品卡
|
||||||
|
* @param subType
|
||||||
|
* @param ProjectId
|
||||||
|
* @param MId
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double sumNumberGift(String subType, Integer ProjectId, Long MId, String type) {
|
||||||
|
Double sumNumber = 0.0;
|
||||||
|
String allNumber = "";
|
||||||
|
try {
|
||||||
|
if (ProjectId != null) {
|
||||||
|
Double sum = depotItemService.findGiftByType(subType, ProjectId, MId, type);
|
||||||
|
if(sum != null) {
|
||||||
|
sumNumber = sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sumNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
235
src/main/java/com/jsh/erp/controller/FunctionsController.java
Normal file
235
src/main/java/com/jsh/erp/controller/FunctionsController.java
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Functions;
|
||||||
|
import com.jsh.erp.service.functions.FunctionsService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/functions")
|
||||||
|
public class FunctionsController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(FunctionsController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FunctionsService functionsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
@PostMapping(value = "/findMenu")
|
||||||
|
public JSONArray findMenu(@RequestParam(value="pNumber") String pNumber,
|
||||||
|
@RequestParam(value="hasFunctions") String hasFunctions,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
try {
|
||||||
|
String fc = hasFunctions; //当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||||
|
List<Functions> dataList = functionsService.getRoleFunctions(pNumber);
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Functions functions : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", functions.getId());
|
||||||
|
List<Functions> dataList1 = functionsService.getRoleFunctions(functions.getNumber());
|
||||||
|
JSONArray dataArray1 = new JSONArray();
|
||||||
|
if (dataList1.size() != 0) {
|
||||||
|
item.put("text", functions.getName()); //是目录就没链接
|
||||||
|
for (Functions functions1 : dataList1) {
|
||||||
|
item.put("state", "open"); //如果不为空,节点展开
|
||||||
|
JSONObject item1 = new JSONObject();
|
||||||
|
List<Functions> dataList2 = functionsService.getRoleFunctions(functions1.getNumber());
|
||||||
|
if (fc.indexOf("[" + functions1.getId().toString() + "]") != -1 || dataList2.size() != 0) {
|
||||||
|
item1.put("id", functions1.getId());
|
||||||
|
JSONArray dataArray2 = new JSONArray();
|
||||||
|
if (dataList2.size() != 0) {
|
||||||
|
item1.put("text", functions1.getName());//是目录就没链接
|
||||||
|
for (Functions functions2 : dataList2) {
|
||||||
|
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||||
|
JSONObject item2 = new JSONObject();
|
||||||
|
List<Functions> dataList3 = functionsService.getRoleFunctions(functions2.getNumber());
|
||||||
|
if (fc.indexOf("[" + functions2.getId().toString() + "]") != -1 || dataList3.size() != 0) {
|
||||||
|
item2.put("id", functions2.getId());
|
||||||
|
JSONArray dataArray3 = new JSONArray();
|
||||||
|
if (dataList3.size() != 0) {
|
||||||
|
item2.put("text", functions2.getName());//是目录就没链接
|
||||||
|
for (Functions functions3 : dataList3) {
|
||||||
|
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||||
|
JSONObject item3 = new JSONObject();
|
||||||
|
item3.put("id", functions3.getId());
|
||||||
|
item3.put("text", functions3.getName());
|
||||||
|
//
|
||||||
|
dataArray3.add(item3);
|
||||||
|
item2.put("children", dataArray3);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是目录,有链接
|
||||||
|
item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getUrl() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是目录,有链接
|
||||||
|
item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getUrl() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
||||||
|
}
|
||||||
|
dataArray2.add(item2);
|
||||||
|
item1.put("children", dataArray2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是目录,有链接
|
||||||
|
item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getUrl() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是目录,有链接
|
||||||
|
item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getUrl() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
||||||
|
}
|
||||||
|
dataArray1.add(item1);
|
||||||
|
item.put("children", dataArray1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是目录,有链接
|
||||||
|
item.put("text", "<a onclick=\"NewTab('" + functions.getName() + "','" + functions.getUrl() + "','" + functions.getId() + "')\">" + functions.getName() + "</a>");
|
||||||
|
}
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
||||||
|
}
|
||||||
|
return dataArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色对应功能显示
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findRoleFunctions")
|
||||||
|
public JSONArray findRoleFunctions(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Functions> dataList = functionsService.findRoleFunctions("0");
|
||||||
|
//开始拼接json数据
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("id", 1);
|
||||||
|
outer.put("text", "功能列表");
|
||||||
|
outer.put("state", "open");
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Functions functions : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", functions.getId());
|
||||||
|
item.put("text", functions.getName());
|
||||||
|
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
|
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
|
||||||
|
JSONArray dataArray1 = new JSONArray();
|
||||||
|
if (null != dataList1) {
|
||||||
|
|
||||||
|
for (Functions functions1 : dataList1) {
|
||||||
|
item.put("state", "open"); //如果不为空,节点不展开
|
||||||
|
JSONObject item1 = new JSONObject();
|
||||||
|
item1.put("id", functions1.getId());
|
||||||
|
item1.put("text", functions1.getName());
|
||||||
|
|
||||||
|
//勾选判断2
|
||||||
|
//Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item1.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
|
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
|
||||||
|
JSONArray dataArray2 = new JSONArray();
|
||||||
|
if (null != dataList2) {
|
||||||
|
|
||||||
|
for (Functions functions2 : dataList2) {
|
||||||
|
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||||
|
JSONObject item2 = new JSONObject();
|
||||||
|
item2.put("id", functions2.getId());
|
||||||
|
item2.put("text", functions2.getName());
|
||||||
|
|
||||||
|
//勾选判断3
|
||||||
|
//Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item2.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
|
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
|
||||||
|
JSONArray dataArray3 = new JSONArray();
|
||||||
|
if (null != dataList3) {
|
||||||
|
|
||||||
|
for (Functions functions3 : dataList3) {
|
||||||
|
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||||
|
JSONObject item3 = new JSONObject();
|
||||||
|
item3.put("id", functions3.getId());
|
||||||
|
item3.put("text", functions3.getName());
|
||||||
|
|
||||||
|
//勾选判断4
|
||||||
|
//Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item3.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
|
dataArray3.add(item3);
|
||||||
|
item2.put("children", dataArray3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataArray2.add(item2);
|
||||||
|
item1.put("children", dataArray2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataArray1.add(item1);
|
||||||
|
item.put("children", dataArray1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
outer.put("children", dataArray);
|
||||||
|
arr.add(outer);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.InOutItem;
|
||||||
|
import com.jsh.erp.service.inOutItem.InOutItemService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/inOutItem")
|
||||||
|
public class InOutItemController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(InOutItemController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private InOutItemService inOutItemService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找收支项目信息-下拉框
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findBySelect")
|
||||||
|
public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) {
|
||||||
|
String res = null;
|
||||||
|
try {
|
||||||
|
List<InOutItem> dataList = inOutItemService.findBySelect(type);
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (InOutItem inOutItem : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Id", inOutItem.getId());
|
||||||
|
//收支项目名称
|
||||||
|
item.put("InOutItemName", inOutItem.getName());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = dataArray.toJSONString();
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||||
|
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/materialCategory")
|
||||||
|
public class MaterialCategoryController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(MaterialCategoryController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialCategoryService materialCategoryService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/getAllList")
|
||||||
|
public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<MaterialCategory> materialCategoryList = materialCategoryService.getAllList(parentId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = materialCategoryList;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id来查询商品名称
|
||||||
|
* @param id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findById")
|
||||||
|
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<MaterialCategory> dataList = materialCategoryService.findById(id);
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (MaterialCategory mc : dataList) {
|
||||||
|
outer.put("name", mc.getName());
|
||||||
|
outer.put("parentId", mc.getParentid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = dataList;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
177
src/main/java/com/jsh/erp/controller/MaterialController.java
Normal file
177
src/main/java/com/jsh/erp/controller/MaterialController.java
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Material;
|
||||||
|
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||||
|
import com.jsh.erp.service.material.MaterialService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/material")
|
||||||
|
public class MaterialController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(MaterialController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialService materialService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/checkIsExist")
|
||||||
|
public String checkIsExist(@RequestParam("materialId") Long id, @RequestParam("name") String name,
|
||||||
|
@RequestParam("model") String model, @RequestParam("color") String color,
|
||||||
|
@RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
|
||||||
|
@RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,
|
||||||
|
@RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
|
||||||
|
otherField1, otherField2, otherField3, unit, unitId);
|
||||||
|
if(exist > 0) {
|
||||||
|
objectMap.put("status", true);
|
||||||
|
} else {
|
||||||
|
objectMap.put("status", false);
|
||||||
|
}
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量设置状态-启用或者禁用
|
||||||
|
* @param enabled
|
||||||
|
* @param materialIDs
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/batchSetEnable")
|
||||||
|
public String batchSetEnable(@RequestParam("enabled") Boolean enabled,
|
||||||
|
@RequestParam("materialIDs") String materialIDs,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int res = materialService.batchSetEnable(enabled, materialIDs);
|
||||||
|
if(res > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id来查询商品名称
|
||||||
|
* @param id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findById")
|
||||||
|
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<MaterialVo4Unit> list = materialService.findById(id);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = list;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找商品信息-下拉框
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findBySelect")
|
||||||
|
public JSONArray findBySelect(@RequestParam("mpList") String mpList, HttpServletRequest request) {
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<MaterialVo4Unit> dataList = materialService.findBySelect();
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
//存放数据json数组
|
||||||
|
if (null != dataList) {
|
||||||
|
for (MaterialVo4Unit material : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("Id", material.getId());
|
||||||
|
String ratio; //比例
|
||||||
|
if (material.getUnitid() == null || material.getUnitid().equals("")) {
|
||||||
|
ratio = "";
|
||||||
|
} else {
|
||||||
|
ratio = material.getUnitName();
|
||||||
|
ratio = ratio.substring(ratio.indexOf("("));
|
||||||
|
}
|
||||||
|
//品名/型号/扩展信息/包装
|
||||||
|
String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
|
||||||
|
for (int i = 0; i < mpArr.length; i++) {
|
||||||
|
if (mpArr[i].equals("颜色")) {
|
||||||
|
MaterialName = MaterialName + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("规格")) {
|
||||||
|
MaterialName = MaterialName + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("制造商")) {
|
||||||
|
MaterialName = MaterialName + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义1")) {
|
||||||
|
MaterialName = MaterialName + ((material.getOtherfield1() == null || material.getOtherfield1().equals("")) ? "" : "(" + material.getOtherfield1() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义2")) {
|
||||||
|
MaterialName = MaterialName + ((material.getOtherfield2() == null || material.getOtherfield2().equals("")) ? "" : "(" + material.getOtherfield2() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义3")) {
|
||||||
|
MaterialName = MaterialName + ((material.getOtherfield3() == null || material.getOtherfield3().equals("")) ? "" : "(" + material.getOtherfield3() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MaterialName = MaterialName + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
|
||||||
|
item.put("MaterialName", MaterialName);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return dataArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找商品信息-统计排序
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findByOrder")
|
||||||
|
public BaseResponseInfo findByOrder(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<Material> dataList = materialService.findByOrder();
|
||||||
|
String mId = "";
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Material material : dataList) {
|
||||||
|
mId = mId + material.getId() + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mId != "") {
|
||||||
|
mId = mId.substring(0, mId.lastIndexOf(","));
|
||||||
|
}
|
||||||
|
map.put("mIds", mId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
121
src/main/java/com/jsh/erp/controller/PersonController.java
Normal file
121
src/main/java/com/jsh/erp/controller/PersonController.java
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Person;
|
||||||
|
import com.jsh.erp.service.person.PersonService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/person")
|
||||||
|
public class PersonController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(PersonController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PersonService personService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/getAllList")
|
||||||
|
public BaseResponseInfo getAllList(HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<Person> personList = personService.getPerson();
|
||||||
|
map.put("personList", personList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = personList;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据Id获取经手人信息
|
||||||
|
* @param personIDs
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getPersonByIds")
|
||||||
|
public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs, HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
String names = personService.getPersonByIds(personIDs);
|
||||||
|
map.put("names", names);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型获取经手人信息
|
||||||
|
* @param type
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getPersonByType")
|
||||||
|
public BaseResponseInfo getPersonByType(@RequestParam("type") String type, HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
List<Person> personList = personService.getPersonByType(type);
|
||||||
|
map.put("personList", personList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
|
||||||
|
* @param typeNum
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/getPersonByNumType")
|
||||||
|
public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, HttpServletRequest request) {
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
try {
|
||||||
|
String type = "";
|
||||||
|
if (typeNum.equals("1")) {
|
||||||
|
type = "业务员";
|
||||||
|
} else if (typeNum.equals("2")) {
|
||||||
|
type = "仓管员";
|
||||||
|
} else if (typeNum.equals("3")) {
|
||||||
|
type = "财务员";
|
||||||
|
}
|
||||||
|
List<Person> personList = personService.getPersonByType(type);
|
||||||
|
if (null != personList) {
|
||||||
|
for (Person person : personList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", person.getId());
|
||||||
|
item.put("name", person.getName());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return dataArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
124
src/main/java/com/jsh/erp/controller/ResourceController.java
Normal file
124
src/main/java/com/jsh/erp/controller/ResourceController.java
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.service.CommonQueryManager;
|
||||||
|
import com.jsh.erp.utils.*;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* by jishenghua 2018-9-12 23:58:10
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class ResourceController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(ResourceController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommonQueryManager configResourceManager;
|
||||||
|
|
||||||
|
@GetMapping(value = "/test/heart")
|
||||||
|
public JSONObject exitHeart(HttpServletRequest request) {
|
||||||
|
return JsonUtils.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/{apiName}/list")
|
||||||
|
public String getList(@PathVariable("apiName") String apiName,
|
||||||
|
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||||
|
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||||
|
@RequestParam(value = Constants.SEARCH, required = false) String search,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||||
|
parameterMap.put(Constants.SEARCH, search);
|
||||||
|
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
if (pageSize != null && pageSize <= 0) {
|
||||||
|
pageSize = 10;
|
||||||
|
}
|
||||||
|
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||||
|
if (StringUtil.isNotEmpty(offset)) {
|
||||||
|
parameterMap.put(Constants.OFFSET, offset);
|
||||||
|
}
|
||||||
|
List<?> list = configResourceManager.select(apiName, parameterMap);
|
||||||
|
objectMap.put("page", queryInfo);
|
||||||
|
if (list == null) {
|
||||||
|
queryInfo.setRows(new ArrayList<Object>());
|
||||||
|
queryInfo.setTotal(0);
|
||||||
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
queryInfo.setRows(list);
|
||||||
|
queryInfo.setTotal(configResourceManager.counts(apiName, parameterMap));
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/{apiName}/add", produces = {"application/javascript", "application/json"})
|
||||||
|
public String addResource(@PathVariable("apiName") String apiName,
|
||||||
|
@RequestParam("info") String beanJson, HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int insert = configResourceManager.insert(apiName, beanJson, request);
|
||||||
|
if(insert > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"})
|
||||||
|
public String updateResource(@PathVariable("apiName") String apiName,
|
||||||
|
@RequestParam("info") String beanJson,
|
||||||
|
@RequestParam("id") Long id, HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int update = configResourceManager.update(apiName, beanJson, id);
|
||||||
|
if(update > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/{apiName}/{id}/delete", produces = {"application/javascript", "application/json"})
|
||||||
|
public String deleteResource(@PathVariable("apiName") String apiName,
|
||||||
|
@PathVariable Long id, HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int delete = configResourceManager.delete(apiName, id);
|
||||||
|
if(delete > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/{apiName}/batchDelete", produces = {"application/javascript", "application/json"})
|
||||||
|
public String batchDeleteResource(@PathVariable("apiName") String apiName,
|
||||||
|
@RequestParam("ids") String ids, HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int delete = configResourceManager.batchDelete(apiName, ids);
|
||||||
|
if(delete > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/{apiName}/checkIsNameExist")
|
||||||
|
public String checkIsNameExist(@PathVariable("apiName") String apiName,
|
||||||
|
@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int exist = configResourceManager.checkIsNameExist(apiName, id, name);
|
||||||
|
if(exist > 0) {
|
||||||
|
objectMap.put("status", true);
|
||||||
|
} else {
|
||||||
|
objectMap.put("status", false);
|
||||||
|
}
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
71
src/main/java/com/jsh/erp/controller/RoleController.java
Normal file
71
src/main/java/com/jsh/erp/controller/RoleController.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Role;
|
||||||
|
import com.jsh.erp.service.role.RoleService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/role")
|
||||||
|
public class RoleController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(RoleController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色对应应用显示
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findUserRole")
|
||||||
|
public JSONArray findUserRole(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Role> dataList = roleService.findUserRole();
|
||||||
|
//开始拼接json数据
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("id", 1);
|
||||||
|
outer.put("text", "角色列表");
|
||||||
|
outer.put("state", "open");
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Role role : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", role.getId());
|
||||||
|
item.put("text", role.getName());
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + role.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("children", dataArray);
|
||||||
|
arr.add(outer);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
192
src/main/java/com/jsh/erp/controller/SupplierController.java
Normal file
192
src/main/java/com/jsh/erp/controller/SupplierController.java
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.Supplier;
|
||||||
|
import com.jsh.erp.service.supplier.SupplierService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/supplier")
|
||||||
|
public class SupplierController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(SupplierController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SupplierService supplierService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新供应商-只更新预付款,其余用原来的值
|
||||||
|
* @param supplierId
|
||||||
|
* @param advanceIn
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/updateAdvanceIn")
|
||||||
|
public String updateAdvanceIn(@RequestParam("supplierId") Long supplierId,
|
||||||
|
@RequestParam("advanceIn") Double advanceIn,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int res = supplierService.updateAdvanceIn(supplierId, advanceIn);
|
||||||
|
if(res > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找客户信息-下拉框
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findBySelect_cus")
|
||||||
|
public JSONArray findBySelectCus(HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Supplier> supplierList = supplierService.findBySelectCus();
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != supplierList) {
|
||||||
|
for (Supplier supplier : supplierList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(null, null, "[" + supplier.getId().toString() + "]");
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("id", supplier.getId());
|
||||||
|
item.put("supplier", supplier.getSupplier()); //客户名称
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arr = dataArray;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找供应商信息-下拉框
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findBySelect_sup")
|
||||||
|
public JSONArray findBySelectSup(HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Supplier> supplierList = supplierService.findBySelectSup();
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != supplierList) {
|
||||||
|
for (Supplier supplier : supplierList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", supplier.getId());
|
||||||
|
//供应商名称
|
||||||
|
item.put("supplier", supplier.getSupplier());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arr = dataArray;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找会员信息-下拉框
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/findBySelect_retail")
|
||||||
|
public JSONArray findBySelectRetail(HttpServletRequest request) {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<Supplier> supplierList = supplierService.findBySelectRetail();
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if (null != supplierList) {
|
||||||
|
for (Supplier supplier : supplierList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", supplier.getId());
|
||||||
|
//客户名称
|
||||||
|
item.put("supplier", supplier.getSupplier());
|
||||||
|
item.put("advanceIn", supplier.getAdvancein()); //预付款金额
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arr = dataArray;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查找信息
|
||||||
|
* @param supplierId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/findById")
|
||||||
|
public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
List<Supplier> dataList = supplierService.findById(supplierId);
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Supplier supplier : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", supplier.getId());
|
||||||
|
//名称
|
||||||
|
item.put("supplier", supplier.getSupplier());
|
||||||
|
item.put("type", supplier.getType());
|
||||||
|
item.put("contacts", supplier.getContacts());
|
||||||
|
item.put("phonenum", supplier.getPhonenum());
|
||||||
|
item.put("email", supplier.getEmail());
|
||||||
|
item.put("AdvanceIn", supplier.getAdvancein());
|
||||||
|
item.put("BeginNeedGet", supplier.getBeginneedget());
|
||||||
|
item.put("BeginNeedPay", supplier.getBeginneedpay());
|
||||||
|
item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
|
||||||
|
item.put("description", supplier.getDescription());
|
||||||
|
item.put("fax", supplier.getFax());
|
||||||
|
item.put("telephone", supplier.getTelephone());
|
||||||
|
item.put("address", supplier.getAddress());
|
||||||
|
item.put("taxNum", supplier.getTaxnum());
|
||||||
|
item.put("bankName", supplier.getBankname());
|
||||||
|
item.put("accountNumber", supplier.getAccountnumber());
|
||||||
|
item.put("taxRate", supplier.getTaxrate());
|
||||||
|
item.put("enabled", supplier.getEnabled());
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = dataArray;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.datasource.entities.UserBusiness;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/userBusiness")
|
||||||
|
public class UserBusinessController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(UserBusinessController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/getBasicData")
|
||||||
|
public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId,
|
||||||
|
@RequestParam(value = "Type") String type,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
List<UserBusiness> list = userBusinessService.getBasicData(keyId, type);
|
||||||
|
Map<String, List> mapData = new HashMap<String, List>();
|
||||||
|
mapData.put("userBusinessList", list);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = mapData;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "查询权限失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/checkIsValueExist")
|
||||||
|
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
|
||||||
|
@RequestParam(value ="keyId", required = false) String keyId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
Long id = userBusinessService.checkIsValueExist(type, keyId);
|
||||||
|
if(id != null) {
|
||||||
|
objectMap.put("id", id);
|
||||||
|
} else {
|
||||||
|
objectMap.put("id", null);
|
||||||
|
}
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user