标签:
if (myMapListprocessor == null) {
myMapListprocessor = new MapListProcessor();
}
String sql="";
try {
new BaseDAO().executeQuery(sql, myMapListprocessor);
} catch (DAOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
out.write(edit.toString());
package nc.saleorder.services;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import nc.bs.ca.capub.mobile.common.MobileCommon;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.itf.bd.material.baseinfo.IMaterialBaseInfoQueryService;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ArrayProcessor;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.saleorder.itf.ISaleOrderMobileService;
import nc.saleorder.itf.PageController;
import nc.uap.lfw.core.log.LfwLogger;
import nc.ui.bill.depend.PageInfo;
import nc.vo.bd.material.MaterialVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.AppContext;
import nc.vo.webts.webts_saleorder.Saleorder;
import nc.vo.webts.webts_saleorder.SaleorderB;
import nc.yanghe.saleorder.constant.ISaleOrderConst;
public class SaleOrderMobileService implements ISaleOrderMobileService {
private BaseDAO dao;
private BaseDAO getDAO() {
if (dao == null)
this.dao = new BaseDAO();
return dao;
}
// @SuppressWarnings("unused")
// private String transNulltoString(Object tempStr)
// {
// return tempStr== null ? ""
// : tempStr.toString();
// }
private MapListProcessor myMapListprocessor;
private MapListProcessor getMapListProcessor() {
if (myMapListprocessor == null)
myMapListprocessor = new MapListProcessor();
return myMapListprocessor;
}
// 获取渠道节点
/**
* @description 获取渠道网点
* @author wangchunhui
*/
public ArrayList<Map<String, Object>> GetChnls(String groupid,
String usrid, String search_text, String visit_type, String ts,
String pageNum, String pagerows) {
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetChnls", new String[] {
"groupid", "usrid", "search_text",
"visit_type", "ts", "pageNum", "pagerows" },
new Object[] { groupid, usrid, search_text, visit_type,
ts, pageNum, pagerows }));
}
// StringBuffer strbuf = new StringBuffer("select * from (select ");
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_channelnode as pk_channelnode");
strbuf.append(" ,t.vname as vname");
strbuf.append(" ,t1.detailinfo as addrname");
strbuf.append(" ,t2.name as chnlname");
strbuf.append(" ,t.vlinkman as vlinkman");
strbuf.append(" ,t.vmobilephone as vmobilephone");
StringBuffer subbuf = new StringBuffer(
" from dcm_chnlnode t "
+ " left join bd_address t1 on t1.pk_address=t.clinkaddrid"
+ " left join bd_channeltype t2 on t2.pk_type=t.cchanltypeid"
+ " where t.dr=0 ");
// app端
if (visit_type != null && visit_type.equals("app")) {
if (groupid != null && !groupid.equals("")) {
subbuf.append(" and t.pk_group=‘" + groupid + "‘");
}
if (search_text != null && !search_text.equals("")) {
subbuf.append(" and (t.vlinkman like ‘%" + search_text
+ "%‘ or t.vname like ‘%" + search_text
+ "%‘ or t.vmobilephone like ‘%" + search_text
+ "%‘ or t1.detailinfo like ‘%" + search_text
+ "%‘)");
}
if (usrid != null && !usrid.equals("")) {
subbuf.append(" and t.pk_channelnode in(select u.chnlnode "
+ "from cv_visitline_nodeb u " + " where u.dr = 0 "
+ " and u.pk_visitline in "
+ " (select pk_visitline " + " from cv_visitline "
+ " where dr=0 " + " and enablestate=2 "
+ " and pk_visitline in "
+ " (select s.pk_visitline "
+ "from cv_visitline_userb s " + " where s.dr = 0 "
+ " and s.bvalidstatus=‘Y‘ " + " and s.userid =‘"
+ usrid + "‘ )))");
}
}
// 店长微信
// else{
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
// strbuf.append(" and rownum <=" + endIndex +
// " order by t.vname ) where rn>="
strbuf.append(" order by t.vname ) A where rownum <=" + endIndex
+ " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
// CacheManager.setObject("123", lists);
// ArrayList<HashMap<String, Object>>
// lists2=(ArrayList<HashMap<String,
// Object>>)CacheManager.getObject("123");
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", null);
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
// 获取物料分类
/**
* @description 获取物料分类
* @author wangchunhui
*/
public ArrayList<Map<String, Object>> GetMaterielCategorys(String groupid,
String usrid, String visit_type, String parentid, String ts,
String pageNum, String pagerows) {
// ArrayList<Map<String, Object>> arr = new ArrayList<Map<String,
// Object>>();
// return arr;
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetMaterielCategorys",
new String[] { "groupid", "usrid", "visit_type",
"parentid", "ts", "pageNum", "pagerows" },
new Object[] { groupid, usrid, visit_type, parentid,
ts, pageNum, pagerows }));
}
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_marbasclass as pk_marbasclass");
strbuf.append(" ,t.code as materialclasscode");
strbuf.append(" ,t.name as materialclassname");
// strbuf.append(" ,to_char((select count(*) from t1 where t1.pk_parent =t.pk_marbasclass)) ishavechild");
StringBuffer subbuf = new StringBuffer(
" from bd_marbasclass t where t.dr=0");
// app端
if (!visit_type.isEmpty() && visit_type.equals("app")) {
if (!groupid.isEmpty()) {
subbuf.append(" and t.pk_group=‘" + groupid + "‘");
}
// if (!parentid.isEmpty() ) {
// subbuf.append(" and t.pk_marbasclass=‘" + parentid + "‘");
// }
if (!usrid.isEmpty()) {
subbuf.append(" and t.pk_marbasclass in (select t1.pk_marbasclass from bd_material t1 where exists (select t2.pk_material from bd_marorg t2 where t2.pk_org="
+ " (select pk_org from cp_user where cuserid=‘"
+ usrid
+ "‘) and t2.pk_material=t1.pk_material and t2.enablestate=2))");
}
}
// 微信端
// else{
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
// strbuf.append(" and rownum <=" + endIndex +
// " order by rownum) where rn>="
strbuf.append(" order by t.name ) A where rownum <=" + endIndex
+ " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
// 获取物料
/**
* @description 获取物料
* @author wangchunhui
*/
public ArrayList<Map<String, Object>> GetMateriels(String groupid,
String usrid, String search_text, String pk_marbasclass,
String visit_type, String ts, String pageNum, String pagerows) {
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetMateriels", new String[] {
"groupid", "usrid", "search_text",
"pk_marbasclass", "visit_type", "ts",
"pageNum", "pagerows" }, new Object[] {
groupid, usrid, search_text, pk_marbasclass,
visit_type, ts, pageNum, pagerows }));
}
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_material as pk_material");
strbuf.append(" ,t.name as name");
// strbuf.append(" ,s.name as unit");
strbuf.append(" ,t.materialspec as materialspec");
StringBuffer subbuf = new StringBuffer(
" from (select * from BD_MATERIAL order by name) t "
// + " left join bd_measdoc s on s.pk_measdoc=t.pk_measdoc"
+ " where t.dr=0 ");
// app端
if (!visit_type.isEmpty() && visit_type.equals("app")) {
if (!groupid.isEmpty()) {
subbuf.append(" and t.pk_group=‘" + groupid + "‘");
}
if (!search_text.isEmpty()) {
subbuf.append(" and (t.code like ‘%" + search_text
+ "%‘ or t.name like ‘%" + search_text + "%‘)");
}
if (!usrid.isEmpty()) {
subbuf.append(" and t.pk_material in"
+ "(select distinct u.pk_material from BD_MARORG u where u.enablestate=2 and u.pk_org="
+ "(select pk_org from cp_user where cuserid=‘"
+ usrid + "‘))");
}
}
if (!pk_marbasclass.isEmpty()) {
// String sql =
// "select * from bd_marbasclass where dr=0 and pk_marbasclass=‘"
// + pk_marbasclass + "‘";
// BaseDAO dao = new BaseDAO();
// @SuppressWarnings("unchecked")
// List<MarBasClassVO> lists = (List<MarBasClassVO>) dao
// .executeQuery(sql, new BeanListProcessor(
// MarBasClassVO.class));
// if (lists.size() > 0) {
// if (lists.get(0).getCode().length() == 13) {
// subbuf.append(" and t.pk_marbasclass=‘"
// + pk_marbasclass + "‘");
// } else if (lists.get(0).getCode().length() == 10) {
// subbuf.append(" and (t.pk_marbasclass=‘"
// + pk_marbasclass
// + "‘ or t.pk_marbasclass in"
// +
// "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
// + pk_marbasclass + "‘))");
// } else if (lists.get(0).getCode().length() == 7) {
// subbuf.append(" and (t.pk_marbasclass in"
// +
// "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
// + pk_marbasclass
// + "‘) or "
// +
// " t.pk_marbasclass in(select pk_marbasclass from bd_marbasclass where pk_parent in"
// +
// "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
// + pk_marbasclass + "‘)))");
// }
// }
subbuf.append(" and t.pk_marbasclass=‘" + pk_marbasclass + "‘");
}
// 微信端
// else{
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
strbuf.append(" order by t.name ) A where rownum <=" + endIndex
+ " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
for (int i = 0; i < lists.size(); i++) {
lists.get(i).put("unit", "箱");
}
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* @description 获取订单列表
* @author wangchunhui
*/
@Override
public ArrayList<Map<String, Object>> GetOrderlist(String groupid,
String usrid, String search_text, String orderstate,
String visit_type, String ts, String pageNum, String pagerows) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetOrderlist", new String[] {
"groupid", "usrid", "search_text",
"orderstate", "visit_type", "ts", "pageNum",
"pagerows" }, new Object[] { groupid, usrid,
search_text, orderstate, visit_type, ts,
pageNum, pagerows }));
}
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_saleorder as id");
strbuf.append(" ,t.vbillno as vbillno");
strbuf.append(" ,s.channelname as channelname");
strbuf.append(" ,s.channelnodeid as channelnodeid");
strbuf.append(" ,s.contact_phone as contact_phone");
strbuf.append(" ,s.contact_name as contact_name");
strbuf.append(" ,s.addrname as addrname");
strbuf.append(" ,s.chnltype as chnltype");
// strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
// strbuf.append(" ,to_char((to_date(t.creationtime,‘yyyy-mm-dd,hh24:mi:ss‘)-to_date(‘1970-01-01‘,‘yyyy-mm-dd‘))*24*60*60*1000) as orderTime");
strbuf.append(" ,t.creationtime as orderTime");
StringBuffer subbuf = new StringBuffer(
" from webts_Saleorder t "
// +
// " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
+ " left join (select t1.vname as vname,t1.pk_channelnode as channelnodeid,t1.vname as channelname,t1.vmobilephone as contact_phone,t1.vlinkman as contact_name,t2.detailinfo as addrname,t3.name as chnltype "
+ " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
+ " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
+ " where t.dr=0 ");
if (!visit_type.isEmpty() && visit_type.equals("app")) {
if (!groupid.isEmpty()) {
subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
}
if (!usrid.isEmpty()) {
subbuf.append(" and t.creator=‘" + usrid + "‘ ");
}
if (!search_text.isEmpty()) {
subbuf.append(" and (t.vbillno like ‘%" + search_text
+ "%‘ or s.vname like ‘%" + search_text + "%‘)");
}
if (!orderstate.isEmpty()) {
subbuf.append(" and t.ibillstatus="
+ Integer.parseInt(orderstate) + "");
}
}
subbuf.append(" and t.vsource=‘" + ISaleOrderConst.SOURCE_APP
+ "‘");
// 微信端
// else
// {
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
strbuf.append(" order by t.creationtime desc) A where rownum <="
+ endIndex + " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
for (int i = 0; i < lists.size(); i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("channelnodeid",
lists.get(i).get("channelnodeid") == null ? "" : lists
.get(i).get("channelnodeid").toString());
jsonObject.put("channelname",
lists.get(i).get("channelname") == null ? "" : lists
.get(i).get("channelname").toString());
jsonObject.put("contact_name",
lists.get(i).get("contact_name") == null ? "" : lists
.get(i).get("contact_name").toString());
jsonObject.put("contact_phone",
lists.get(i).get("contact_phone") == null ? "" : lists
.get(i).get("contact_phone").toString());
jsonObject.put("addrname",
lists.get(i).get("addrname") == null ? "" : lists
.get(i).get("addrname").toString());
jsonObject.put("chnltype",
lists.get(i).get("chnltype") == null ? "" : lists
.get(i).get("chnltype").toString());
lists.get(i).remove("channelnodeid");
lists.get(i).remove("contact_name");
lists.get(i).remove("contact_phone");
lists.get(i).remove("addrname");
lists.get(i).remove("chnltype");
lists.get(i).put("website", jsonObject.toString());
}
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* @description 订单保存
* @author wangchunhui
*/
@Override
public ArrayList<Map<String, Object>> SaveOrders(String groupid,
String usrid, String visit_type, String channelnodeid,
String contact_name, String contact_phone, String sendDate,
String productlist, String ts) {
// LfwLogger.error("***********"+groupid+""+usrid+""+visit_type+""+channelnodeid+""+contact_name+""+contact_phone+productlist);
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.SaveOrders", new String[] {
"groupid", "usrid", "visit_type",
"channelnodeid", "contact_name",
"contact_phone", "productlist", "ts" },
new Object[] { groupid, usrid, visit_type,
channelnodeid, contact_name, contact_phone,
productlist, ts }));
}
IUAPQueryBS qry = NCLocator.getInstance().lookup(IUAPQueryBS.class);
// app端
if (visit_type != null && visit_type.equals("app")) {
// 保存
Saleorder saleorder = new Saleorder();
saleorder.setPk_psndoc(usrid);
saleorder.setCreator(usrid);
saleorder.setCreationtime(new UFDateTime(System
.currentTimeMillis()));
// TODO 用户关联的公司
@SuppressWarnings("unchecked")
ArrayList<String> clist = (ArrayList<String>) qry.executeQuery(
"select t.pk_org from cp_user t where t.cuserid=‘"
+ usrid + "‘", new ColumnListProcessor());
if (clist.size() > 0) {
saleorder.setPk_org(clist.get(0));
}
saleorder.setVbillno("SO" + new Date().getTime());
saleorder.setPk_group(groupid); // 所属集团
saleorder.setPk_channel(channelnodeid);// 渠道网点
saleorder.setVname(contact_name);// 联系人
saleorder.setVphoneno(contact_phone);// 联系电话
saleorder.setVdef1(new UFDate(sendDate).toString());
/**
* TODO 1.根据网点带出对应的省市县,nc.yangh.webts.SaleOrder.SaleOrder.
* SaleOrderCardWinMainViewCtrl
* .onAfterDataChange(DatasetCellEvent)
*
*/
IUAPQueryBS chnesrv = NCLocator.getInstance().lookup(
IUAPQueryBS.class);
Object[] chnldata = (Object[]) chnesrv
.executeQuery(
"select addr.province,addr.city,addr.vsection,addr.detailinfo,addr.postcode from dcm_chnlnode node join bd_address addr on node.clinkaddrid=addr.pk_address where pk_channelnode=‘"
+ channelnodeid + "‘",
new ArrayProcessor());
if (chnldata != null && chnldata.length > 0) {
saleorder.setPk_province(chnldata[0] == null ? ""
: chnldata[0].toString());
saleorder.setPk_city(chnldata[1] == null ? "" : chnldata[1]
.toString());
saleorder.setPk_region(chnldata[2] == null ? ""
: chnldata[2].toString());
saleorder.setVaddress(chnldata[3] == null ? ""
: chnldata[3].toString());
saleorder.setVzipcode(chnldata[4] == null ? ""
: chnldata[4].toString());
}
saleorder.setVsource(ISaleOrderConst.SOURCE_APP);// 订单来源
saleorder.setIbillstatus(ISaleOrderConst.COMMIT);// 提交态
saleorder.setDbilldate(AppContext.getInstance().getBusiDate());// 业务日期
String parentpk = getDAO().insertVO(saleorder);
// 解析json字符串
JSONArray jsonarray = new JSONArray(productlist);
List<SaleorderB> list = new ArrayList<SaleorderB>();
for (int i = 0; i < jsonarray.length(); i++) {
org.json.JSONObject jo = jsonarray.getJSONObject(i);
String pk_material = jo.get("productid").toString();
UFDouble nnum = new UFDouble(jo.get("num").toString());
String materialname = jo.get("materialname").toString();
String materialspec = jo.get("materialspec").toString();
SaleorderB saleb = new SaleorderB();
saleb.setPk_saleorder(parentpk);
saleb.setPk_material(pk_material);
saleb.setInvname(materialname);
saleb.setInvspec(materialspec);
saleb.setNnum(nnum);
saleb.setCrowno("" + (i + 1) * 10);
saleb.setPk_unit("0001Z0100000000000XU");// 计量单位:箱
saleb.setDsenddate(new UFDate(sendDate));
// saleb.setStatus(ISaleOrderConst.APPROVE_B);//已审核
/**
* TODO 2.带出表体对应的经销商nc.yangh.webts.SaleOrder.SaleOrder.
* SaleOrderCardWinMainViewCtrl.afterEdit(CellEvent)
*/
IMaterialBaseInfoQueryService materialQry = NCLocator
.getInstance().lookup(
IMaterialBaseInfoQueryService.class);
if (pk_material != null && pk_material.trim().length() > 0) {
MaterialVO materialvo = materialQry
.queryDataByPks(new String[] { pk_material })[0];
saleb.setSubclass(materialvo.getPk_marbasclass());
@SuppressWarnings("unchecked")
ArrayList<String> jxs = (ArrayList<String>) qry
.executeQuery(
"select code from webts_goodsrelation_h where"
+ " pk_relation in (select distinct(b.pk_relation) from webts_goodsrelation_order a "
+ " full join webts_goodsrelation_person b on a.pk_relation=b.pk_relation where nvl(a.dr,0)=0 and nvl(b.dr,0)=0 "
+ " and pk_psndoc=‘" + usrid
+ "‘ and a.pk_material=‘"
+ pk_material
+ "‘ ) and nvl(dr,0)=0",
new ColumnListProcessor());
if (jxs.size() == 1) {
saleb.setPk_dealer(jxs.get(0));
}
}
list.add(saleb);
}
SaleorderB[] salebs = list.toArray(new SaleorderB[0]);
getDAO().insertVOArray(salebs);
}
// 微信端
// else
// {
//
// }
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "0");
resMap.put("status", "1");
resMap.put("des", "保存成功");
resMap.put("ts", currenttime.toString());
resList.add(resMap);
return resList;
} catch (Exception e) {
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("status", "2");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
// 修改订单
@Override
public ArrayList<Map<String, Object>> UpdateOrders(String visit_type,
String usrid, String orderid, String sendDate, String productlist,
String contact_name, String contact_phone, String ts) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.UpdateOrders", new String[] {
"visit_type", "orderid", "sendDate",
"productlist", "ts" },
new Object[] { visit_type, orderid, sendDate,
productlist, ts }));
}
IUAPQueryBS qry = NCLocator.getInstance().lookup(IUAPQueryBS.class);
// app端
if (visit_type != null && visit_type.equals("app")) {
String wherestr = " dr=0 and pk_saleorder=‘" + orderid + "‘";
getDAO().deleteByClause(SaleorderB.class, wherestr);
String sql = " select * from webts_Saleorder where dr=0 and pk_saleorder=‘"
+ orderid + "‘";
@SuppressWarnings("unchecked")
List<Saleorder> lists = (List<Saleorder>) dao.executeQuery(sql,
new BeanListProcessor(Saleorder.class));
if (lists.size() > 0) {
Saleorder sorder = lists.get(0);
sorder.setVname(contact_name);
sorder.setVphoneno(contact_phone);
sorder.setVdef1(new UFDate(sendDate).toString());
getDAO().updateVO(sorder);
}
// 解析json字符串
JSONArray jsonarray = new JSONArray(productlist);
List<SaleorderB> list = new ArrayList<SaleorderB>();
for (int i = 0; i < jsonarray.length(); i++) {
org.json.JSONObject jo = jsonarray.getJSONObject(i);
String pk_material = jo.get("productid").toString();
UFDouble nnum = new UFDouble(jo.get("num").toString());
String materialname = jo.get("materialname").toString();
String materialspec = jo.get("materialspec").toString();
SaleorderB saleb = new SaleorderB();
saleb.setPk_saleorder(orderid);
saleb.setPk_material(pk_material);
saleb.setNnum(nnum);
saleb.setCrowno("" + (i + 1) * 10);
saleb.setPk_unit("0001Z0100000000000XU");// 计量单位:箱
saleb.setInvname(materialname);
saleb.setInvspec(materialspec);
saleb.setDsenddate(new UFDate(sendDate));
// saleb.setStatus(ISaleOrderConst.APPROVE_B);//已审核
/**
* TODO 2.带出表体对应的经销商nc.yangh.webts.SaleOrder.SaleOrder.
* SaleOrderCardWinMainViewCtrl.afterEdit(CellEvent)
*/
IMaterialBaseInfoQueryService materialQry = NCLocator
.getInstance().lookup(
IMaterialBaseInfoQueryService.class);
if (pk_material != null && pk_material.trim().length() > 0) {
MaterialVO materialvo = materialQry
.queryDataByPks(new String[] { pk_material })[0];
saleb.setSubclass(materialvo.getPk_marbasclass());
@SuppressWarnings("unchecked")
ArrayList<String> jxs = (ArrayList<String>) qry
.executeQuery(
"select code from webts_goodsrelation_h where"
+ " pk_relation in (select distinct(b.pk_relation) from webts_goodsrelation_order a "
+ " full join webts_goodsrelation_person b on a.pk_relation=b.pk_relation where nvl(a.dr,0)=0 and nvl(b.dr,0)=0 "
+ " and pk_psndoc=‘" + usrid
+ "‘ and a.pk_material=‘"
+ pk_material
+ "‘ ) and nvl(dr,0)=0",
new ColumnListProcessor());
if (jxs.size() == 1) {
saleb.setPk_dealer(jxs.get(0));
}
}
list.add(saleb);
}
SaleorderB[] salebs = list.toArray(new SaleorderB[0]);
getDAO().insertVOArray(salebs);
}
// 微信端
// else
// {
//
// }
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "0");
resMap.put("des", "更新成功");
resMap.put("ts", currenttime.toString());
resList.add(resMap);
return resList;
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* @description 获取订单子表详情
* @author wangchunhui
*/
@SuppressWarnings("unused")
@Override
public ArrayList<Map<String, Object>> GetOrderBlist(String visit_type,
String usrid, String orderid, String ts) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetOrderBlist", new String[] {
"visit_type", "usrid", "ts" }, new Object[] {
visit_type, usrid, visit_type, ts, }));
}
// StringBuffer strbuf = new StringBuffer("select * from (select ");
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_saleorder as orderid");
// strbuf.append(" ,to_char((to_date(t.dsenddate,‘yyyy-mm-dd,hh24:mi:ss‘)-to_date(‘1970-01-01‘,‘yyyy-mm-dd‘))*24*60*60*1000) as sendDate");
// strbuf.append(" ,to_char(to_date(t.dsenddate,‘yyyy-mm-dd‘)) as sendDate");
strbuf.append(" , substr(t.dsenddate,0,10) as senddate");
strbuf.append(" ,t.pk_material as productid");
strbuf.append(" ,t1.vname as contact_name");
strbuf.append(" ,t1.vphoneno as contact_phone");
strbuf.append(" ,t.nnum as num");
strbuf.append(" ,t.invname as name");
strbuf.append(" ,t.invspec as materialspec");
StringBuffer subbuf = new StringBuffer(
" from webts_SaleorderB t "
+ " left join webts_Saleorder t1 on t1.pk_saleorder=t.pk_saleorder"
// +
// " left join (select t2.pk_channelnode,t2.vname,t2.vlinkman,t2.vmobilephone from webts_Saleorder t1 join dcm_chnlnode t2 on t2.pk_channelnode=t.pk_channel where t1.dr=0 and t1.pk_saleorder=‘"+orderid+"‘) s on "
+ " where t.dr=0 and t.pk_saleorder=‘" + orderid
+ "‘");
// app端
if (visit_type != null && visit_type.equals("app")) {
}
// 微信端
// else
// {
//
// }
PageController pageController = new PageController(50, 1,
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
// strbuf.append(" and rownum <=" + endIndex +
// " order by invname) where rn>="
strbuf.append(" order by t.invname ) A where rownum <=" + endIndex
+ " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
JSONArray jsonArray = new JSONArray();
String senddate = null;
String contact_name = null;
String contact_phone = null;
if (lists.size() > 0) {
senddate = lists.get(0).get("senddate") == null ? "" : lists
.get(0).get("senddate").toString();
contact_name = lists.get(0).get("contact_name") == null ? ""
: lists.get(0).get("contact_name").toString();
contact_phone = lists.get(0).get("contact_phone") == null ? ""
: lists.get(0).get("contact_phone").toString();
}
for (int i = 0; i < lists.size(); i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.put(
"productid",
lists.get(i).get("productid") == null ? "" : lists
.get(i).get("productid").toString());
jsonObject.put("num", lists.get(i).get("num") == null ? ""
: lists.get(i).get("num").toString());
jsonObject.put("name", lists.get(i).get("name") == null ? ""
: lists.get(i).get("name").toString());
jsonObject.put("materialspec",
lists.get(i).get("materialspec") == null ? "" : lists
.get(i).get("materialspec").toString());
jsonObject.put("unit", "箱");
jsonArray.put(jsonObject);
}
lists.clear();
Map<String, Object> tempMap = new HashMap<String, Object>();
tempMap.put("orderid", orderid);
tempMap.put("senddate", senddate);
tempMap.put("contact_name", contact_name);
tempMap.put("contact_phone", contact_phone);
tempMap.put("productlist", jsonArray.toString());
lists.add((HashMap<String, Object>) tempMap);
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* 待收获列表
*
* @author heyang
*
*/
@Override
public ArrayList<Map<String, Object>> GetOrderconfirmlist(
String visit_type, String usrid, String search_text, String istatus,String ts,
String pageNum, String pagerows) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetOrderconfirmlist",
new String[] { "visit_type", "usrid", "search_text","istatus",
"ts", "pageNum", "pagerows" }, new Object[] {
visit_type, usrid, search_text,istatus, ts, pageNum,
pagerows }));
}
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
// strbuf.append(" t.pk_accounts as pk_accounts");
// strbuf.append(" ,t.nsendnum as sendcount");
strbuf.append(" distinct s.channelnodeid as pk_channelnode");
if ("0".equals(istatus)) {
strbuf.append(" ,t.dsenddate as senddate");}
else{
strbuf.append(" ,t.dreceivedate as receivedate");
}
strbuf.append(" ,s.channelname as vname");
strbuf.append(" ,s.contact_phone as vmobilephone");
strbuf.append(" ,s.contact_name as vlinkman");
strbuf.append(" ,s.addrname as addrname");
strbuf.append(" ,s.chnltype as chnlname");
// strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
// strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
// strbuf.append(" ,to_char((to_date(t.creationtime,‘yyyy-mm-dd,hh24:mi:ss‘)-to_date(‘1970-01-01‘,‘yyyy-mm-dd‘))*24*60*60*1000) as orderTime");
// strbuf.append(" ,t.creationtime as orderTime");
StringBuffer subbuf = new StringBuffer(
" from webts_goodaccounts t "
// +
// " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
+ " left join (select t1.vname as vname,t1.pk_channelnode as channelnodeid,t1.vname as channelname,t1.vmobilephone as contact_phone,t1.vlinkman as contact_name,t2.detailinfo as addrname,t3.name as chnltype "
+ " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
+ " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
+ " where t.dr=0 and nvl(t.istatus,0) = "+istatus);
if (!visit_type.isEmpty() && visit_type.equals("app")) {
// if (!groupid.isEmpty()) {
// subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
// }
if (!usrid.isEmpty()) {
subbuf.append(" and t.pk_psndoc=‘" + usrid + "‘ ");
}
if (!search_text.isEmpty()) {
subbuf.append(" and (s.channelname like ‘%" + search_text
+ "%‘ or s.addrname like ‘%" + search_text + "%‘)");
}
// if (!orderstate.isEmpty()) {
// subbuf.append(" and t.ibillstatus="
// + Integer.parseInt(orderstate) + "");
// }
}
// 微信端
// else
// {
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
strbuf.append(" and (t.dsenddate is null or t.dsenddate = (select max(t4.dsenddate) from webts_goodaccounts t4 where t4.pk_channel=s.channelnodeid)) ");
strbuf.append(" and (t.dreceivedate is null or t.dreceivedate = (select max(t4.dreceivedate) from webts_goodaccounts t4 where t4.pk_channel=s.channelnodeid)) ");
if ("0".equals(istatus)) {
strbuf.append(" order by t.dsenddate desc ");
}else {
strbuf.append(" order by t.dreceivedate desc ");
}
strbuf.append(") A where rownum <="
+ endIndex + " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: 操作异常
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* 待收货网点明细
*/
@Override
public ArrayList<Map<String, Object>> GetOrderBconfirmlist(
String channelnodeid, String usrid, String visit_type,String istatus,
String pageNum, String pagerows, String ts) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetOrderBconfirmlist",
new String[] { "channelnodeid", "usrid", "visit_type",
"istatus","pageNum", "pagerows", "ts" }, new Object[] {
channelnodeid, usrid, ts, visit_type,istatus, pageNum,
pagerows, ts }));
}
StringBuffer strbuf = new StringBuffer(
"select * from (select A.*,rownum rn from (select ");
strbuf.append(" t.pk_accounts as id");// 台帐主键
strbuf.append(" ,to_char(t.nnum) as num");// 要货数量
strbuf.append(" ,t.pk_material as productid"); // 产品pk
strbuf.append(" ,m.name as name"); // 产品名称
strbuf.append(" ,t.unit as unit"); // 产品单位
strbuf.append(" ,t.invspec as materialspec"); // 产品规格
strbuf.append(" ,to_char(t.nsendnum) as sendnum");// 发货数量
strbuf.append(" ,to_char(t.nfinishnum) as finishnum");// 累计发货数量
strbuf.append(" ,t.sendman as sendman");// 发货人
strbuf.append(" ,s.addrname as addrname");// 地址
strbuf.append(" ,substr(t.dsenddate,0,16) as dsenddate");// 发货日期
// strbuf.append(" ,to_char(t.ntotalrevnum) as ntotalrevnum");//
// 累计收获数量
// strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
// strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
// strbuf.append(" ,to_char((to_date(t.creationtime,‘yyyy-mm-dd,hh24:mi:ss‘)-to_date(‘1970-01-01‘,‘yyyy-mm-dd‘))*24*60*60*1000) as orderTime");
// strbuf.append(" ,t.creationtime as orderTime");
StringBuffer subbuf = new StringBuffer(
" from webts_goodaccounts t "
+ " left join bd_material m on m.pk_material=t.pk_material "
+ " left join (select t1.vname as vname,t1.pk_channelnode as channelnodeid,t1.vname as channelname,t1.vmobilephone as contact_phone,t1.vlinkman as contact_name,t2.detailinfo as addrname,t3.name as chnltype "
+ " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
+ " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
+ " where t.dr=0 and nvl(t.istatus,0) ="+istatus+" and t.pk_channel=‘"
+ channelnodeid + "‘");
if (!visit_type.isEmpty() && visit_type.equals("app")) {
// if (!groupid.isEmpty()) {
// subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
// }
}
// 微信端
// else
// {
//
// }
PageController pageController = new PageController(
Integer.parseInt(pagerows), Integer.parseInt(pageNum),
subbuf.toString());
PageInfo pageinfo = new PageInfo();
pageinfo = pageController.getPageinfo();
int beginIndex = pageinfo.getM_iStartRow();
int endIndex = pageinfo.getM_iEndRow();
strbuf.append(subbuf).toString();
strbuf.append(" order by t.dsenddate ) A where rownum <="
+ endIndex + " ) where rn>=" + beginIndex + "");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
for (int i = 0; i < lists.size(); i++) {
String productid = (String) lists.get(i).get("productid");
// 累计收获数量的计算。查询台帐里的相同产品的收货数量+加上本次确认的是就是本次累计收货数量
String querysql = "select sum(nvl(nreveivenum,0)) as beforerecievenum from webts_goodaccounts where pk_material=‘"
+ productid + "‘ and nvl(dr,0)=0 and nvl(istatus,0)="+istatus;
IUAPQueryBS queryBS = (IUAPQueryBS) NCLocator.getInstance()
.lookup(IUAPQueryBS.class.getName());
ArrayList<HashMap<String, Object>> list1 = (ArrayList<HashMap<String, Object>>) queryBS
.executeQuery(querysql, new MapListProcessor());
UFDouble beforerecievenum = new UFDouble(String.valueOf(list1
.get(0).get("beforerecievenum") == null ? "0" : list1
.get(0).get("beforerecievenum")));
lists.get(i).put("totalrevnum", beforerecievenum.toString());
}
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: 操作异常
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
*
* 收获确认
*
* @param id
* @param reveivenum
* @param ts
* @return
*/
@Override
public ArrayList<Map<String, Object>> UpdateGoodsaccounts(
String reveiveinfo, String ts) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.UpdateOrders", new String[] {
"reveiveinfo", "ts" }, new Object[] {
reveiveinfo, ts }));
}
// 解析字符串
// 解析
org.json.JSONArray jsonarray = new JSONArray(reveiveinfo);
// 遍历
for (int i = 0; i < jsonarray.length(); i++) {
org.json.JSONObject jo = jsonarray.getJSONObject(i);
String id = (String) jo.get("id");// 台帐id
String pk_material = (String) jo.get("productid");
String reveivenum = (String) jo.get("reveivenum");// 本次收货数量
String userid = (String) jo.get("userid");
UFDouble receivenum = new UFDouble(reveivenum);
// 累计收获数量的计算。查询台帐里的相同产品的收货数量+加上本次确认的是就是本次累计收货数量
String querysql = "select sum(nvl(nreveivenum,0)) as beforerecievenum from webts_goodaccounts where pk_material=‘"
+ pk_material
+ "‘ and nvl(dr,0)=0 and nvl(istatus,0)=1";
IUAPQueryBS queryBS = (IUAPQueryBS) NCLocator.getInstance()
.lookup(IUAPQueryBS.class.getName());
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) queryBS
.executeQuery(querysql, new MapListProcessor());
UFDouble beforerecievenum = new UFDouble(String.valueOf(lists
.get(0).get("beforerecievenum") == null ? "0" : lists
.get(0).get("beforerecievenum")));
UFDouble totalreceivenum = beforerecievenum.add(receivenum);// 累计收货数量
String sql = "update webts_goodaccounts set nreveivenum="
+ receivenum + ",istatus=1,ntotalrevnum="
+ totalreceivenum +", dreceiveman=\‘"+userid+"\‘,dreceivedate=\‘"+new UFDateTime().toStdString() + "\‘ where pk_accounts=‘" + id
+ "‘ and nvl(dr,0)=0";
getDAO().executeUpdate(sql);
}
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "0");
resMap.put("des", "更新成功");
resMap.put("ts", currenttime.toString());
resList.add(resMap);
return resList;
} catch (Exception e) {
// TODO: handle exception
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
/**
* 待收获列表
*
* @author heyang
*
*/
@Override
public ArrayList<Map<String, Object>> GetOrdercounts(
String visit_type, String usrid, String ts
) {
// TODO 自动生成的方法存根
try {
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error(MobileCommon.getRequestDebugInfo(
"SaleOrderMobileService.GetOrdercounts",
new String[] { "visit_type", "usrid",
"ts"}, new Object[] {
visit_type, usrid, ts}));
}
StringBuffer strbuf = new StringBuffer(
"select to_char(count(*)) AS num from (select A.*,rownum rn from (select ");
// strbuf.append(" t.pk_accounts as pk_accounts");
// strbuf.append(" ,t.nsendnum as sendcount");
strbuf.append(" distinct s.channelnodeid as pk_channelnode");
strbuf.append(" ,s.channelname as vname");
strbuf.append(" ,s.contact_phone as vmobilephone");
strbuf.append(" ,s.contact_name as vlinkman");
strbuf.append(" ,s.addrname as addrname");
strbuf.append(" ,s.chnltype as chnlname");
// strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
// strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
// strbuf.append(" ,to_char((to_date(t.creationtime,‘yyyy-mm-dd,hh24:mi:ss‘)-to_date(‘1970-01-01‘,‘yyyy-mm-dd‘))*24*60*60*1000) as orderTime");
// strbuf.append(" ,t.creationtime as orderTime");
StringBuffer subbuf = new StringBuffer(
" from webts_goodaccounts t "
// +
// " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
+ " left join (select t1.vname as vname,t1.pk_channelnode as channelnodeid,t1.vname as channelname,t1.vmobilephone as contact_phone,t1.vlinkman as contact_name,t2.detailinfo as addrname,t3.name as chnltype "
+ " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
+ " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
+ " where t.dr=0 and nvl(t.istatus,0) !=1");
if (!visit_type.isEmpty() && visit_type.equals("app")) {
// if (!groupid.isEmpty()) {
// subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
// }
if (!usrid.isEmpty()) {
subbuf.append(" and t.pk_psndoc=‘" + usrid + "‘ ");
}
}
// 微信端
// else
// {
//
// }
strbuf.append(subbuf).toString();
strbuf.append(" order by s.channelname ) A )");
UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
.executeQuery(strbuf.toString(), getMapListProcessor());
if (LfwLogger.isErrorEnabled()) {
LfwLogger.error("***************" + strbuf.toString()
+ "***************");
}
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
if (lists == null || lists.size() <= 0) {
map.put("flag", 0);
map.put("des", "没有符合条件的数据");
arrFinal.add(map);
return arrFinal;
} else {
map.put("flag", "0");
map.put("des", "查询成功");
map.put("ts", currenttime.toString());
map.put("resultList", lists);
ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map);
return list;
}
} catch (Exception e) {
// TODO: 操作异常
LfwLogger.error(e.getMessage(), e);
ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
Map<String, Object> resMap = new HashMap<String, Object>();
resMap.put("flag", "1");
resMap.put("des", e.getMessage());
resList.add(resMap);
return resList;
}
}
}
标签:
原文地址:http://www.cnblogs.com/lanzhiming/p/4902414.html