增加系统配置的功能

This commit is contained in:
季圣华
2017-10-05 16:19:41 +08:00
parent ea7e53fbd9
commit e4e957ef20
25 changed files with 4863 additions and 101 deletions

View File

@@ -0,0 +1,143 @@
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;
}
}

View File

@@ -0,0 +1,17 @@
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;
}
}

View File

@@ -0,0 +1,9 @@
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.SystemConfig;
public interface SystemConfigIDAO extends BaseIDAO<SystemConfig>
{
}

View File

@@ -0,0 +1,51 @@
package com.jsh.model.po;
@SuppressWarnings("serial")
public class SystemConfig implements java.io.Serializable
{
private Long id;
private String type;
private String name;
private String value;
private String description;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@@ -0,0 +1,77 @@
package com.jsh.model.vo.basic;
import java.io.Serializable;
@SuppressWarnings("serial")
public class SystemConfigModel implements Serializable
{
private SystemConfigShowModel showModel = new SystemConfigShowModel();
/**======开始接受页面参数=================**/
private Long id = 0l;
private String type = "";
private String name = "";
private String value = "";
private String description = "";
/**
* 用户IP用户记录操作日志
*/
private String clientIp = "";
public SystemConfigShowModel getShowModel() {
return showModel;
}
public void setShowModel(SystemConfigShowModel showModel) {
this.showModel = showModel;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
}

View File

@@ -0,0 +1,22 @@
package com.jsh.model.vo.basic;
import java.io.Serializable;
@SuppressWarnings("serial")
public class SystemConfigShowModel implements Serializable
{
/**
* 提示信息
*/
private String msgTip = "";
public String getMsgTip()
{
return msgTip;
}
public void setMsgTip(String msgTip)
{
this.msgTip = msgTip;
}
}

View File

@@ -0,0 +1,9 @@
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.model.po.SystemConfig;
public interface SystemConfigIService extends BaseIService<SystemConfig>
{
}

View File

@@ -0,0 +1,23 @@
package com.jsh.service.basic;
import com.jsh.base.BaseService;
import com.jsh.dao.basic.SystemConfigIDAO;
import com.jsh.model.po.SystemConfig;
public class SystemConfigService extends BaseService<SystemConfig> implements SystemConfigIService
{
@SuppressWarnings("unused")
private SystemConfigIDAO systemConfigDao;
public void setSystemConfigDao(SystemConfigIDAO systemConfigDao)
{
this.systemConfigDao = systemConfigDao;
}
@Override
protected Class<SystemConfig> getEntityClass()
{
return SystemConfig.class;
}
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.jsh.model.po.SystemConfig" table="jsh_systemconfig">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<property generated="never" lazy="false" name="type" type="java.lang.String">
<column length="50" name="type">
<comment>类型</comment>
</column>
</property>
<property generated="never" lazy="false" name="name" type="java.lang.String">
<column length="100" name="name">
<comment>名称</comment>
</column>
</property>
<property generated="never" lazy="false" name="value" type="java.lang.String">
<column length="200" name="value">
<comment></comment>
</column>
</property>
<property generated="never" lazy="false" name="description" type="java.lang.String">
<column length="100" name="description">
<comment>描述</comment>
</column>
</property>
</class>
</hibernate-mapping>

View File

@@ -43,5 +43,6 @@
<mapping resource="hibernate/InOutItem.hbm.xml" />
<mapping resource="hibernate/AccountHead.hbm.xml" />
<mapping resource="hibernate/AccountItem.hbm.xml" />
<mapping resource="hibernate/SystemConfig.hbm.xml" />
</session-factory>
</hibernate-configuration>

View File

@@ -106,7 +106,6 @@
<bean id="supplierService" class="com.jsh.service.basic.SupplierService">
<property name="baseDao" ref="baseDao"/>
<property name="supplierDao" ref="supplierDao"/>
<property name="userBusinessDao" ref="userBusinessDao"/>
</bean>
<!-- spring整合struts2需要默认为request或者 prototype不能是单例 -->
<bean id="supplierAction" class="com.jsh.action.basic.SupplierAction" scope="prototype">
@@ -115,6 +114,17 @@
<property name="logService" ref="logService"/>
</bean>
<!--供应商配置结束 -->
<!--系统配置开始 -->
<bean id="systemConfigService" class="com.jsh.service.basic.SystemConfigService">
<property name="baseDao" ref="baseDao"/>
</bean>
<!-- spring整合struts2需要默认为request或者 prototype不能是单例 -->
<bean id="systemConfigAction" class="com.jsh.action.basic.SystemConfigAction" scope="prototype">
<property name="systemConfigService" ref="systemConfigService"/>
<property name="logService" ref="logService"/>
</bean>
<!--系统配置结束 -->
<!--分类配置开始 -->
<bean id="categoryService" class="com.jsh.service.basic.CategoryService">
@@ -255,7 +265,6 @@
<!--经手人配置开始 -->
<bean id="personService" class="com.jsh.service.materials.PersonService">
<property name="baseDao" ref="baseDao"/>
<property name="personDao" ref="personDao"/>
</bean>
<!-- spring整合struts2需要默认为request或者 prototype不能是单例 -->
<bean id="personAction" class="com.jsh.action.materials.PersonAction" scope="prototype">
@@ -363,4 +372,5 @@
<property name="logService" ref="logService"/>
</bean>
<!--账户明细配置结束 -->
</beans>

View File

@@ -54,4 +54,6 @@
<bean id="accountHeadDao" parent="daoTemplate" class="com.jsh.dao.materials.AccountHeadDAO"/>
<!-- 配置accountItemDao组件 -->
<bean id="accountItemDao" parent="daoTemplate" class="com.jsh.dao.materials.AccountItemDAO"/>
<!-- 配置systemConfigDAO组件 -->
<bean id="systemConfigDAO" parent="daoTemplate" class="com.jsh.dao.basic.SystemConfigDAO"/>
</beans>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="systemConfig" namespace="/systemConfig" extends="json-default">
<action name="*" class="systemConfigAction" method="{1}">
<result type="json"/>
</action>
</package>
</struts>

View File

@@ -23,3 +23,12 @@
padding-left: 20px;
}
.system-config {
padding: 5px;
font-size: 13px;
}
.system-config td{
padding: 10px 0px 10px 10px;
}

View File

@@ -1,12 +1,37 @@
// strPrintName 打印任务名
// printDatagrid 要打印的datagrid
function CreateFormPage(strPrintName, printDatagrid) {
function CreateFormPage(strPrintName, printDatagrid, path) {
var beginDate= $("#searchBeginTime").val();
var endDate= $("#searchEndTime").val();
var getMonth= $("#searchMonth").val();
var listTitle = $("#tablePanel").prev().text();
listTitle = listTitle.replace("列表","");
var tableString = '<div class="div-title">上海某某某某有限责任公司' + listTitle + '\n</div>';
var companyName = "";
//加载公司信息
$.ajax({
type:"get",
url: path + "/systemConfig/findBy.action",
dataType: "json",
async: false,
success: function (res) {
if(res && res.rows) {
var array = res.rows;
for(var i=0; i<array.length; i++){
var name = array[i].name;
if(name === "company_name") {
companyName = array[i].value;
}
}
}
},
//此处添加错误处理
error:function() {
$.messager.alert('查询失败','查询系统配置信息异常,请稍后再试!','error');
return;
}
});
var tableString = '<div class="div-title">' + companyName + "-" + listTitle + '\n</div>';
if(beginDate && endDate) {
tableString+='\n<div class="div-time">日期:' + beginDate + ' 至 ' + endDate + ' \n</div>';
}

View File

@@ -0,0 +1,141 @@
<%@page import="com.jsh.util.Tools"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String clientIp = Tools.getLocalIp(request);
%>
<!DOCTYPE html>
<html>
<head>
<title>系统配置</title>
<meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="<%=path %>/js/colorbox/colorboxSet.js"></script>
<link href="<%=path %>/js/colorbox/colorbox.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
<script type="text/javascript" src="<%=path %>/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=path %>/js/common/common.js"></script>
<script>
$(function(){
//加载信息
function loadInfo() {
$.ajax({
type:"get",
url: "<%=path %>/systemConfig/findBy.action",
dataType: "json",
success: function (res) {
if(res && res.rows) {
var array = res.rows;
for(var i=0; i<array.length; i++){
var name = array[i].name;
$("." + name).val(array[i].value).attr("data-value",array[i].value).attr("data-id",array[i].id);
}
}
},
//此处添加错误处理
error:function() {
$.messager.alert('查询失败','查询系统配置信息异常,请稍后再试!','error');
return;
}
});
}
loadInfo(); //加载信息
$("#saveSystemConfig").off("click").on("click",function(){
var status = false;
$("#searchTable input").each(function(){
var thisId = $(this).attr("data-id");
var thisValue = $(this).attr("data-value");
if($(this).val() != thisValue){
//更新修改过的单行信息
$.ajax({
type: "post",
url: "<%=path %>/systemConfig/update.action",
dataType: "json",
data: {
id: thisId,
value: $(this).val()
},
success: function (res) {
if(res) {
status = true;
}
},
//此处添加错误处理
error: function () {
$.messager.alert('保存失败', '保存系统配置信息失败,请稍后再试!', 'error');
return;
}
});
}
});
setTimeout(function(){
if(status) {
$.messager.alert('保存成功','保存系统配置信息成功!','info');
loadInfo(); //加载信息
}
else {
$.messager.alert('提示','信息未修改,无需保存!','info');
}
},1000);
});
})
</script>
</head>
<body>
<div class="system-config">
<table id="searchTable">
<tr>
<td>公司名称:</td>
<td>
<input type="text" class="company_name easyui-validatebox" data-options="required:true,validType:'length[2,30]'" style="width:250px;"/>
</td>
</tr>
<tr>
<td>联系人:</td>
<td>
<input type="text" class="company_contacts" style="width:250px;"/>
</td>
</tr>
<tr>
<td>公司地址:</td>
<td>
<input type="text" class="company_address" style="width:250px;"/>
</td>
</tr>
<tr>
<td>公司电话:</td>
<td>
<input type="text" class="company_tel" style="width:250px;"/>
</td>
</tr>
<tr>
<td>公司传真:</td>
<td>
<input type="text" class="company_fax" style="width:250px;"/>
</td>
</tr>
<tr>
<td>公司邮编:</td>
<td>
<input type="text" class="company_post_code" style="width:250px;"/>
</td>
</tr>
<tr>
<td></td>
<td>
<a href="javascript:void(0)" id="saveSystemConfig" class="easyui-linkbutton" iconCls="icon-ok">保存信息</a>
</td>
</tr>
</table>
</div>
</body>
</html>

View File

@@ -187,7 +187,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -232,7 +232,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -311,7 +311,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -305,7 +305,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -409,7 +409,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -310,7 +310,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -305,7 +305,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>

View File

@@ -234,7 +234,8 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click",function(){
CreateFormPage('打印报表', $('#tableData'));
var path = "<%=path %>";
CreateFormPage('打印报表', $('#tableData'), path);
});
}
</script>