楼上连什么是小程序(applet)都不懂就把代码贴上来了。。。。。。
500多行,不过是我一个工程里的文件,很多类你没有,先凑合吧。
package com.shuanghu.action;
/**
* 采购
*/
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.shuanghu.domain.StockParticular;
import com.shuanghu.domain.Product;
import com.shuanghu.domain.ProductType;
import com.shuanghu.domain.Stock;
import com.shuanghu.domain.User;
import com.shuanghu.domain.Branch;
import com.shuanghu.service.impl.BranchServiceImpl;
import com.shuanghu.service.impl.ProductManageServiceImpl;
import com.shuanghu.service.impl.StockManageServiceImpl;
import com.shuanghu.utils.CurrentDate;
public class StockAction {
private ProductManageServiceImpl productService;
private StockManageServiceImpl stockService;
private BranchServiceImpl branchService;
//createStockParticular
private long attributeStockId; //in
private String number; //in
private String unitPrice; //in
private long productId; //in
private String needDate;//in
//createStock
private List
private String passivityBranchId;
private String transportPrice="0";
private String remark="";
//session中订单项修改id
private long tempId;
private StockParticular stockOption;
private List
private List
private String getBranchName; //[显示使用]
private String message;
//ajax选择产品使用
private String firstIndexId;
//新建订单 采购详细列表 使用
private List
private Stock stock;
private long stockId;
//所有采购订单列表
private List
private int sumPage;
private int pageSize=15;
private int nowPage;
private int beforePage;
private int backPage;
private List
public long getStockId() {
return stockId;
}
public void setStockId(long stockId) {
this.stockId = stockId;
}
public List
return pageList;
}
public void setPageList(List
this.pageList = pageList;
}
public int getBeforePage() {
return beforePage;
}
public void setBeforePage(int beforePage) {
this.beforePage = beforePage;
}
public int getBackPage() {
return backPage;
}
public void setBackPage(int backPage) {
this.backPage = backPage;
}
public int getSumPage() {
return sumPage;
}
public void setSumPage(int sumPage) {
this.sumPage = sumPage;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getNowPage() {
return nowPage;
}
public void setNowPage(int nowPage) {
this.nowPage = nowPage;
}
public List
return stockList;
}
public void setStockList(List
this.stockList = stockList;
}
public List
return stockParticularList;
}
public void setStockParticularList(List
this.stockParticularList = stockParticularList;
}
public Stock getStock() {
return stock;
}
public void setStock(Stock stock) {
this.stock = stock;
}
public String getFirstIndexId() {
return firstIndexId;
}
public void setFirstIndexId(String firstIndexId) {
this.firstIndexId = firstIndexId;
}
public ProductManageServiceImpl getProductService() {
return productService;
}
public void setProductService(ProductManageServiceImpl productService) {
this.productService = productService;
}
public String getNeedDate() {
return needDate;
}
public void setNeedDate(String needDate) {
this.needDate = needDate;
}
public StockParticular getStockOption() {
return stockOption;
}
public void setStockOption(StockParticular stockOption) {
this.stockOption = stockOption;
}
public long getTempId() {
return tempId;
}
public void setTempId(long tempId) {
this.tempId = tempId;
}
public BranchServiceImpl getBranchService() {
return branchService;
}
public void setBranchService(BranchServiceImpl branchService) {
this.branchService = branchService;
}
public List
return branchList;
}
public void setBranchList(List
this.branchList = branchList;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public long getAttributeStockId() {
return attributeStockId;
}
public void setAttributeStockId(long attributeStockId) {
this.attributeStockId = attributeStockId;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(String unitPrice) {
this.unitPrice = unitPrice;
}
public long getProductId() {
return productId;
}
public void setProductId(long productId) {
this.productId = productId;
}
public List
return productTypeList;
}
public void setProductTypeList(List
this.productTypeList = productTypeList;
}
public List
return productList;
}
public void setProductList(List
this.productList = productList;
}
public String getGetBranchName() {
return getBranchName;
}
public void setGetBranchName(String getBranchName) {
this.getBranchName = getBranchName;
}
public StockManageServiceImpl getStockService() {
return stockService;
}
public void setStockService(StockManageServiceImpl stockService) {
this.stockService = stockService;
}
public String getPassivityBranchId() {
return passivityBranchId;
}
public void setPassivityBranchId(String passivityBranchId) {
this.passivityBranchId = passivityBranchId;
}
public String getTransportPrice() {
return transportPrice;
}
public void setTransportPrice(String transportPrice) {
this.transportPrice = transportPrice;
}
public String getRemark() {
if(this.remark==null) return "";
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String prepareCreateStock(){
Map
User user=(User)map.get("user");
Branch branch=branchService.getBranchById(user.getBranchId());
branchList=new ArrayList
try{
branchList.add(branchService.getUpLever(branch.getSuperiorId()));
branchList.addAll(branchService.getAllEqually(user.getBranchId()));
}catch(Exception e){
e.printStackTrace();
message="数据库连接错误!";
return "ERROR";
}
return "SUCCEED";
}
public String createStock(){
Map
Map
User user=(User)map.get("user");
Stock stock=new Stock();
double transportPriceX=0.0;
long passivityBranchIdX=0;
try{
transportPriceX=Double.valueOf(transportPrice);
passivityBranchIdX=Long.valueOf(passivityBranchId);
}catch(Exception e){
message="你输入的数据不合法!";
return "ERROR";
}
stock.setPassivityBranchId(passivityBranchIdX);
stock.setStockProductList("");
stock.setRemark(remark);
stock.setStockDate(CurrentDate.getDateString());
stock.setSumPrice(0.0);
stock.setTransportPrice(transportPriceX);
try{
stock.setStockBranchId(user.getBranchId());
//stock=stockService.addStock(stock);//加入订单
stock.setStockBranch(branchService.getBranchById(stock.getStockBranchId()));
stock.setPassivityBranch(branchService.getBranchById(stock.getPassivityBranchId()));
if(appliaction.get("productTypeList")==null) appliaction.put("productTypeList", productService.getAllProductType());//将产品所有数据装载到application以恭使用(减少磁盘压力)
if(appliaction.get("productList")==null) appliaction.put("productList",productService.getAllProduct());
}catch(Exception e){
e.printStackTrace();
message="数据库连接错误!";
return "ERROR";
}
stockParticularList=new ArrayList
this.stock=stock;
map.put("stock", stock);
map.put("stockOption", new ArrayList
return "SUCCEED";
}
public String prepareAddStockOption(){
Map
Map
User user=(User)map.get("user");
try{
productTypeList=(List
List
productList=new ArrayList
for(int i=0;i
productList.add(list.get(i));
}
//else list.remove(i);//移除不用的数据,减少内存
}
}catch(Exception e){
message="数据库连接错误!";
return "ERROR";
}
return "SUCCEED"; //返回到准备添加订单详细项form
}
public String addStockOption(){
Map
Stock stock=(Stock)map.get("stock");
List
User user=(User)map.get("user");
double unitPriceX=0;
long numberX=0;
if(unitPrice==null || unitPrice.length()==0) unitPrice="0";
if(number==null ||number.length()==0 || number.equals("0")) {
message="你输入的价格、数量格式不正确!";
return "ERROR";
}
try{
unitPriceX=Double.valueOf(unitPrice);
numberX=Long.valueOf(number);
}catch(Exception e){
e.printStackTrace();
message="你输入的价格、数量格式不正确!";
return "ERROR";
}
StockParticular stockOptionT=new StockParticular();
stockOptionT.setProduct(productService.getProductByProductId(productId));
stockOptionT.setAttributeStockId(stock.getId());
stockOptionT.setBranchId(stock.getStockBranchId());
stockOptionT.setGetBranchId(stock.getPassivityBranchId());
stockOptionT.setNeedDate(needDate);
stockOptionT.setNumber(numberX);
stockOptionT.setProductId(productId);
stockOptionT.setRemark("");
stockOptionT.setStandby2("");
stockOptionT.setStandby1("");
stockOptionT.setSendDate(CurrentDate.getDateString());
stockOptionT.setState(0);
stockOptionT.setUserId(user.getId());
if(unitPriceX!=0){
stockOptionT.setUnitPrice(unitPriceX);
}
else stockOptionT.setUnitPrice(stockOptionT.getProduct().getPrice());
stockOptionT.setSumPrice(stockOptionT.getUnitPrice()*numberX);
stock.setSumPrice(stock.getSumPrice()+stockOptionT.getSumPrice());
list.add(stockOptionT);
map.put("stockOption", list);
map.put("stock", stock);
stockParticularList=list;
this.stock=stock;
return "SUCCEED";//返回到listStockPage
}
public String deleteTempStockOption(){
Map
try{
List
StockParticular stockParticular=list.remove((int)tempId);
Stock stock=(Stock)map.get("stock");
stock.setSumPrice(stock.getSumPrice()-stockParticular.getSumPrice());
map.put("stockOption", list);
map.put("stock", stock);
stockParticularList=list;
this.stock=stock;
}catch(Exception e){
message="读取写入session出错,该项已经删除!";
return "ERROR";
}
return "SUCCEED"; //返回到listStockPage
}
public String updateTempStockOption(){
Map
Map
try{
productTypeList=(List
List
productList=new ArrayList
for(int i=0;i
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
List
Stock stock=(Stock)map.get("stock");
stockOption=list.remove((int)tempId);
stock.setSumPrice(stock.getSumPrice()-stockOption.getSumPrice());
map.put("stockOption", list);
map.put("stock", stock);
}catch(Exception e){
message="读取写入session出错!";
return "ERROR";
}
return "SUCCEED"; //返回到准备添加订单详细项form
}
public String secondIndexProduct(){
Map
List
int selectProductTypeId=0;
try{
selectProductTypeId=Integer.valueOf(firstIndexId);
}catch(Exception e){
message="你选择的产品类型Id格式错误!";
return "ERROR";
}
productList=new ArrayList
for(int i=0;i
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
return "SUCCEED"; //返回产品列表
}
public String addStock(){
Map
Stock stock=(Stock)map.get("stock");
List
double sumMoney=0;
if(list!=null && list.size()>0){
for(int i=0;i
}
stock.setSumPrice(sumMoney);
}
else{
message="订单项目为空!";
return "ERROR";
}
try{
stockService.addStockParticularList(list, stock);
}catch(Exception e){
message="数据库连接失败!";
return "ERROR";
}
map.remove("stock");
map.remove("stockOption");
map.remove("stockList");
return listAllStock();
//return "SUCCEED"; //返回所有订单列表
}
public String listAllStock(){
if(nowPage==0) nowPage=1;
Map
User user=(User)map.get("user");
List
if(stockListT==null) stockListT=stockService.getAllStockByBranchId(user.getBranchId());
if(stockListT==null && stockListT.size()==0){
message="暂时没有向任何部门采购!";
return "ERROR";
}
stockList=new ArrayList
//分页
sumPage=(stockListT.size()-1)/pageSize+1;
if(nowPage<1 || nowPage>sumPage) {message="查看页码错误!";return "ERROR";}
for(int i=(nowPage-1)*pageSize;i<((nowPage)*pageSize
}
if(nowPage==1) this.beforePage=0;
else this.beforePage=nowPage-1;
if(nowPage==sumPage) this.backPage=0;
else this.backPage=nowPage+1;
if(sumPage!=0) {
pageList=new ArrayList
for(int i=0;i
}
}
return "SUCCEED"; //返回所有订单列表
}
public String listLookStockParticular(){
if(nowPage==0) nowPage=1;
Map
User user=(User)map.get("user");
stock=stockService.getStockById(stockId);
if(stock.getStockBranchId().longValue()!=user.getBranchId()){
message="该订单不属于贵部门,无权查看!";
return "ERROR";
}
stock.setPassivityBranch(branchService.getBranchById(stock.getPassivityBranchId()));
stockParticularList=stockService.getAllStockParticularByStockId(stock.getId());
return "SUCCEED";
}
}