2个回答
2009-11-01
展开全部
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<Branch> branchList;
private String passivityBranchId;
private String transportPrice="0";
private String remark="";
//session中订单项修改id
private long tempId;
private StockParticular stockOption;
private List<ProductType> productTypeList; //货物分类
private List<Product> productList; //货物数据
private String getBranchName; //[显示使用]
private String message;
//ajax选择产品使用
private String firstIndexId;
//新建订单 采购详细列表 使用
private List<StockParticular> stockParticularList;
private Stock stock;
private long stockId;
//所有采购订单列表
private List<Stock> stockList;
private int sumPage;
private int pageSize=15;
private int nowPage;
private int beforePage;
private int backPage;
private List<Integer> pageList;
public long getStockId() {
return stockId;
}
public void setStockId(long stockId) {
this.stockId = stockId;
}
public List<Integer> getPageList() {
return pageList;
}
public void setPageList(List<Integer> pageList) {
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<Stock> getStockList() {
return stockList;
}
public void setStockList(List<Stock> stockList) {
this.stockList = stockList;
}
public List<StockParticular> getStockParticularList() {
return stockParticularList;
}
public void setStockParticularList(List<StockParticular> stockParticularList) {
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<Branch> getBranchList() {
return branchList;
}
public void setBranchList(List<Branch> branchList) {
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<ProductType> getProductTypeList() {
return productTypeList;
}
public void setProductTypeList(List<ProductType> productTypeList) {
this.productTypeList = productTypeList;
}
public List<Product> getProductList() {
return productList;
}
public void setProductList(List<Product> productList) {
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<String,Object> map=ActionContext.getContext().getSession();
User user=(User)map.get("user");
Branch branch=branchService.getBranchById(user.getBranchId());
branchList=new ArrayList<Branch>();
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<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
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<StockParticular>();
this.stock=stock;
map.put("stock", stock);
map.put("stockOption", new ArrayList<StockParticular>());
return "SUCCEED";
}
public String prepareAddStockOption(){
Map<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
User user=(User)map.get("user");
try{
productTypeList=(List<ProductType>)appliaction.get("productTypeList");
List<Product> list=(List<Product>)appliaction.get("productList");
productList=new ArrayList<Product>();
for(int i=0;i<list.size();i++){
if(list.get(i).getProductType().intValue()==productTypeList.get(0).getId().intValue()){
productList.add(list.get(i));
}
//else list.remove(i);//移除不用的数据,减少内存
}
}catch(Exception e){
message="数据库连接错误!";
return "ERROR";
}
return "SUCCEED"; //返回到准备添加订单详细项form
}
public String addStockOption(){
Map<String,Object> map=ActionContext.getContext().getSession();
Stock stock=(Stock)map.get("stock");
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> map=ActionContext.getContext().getSession();
try{
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
try{
productTypeList=(List<ProductType>)appliaction.get("productTypeList");
List<Product> listT=(List<Product>)appliaction.get("productList");
productList=new ArrayList<Product>();
for(int i=0;i<listT.size();i++){
if(listT.get(i).getProductType().intValue()==productTypeList.get(0).getId().intValue()){
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> appliaction=ActionContext.getContext().getApplication();
List<Product> listT=(List<Product>)appliaction.get("productList");
int selectProductTypeId=0;
try{
selectProductTypeId=Integer.valueOf(firstIndexId);
}catch(Exception e){
message="你选择的产品类型Id格式错误!";
return "ERROR";
}
productList=new ArrayList<Product>();
for(int i=0;i<listT.size();i++){
if(listT.get(i).getProductType().intValue()==selectProductTypeId){
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
return "SUCCEED"; //返回产品列表
}
public String addStock(){
Map<String,Object> map=ActionContext.getContext().getSession();
Stock stock=(Stock)map.get("stock");
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
double sumMoney=0;
if(list!=null && list.size()>0){
for(int i=0;i<list.size();i++){
sumMoney=sumMoney+list.get(i).getSumPrice();
}
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<String,Object> map=ActionContext.getContext().getSession();
User user=(User)map.get("user");
List<Stock> stockListT=(List<Stock>)map.get("stockList");
if(stockListT==null) stockListT=stockService.getAllStockByBranchId(user.getBranchId());
if(stockListT==null && stockListT.size()==0){
message="暂时没有向任何部门采购!";
return "ERROR";
}
stockList=new ArrayList<Stock>();
//分页
sumPage=(stockListT.size()-1)/pageSize+1;
if(nowPage<1 || nowPage>sumPage) {message="查看页码错误!";return "ERROR";}
for(int i=(nowPage-1)*pageSize;i<((nowPage)*pageSize<stockListT.size()?(nowPage)*pageSize:stockListT.size());i++){
stockList.add(stockListT.get(i));
}
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<Integer>();
for(int i=0;i<sumPage;i++){
pageList.add(i+1);
}
}
return "SUCCEED"; //返回所有订单列表
}
public String listLookStockParticular(){
if(nowPage==0) nowPage=1;
Map<String,Object> map=ActionContext.getContext().getSession();
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";
}
}
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<Branch> branchList;
private String passivityBranchId;
private String transportPrice="0";
private String remark="";
//session中订单项修改id
private long tempId;
private StockParticular stockOption;
private List<ProductType> productTypeList; //货物分类
private List<Product> productList; //货物数据
private String getBranchName; //[显示使用]
private String message;
//ajax选择产品使用
private String firstIndexId;
//新建订单 采购详细列表 使用
private List<StockParticular> stockParticularList;
private Stock stock;
private long stockId;
//所有采购订单列表
private List<Stock> stockList;
private int sumPage;
private int pageSize=15;
private int nowPage;
private int beforePage;
private int backPage;
private List<Integer> pageList;
public long getStockId() {
return stockId;
}
public void setStockId(long stockId) {
this.stockId = stockId;
}
public List<Integer> getPageList() {
return pageList;
}
public void setPageList(List<Integer> pageList) {
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<Stock> getStockList() {
return stockList;
}
public void setStockList(List<Stock> stockList) {
this.stockList = stockList;
}
public List<StockParticular> getStockParticularList() {
return stockParticularList;
}
public void setStockParticularList(List<StockParticular> stockParticularList) {
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<Branch> getBranchList() {
return branchList;
}
public void setBranchList(List<Branch> branchList) {
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<ProductType> getProductTypeList() {
return productTypeList;
}
public void setProductTypeList(List<ProductType> productTypeList) {
this.productTypeList = productTypeList;
}
public List<Product> getProductList() {
return productList;
}
public void setProductList(List<Product> productList) {
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<String,Object> map=ActionContext.getContext().getSession();
User user=(User)map.get("user");
Branch branch=branchService.getBranchById(user.getBranchId());
branchList=new ArrayList<Branch>();
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<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
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<StockParticular>();
this.stock=stock;
map.put("stock", stock);
map.put("stockOption", new ArrayList<StockParticular>());
return "SUCCEED";
}
public String prepareAddStockOption(){
Map<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
User user=(User)map.get("user");
try{
productTypeList=(List<ProductType>)appliaction.get("productTypeList");
List<Product> list=(List<Product>)appliaction.get("productList");
productList=new ArrayList<Product>();
for(int i=0;i<list.size();i++){
if(list.get(i).getProductType().intValue()==productTypeList.get(0).getId().intValue()){
productList.add(list.get(i));
}
//else list.remove(i);//移除不用的数据,减少内存
}
}catch(Exception e){
message="数据库连接错误!";
return "ERROR";
}
return "SUCCEED"; //返回到准备添加订单详细项form
}
public String addStockOption(){
Map<String,Object> map=ActionContext.getContext().getSession();
Stock stock=(Stock)map.get("stock");
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> map=ActionContext.getContext().getSession();
try{
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> map=ActionContext.getContext().getSession();
Map<String,Object> appliaction=ActionContext.getContext().getApplication();
try{
productTypeList=(List<ProductType>)appliaction.get("productTypeList");
List<Product> listT=(List<Product>)appliaction.get("productList");
productList=new ArrayList<Product>();
for(int i=0;i<listT.size();i++){
if(listT.get(i).getProductType().intValue()==productTypeList.get(0).getId().intValue()){
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
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<String,Object> appliaction=ActionContext.getContext().getApplication();
List<Product> listT=(List<Product>)appliaction.get("productList");
int selectProductTypeId=0;
try{
selectProductTypeId=Integer.valueOf(firstIndexId);
}catch(Exception e){
message="你选择的产品类型Id格式错误!";
return "ERROR";
}
productList=new ArrayList<Product>();
for(int i=0;i<listT.size();i++){
if(listT.get(i).getProductType().intValue()==selectProductTypeId){
productList.add(listT.get(i));
}
//else listT.remove(i);//移除不用的数据,减少内存
}
return "SUCCEED"; //返回产品列表
}
public String addStock(){
Map<String,Object> map=ActionContext.getContext().getSession();
Stock stock=(Stock)map.get("stock");
List<StockParticular> list=(List<StockParticular>)map.get("stockOption");
double sumMoney=0;
if(list!=null && list.size()>0){
for(int i=0;i<list.size();i++){
sumMoney=sumMoney+list.get(i).getSumPrice();
}
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<String,Object> map=ActionContext.getContext().getSession();
User user=(User)map.get("user");
List<Stock> stockListT=(List<Stock>)map.get("stockList");
if(stockListT==null) stockListT=stockService.getAllStockByBranchId(user.getBranchId());
if(stockListT==null && stockListT.size()==0){
message="暂时没有向任何部门采购!";
return "ERROR";
}
stockList=new ArrayList<Stock>();
//分页
sumPage=(stockListT.size()-1)/pageSize+1;
if(nowPage<1 || nowPage>sumPage) {message="查看页码错误!";return "ERROR";}
for(int i=(nowPage-1)*pageSize;i<((nowPage)*pageSize<stockListT.size()?(nowPage)*pageSize:stockListT.size());i++){
stockList.add(stockListT.get(i));
}
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<Integer>();
for(int i=0;i<sumPage;i++){
pageList.add(i+1);
}
}
return "SUCCEED"; //返回所有订单列表
}
public String listLookStockParticular(){
if(nowPage==0) nowPage=1;
Map<String,Object> map=ActionContext.getContext().getSession();
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";
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询