码迷,mamicode.com
首页 > 其他好文 > 详细

使用BaseDao新建服务

时间:2015-10-22 20:50:48      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:

  1. if (myMapListprocessor == null) {
  2. myMapListprocessor = new MapListProcessor();
  3. }
  4. String sql="";
  5. try {
  6. new BaseDAO().executeQuery(sql, myMapListprocessor);
  7. } catch (DAOException e) {
  8. // TODO 自动生成的 catch 块
  9. e.printStackTrace();
  10. }
  11. out.write(edit.toString());
示例
  1. package nc.saleorder.services;
  2. import java.util.ArrayList;
  3. import java.util.Date;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.json.JSONArray;
  8. import org.json.JSONObject;
  9. import nc.bs.ca.capub.mobile.common.MobileCommon;
  10. import nc.bs.dao.BaseDAO;
  11. import nc.bs.framework.common.NCLocator;
  12. import nc.itf.bd.material.baseinfo.IMaterialBaseInfoQueryService;
  13. import nc.itf.uap.IUAPQueryBS;
  14. import nc.jdbc.framework.processor.ArrayProcessor;
  15. import nc.jdbc.framework.processor.BeanListProcessor;
  16. import nc.jdbc.framework.processor.ColumnListProcessor;
  17. import nc.jdbc.framework.processor.MapListProcessor;
  18. import nc.saleorder.itf.ISaleOrderMobileService;
  19. import nc.saleorder.itf.PageController;
  20. import nc.uap.lfw.core.log.LfwLogger;
  21. import nc.ui.bill.depend.PageInfo;
  22. import nc.vo.bd.material.MaterialVO;
  23. import nc.vo.pub.lang.UFDate;
  24. import nc.vo.pub.lang.UFDateTime;
  25. import nc.vo.pub.lang.UFDouble;
  26. import nc.vo.pubapp.AppContext;
  27. import nc.vo.webts.webts_saleorder.Saleorder;
  28. import nc.vo.webts.webts_saleorder.SaleorderB;
  29. import nc.yanghe.saleorder.constant.ISaleOrderConst;
  30. public class SaleOrderMobileService implements ISaleOrderMobileService {
  31. private BaseDAO dao;
  32. private BaseDAO getDAO() {
  33. if (dao == null)
  34. this.dao = new BaseDAO();
  35. return dao;
  36. }
  37. // @SuppressWarnings("unused")
  38. // private String transNulltoString(Object tempStr)
  39. // {
  40. // return tempStr== null ? ""
  41. // : tempStr.toString();
  42. // }
  43. private MapListProcessor myMapListprocessor;
  44. private MapListProcessor getMapListProcessor() {
  45. if (myMapListprocessor == null)
  46. myMapListprocessor = new MapListProcessor();
  47. return myMapListprocessor;
  48. }
  49. // 获取渠道节点
  50. /**
  51. * @description 获取渠道网点
  52. * @author wangchunhui
  53. */
  54. public ArrayList<Map<String, Object>> GetChnls(String groupid,
  55. String usrid, String search_text, String visit_type, String ts,
  56. String pageNum, String pagerows) {
  57. try {
  58. if (LfwLogger.isErrorEnabled()) {
  59. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  60. "SaleOrderMobileService.GetChnls", new String[] {
  61. "groupid", "usrid", "search_text",
  62. "visit_type", "ts", "pageNum", "pagerows" },
  63. new Object[] { groupid, usrid, search_text, visit_type,
  64. ts, pageNum, pagerows }));
  65. }
  66. // StringBuffer strbuf = new StringBuffer("select * from (select ");
  67. StringBuffer strbuf = new StringBuffer(
  68. "select * from (select A.*,rownum rn from (select ");
  69. strbuf.append(" t.pk_channelnode as pk_channelnode");
  70. strbuf.append(" ,t.vname as vname");
  71. strbuf.append(" ,t1.detailinfo as addrname");
  72. strbuf.append(" ,t2.name as chnlname");
  73. strbuf.append(" ,t.vlinkman as vlinkman");
  74. strbuf.append(" ,t.vmobilephone as vmobilephone");
  75. StringBuffer subbuf = new StringBuffer(
  76. " from dcm_chnlnode t "
  77. + " left join bd_address t1 on t1.pk_address=t.clinkaddrid"
  78. + " left join bd_channeltype t2 on t2.pk_type=t.cchanltypeid"
  79. + " where t.dr=0 ");
  80. // app端
  81. if (visit_type != null && visit_type.equals("app")) {
  82. if (groupid != null && !groupid.equals("")) {
  83. subbuf.append(" and t.pk_group=‘" + groupid + "‘");
  84. }
  85. if (search_text != null && !search_text.equals("")) {
  86. subbuf.append(" and (t.vlinkman like ‘%" + search_text
  87. + "%‘ or t.vname like ‘%" + search_text
  88. + "%‘ or t.vmobilephone like ‘%" + search_text
  89. + "%‘ or t1.detailinfo like ‘%" + search_text
  90. + "%‘)");
  91. }
  92. if (usrid != null && !usrid.equals("")) {
  93. subbuf.append(" and t.pk_channelnode in(select u.chnlnode "
  94. + "from cv_visitline_nodeb u " + " where u.dr = 0 "
  95. + " and u.pk_visitline in "
  96. + " (select pk_visitline " + " from cv_visitline "
  97. + " where dr=0 " + " and enablestate=2 "
  98. + " and pk_visitline in "
  99. + " (select s.pk_visitline "
  100. + "from cv_visitline_userb s " + " where s.dr = 0 "
  101. + " and s.bvalidstatus=‘Y‘ " + " and s.userid =‘"
  102. + usrid + "‘ )))");
  103. }
  104. }
  105. // 店长微信
  106. // else{
  107. //
  108. // }
  109. PageController pageController = new PageController(
  110. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  111. subbuf.toString());
  112. PageInfo pageinfo = new PageInfo();
  113. pageinfo = pageController.getPageinfo();
  114. int beginIndex = pageinfo.getM_iStartRow();
  115. int endIndex = pageinfo.getM_iEndRow();
  116. strbuf.append(subbuf).toString();
  117. // strbuf.append(" and rownum <=" + endIndex +
  118. // " order by t.vname ) where rn>="
  119. strbuf.append(" order by t.vname ) A where rownum <=" + endIndex
  120. + " ) where rn>=" + beginIndex + "");
  121. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  122. @SuppressWarnings("unchecked")
  123. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  124. .executeQuery(strbuf.toString(), getMapListProcessor());
  125. if (LfwLogger.isErrorEnabled()) {
  126. LfwLogger.error("***************" + strbuf.toString()
  127. + "***************");
  128. }
  129. // CacheManager.setObject("123", lists);
  130. // ArrayList<HashMap<String, Object>>
  131. // lists2=(ArrayList<HashMap<String,
  132. // Object>>)CacheManager.getObject("123");
  133. Map<String, Object> map = new HashMap<String, Object>();
  134. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  135. if (lists == null || lists.size() <= 0) {
  136. map.put("flag", 0);
  137. map.put("des", "没有符合条件的数据");
  138. arrFinal.add(map);
  139. return arrFinal;
  140. } else {
  141. map.put("flag", "0");
  142. map.put("des", null);
  143. map.put("ts", currenttime.toString());
  144. map.put("resultList", lists);
  145. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  146. list.add(map);
  147. return list;
  148. }
  149. } catch (Exception e) {
  150. // TODO: handle exception
  151. LfwLogger.error(e.getMessage(), e);
  152. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  153. Map<String, Object> resMap = new HashMap<String, Object>();
  154. resMap.put("flag", "1");
  155. resMap.put("des", e.getMessage());
  156. resList.add(resMap);
  157. return resList;
  158. }
  159. }
  160. // 获取物料分类
  161. /**
  162. * @description 获取物料分类
  163. * @author wangchunhui
  164. */
  165. public ArrayList<Map<String, Object>> GetMaterielCategorys(String groupid,
  166. String usrid, String visit_type, String parentid, String ts,
  167. String pageNum, String pagerows) {
  168. // ArrayList<Map<String, Object>> arr = new ArrayList<Map<String,
  169. // Object>>();
  170. // return arr;
  171. try {
  172. if (LfwLogger.isErrorEnabled()) {
  173. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  174. "SaleOrderMobileService.GetMaterielCategorys",
  175. new String[] { "groupid", "usrid", "visit_type",
  176. "parentid", "ts", "pageNum", "pagerows" },
  177. new Object[] { groupid, usrid, visit_type, parentid,
  178. ts, pageNum, pagerows }));
  179. }
  180. StringBuffer strbuf = new StringBuffer(
  181. "select * from (select A.*,rownum rn from (select ");
  182. strbuf.append(" t.pk_marbasclass as pk_marbasclass");
  183. strbuf.append(" ,t.code as materialclasscode");
  184. strbuf.append(" ,t.name as materialclassname");
  185. // strbuf.append(" ,to_char((select count(*) from t1 where t1.pk_parent =t.pk_marbasclass)) ishavechild");
  186. StringBuffer subbuf = new StringBuffer(
  187. " from bd_marbasclass t where t.dr=0");
  188. // app端
  189. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  190. if (!groupid.isEmpty()) {
  191. subbuf.append(" and t.pk_group=‘" + groupid + "‘");
  192. }
  193. // if (!parentid.isEmpty() ) {
  194. // subbuf.append(" and t.pk_marbasclass=‘" + parentid + "‘");
  195. // }
  196. if (!usrid.isEmpty()) {
  197. 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="
  198. + " (select pk_org from cp_user where cuserid=‘"
  199. + usrid
  200. + "‘) and t2.pk_material=t1.pk_material and t2.enablestate=2))");
  201. }
  202. }
  203. // 微信端
  204. // else{
  205. //
  206. // }
  207. PageController pageController = new PageController(
  208. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  209. subbuf.toString());
  210. PageInfo pageinfo = new PageInfo();
  211. pageinfo = pageController.getPageinfo();
  212. int beginIndex = pageinfo.getM_iStartRow();
  213. int endIndex = pageinfo.getM_iEndRow();
  214. strbuf.append(subbuf).toString();
  215. // strbuf.append(" and rownum <=" + endIndex +
  216. // " order by rownum) where rn>="
  217. strbuf.append(" order by t.name ) A where rownum <=" + endIndex
  218. + " ) where rn>=" + beginIndex + "");
  219. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  220. @SuppressWarnings("unchecked")
  221. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  222. .executeQuery(strbuf.toString(), getMapListProcessor());
  223. if (LfwLogger.isErrorEnabled()) {
  224. LfwLogger.error("***************" + strbuf.toString()
  225. + "***************");
  226. }
  227. Map<String, Object> map = new HashMap<String, Object>();
  228. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  229. if (lists == null || lists.size() <= 0) {
  230. map.put("flag", 0);
  231. map.put("des", "没有符合条件的数据");
  232. arrFinal.add(map);
  233. return arrFinal;
  234. } else {
  235. map.put("flag", "0");
  236. map.put("des", "查询成功");
  237. map.put("ts", currenttime.toString());
  238. map.put("resultList", lists);
  239. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  240. list.add(map);
  241. return list;
  242. }
  243. } catch (Exception e) {
  244. // TODO: handle exception
  245. LfwLogger.error(e.getMessage(), e);
  246. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  247. Map<String, Object> resMap = new HashMap<String, Object>();
  248. resMap.put("flag", "1");
  249. resMap.put("des", e.getMessage());
  250. resList.add(resMap);
  251. return resList;
  252. }
  253. }
  254. // 获取物料
  255. /**
  256. * @description 获取物料
  257. * @author wangchunhui
  258. */
  259. public ArrayList<Map<String, Object>> GetMateriels(String groupid,
  260. String usrid, String search_text, String pk_marbasclass,
  261. String visit_type, String ts, String pageNum, String pagerows) {
  262. try {
  263. if (LfwLogger.isErrorEnabled()) {
  264. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  265. "SaleOrderMobileService.GetMateriels", new String[] {
  266. "groupid", "usrid", "search_text",
  267. "pk_marbasclass", "visit_type", "ts",
  268. "pageNum", "pagerows" }, new Object[] {
  269. groupid, usrid, search_text, pk_marbasclass,
  270. visit_type, ts, pageNum, pagerows }));
  271. }
  272. StringBuffer strbuf = new StringBuffer(
  273. "select * from (select A.*,rownum rn from (select ");
  274. strbuf.append(" t.pk_material as pk_material");
  275. strbuf.append(" ,t.name as name");
  276. // strbuf.append(" ,s.name as unit");
  277. strbuf.append(" ,t.materialspec as materialspec");
  278. StringBuffer subbuf = new StringBuffer(
  279. " from (select * from BD_MATERIAL order by name) t "
  280. // + " left join bd_measdoc s on s.pk_measdoc=t.pk_measdoc"
  281. + " where t.dr=0 ");
  282. // app端
  283. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  284. if (!groupid.isEmpty()) {
  285. subbuf.append(" and t.pk_group=‘" + groupid + "‘");
  286. }
  287. if (!search_text.isEmpty()) {
  288. subbuf.append(" and (t.code like ‘%" + search_text
  289. + "%‘ or t.name like ‘%" + search_text + "%‘)");
  290. }
  291. if (!usrid.isEmpty()) {
  292. subbuf.append(" and t.pk_material in"
  293. + "(select distinct u.pk_material from BD_MARORG u where u.enablestate=2 and u.pk_org="
  294. + "(select pk_org from cp_user where cuserid=‘"
  295. + usrid + "‘))");
  296. }
  297. }
  298. if (!pk_marbasclass.isEmpty()) {
  299. // String sql =
  300. // "select * from bd_marbasclass where dr=0 and pk_marbasclass=‘"
  301. // + pk_marbasclass + "‘";
  302. // BaseDAO dao = new BaseDAO();
  303. // @SuppressWarnings("unchecked")
  304. // List<MarBasClassVO> lists = (List<MarBasClassVO>) dao
  305. // .executeQuery(sql, new BeanListProcessor(
  306. // MarBasClassVO.class));
  307. // if (lists.size() > 0) {
  308. // if (lists.get(0).getCode().length() == 13) {
  309. // subbuf.append(" and t.pk_marbasclass=‘"
  310. // + pk_marbasclass + "‘");
  311. // } else if (lists.get(0).getCode().length() == 10) {
  312. // subbuf.append(" and (t.pk_marbasclass=‘"
  313. // + pk_marbasclass
  314. // + "‘ or t.pk_marbasclass in"
  315. // +
  316. // "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
  317. // + pk_marbasclass + "‘))");
  318. // } else if (lists.get(0).getCode().length() == 7) {
  319. // subbuf.append(" and (t.pk_marbasclass in"
  320. // +
  321. // "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
  322. // + pk_marbasclass
  323. // + "‘) or "
  324. // +
  325. // " t.pk_marbasclass in(select pk_marbasclass from bd_marbasclass where pk_parent in"
  326. // +
  327. // "(select pk_marbasclass from bd_marbasclass where pk_parent=‘"
  328. // + pk_marbasclass + "‘)))");
  329. // }
  330. // }
  331. subbuf.append(" and t.pk_marbasclass=‘" + pk_marbasclass + "‘");
  332. }
  333. // 微信端
  334. // else{
  335. //
  336. // }
  337. PageController pageController = new PageController(
  338. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  339. subbuf.toString());
  340. PageInfo pageinfo = new PageInfo();
  341. pageinfo = pageController.getPageinfo();
  342. int beginIndex = pageinfo.getM_iStartRow();
  343. int endIndex = pageinfo.getM_iEndRow();
  344. strbuf.append(subbuf).toString();
  345. strbuf.append(" order by t.name ) A where rownum <=" + endIndex
  346. + " ) where rn>=" + beginIndex + "");
  347. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  348. @SuppressWarnings("unchecked")
  349. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  350. .executeQuery(strbuf.toString(), getMapListProcessor());
  351. for (int i = 0; i < lists.size(); i++) {
  352. lists.get(i).put("unit", "箱");
  353. }
  354. if (LfwLogger.isErrorEnabled()) {
  355. LfwLogger.error("***************" + strbuf.toString()
  356. + "***************");
  357. }
  358. Map<String, Object> map = new HashMap<String, Object>();
  359. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  360. if (lists == null || lists.size() <= 0) {
  361. map.put("flag", 0);
  362. map.put("des", "没有符合条件的数据");
  363. arrFinal.add(map);
  364. return arrFinal;
  365. } else {
  366. map.put("flag", "0");
  367. map.put("des", "查询成功");
  368. map.put("ts", currenttime.toString());
  369. map.put("resultList", lists);
  370. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  371. list.add(map);
  372. return list;
  373. }
  374. } catch (Exception e) {
  375. // TODO: handle exception
  376. LfwLogger.error(e.getMessage(), e);
  377. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  378. Map<String, Object> resMap = new HashMap<String, Object>();
  379. resMap.put("flag", "1");
  380. resMap.put("des", e.getMessage());
  381. resList.add(resMap);
  382. return resList;
  383. }
  384. }
  385. /**
  386. * @description 获取订单列表
  387. * @author wangchunhui
  388. */
  389. @Override
  390. public ArrayList<Map<String, Object>> GetOrderlist(String groupid,
  391. String usrid, String search_text, String orderstate,
  392. String visit_type, String ts, String pageNum, String pagerows) {
  393. // TODO 自动生成的方法存根
  394. try {
  395. if (LfwLogger.isErrorEnabled()) {
  396. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  397. "SaleOrderMobileService.GetOrderlist", new String[] {
  398. "groupid", "usrid", "search_text",
  399. "orderstate", "visit_type", "ts", "pageNum",
  400. "pagerows" }, new Object[] { groupid, usrid,
  401. search_text, orderstate, visit_type, ts,
  402. pageNum, pagerows }));
  403. }
  404. StringBuffer strbuf = new StringBuffer(
  405. "select * from (select A.*,rownum rn from (select ");
  406. strbuf.append(" t.pk_saleorder as id");
  407. strbuf.append(" ,t.vbillno as vbillno");
  408. strbuf.append(" ,s.channelname as channelname");
  409. strbuf.append(" ,s.channelnodeid as channelnodeid");
  410. strbuf.append(" ,s.contact_phone as contact_phone");
  411. strbuf.append(" ,s.contact_name as contact_name");
  412. strbuf.append(" ,s.addrname as addrname");
  413. strbuf.append(" ,s.chnltype as chnltype");
  414. // strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
  415. strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
  416. // 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");
  417. strbuf.append(" ,t.creationtime as orderTime");
  418. StringBuffer subbuf = new StringBuffer(
  419. " from webts_Saleorder t "
  420. // +
  421. // " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
  422. + " 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 "
  423. + " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
  424. + " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
  425. + " where t.dr=0 ");
  426. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  427. if (!groupid.isEmpty()) {
  428. subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
  429. }
  430. if (!usrid.isEmpty()) {
  431. subbuf.append(" and t.creator=‘" + usrid + "‘ ");
  432. }
  433. if (!search_text.isEmpty()) {
  434. subbuf.append(" and (t.vbillno like ‘%" + search_text
  435. + "%‘ or s.vname like ‘%" + search_text + "%‘)");
  436. }
  437. if (!orderstate.isEmpty()) {
  438. subbuf.append(" and t.ibillstatus="
  439. + Integer.parseInt(orderstate) + "");
  440. }
  441. }
  442. subbuf.append(" and t.vsource=‘" + ISaleOrderConst.SOURCE_APP
  443. + "‘");
  444. // 微信端
  445. // else
  446. // {
  447. //
  448. // }
  449. PageController pageController = new PageController(
  450. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  451. subbuf.toString());
  452. PageInfo pageinfo = new PageInfo();
  453. pageinfo = pageController.getPageinfo();
  454. int beginIndex = pageinfo.getM_iStartRow();
  455. int endIndex = pageinfo.getM_iEndRow();
  456. strbuf.append(subbuf).toString();
  457. strbuf.append(" order by t.creationtime desc) A where rownum <="
  458. + endIndex + " ) where rn>=" + beginIndex + "");
  459. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  460. @SuppressWarnings("unchecked")
  461. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  462. .executeQuery(strbuf.toString(), getMapListProcessor());
  463. for (int i = 0; i < lists.size(); i++) {
  464. JSONObject jsonObject = new JSONObject();
  465. jsonObject.put("channelnodeid",
  466. lists.get(i).get("channelnodeid") == null ? "" : lists
  467. .get(i).get("channelnodeid").toString());
  468. jsonObject.put("channelname",
  469. lists.get(i).get("channelname") == null ? "" : lists
  470. .get(i).get("channelname").toString());
  471. jsonObject.put("contact_name",
  472. lists.get(i).get("contact_name") == null ? "" : lists
  473. .get(i).get("contact_name").toString());
  474. jsonObject.put("contact_phone",
  475. lists.get(i).get("contact_phone") == null ? "" : lists
  476. .get(i).get("contact_phone").toString());
  477. jsonObject.put("addrname",
  478. lists.get(i).get("addrname") == null ? "" : lists
  479. .get(i).get("addrname").toString());
  480. jsonObject.put("chnltype",
  481. lists.get(i).get("chnltype") == null ? "" : lists
  482. .get(i).get("chnltype").toString());
  483. lists.get(i).remove("channelnodeid");
  484. lists.get(i).remove("contact_name");
  485. lists.get(i).remove("contact_phone");
  486. lists.get(i).remove("addrname");
  487. lists.get(i).remove("chnltype");
  488. lists.get(i).put("website", jsonObject.toString());
  489. }
  490. if (LfwLogger.isErrorEnabled()) {
  491. LfwLogger.error("***************" + strbuf.toString()
  492. + "***************");
  493. }
  494. Map<String, Object> map = new HashMap<String, Object>();
  495. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  496. if (lists == null || lists.size() <= 0) {
  497. map.put("flag", 0);
  498. map.put("des", "没有符合条件的数据");
  499. arrFinal.add(map);
  500. return arrFinal;
  501. } else {
  502. map.put("flag", "0");
  503. map.put("des", "查询成功");
  504. map.put("ts", currenttime.toString());
  505. map.put("resultList", lists);
  506. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  507. list.add(map);
  508. return list;
  509. }
  510. } catch (Exception e) {
  511. // TODO: handle exception
  512. LfwLogger.error(e.getMessage(), e);
  513. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  514. Map<String, Object> resMap = new HashMap<String, Object>();
  515. resMap.put("flag", "1");
  516. resMap.put("des", e.getMessage());
  517. resList.add(resMap);
  518. return resList;
  519. }
  520. }
  521. /**
  522. * @description 订单保存
  523. * @author wangchunhui
  524. */
  525. @Override
  526. public ArrayList<Map<String, Object>> SaveOrders(String groupid,
  527. String usrid, String visit_type, String channelnodeid,
  528. String contact_name, String contact_phone, String sendDate,
  529. String productlist, String ts) {
  530. // LfwLogger.error("***********"+groupid+""+usrid+""+visit_type+""+channelnodeid+""+contact_name+""+contact_phone+productlist);
  531. // TODO 自动生成的方法存根
  532. try {
  533. if (LfwLogger.isErrorEnabled()) {
  534. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  535. "SaleOrderMobileService.SaveOrders", new String[] {
  536. "groupid", "usrid", "visit_type",
  537. "channelnodeid", "contact_name",
  538. "contact_phone", "productlist", "ts" },
  539. new Object[] { groupid, usrid, visit_type,
  540. channelnodeid, contact_name, contact_phone,
  541. productlist, ts }));
  542. }
  543. IUAPQueryBS qry = NCLocator.getInstance().lookup(IUAPQueryBS.class);
  544. // app端
  545. if (visit_type != null && visit_type.equals("app")) {
  546. // 保存
  547. Saleorder saleorder = new Saleorder();
  548. saleorder.setPk_psndoc(usrid);
  549. saleorder.setCreator(usrid);
  550. saleorder.setCreationtime(new UFDateTime(System
  551. .currentTimeMillis()));
  552. // TODO 用户关联的公司
  553. @SuppressWarnings("unchecked")
  554. ArrayList<String> clist = (ArrayList<String>) qry.executeQuery(
  555. "select t.pk_org from cp_user t where t.cuserid=‘"
  556. + usrid + "‘", new ColumnListProcessor());
  557. if (clist.size() > 0) {
  558. saleorder.setPk_org(clist.get(0));
  559. }
  560. saleorder.setVbillno("SO" + new Date().getTime());
  561. saleorder.setPk_group(groupid); // 所属集团
  562. saleorder.setPk_channel(channelnodeid);// 渠道网点
  563. saleorder.setVname(contact_name);// 联系人
  564. saleorder.setVphoneno(contact_phone);// 联系电话
  565. saleorder.setVdef1(new UFDate(sendDate).toString());
  566. /**
  567. * TODO 1.根据网点带出对应的省市县,nc.yangh.webts.SaleOrder.SaleOrder.
  568. * SaleOrderCardWinMainViewCtrl
  569. * .onAfterDataChange(DatasetCellEvent)
  570. *
  571. */
  572. IUAPQueryBS chnesrv = NCLocator.getInstance().lookup(
  573. IUAPQueryBS.class);
  574. Object[] chnldata = (Object[]) chnesrv
  575. .executeQuery(
  576. "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=‘"
  577. + channelnodeid + "‘",
  578. new ArrayProcessor());
  579. if (chnldata != null && chnldata.length > 0) {
  580. saleorder.setPk_province(chnldata[0] == null ? ""
  581. : chnldata[0].toString());
  582. saleorder.setPk_city(chnldata[1] == null ? "" : chnldata[1]
  583. .toString());
  584. saleorder.setPk_region(chnldata[2] == null ? ""
  585. : chnldata[2].toString());
  586. saleorder.setVaddress(chnldata[3] == null ? ""
  587. : chnldata[3].toString());
  588. saleorder.setVzipcode(chnldata[4] == null ? ""
  589. : chnldata[4].toString());
  590. }
  591. saleorder.setVsource(ISaleOrderConst.SOURCE_APP);// 订单来源
  592. saleorder.setIbillstatus(ISaleOrderConst.COMMIT);// 提交态
  593. saleorder.setDbilldate(AppContext.getInstance().getBusiDate());// 业务日期
  594. String parentpk = getDAO().insertVO(saleorder);
  595. // 解析json字符串
  596. JSONArray jsonarray = new JSONArray(productlist);
  597. List<SaleorderB> list = new ArrayList<SaleorderB>();
  598. for (int i = 0; i < jsonarray.length(); i++) {
  599. org.json.JSONObject jo = jsonarray.getJSONObject(i);
  600. String pk_material = jo.get("productid").toString();
  601. UFDouble nnum = new UFDouble(jo.get("num").toString());
  602. String materialname = jo.get("materialname").toString();
  603. String materialspec = jo.get("materialspec").toString();
  604. SaleorderB saleb = new SaleorderB();
  605. saleb.setPk_saleorder(parentpk);
  606. saleb.setPk_material(pk_material);
  607. saleb.setInvname(materialname);
  608. saleb.setInvspec(materialspec);
  609. saleb.setNnum(nnum);
  610. saleb.setCrowno("" + (i + 1) * 10);
  611. saleb.setPk_unit("0001Z0100000000000XU");// 计量单位:箱
  612. saleb.setDsenddate(new UFDate(sendDate));
  613. // saleb.setStatus(ISaleOrderConst.APPROVE_B);//已审核
  614. /**
  615. * TODO 2.带出表体对应的经销商nc.yangh.webts.SaleOrder.SaleOrder.
  616. * SaleOrderCardWinMainViewCtrl.afterEdit(CellEvent)
  617. */
  618. IMaterialBaseInfoQueryService materialQry = NCLocator
  619. .getInstance().lookup(
  620. IMaterialBaseInfoQueryService.class);
  621. if (pk_material != null && pk_material.trim().length() > 0) {
  622. MaterialVO materialvo = materialQry
  623. .queryDataByPks(new String[] { pk_material })[0];
  624. saleb.setSubclass(materialvo.getPk_marbasclass());
  625. @SuppressWarnings("unchecked")
  626. ArrayList<String> jxs = (ArrayList<String>) qry
  627. .executeQuery(
  628. "select code from webts_goodsrelation_h where"
  629. + " pk_relation in (select distinct(b.pk_relation) from webts_goodsrelation_order a "
  630. + " 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 "
  631. + " and pk_psndoc=‘" + usrid
  632. + "‘ and a.pk_material=‘"
  633. + pk_material
  634. + "‘ ) and nvl(dr,0)=0",
  635. new ColumnListProcessor());
  636. if (jxs.size() == 1) {
  637. saleb.setPk_dealer(jxs.get(0));
  638. }
  639. }
  640. list.add(saleb);
  641. }
  642. SaleorderB[] salebs = list.toArray(new SaleorderB[0]);
  643. getDAO().insertVOArray(salebs);
  644. }
  645. // 微信端
  646. // else
  647. // {
  648. //
  649. // }
  650. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  651. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  652. Map<String, Object> resMap = new HashMap<String, Object>();
  653. resMap.put("flag", "0");
  654. resMap.put("status", "1");
  655. resMap.put("des", "保存成功");
  656. resMap.put("ts", currenttime.toString());
  657. resList.add(resMap);
  658. return resList;
  659. } catch (Exception e) {
  660. LfwLogger.error(e.getMessage(), e);
  661. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  662. Map<String, Object> resMap = new HashMap<String, Object>();
  663. resMap.put("flag", "1");
  664. resMap.put("status", "2");
  665. resMap.put("des", e.getMessage());
  666. resList.add(resMap);
  667. return resList;
  668. }
  669. }
  670. // 修改订单
  671. @Override
  672. public ArrayList<Map<String, Object>> UpdateOrders(String visit_type,
  673. String usrid, String orderid, String sendDate, String productlist,
  674. String contact_name, String contact_phone, String ts) {
  675. // TODO 自动生成的方法存根
  676. try {
  677. if (LfwLogger.isErrorEnabled()) {
  678. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  679. "SaleOrderMobileService.UpdateOrders", new String[] {
  680. "visit_type", "orderid", "sendDate",
  681. "productlist", "ts" },
  682. new Object[] { visit_type, orderid, sendDate,
  683. productlist, ts }));
  684. }
  685. IUAPQueryBS qry = NCLocator.getInstance().lookup(IUAPQueryBS.class);
  686. // app端
  687. if (visit_type != null && visit_type.equals("app")) {
  688. String wherestr = " dr=0 and pk_saleorder=‘" + orderid + "‘";
  689. getDAO().deleteByClause(SaleorderB.class, wherestr);
  690. String sql = " select * from webts_Saleorder where dr=0 and pk_saleorder=‘"
  691. + orderid + "‘";
  692. @SuppressWarnings("unchecked")
  693. List<Saleorder> lists = (List<Saleorder>) dao.executeQuery(sql,
  694. new BeanListProcessor(Saleorder.class));
  695. if (lists.size() > 0) {
  696. Saleorder sorder = lists.get(0);
  697. sorder.setVname(contact_name);
  698. sorder.setVphoneno(contact_phone);
  699. sorder.setVdef1(new UFDate(sendDate).toString());
  700. getDAO().updateVO(sorder);
  701. }
  702. // 解析json字符串
  703. JSONArray jsonarray = new JSONArray(productlist);
  704. List<SaleorderB> list = new ArrayList<SaleorderB>();
  705. for (int i = 0; i < jsonarray.length(); i++) {
  706. org.json.JSONObject jo = jsonarray.getJSONObject(i);
  707. String pk_material = jo.get("productid").toString();
  708. UFDouble nnum = new UFDouble(jo.get("num").toString());
  709. String materialname = jo.get("materialname").toString();
  710. String materialspec = jo.get("materialspec").toString();
  711. SaleorderB saleb = new SaleorderB();
  712. saleb.setPk_saleorder(orderid);
  713. saleb.setPk_material(pk_material);
  714. saleb.setNnum(nnum);
  715. saleb.setCrowno("" + (i + 1) * 10);
  716. saleb.setPk_unit("0001Z0100000000000XU");// 计量单位:箱
  717. saleb.setInvname(materialname);
  718. saleb.setInvspec(materialspec);
  719. saleb.setDsenddate(new UFDate(sendDate));
  720. // saleb.setStatus(ISaleOrderConst.APPROVE_B);//已审核
  721. /**
  722. * TODO 2.带出表体对应的经销商nc.yangh.webts.SaleOrder.SaleOrder.
  723. * SaleOrderCardWinMainViewCtrl.afterEdit(CellEvent)
  724. */
  725. IMaterialBaseInfoQueryService materialQry = NCLocator
  726. .getInstance().lookup(
  727. IMaterialBaseInfoQueryService.class);
  728. if (pk_material != null && pk_material.trim().length() > 0) {
  729. MaterialVO materialvo = materialQry
  730. .queryDataByPks(new String[] { pk_material })[0];
  731. saleb.setSubclass(materialvo.getPk_marbasclass());
  732. @SuppressWarnings("unchecked")
  733. ArrayList<String> jxs = (ArrayList<String>) qry
  734. .executeQuery(
  735. "select code from webts_goodsrelation_h where"
  736. + " pk_relation in (select distinct(b.pk_relation) from webts_goodsrelation_order a "
  737. + " 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 "
  738. + " and pk_psndoc=‘" + usrid
  739. + "‘ and a.pk_material=‘"
  740. + pk_material
  741. + "‘ ) and nvl(dr,0)=0",
  742. new ColumnListProcessor());
  743. if (jxs.size() == 1) {
  744. saleb.setPk_dealer(jxs.get(0));
  745. }
  746. }
  747. list.add(saleb);
  748. }
  749. SaleorderB[] salebs = list.toArray(new SaleorderB[0]);
  750. getDAO().insertVOArray(salebs);
  751. }
  752. // 微信端
  753. // else
  754. // {
  755. //
  756. // }
  757. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  758. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  759. Map<String, Object> resMap = new HashMap<String, Object>();
  760. resMap.put("flag", "0");
  761. resMap.put("des", "更新成功");
  762. resMap.put("ts", currenttime.toString());
  763. resList.add(resMap);
  764. return resList;
  765. } catch (Exception e) {
  766. // TODO: handle exception
  767. LfwLogger.error(e.getMessage(), e);
  768. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  769. Map<String, Object> resMap = new HashMap<String, Object>();
  770. resMap.put("flag", "1");
  771. resMap.put("des", e.getMessage());
  772. resList.add(resMap);
  773. return resList;
  774. }
  775. }
  776. /**
  777. * @description 获取订单子表详情
  778. * @author wangchunhui
  779. */
  780. @SuppressWarnings("unused")
  781. @Override
  782. public ArrayList<Map<String, Object>> GetOrderBlist(String visit_type,
  783. String usrid, String orderid, String ts) {
  784. // TODO 自动生成的方法存根
  785. try {
  786. if (LfwLogger.isErrorEnabled()) {
  787. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  788. "SaleOrderMobileService.GetOrderBlist", new String[] {
  789. "visit_type", "usrid", "ts" }, new Object[] {
  790. visit_type, usrid, visit_type, ts, }));
  791. }
  792. // StringBuffer strbuf = new StringBuffer("select * from (select ");
  793. StringBuffer strbuf = new StringBuffer(
  794. "select * from (select A.*,rownum rn from (select ");
  795. strbuf.append(" t.pk_saleorder as orderid");
  796. // 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");
  797. // strbuf.append(" ,to_char(to_date(t.dsenddate,‘yyyy-mm-dd‘)) as sendDate");
  798. strbuf.append(" , substr(t.dsenddate,0,10) as senddate");
  799. strbuf.append(" ,t.pk_material as productid");
  800. strbuf.append(" ,t1.vname as contact_name");
  801. strbuf.append(" ,t1.vphoneno as contact_phone");
  802. strbuf.append(" ,t.nnum as num");
  803. strbuf.append(" ,t.invname as name");
  804. strbuf.append(" ,t.invspec as materialspec");
  805. StringBuffer subbuf = new StringBuffer(
  806. " from webts_SaleorderB t "
  807. + " left join webts_Saleorder t1 on t1.pk_saleorder=t.pk_saleorder"
  808. // +
  809. // " 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 "
  810. + " where t.dr=0 and t.pk_saleorder=‘" + orderid
  811. + "‘");
  812. // app端
  813. if (visit_type != null && visit_type.equals("app")) {
  814. }
  815. // 微信端
  816. // else
  817. // {
  818. //
  819. // }
  820. PageController pageController = new PageController(50, 1,
  821. subbuf.toString());
  822. PageInfo pageinfo = new PageInfo();
  823. pageinfo = pageController.getPageinfo();
  824. int beginIndex = pageinfo.getM_iStartRow();
  825. int endIndex = pageinfo.getM_iEndRow();
  826. strbuf.append(subbuf).toString();
  827. // strbuf.append(" and rownum <=" + endIndex +
  828. // " order by invname) where rn>="
  829. strbuf.append(" order by t.invname ) A where rownum <=" + endIndex
  830. + " ) where rn>=" + beginIndex + "");
  831. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  832. @SuppressWarnings("unchecked")
  833. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  834. .executeQuery(strbuf.toString(), getMapListProcessor());
  835. JSONArray jsonArray = new JSONArray();
  836. String senddate = null;
  837. String contact_name = null;
  838. String contact_phone = null;
  839. if (lists.size() > 0) {
  840. senddate = lists.get(0).get("senddate") == null ? "" : lists
  841. .get(0).get("senddate").toString();
  842. contact_name = lists.get(0).get("contact_name") == null ? ""
  843. : lists.get(0).get("contact_name").toString();
  844. contact_phone = lists.get(0).get("contact_phone") == null ? ""
  845. : lists.get(0).get("contact_phone").toString();
  846. }
  847. for (int i = 0; i < lists.size(); i++) {
  848. JSONObject jsonObject = new JSONObject();
  849. jsonObject.put(
  850. "productid",
  851. lists.get(i).get("productid") == null ? "" : lists
  852. .get(i).get("productid").toString());
  853. jsonObject.put("num", lists.get(i).get("num") == null ? ""
  854. : lists.get(i).get("num").toString());
  855. jsonObject.put("name", lists.get(i).get("name") == null ? ""
  856. : lists.get(i).get("name").toString());
  857. jsonObject.put("materialspec",
  858. lists.get(i).get("materialspec") == null ? "" : lists
  859. .get(i).get("materialspec").toString());
  860. jsonObject.put("unit", "箱");
  861. jsonArray.put(jsonObject);
  862. }
  863. lists.clear();
  864. Map<String, Object> tempMap = new HashMap<String, Object>();
  865. tempMap.put("orderid", orderid);
  866. tempMap.put("senddate", senddate);
  867. tempMap.put("contact_name", contact_name);
  868. tempMap.put("contact_phone", contact_phone);
  869. tempMap.put("productlist", jsonArray.toString());
  870. lists.add((HashMap<String, Object>) tempMap);
  871. Map<String, Object> map = new HashMap<String, Object>();
  872. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  873. if (lists == null || lists.size() <= 0) {
  874. map.put("flag", 0);
  875. map.put("des", "没有符合条件的数据");
  876. arrFinal.add(map);
  877. return arrFinal;
  878. } else {
  879. map.put("flag", "0");
  880. map.put("des", "查询成功");
  881. map.put("ts", currenttime.toString());
  882. map.put("resultList", lists);
  883. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  884. list.add(map);
  885. return list;
  886. }
  887. } catch (Exception e) {
  888. // TODO: handle exception
  889. LfwLogger.error(e.getMessage(), e);
  890. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  891. Map<String, Object> resMap = new HashMap<String, Object>();
  892. resMap.put("flag", "1");
  893. resMap.put("des", e.getMessage());
  894. resList.add(resMap);
  895. return resList;
  896. }
  897. }
  898. /**
  899. * 待收获列表
  900. *
  901. * @author heyang
  902. *
  903. */
  904. @Override
  905. public ArrayList<Map<String, Object>> GetOrderconfirmlist(
  906. String visit_type, String usrid, String search_text, String istatus,String ts,
  907. String pageNum, String pagerows) {
  908. // TODO 自动生成的方法存根
  909. try {
  910. if (LfwLogger.isErrorEnabled()) {
  911. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  912. "SaleOrderMobileService.GetOrderconfirmlist",
  913. new String[] { "visit_type", "usrid", "search_text","istatus",
  914. "ts", "pageNum", "pagerows" }, new Object[] {
  915. visit_type, usrid, search_text,istatus, ts, pageNum,
  916. pagerows }));
  917. }
  918. StringBuffer strbuf = new StringBuffer(
  919. "select * from (select A.*,rownum rn from (select ");
  920. // strbuf.append(" t.pk_accounts as pk_accounts");
  921. // strbuf.append(" ,t.nsendnum as sendcount");
  922. strbuf.append(" distinct s.channelnodeid as pk_channelnode");
  923. if ("0".equals(istatus)) {
  924. strbuf.append(" ,t.dsenddate as senddate");}
  925. else{
  926. strbuf.append(" ,t.dreceivedate as receivedate");
  927. }
  928. strbuf.append(" ,s.channelname as vname");
  929. strbuf.append(" ,s.contact_phone as vmobilephone");
  930. strbuf.append(" ,s.contact_name as vlinkman");
  931. strbuf.append(" ,s.addrname as addrname");
  932. strbuf.append(" ,s.chnltype as chnlname");
  933. // strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
  934. // strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
  935. // 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");
  936. // strbuf.append(" ,t.creationtime as orderTime");
  937. StringBuffer subbuf = new StringBuffer(
  938. " from webts_goodaccounts t "
  939. // +
  940. // " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
  941. + " 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 "
  942. + " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
  943. + " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
  944. + " where t.dr=0 and nvl(t.istatus,0) = "+istatus);
  945. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  946. // if (!groupid.isEmpty()) {
  947. // subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
  948. // }
  949. if (!usrid.isEmpty()) {
  950. subbuf.append(" and t.pk_psndoc=‘" + usrid + "‘ ");
  951. }
  952. if (!search_text.isEmpty()) {
  953. subbuf.append(" and (s.channelname like ‘%" + search_text
  954. + "%‘ or s.addrname like ‘%" + search_text + "%‘)");
  955. }
  956. // if (!orderstate.isEmpty()) {
  957. // subbuf.append(" and t.ibillstatus="
  958. // + Integer.parseInt(orderstate) + "");
  959. // }
  960. }
  961. // 微信端
  962. // else
  963. // {
  964. //
  965. // }
  966. PageController pageController = new PageController(
  967. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  968. subbuf.toString());
  969. PageInfo pageinfo = new PageInfo();
  970. pageinfo = pageController.getPageinfo();
  971. int beginIndex = pageinfo.getM_iStartRow();
  972. int endIndex = pageinfo.getM_iEndRow();
  973. strbuf.append(subbuf).toString();
  974. strbuf.append(" and (t.dsenddate is null or t.dsenddate = (select max(t4.dsenddate) from webts_goodaccounts t4 where t4.pk_channel=s.channelnodeid)) ");
  975. strbuf.append(" and (t.dreceivedate is null or t.dreceivedate = (select max(t4.dreceivedate) from webts_goodaccounts t4 where t4.pk_channel=s.channelnodeid)) ");
  976. if ("0".equals(istatus)) {
  977. strbuf.append(" order by t.dsenddate desc ");
  978. }else {
  979. strbuf.append(" order by t.dreceivedate desc ");
  980. }
  981. strbuf.append(") A where rownum <="
  982. + endIndex + " ) where rn>=" + beginIndex + "");
  983. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  984. @SuppressWarnings("unchecked")
  985. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  986. .executeQuery(strbuf.toString(), getMapListProcessor());
  987. if (LfwLogger.isErrorEnabled()) {
  988. LfwLogger.error("***************" + strbuf.toString()
  989. + "***************");
  990. }
  991. Map<String, Object> map = new HashMap<String, Object>();
  992. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  993. if (lists == null || lists.size() <= 0) {
  994. map.put("flag", 0);
  995. map.put("des", "没有符合条件的数据");
  996. arrFinal.add(map);
  997. return arrFinal;
  998. } else {
  999. map.put("flag", "0");
  1000. map.put("des", "查询成功");
  1001. map.put("ts", currenttime.toString());
  1002. map.put("resultList", lists);
  1003. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  1004. list.add(map);
  1005. return list;
  1006. }
  1007. } catch (Exception e) {
  1008. // TODO: 操作异常
  1009. LfwLogger.error(e.getMessage(), e);
  1010. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  1011. Map<String, Object> resMap = new HashMap<String, Object>();
  1012. resMap.put("flag", "1");
  1013. resMap.put("des", e.getMessage());
  1014. resList.add(resMap);
  1015. return resList;
  1016. }
  1017. }
  1018. /**
  1019. * 待收货网点明细
  1020. */
  1021. @Override
  1022. public ArrayList<Map<String, Object>> GetOrderBconfirmlist(
  1023. String channelnodeid, String usrid, String visit_type,String istatus,
  1024. String pageNum, String pagerows, String ts) {
  1025. // TODO 自动生成的方法存根
  1026. try {
  1027. if (LfwLogger.isErrorEnabled()) {
  1028. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  1029. "SaleOrderMobileService.GetOrderBconfirmlist",
  1030. new String[] { "channelnodeid", "usrid", "visit_type",
  1031. "istatus","pageNum", "pagerows", "ts" }, new Object[] {
  1032. channelnodeid, usrid, ts, visit_type,istatus, pageNum,
  1033. pagerows, ts }));
  1034. }
  1035. StringBuffer strbuf = new StringBuffer(
  1036. "select * from (select A.*,rownum rn from (select ");
  1037. strbuf.append(" t.pk_accounts as id");// 台帐主键
  1038. strbuf.append(" ,to_char(t.nnum) as num");// 要货数量
  1039. strbuf.append(" ,t.pk_material as productid"); // 产品pk
  1040. strbuf.append(" ,m.name as name"); // 产品名称
  1041. strbuf.append(" ,t.unit as unit"); // 产品单位
  1042. strbuf.append(" ,t.invspec as materialspec"); // 产品规格
  1043. strbuf.append(" ,to_char(t.nsendnum) as sendnum");// 发货数量
  1044. strbuf.append(" ,to_char(t.nfinishnum) as finishnum");// 累计发货数量
  1045. strbuf.append(" ,t.sendman as sendman");// 发货人
  1046. strbuf.append(" ,s.addrname as addrname");// 地址
  1047. strbuf.append(" ,substr(t.dsenddate,0,16) as dsenddate");// 发货日期
  1048. // strbuf.append(" ,to_char(t.ntotalrevnum) as ntotalrevnum");//
  1049. // 累计收获数量
  1050. // strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
  1051. // strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
  1052. // 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");
  1053. // strbuf.append(" ,t.creationtime as orderTime");
  1054. StringBuffer subbuf = new StringBuffer(
  1055. " from webts_goodaccounts t "
  1056. + " left join bd_material m on m.pk_material=t.pk_material "
  1057. + " 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 "
  1058. + " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
  1059. + " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
  1060. + " where t.dr=0 and nvl(t.istatus,0) ="+istatus+" and t.pk_channel=‘"
  1061. + channelnodeid + "‘");
  1062. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  1063. // if (!groupid.isEmpty()) {
  1064. // subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
  1065. // }
  1066. }
  1067. // 微信端
  1068. // else
  1069. // {
  1070. //
  1071. // }
  1072. PageController pageController = new PageController(
  1073. Integer.parseInt(pagerows), Integer.parseInt(pageNum),
  1074. subbuf.toString());
  1075. PageInfo pageinfo = new PageInfo();
  1076. pageinfo = pageController.getPageinfo();
  1077. int beginIndex = pageinfo.getM_iStartRow();
  1078. int endIndex = pageinfo.getM_iEndRow();
  1079. strbuf.append(subbuf).toString();
  1080. strbuf.append(" order by t.dsenddate ) A where rownum <="
  1081. + endIndex + " ) where rn>=" + beginIndex + "");
  1082. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  1083. @SuppressWarnings("unchecked")
  1084. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  1085. .executeQuery(strbuf.toString(), getMapListProcessor());
  1086. for (int i = 0; i < lists.size(); i++) {
  1087. String productid = (String) lists.get(i).get("productid");
  1088. // 累计收获数量的计算。查询台帐里的相同产品的收货数量+加上本次确认的是就是本次累计收货数量
  1089. String querysql = "select sum(nvl(nreveivenum,0)) as beforerecievenum from webts_goodaccounts where pk_material=‘"
  1090. + productid + "‘ and nvl(dr,0)=0 and nvl(istatus,0)="+istatus;
  1091. IUAPQueryBS queryBS = (IUAPQueryBS) NCLocator.getInstance()
  1092. .lookup(IUAPQueryBS.class.getName());
  1093. ArrayList<HashMap<String, Object>> list1 = (ArrayList<HashMap<String, Object>>) queryBS
  1094. .executeQuery(querysql, new MapListProcessor());
  1095. UFDouble beforerecievenum = new UFDouble(String.valueOf(list1
  1096. .get(0).get("beforerecievenum") == null ? "0" : list1
  1097. .get(0).get("beforerecievenum")));
  1098. lists.get(i).put("totalrevnum", beforerecievenum.toString());
  1099. }
  1100. if (LfwLogger.isErrorEnabled()) {
  1101. LfwLogger.error("***************" + strbuf.toString()
  1102. + "***************");
  1103. }
  1104. Map<String, Object> map = new HashMap<String, Object>();
  1105. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  1106. if (lists == null || lists.size() <= 0) {
  1107. map.put("flag", 0);
  1108. map.put("des", "没有符合条件的数据");
  1109. arrFinal.add(map);
  1110. return arrFinal;
  1111. } else {
  1112. map.put("flag", "0");
  1113. map.put("des", "查询成功");
  1114. map.put("ts", currenttime.toString());
  1115. map.put("resultList", lists);
  1116. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  1117. list.add(map);
  1118. return list;
  1119. }
  1120. } catch (Exception e) {
  1121. // TODO: 操作异常
  1122. LfwLogger.error(e.getMessage(), e);
  1123. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  1124. Map<String, Object> resMap = new HashMap<String, Object>();
  1125. resMap.put("flag", "1");
  1126. resMap.put("des", e.getMessage());
  1127. resList.add(resMap);
  1128. return resList;
  1129. }
  1130. }
  1131. /**
  1132. *
  1133. * 收获确认
  1134. *
  1135. * @param id
  1136. * @param reveivenum
  1137. * @param ts
  1138. * @return
  1139. */
  1140. @Override
  1141. public ArrayList<Map<String, Object>> UpdateGoodsaccounts(
  1142. String reveiveinfo, String ts) {
  1143. // TODO 自动生成的方法存根
  1144. try {
  1145. if (LfwLogger.isErrorEnabled()) {
  1146. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  1147. "SaleOrderMobileService.UpdateOrders", new String[] {
  1148. "reveiveinfo", "ts" }, new Object[] {
  1149. reveiveinfo, ts }));
  1150. }
  1151. // 解析字符串
  1152. // 解析
  1153. org.json.JSONArray jsonarray = new JSONArray(reveiveinfo);
  1154. // 遍历
  1155. for (int i = 0; i < jsonarray.length(); i++) {
  1156. org.json.JSONObject jo = jsonarray.getJSONObject(i);
  1157. String id = (String) jo.get("id");// 台帐id
  1158. String pk_material = (String) jo.get("productid");
  1159. String reveivenum = (String) jo.get("reveivenum");// 本次收货数量
  1160. String userid = (String) jo.get("userid");
  1161. UFDouble receivenum = new UFDouble(reveivenum);
  1162. // 累计收获数量的计算。查询台帐里的相同产品的收货数量+加上本次确认的是就是本次累计收货数量
  1163. String querysql = "select sum(nvl(nreveivenum,0)) as beforerecievenum from webts_goodaccounts where pk_material=‘"
  1164. + pk_material
  1165. + "‘ and nvl(dr,0)=0 and nvl(istatus,0)=1";
  1166. IUAPQueryBS queryBS = (IUAPQueryBS) NCLocator.getInstance()
  1167. .lookup(IUAPQueryBS.class.getName());
  1168. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) queryBS
  1169. .executeQuery(querysql, new MapListProcessor());
  1170. UFDouble beforerecievenum = new UFDouble(String.valueOf(lists
  1171. .get(0).get("beforerecievenum") == null ? "0" : lists
  1172. .get(0).get("beforerecievenum")));
  1173. UFDouble totalreceivenum = beforerecievenum.add(receivenum);// 累计收货数量
  1174. String sql = "update webts_goodaccounts set nreveivenum="
  1175. + receivenum + ",istatus=1,ntotalrevnum="
  1176. + totalreceivenum +", dreceiveman=\‘"+userid+"\‘,dreceivedate=\‘"+new UFDateTime().toStdString() + "\‘ where pk_accounts=‘" + id
  1177. + "‘ and nvl(dr,0)=0";
  1178. getDAO().executeUpdate(sql);
  1179. }
  1180. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  1181. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  1182. Map<String, Object> resMap = new HashMap<String, Object>();
  1183. resMap.put("flag", "0");
  1184. resMap.put("des", "更新成功");
  1185. resMap.put("ts", currenttime.toString());
  1186. resList.add(resMap);
  1187. return resList;
  1188. } catch (Exception e) {
  1189. // TODO: handle exception
  1190. LfwLogger.error(e.getMessage(), e);
  1191. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  1192. Map<String, Object> resMap = new HashMap<String, Object>();
  1193. resMap.put("flag", "1");
  1194. resMap.put("des", e.getMessage());
  1195. resList.add(resMap);
  1196. return resList;
  1197. }
  1198. }
  1199. /**
  1200. * 待收获列表
  1201. *
  1202. * @author heyang
  1203. *
  1204. */
  1205. @Override
  1206. public ArrayList<Map<String, Object>> GetOrdercounts(
  1207. String visit_type, String usrid, String ts
  1208. ) {
  1209. // TODO 自动生成的方法存根
  1210. try {
  1211. if (LfwLogger.isErrorEnabled()) {
  1212. LfwLogger.error(MobileCommon.getRequestDebugInfo(
  1213. "SaleOrderMobileService.GetOrdercounts",
  1214. new String[] { "visit_type", "usrid",
  1215. "ts"}, new Object[] {
  1216. visit_type, usrid, ts}));
  1217. }
  1218. StringBuffer strbuf = new StringBuffer(
  1219. "select to_char(count(*)) AS num from (select A.*,rownum rn from (select ");
  1220. // strbuf.append(" t.pk_accounts as pk_accounts");
  1221. // strbuf.append(" ,t.nsendnum as sendcount");
  1222. strbuf.append(" distinct s.channelnodeid as pk_channelnode");
  1223. strbuf.append(" ,s.channelname as vname");
  1224. strbuf.append(" ,s.contact_phone as vmobilephone");
  1225. strbuf.append(" ,s.contact_name as vlinkman");
  1226. strbuf.append(" ,s.addrname as addrname");
  1227. strbuf.append(" ,s.chnltype as chnlname");
  1228. // strbuf.append(" ,nvl(to_char(t.ibillstatus),‘3‘) as orderstate");
  1229. // strbuf.append(" ,to_char(t.ibillstatus) as orderstate");
  1230. // 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");
  1231. // strbuf.append(" ,t.creationtime as orderTime");
  1232. StringBuffer subbuf = new StringBuffer(
  1233. " from webts_goodaccounts t "
  1234. // +
  1235. // " left join dcm_chnlnode s on s.pk_channelnode=t.pk_channel "
  1236. + " 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 "
  1237. + " from dcm_chnlnode t1 left join bd_address t2 on t2.pk_address=t1.clinkaddrid "
  1238. + " left join bd_channeltype t3 on t3.pk_type=t1.cchanltypeid where t1.dr=0) s on t.pk_channel=s.channelnodeid"
  1239. + " where t.dr=0 and nvl(t.istatus,0) !=1");
  1240. if (!visit_type.isEmpty() && visit_type.equals("app")) {
  1241. // if (!groupid.isEmpty()) {
  1242. // subbuf.append(" and t.pk_group=‘" + groupid + "‘ ");
  1243. // }
  1244. if (!usrid.isEmpty()) {
  1245. subbuf.append(" and t.pk_psndoc=‘" + usrid + "‘ ");
  1246. }
  1247. }
  1248. // 微信端
  1249. // else
  1250. // {
  1251. //
  1252. // }
  1253. strbuf.append(subbuf).toString();
  1254. strbuf.append(" order by s.channelname ) A )");
  1255. UFDateTime currenttime = new UFDateTime(System.currentTimeMillis());
  1256. @SuppressWarnings("unchecked")
  1257. ArrayList<HashMap<String, Object>> lists = (ArrayList<HashMap<String, Object>>) getDAO()
  1258. .executeQuery(strbuf.toString(), getMapListProcessor());
  1259. if (LfwLogger.isErrorEnabled()) {
  1260. LfwLogger.error("***************" + strbuf.toString()
  1261. + "***************");
  1262. }
  1263. Map<String, Object> map = new HashMap<String, Object>();
  1264. ArrayList<Map<String, Object>> arrFinal = new ArrayList<Map<String, Object>>();
  1265. if (lists == null || lists.size() <= 0) {
  1266. map.put("flag", 0);
  1267. map.put("des", "没有符合条件的数据");
  1268. arrFinal.add(map);
  1269. return arrFinal;
  1270. } else {
  1271. map.put("flag", "0");
  1272. map.put("des", "查询成功");
  1273. map.put("ts", currenttime.toString());
  1274. map.put("resultList", lists);
  1275. ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  1276. list.add(map);
  1277. return list;
  1278. }
  1279. } catch (Exception e) {
  1280. // TODO: 操作异常
  1281. LfwLogger.error(e.getMessage(), e);
  1282. ArrayList<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  1283. Map<String, Object> resMap = new HashMap<String, Object>();
  1284. resMap.put("flag", "1");
  1285. resMap.put("des", e.getMessage());
  1286. resList.add(resMap);
  1287. return resList;
  1288. }
  1289. }
  1290. }





使用BaseDao新建服务

标签:

原文地址:http://www.cnblogs.com/lanzhiming/p/4902414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!