package com.bsp.action;
import java.util.List;
import java.util.Set;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.bsp.entity.*;
import com.bsp.vo.BUY_INQ_EDITVO;
import com.opensymphony.xwork2.ActionContext;
@Namespace("/MyOrderParts")
@Results( { @Result(name = "error", location = "/error.jsp") })
public class BUY_INQ_EDITAction extends SecureValidBaseAction {
private static final long serialVersionUID = 1L;
private BUY_INQ_EDITVO buyinqedit;// 获得表单
private String Clist[];
public BUY_INQ_EDITVO getBuyinqedit() {
return buyinqedit;
}
public void setBuyinqedit(BUY_INQ_EDITVO buyinqedit) {
this.buyinqedit = buyinqedit;
}
public String Setlist(String uid) {// 保存所选择的联系人信息
System.out.println("响应DWR调用" + uid);
if (uid.indexOf("~") > 0) {
try {
String nbr[] = uid.split("~");
Clist=nbr;
} catch (Exception ex) {
ex.printStackTrace();
}
}
else {
Clist=new String[1];
Clist[0]=uid;
}
return "成功保存所选择的联系人信息";
}
@Override
// 实现安全控制动作
@Action(value = "BUYINQEDIT", results = {
@Result(name = "list", type = "redirect", location = "/MyOrderParts/BUY_SEND_INQ_LIST.jsp"),
@Result(name = "input", location = "/MyOrderParts/BUY_INQ_EDIT.jsp"),
@Result(name = "view", location = "/MyOrderParts/VBUY_SENDINQ_EDIT.jsp") })
public String execute() throws Exception {
return super.execute();
}
protected String todoExecute() throws Exception {
ActionContext context = ActionContext.getContext();
String tag = ServletActionContext.getRequest().getParameter("tag");// 获取操作标记
if (tag == null)
tag = "new";
if (tag.equals("list")) {// 查询己发送的询价单列表
try {
List<?> list = this.managerfactory.getInqmanager()
.findInqByProperty("buyerId",
(String) context.getSession().get("ID"));
context.getSession().put("sendlist", list);// 保存到会话中
} catch (Exception ex) {
ex.printStackTrace();
}
return "list";
}
if (tag.equals("view")) {// 查看询价单详细信息
try {
if (buyinqedit == null)
buyinqedit = new BUY_INQ_EDITVO();
String id = ServletActionContext.getRequest().getParameter(
"nbr");// 读取询价单号参数
BspInq inq = this.managerfactory.getInqmanager().findById(id);
Set set = inq.getBspInqPartses();// 读到询价单涉及到的部件集合
buyinqedit.setBUYER_ID(inq.getBuyerId());// 显示到表单中
buyinqedit.setCDATE(String.valueOf(inq.getCdate()));
buyinqedit.setIID(inq.getIid());
buyinqedit.setOIC(inq.getOic());
buyinqedit.setREM(inq.getRem());
context.getSession().put("partslist", set);// 在会话中保存部件集合
} catch (Exception ex) {
ex.printStackTrace();
}
return "view";
}
if (tag.equals("new")) {// 新增一个询价单
java.text.SimpleDateFormat sim = new java.text.SimpleDateFormat(
"yyyyMMdd");
sim = new java.text.SimpleDateFormat("yyyy-MM-dd");
if (buyinqedit == null)
buyinqedit = new BUY_INQ_EDITVO();
buyinqedit.setCDATE(sim.format(new java.util.Date()));
buyinqedit.setOIC("");
buyinqedit.setIID("");
context.getSession().remove("partlist");
// 以下是读取我的联系人信息,按公司分组,以便在发送询价单时选择联系人进显示。
java.util.HashMap<String, List> maplist = new java.util.HashMap<String, List>();
List<?> clist = this.managerfactory.getAccountmanager()
.getMyContact((String) context.getSession().get("ID"));// 读取联系人公司信息,按公司进行分组
java.util.Iterator<?> cit = clist.iterator();
while (cit.hasNext()) {// 读取联系人公司下的所有员工信息
Object obj = cit.next();
System.out.println(obj);
java.util.List ulist = this.managerfactory.getAccountmanager()
.getUser((String) obj,
(String) context.getSession().get("ID"));
maplist.put(this.managerfactory.getAccountmanager()
.findByCorpId((String) obj).getCorpnameCn(), ulist);// 哈稀表关键字为公司名称,值为员工信息集合
}
context.getSession().put("MyContactList", maplist);// 保存我的联系人列表
return "input";
}
if (tag.equals("save")) {// 发送询价单
try {
BspInq inq = new BspInq();
String type = ServletActionContext.getRequest().getParameter(
"CORPTYPE");// 发送给联系人方式
if (type == null)
type = "1";
java.util.Vector v = new java.util.Vector();
// 读取部件信息
String pn[] = ServletActionContext.getRequest()
.getParameterValues("PN");
String mfr[] = ServletActionContext.getRequest()
.getParameterValues("MFR");
String keyw[] = ServletActionContext.getRequest()
.getParameterValues("KEYW");
String qut[] = ServletActionContext.getRequest()
.getParameterValues("QUT");
String unit[] = ServletActionContext.getRequest()
.getParameterValues("UNIT");
String status[] = ServletActionContext.getRequest()
.getParameterValues("STATUS");
String lim[] = ServletActionContext.getRequest()
.getParameterValues("LIM");
String pri[] = ServletActionContext.getRequest()
.getParameterValues("PRI");
String notes[] = ServletActionContext.getRequest()
.getParameterValues("NOTES");
java.util.ArrayList<BspInqParts> avlist = new java.util.ArrayList<BspInqParts>();
for (int i = 0; i < pn.length; i++) {
BspInqParts partlist = new BspInqParts();
partlist.setPnr(pn[i]);
partlist.setMfr(mfr[i]);
partlist.setCert("CAA");
try {
partlist.setBqu(Double.valueOf(qut[i]));
} catch (Exception ex) {
}
partlist.setKwd(keyw[i]);
partlist.setKwdCn(keyw[i]);
try {
partlist.setLtm(Integer.parseInt(lim[i]));
} catch (Exception e) {
}
partlist.setRem(notes[i]);
partlist.setPri(pri[i]);
partlist.setUnt(unit[i]);
partlist.setCnd(status[i]);
BspInqPartsId pid = new BspInqPartsId();
pid.setIid(buyinqedit.getIID());
pid.setIin((i + 1));
partlist.setId(pid);
partlist.setBspInq(inq);
avlist.add(partlist);
}
// 保存部件信息到会话中,以便在页面中显示
context.getSession().put("partlist", avlist);
if (type.equals("1")) {// 选择的发送类型为发送给我的联系人
List list = this.managerfactory.getAccountmanager()
.getInqContact(
(String) context.getSession().get("ID"));
if (list.size() <= 0) {
this.setTip("在系统未找到您的联系人,请创建您的联系人");
return "input";
}
java.util.Iterator cit = list.iterator();
while (cit.hasNext()) {// 保存联系人信息
Object obj = cit.next();
v.add(obj);
System.out.println(obj);
}
}
if (type.equals("2")) {// 选择的发送类型为发送给认证过的供应商
List list = this.managerfactory.getAccountmanager()
.getCerCorp(
(String) context.getSession().get("corp"));
if (list.size() <= 0) {
this.setTip("在系统未找到认证的供应商,请认证供应商");
return "input";
}
java.util.Iterator cit = list.iterator();
while (cit.hasNext()) {// 保存供应商信息
Object obj = cit.next();
BspCorp corp = (BspCorp) cit.next();
v.add(corp.getCorpId());
}
}
if (type.equals("3")) {// 选择的发送类型为发送给我指定的联系人
v = new java.util.Vector<String>();
String c1[] = Clist;
if (c1 != null) {
for (int j = 0; j < c1.length; j++) {
v.add(c1[j]);
System.out.println("Clsit:" + c1[j]);
}
} else {
this.setTip("在系统未找到您的联系人,请创建您的联系人");
if (tag.equals("update") || tag.equals("update1"))
return "update";
else
return "input";
}
}
if
- 1
- 2
- 3
前往页