1. 程式人生 > >SSH:2

SSH:2

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

	<constant name="struts.devMode" value="true"></constant>
	
	<include file="global.xml"></include>
	<include file="hc.xml"></include>
</struts>

 開發者

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

	<package name="global" namespace="/" extends="struts-default">
	

		<!-- <global-results>
			<result name="error">/error.jsp</result>
		</global-results>

		<global-exception-mappings>
			<exception-mapping result="error"
				exception="java.lang.Exception">
			</exception-mapping>
		</global-exception-mappings> -->

	</package>

</struts>

global 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

	<package name="hc" namespace="/" extends="global">

		<interceptors>
			<interceptor name="empIntercept"
				class="com.cn.action.LoginIntercept"></interceptor>
			<interceptor-stack name="loginInter">
				<interceptor-ref name="empIntercept"></interceptor-ref>
				<interceptor-ref name="defaultStack"></interceptor-ref>
			</interceptor-stack>
		</interceptors>

		<global-results>
			<result name="loginEmp">/login.jsp</result>
		</global-results>


		<action name="PermAction_*" class="PermAction" method="{1}">
			<result name="syaobjPerm">../page/syaobjPerm.jsp</result>
			<result name="syAllobj" type="redirect">/page/syAllobj.jsp</result>
			<result name="menupowerset">../page/sys_menupower_set.jsp</result>
		</action>

		<action name="MenuAction_*" class="MenuAction" method="{1}">
		<result name="syAllobj">../page/syAllobj.jsp</result>
			<result name="MenupowerObj">../page/syMenupowerObj.jsp</result>
			<result name="menupower" type="redirect">/page/sys_menupower.jsp</result>
			<interceptor-ref name="loginInter"></interceptor-ref>
		</action>

		<action name="AreaSetAction_*" class="AreaSetAction"
			method="{1}">
			<result name="areapowerset">../page/sys_areapower_set.jsp</result>
			<result name="areapower" type="redirect">/page/sys_areapower.jsp</result>
		</action>

		<action name="PowerAction_*" class="PowerAction" method="{1}">
			<result name="sysarea">../page/sys_area.jsp</result>
			<result name="smeterType">../page/sys_meterType.jsp</result>
			<result name="sysarea">../page/sys_area.jsp</result>
			<result name="syAllobj" type="redirect">/page/syAllobj.jsp</result>
		</action>

		<action name="PayAction_*" class="PayAction" method="{1}">
			<result name="paybatch">../page/pay_batch.jsp</result>
			<result name="paywindow">../page/pay_window.jsp</result>
			<result name="userSearch" type="redirect">page/user_search.jsp</result>
			<result name="reportPay">../page/pay_reportPay.jsp</result>
			<result name="reportBalance">../page/pay_reportBalance.jsp</result>
			<result name="reportDebts">../page/pay_reportDebts.jsp</result>
		</action>

		<action name="UsersAction_*" class="UsersAction" method="{1}">
			<result name="userLike">../page/userLike.jsp</result>
			<result name="Shortcut">../page/user_reportShortcut.jsp</result>
			<result name="searchlike">../page/user_search.jsp</result>

			<result name="userdocnum">../page/user_docNum.jsp</result>
		</action>


		<action name="EmpAction_*" class="EmpAction" method="{1}">
			<result name="INPUT" type="redirect">login.jsp</result>
			<result name="SUCCESS" type="redirect">workspace.jsp</result>
			<result name="sysemp">../page/sys_emp.jsp</result>
			<result name="sempadd">../page/sys_emp_add.jsp</result>

			<result name="menuemp">../page/sys_menupower.jsp</result>

			<result name="sysempal">../page/sys_areapower.jsp</result>
			<result name="sysemprt" type="redirect">page/sys_emp.jsp</result>
			<result name="sysdept">../page/sys_dept.jsp</result>
			<result name="sysdeptr" type="redirect">page/sys_dept.jsp</result>
		</action>


		<action name="DeleteUserAction" class="UserMeterAction"
			method="deleteUser">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="GetUmoneyAction" class="UserMeterAction"
			method="getUserMoney">
			<result>../page/user_delete.jsp</result>
		</action>

		<action name="UpdateUforAction" class="UserMeterAction"
			method="updateUforma">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="GetUformuAction" class="UserMeterAction"
			method="getUserformu">
			<result>../page/user_changeFormula.jsp</result>
		</action>

		<action name="UpdateUmetAction" class="UserMeterAction"
			method="updateUmeter">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="UpdateUnameAction" class="SearchUserAction"
			method="updateUserName">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="GetUnameAction" class="SearchUserAction"
			method="getUpdateUname">
			<result>../page/user_changeName.jsp</result>
		</action>

		<action name="UpdateUbankAction" class="SearchUserAction"
			method="updateUserBank">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="GetUbankAction" class="SearchUserAction"
			method="getUpdateUbank">
			<result>../page/user_changeBank.jsp</result>
		</action>

		<action name="SaveUserAction" class="SaveUserAction"
			method="saveUser">
			<result type="redirect">page/user_search.jsp</result>
		</action>

		<action name="SearchUserAction" class="SearchUserAction"
			method="searchUser">
			<result>../page/user_search.jsp</result>
		</action>

		<action name="GetUmeterAction" class="UserMeterAction"
			method="getUserMeter">
			<result>../page/user_changeMeter.jsp</result>
		</action>

	</package>

	<package name="NOtFind" extends="global">
		<action name="*">
			<result type="redirect">/error.jsp</result>
		</action>
	</package>

</struts>

struts

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
		"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

		<property name="show_sql">true</property>
		<property name="format_sql">true</property>


		<property name="cache.use_second_level_cache">true</property>
		<property name="cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
		<property name="cache.use_query_cache">true</property>
		<class-cache usage="read-write"
			class="com.cn.entity.Sy_Metertype" />
	</session-factory>
</hibernate-configuration>

hibernate

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

log4j.rootLogger=debug,stdout

log4j

package com.cn.biz;

import java.util.List;
import java.util.Set;

import com.cn.entity.Py_Bill;
import com.cn.entity.Py_Pay;
import com.cn.entity.Us_user;

/**
 * pyBiz ½Ó¿Ú
 * 
 * @author admin
 *
 */
public interface PyBiz {

	public List<Us_user> UsershaveMoney(Set<String> uidList); // ÅúÁ¿»ñÈ¡Óà¶î

	public List<Py_Bill> UserNPMoney(String needPMoney);// Ç··Ñ

	public List<Us_user> findUneedMoney(Double needPMoney);// Ðè½É·ÑÇé¿ö

	public List<Py_Pay> findGPays(Integer empid);// ËÑ ½É·Ñ ÊÕ·ÑÇé¿ö

	public List<Py_Pay> searchPay(String like);// ¾«È·ËÑ ½É·Ñ

	public void savePypay(Py_Pay pay);// ½É·Ñ¼Ç¼

	public void updateUpay(Us_user user);// ½É·Ñ

	public Us_user UserhaveMoney(String like); // »ñÈ¡Óà¶î
}

biz、 impl

package com.cn.dao;

import java.util.List;
import java.util.Set;

import com.cn.entity.Py_Bill;
import com.cn.entity.Py_Pay;
import com.cn.entity.Us_user;

public interface PyDao {
	public List<Us_user> UsershaveMoney(Set<String> uidList); // ÅúÁ¿»ñÈ¡Óà¶î

	public List<Py_Bill> UserNPMoney(String needPMoney);// Ç··Ñ

	public List<Us_user> findUneedMoney(Double needPMoney);// Ðè½É·ÑÇé¿ö

	public List<Py_Pay> findGPays(Integer empid);// ËÑ ½É·Ñ ÊÕ·ÑÇé¿ö

	public List<Py_Pay> searchPay(String like);// ¾«È·ËÑ ½É·Ñ

	public void savePypay(Py_Pay pay);// ½É·Ñ¼Ç¼

	public void updateUpay(Us_user user);// ½É·Ñ

	public Us_user UserhaveMoney(String like); // »ñÈ¡Óà¶î
}

dao、implement、

package com.cn.entity;

public class Py_Pay {

	private Integer payNo;// ½»·Ñµ¥ºÅ£¨¹æÔò£ºJF0100000987-201401-02£¬¹²22λ¡£JFÓû§±àÂë-ÄêÔÂ-°´ÔÂÁ÷Ë®

	private Integer empID;// ÊÕ·ÑÔ±

	private String invoice;// ·¢Æ±ºÅÂë

	private String payDate;// ½»·ÑÈÕÆÚ

	private Double payMoney;// ½»·Ñ½ð¶î

	private String payType;// ½»·Ñ·½Ê½£¨1×øÊÕ ×ßÊÕ ÒøÐдú¿Û£©

	private Double useMoney;// ÒÑÓýð¶î

	private String userNo;// Óû§±àÂë

	public Py_Pay() {
		super();
		// TODO Auto-generated constructor stub
	}
}

User物件

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2018-9-14 18:46:21 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
    <class name="com.cn.entity.Py_Pay" table="PY_PAY">
        <id name="payNo" type="java.lang.Integer">
            <column name="PAYNO" />
            <generator class="native" />
        </id>
        
        <property name="empID" type="java.lang.Integer">
            <column name="EMPID" />
        </property>
        

        <property name="invoice" type="java.lang.String">
            <column name="INVOICE" />
        </property>
        <property name="payDate" type="java.lang.String">
            <column name="PAYDATE" />
        </property>
        <property name="payMoney" type="java.lang.Double">
            <column name="PAYMONEY" />
        </property>
        <property name="payType" type="java.lang.String">
            <column name="PAYTYPE" />
        </property>
        <property name="useMoney" type="java.lang.Double">
            <column name="USEMONEY" />
        </property>
        <property name="userNo" type="java.lang.String">
            <column name="USERNO" />
        </property>
    </class>
</hibernate-mapping>

物件配置

package com.cn.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.cn.biz.PyBiz;
import com.cn.entity.Py_Bill;
import com.cn.entity.Py_Pay;
import com.cn.entity.Sy_Emp;
import com.cn.entity.Us_user;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class PayAction extends ActionSupport {

	private List<Py_Pay> pays;
	private Sy_Emp emp;
	private Double UpMoney;
	private Us_user usUsers;
	private String like;
	private PyBiz pyBiz;
	private Py_Bill bill;
	private List<Py_Bill> billList;
	private List<Us_user> userList = new ArrayList<Us_user>();

	public String UsNeedPMoney() {// Ö¸¶¨Ç··Ñ ²éuser
		billList = pyBiz.UserNPMoney(bill.getCreateDate());
		return "reportDebts";
	}

	public String findUnMoney() {// Ö¸¶¨Ô¤´æ·Ñ ²éuser
		userList = pyBiz.findUneedMoney(UpMoney);
		return "reportBalance";
	}

	public String findGPays() {// »ñÈ¡ ÊÕ·ÑÇé¿ö Óû§½É·Ñ

		pays = pyBiz.findGPays(emp.getEmpNo()); // ½É·Ñ¼Ç¼

		return "reportPay";
	}

	@SuppressWarnings("unchecked")
	public String getPusers() {// ÐèÅúÁ¿½É·ÑµÄ
		HttpSession session = ServletActionContext.getRequest().getSession();
		Set<String> uids = (Set<String>) session.getAttribute("uidss");// µÃµ½sessionÖÐ
		if (uids == null) {
			uids = new HashSet<String>();
		}
		uids.add(like);

		userList = pyBiz.UsershaveMoney(uids);// in()
		Set<String> uidss = new HashSet<String>();
		for (Us_user user : userList) {
			uidss.add(user.getUserNo());
		}
		session.setAttribute("uidss", uidss);// ±£´æuserid
		return "paybatch";
	}

	public String UpayMoney() {// Óû§½É·Ñ
		Double sumuMoney = usUsers.getUserMoney();//Ô­±¾·ÑÓÃ
		usUsers.setUserMoney(sumuMoney + UpMoney);//+ ½»Ç®
		pyBiz.updateUpay(usUsers);

		Py_Pay pay = new Py_Pay();// ½É·Ñµ¥
		pay.setUserNo(usUsers.getUserNo());
		Integer empID = (Integer) ServletActionContext.getRequest().getSession().getAttribute("loginEmp");
		pay.setEmpID(empID);
		pay.setPayType(1 + "");
		pay.setPayMoney(UpMoney);

		pay.setPayDate(new SimpleDateFormat("yyyyMMddHHmm").format(new Date()));
		pay.setInvoice("P" + usUsers.getUserNo() + new SimpleDateFormat("yyyyMM").format(new Date()));
		Double useMoney = 0.0;//ÒÑÓÃʹÓõÄ
		if (sumuMoney < 0.0) {//Ô­À´µÄ½ð¶î
			Double testmoney = UpMoney + sumuMoney;//½É·Ñºó
			if (testmoney >= 0.0) {
				useMoney = -sumuMoney;//ÌǷ·Ñ
			} else if (testmoney < 0) {
				useMoney = UpMoney;
			}
		}
		pay.setUseMoney(useMoney);
		pyBiz.savePypay(pay);

		return "userSearch";
	}

	public String GUpMoney() {// »ñÈ¡Óû§Óà¶î
		usUsers = pyBiz.UserhaveMoney(like);

		pays = pyBiz.searchPay(like); // ½É·Ñ¼Ç¼

		return "paywindow";
	}

	public PyBiz getPyBiz() {
		return pyBiz;
	}

	public void setPyBiz(PyBiz pyBiz) {
		this.pyBiz = pyBiz;
	}

	public String getLike() {
		return like;
	}

	public void setLike(String like) {
		this.like = like;
	}

	public Double getUpMoney() {
		return UpMoney;
	}

	public void setUpMoney(Double upMoney) {
		UpMoney = upMoney;
	}

	public Us_user getUsUsers() {
		return usUsers;
	}

	public void setUsUsers(Us_user usUsers) {
		this.usUsers = usUsers;
	}

	public List<Us_user> getUserList() {
		return userList;
	}

	public void setUserList(List<Us_user> userList) {
		this.userList = userList;
	}

	public List<Py_Pay> getPays() {
		return pays;
	}

	public void setPays(List<Py_Pay> pays) {
		this.pays = pays;
	}

	public Sy_Emp getEmp() {
		return emp;
	}

	public void setEmp(Sy_Emp emp) {
		this.emp = emp;
	}

	public List<Py_Bill> getBillList() {
		return billList;
	}

	public void setBillList(List<Py_Bill> billList) {
		this.billList = billList;
	}

	public Py_Bill getBill() {
		return bill;
	}

	public void setBill(Py_Bill bill) {
		this.bill = bill;
	}

}