Titem.java 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. /**
  2. *
  3. */
  4. package openapi.restcontroller.wechatapp.titem;
  5. import net.sf.json.JSONArray;
  6. import net.sf.json.JSONObject;
  7. import openapi.base.Controller;
  8. import openapi.base.SQLFactory;
  9. import openapi.base.data.Row;
  10. import openapi.base.data.Rows;
  11. import openapi.base.data.RowsMap;
  12. import openapi.base.data.RowsPool.RowsPool;
  13. import openapi.base.data.db.DBConnect;
  14. import p2.pao.PaoRemote;
  15. import p2.pao.PaoSetRemote;
  16. import p2.util.P2Exception;
  17. import titem.icinvbalMsg;
  18. import titem.titem;
  19. import java.sql.SQLData;
  20. import java.util.Arrays;
  21. import java.util.HashMap;
  22. /**
  23. * @author Administrator
  24. *
  25. */
  26. public class Titem extends Controller {
  27. /**
  28. * @param content
  29. */
  30. public Titem(JSONObject content) {
  31. super(content);
  32. }
  33. public String query() throws Exception {
  34. /**
  35. * 创建数据库连接
  36. */
  37. DBConnect drpConnect = new DBConnect();
  38. /**
  39. *排序条件设置
  40. */
  41. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  42. String sort = sortmsg[0];
  43. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  44. sort = content.getString("sort");
  45. }
  46. /**
  47. * 过滤条件设置
  48. */
  49. String where = " 1=1 ";
  50. if (content.containsKey("where")) {
  51. JSONObject whereObject = content.getJSONObject("where");
  52. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  53. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  54. }
  55. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  56. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  57. }
  58. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  59. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  60. }
  61. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  62. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  63. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  64. flongsaleslsFactory.addParameter("siteid", siteid);
  65. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  66. if (flongsaleslsRows.isEmpty()) {
  67. where = where + " and 1=2";
  68. } else {
  69. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  70. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  71. }
  72. }
  73. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  74. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  75. }
  76. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  77. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  78. }
  79. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  80. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  81. }
  82. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  83. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  84. }
  85. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  86. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  87. }
  88. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  89. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  90. }
  91. if (whereObject.containsKey("fvalue8") && whereObject.getBoolean("fvalue8")) {
  92. //如果是中线碟阀
  93. where = where + " and t1.fvalue8=1";
  94. }
  95. if (whereObject.containsKey("fvalue7") && !"".equals(whereObject.getString("fvalue7"))) {
  96. where = where + " and t1.fvalue7 ='" + whereObject.getString("fvalue7") + "'";
  97. }
  98. if (whereObject.containsKey("fvalue6") && !"".equals(whereObject.getString("fvalue6"))) {
  99. where = where + " and t1.fvalue6 ='" + whereObject.getString("fvalue6") + "'";
  100. }
  101. if (whereObject.containsKey("fvalue5") && !"".equals(whereObject.getString("fvalue5"))) {
  102. where = where + " and t1.fvalue5 ='" + whereObject.getString("fvalue5") + "'";
  103. }
  104. if (whereObject.containsKey("fvalue4") && !"".equals(whereObject.getString("fvalue4"))) {
  105. where = where + " and t1.fvalue4 ='" + whereObject.getString("fvalue4") + "'";
  106. }
  107. if (whereObject.containsKey("fvalue3") && !"".equals(whereObject.getString("fvalue3"))) {
  108. where = where + " and t1.fvalue3 ='" + whereObject.getString("fvalue3") + "'";
  109. }
  110. if (whereObject.containsKey("fvalue2") && !"".equals(whereObject.getString("fvalue2"))) {
  111. where = where + " and t1.fvalue2 ='" + whereObject.getString("fvalue2") + "'";
  112. }
  113. if (whereObject.containsKey("fvalue1") && !"".equals(whereObject.getString("fvalue1"))) {
  114. where = where + " and t1.fvalue1 ='" + whereObject.getString("fvalue1") + "'";
  115. }
  116. }
  117. /**
  118. * SQL货品档案查询参数设置并查询
  119. */
  120. SQLFactory factory = new SQLFactory(this, "货品档案列表查询", pageSize, pageNumber, sort);
  121. factory.addParameter("fagentnum", fagentnum);
  122. factory.addParameter("siteid", siteid);
  123. factory.addParameter_SQL("where", where);
  124. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  125. /**
  126. * 获取品号批查条件
  127. */
  128. String itemwhere = rows.getInWhere("fitemno");
  129. String[] itemarray = rows.toArray("fitemno");
  130. /**
  131. *商品图片查询参数设置,并将结果存放置map
  132. */
  133. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  134. /**
  135. *商品产品样册查询参数设置,并将结果存放置map
  136. */
  137. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  138. /**
  139. *商品说明书查询参数设置,并将结果存放置map
  140. */
  141. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  142. /**
  143. *商品安装教程查询参数设置,并将结果存放置map
  144. */
  145. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  146. /**
  147. * 商品营销类别
  148. */
  149. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  150. saleclsnumsqlFactory.addParameter("siteid", siteid);
  151. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  152. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  153. /**
  154. *更新即时库存
  155. */
  156. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  157. /**
  158. * 获取商品相关信息
  159. */
  160. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  161. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  162. /**
  163. * 遍历货品档案,设置商品信息
  164. */
  165. for (Row itemrow : rows) {
  166. String fitemno = itemrow.getString("fitemno");
  167. titem titem = (titem) itemmap.get(fitemno);
  168. double foldprice = titem.getCardPriceByAagentnum(fagentnum);
  169. double fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  170. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  171. double ficqty = titem.getDouble("ficqty");
  172. //库存状态
  173. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  174. //库存数量
  175. itemrow.put("ficqty", ficqty);
  176. //牌价
  177. itemrow.put("foldprice", foldprice);
  178. //销售价
  179. itemrow.put("fprice", fprice);
  180. //图片
  181. itemrow.put("pics", picmap.get(fitemno));
  182. //产品样册
  183. itemrow.put("samplebook", samplebookmap.get(fitemno));
  184. //产品说明书
  185. itemrow.put("instructions", instructionsmap.get(fitemno));
  186. //安装教程
  187. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  188. //营销分类
  189. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  190. }
  191. titemset.close();
  192. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  193. }
  194. public String query_tool() throws Exception {
  195. /**
  196. * 创建数据库连接
  197. */
  198. DBConnect drpConnect = new DBConnect();
  199. /**
  200. *排序条件设置
  201. */
  202. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  203. String sort = sortmsg[0];
  204. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  205. sort = content.getString("sort");
  206. }
  207. /**
  208. * 过滤条件设置
  209. */
  210. String where = " t1.fistool=1 ";
  211. if (content.containsKey("where")) {
  212. JSONObject whereObject = content.getJSONObject("where");
  213. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  214. //where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  215. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  216. }
  217. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  218. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  219. }
  220. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  221. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  222. }
  223. if (whereObject.containsKey("fproductstandard") && !"".equals(whereObject.getString("fproductstandard"))) {
  224. where = where + " and t1.fproductstandard ='" + whereObject.getString("fproductstandard") + "'";
  225. }
  226. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  227. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  228. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  229. flongsaleslsFactory.addParameter("siteid", siteid);
  230. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  231. if (flongsaleslsRows.isEmpty()) {
  232. where = where + " and 1=2";
  233. } else {
  234. // where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  235. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  236. }
  237. }
  238. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  239. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  240. }
  241. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  242. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  243. }
  244. }
  245. /**
  246. * SQL货品档案查询参数设置并查询
  247. */
  248. SQLFactory factory = new SQLFactory(this, "工具档案列表查询", pageSize, pageNumber, sort);
  249. factory.addParameter("fagentnum", fagentnum);
  250. factory.addParameter("siteid", siteid);
  251. factory.addParameter_SQL("where", where);
  252. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  253. /**
  254. * 获取品号批查条件
  255. */
  256. String itemwhere = rows.getInWhere("fitemno");
  257. String[] itemarray = rows.toArray("fitemno");
  258. /**
  259. *商品图片查询参数设置,并将结果存放置map
  260. */
  261. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  262. /**
  263. *商品产品样册查询参数设置,并将结果存放置map
  264. */
  265. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  266. /**
  267. *商品说明书查询参数设置,并将结果存放置map
  268. */
  269. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  270. /**
  271. *商品安装教程查询参数设置,并将结果存放置map
  272. */
  273. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  274. /**
  275. * 商品营销类别
  276. */
  277. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  278. saleclsnumsqlFactory.addParameter("siteid", siteid);
  279. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  280. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  281. /**
  282. *更新即时库存
  283. */
  284. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  285. /**
  286. * 获取商品相关信息
  287. */
  288. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  289. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  290. /**
  291. * 遍历货品档案,设置商品信息
  292. */
  293. for (Row itemrow : rows) {
  294. String fitemno = itemrow.getString("fitemno");
  295. titem titem = (titem) itemmap.get(fitemno);
  296. double foldprice = titem.getCardPriceByAagentnum(fagentnum);
  297. double fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  298. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  299. double ficqty = titem.getDouble("ficqty");
  300. //库存状态
  301. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  302. itemrow.put("ficqty", ficqty);
  303. //牌价
  304. itemrow.put("foldprice", foldprice);
  305. //销售价
  306. itemrow.put("fprice", fprice);
  307. //图片
  308. itemrow.put("pics", picmap.get(fitemno));
  309. //产品样册
  310. itemrow.put("samplebook", samplebookmap.get(fitemno));
  311. //产品说明书
  312. itemrow.put("instructions", instructionsmap.get(fitemno));
  313. //安装教程
  314. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  315. //营销分类
  316. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  317. }
  318. titemset.close();
  319. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  320. }
  321. public String query_toolsaler() throws Exception {
  322. /**
  323. * 创建数据库连接
  324. */
  325. DBConnect drpConnect = new DBConnect();
  326. /**
  327. *排序条件设置
  328. */
  329. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  330. String sort = sortmsg[0];
  331. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  332. sort = content.getString("sort");
  333. }
  334. /**
  335. * 过滤条件设置
  336. */
  337. String where = " t1.fistool=1 ";
  338. if (content.containsKey("where")) {
  339. JSONObject whereObject = content.getJSONObject("where");
  340. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  341. // where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  342. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  343. }
  344. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  345. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  346. }
  347. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  348. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  349. }
  350. if (whereObject.containsKey("fproductstandard") && !"".equals(whereObject.getString("fproductstandard"))) {
  351. where = where + " and t1.fproductstandard ='" + whereObject.getString("fproductstandard") + "'";
  352. }
  353. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  354. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  355. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  356. flongsaleslsFactory.addParameter("siteid", siteid);
  357. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  358. if (flongsaleslsRows.isEmpty()) {
  359. where = where + " and 1=2";
  360. } else {
  361. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  362. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  363. }
  364. }
  365. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  366. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  367. }
  368. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  369. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  370. }
  371. }
  372. /**
  373. * SQL货品档案查询参数设置并查询
  374. */
  375. SQLFactory factory = new SQLFactory(this, "工具档案列表查询_业务员", pageSize, pageNumber, sort);
  376. factory.addParameter("siteid", siteid);
  377. factory.addParameter_SQL("where", where);
  378. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  379. /**
  380. * 获取品号批查条件
  381. */
  382. String itemwhere = rows.getInWhere("fitemno");
  383. String[] itemarray = rows.toArray("fitemno");
  384. /**
  385. *商品图片查询参数设置,并将结果存放置map
  386. */
  387. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  388. /**
  389. *商品产品样册查询参数设置,并将结果存放置map
  390. */
  391. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  392. /**
  393. *商品说明书查询参数设置,并将结果存放置map
  394. */
  395. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  396. /**
  397. *商品安装教程查询参数设置,并将结果存放置map
  398. */
  399. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  400. /**
  401. * 商品营销类别
  402. */
  403. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  404. saleclsnumsqlFactory.addParameter("siteid", siteid);
  405. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  406. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  407. /**
  408. *更新即时库存
  409. */
  410. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  411. /**
  412. * 获取商品相关信息
  413. */
  414. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  415. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  416. /**
  417. * 遍历货品档案,设置商品信息
  418. */
  419. for (Row itemrow : rows) {
  420. String fitemno = itemrow.getString("fitemno");
  421. titem titem = (titem) itemmap.get(fitemno);
  422. double foldprice = titem.getCardPriceByGrade("1");
  423. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  424. double ficqty = titem.getDouble("ficqty");
  425. //库存状态
  426. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  427. itemrow.put("ficqty", ficqty);
  428. //牌价
  429. itemrow.put("foldprice", foldprice);
  430. //销售价
  431. itemrow.put("fprice", foldprice);
  432. //图片
  433. itemrow.put("pics", picmap.get(fitemno));
  434. //产品样册
  435. itemrow.put("samplebook", samplebookmap.get(fitemno));
  436. //产品说明书
  437. itemrow.put("instructions", instructionsmap.get(fitemno));
  438. //安装教程
  439. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  440. //营销分类
  441. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  442. }
  443. titemset.close();
  444. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  445. }
  446. /**
  447. * 订单商品添加查询
  448. * @return
  449. */
  450. public String query_order() throws Exception {
  451. /**
  452. * 创建数据库连接
  453. */
  454. DBConnect drpConnect = new DBConnect();
  455. /**
  456. *排序条件设置
  457. */
  458. String[] sortmsg = {"t6.sequence,t5.fgroupnum,t5.frownum"};
  459. String sort = sortmsg[0];
  460. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  461. sort = content.getString("sort");
  462. }
  463. /**
  464. * 过滤条件设置
  465. */
  466. String where = " 1=1 ";
  467. if (content.containsKey("where")) {
  468. JSONObject whereObject = content.getJSONObject("where");
  469. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  470. where = where + " and(t1.fitemno like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  471. }
  472. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  473. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  474. }
  475. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  476. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  477. }
  478. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  479. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  480. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  481. flongsaleslsFactory.addParameter("siteid", siteid);
  482. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  483. if (flongsaleslsRows.isEmpty()) {
  484. where = where + " and 1=2";
  485. } else {
  486. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  487. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  488. }
  489. }
  490. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  491. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  492. }
  493. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  494. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  495. }
  496. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  497. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  498. }
  499. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  500. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  501. }
  502. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  503. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  504. }
  505. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  506. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  507. }
  508. }
  509. /**
  510. * SQL货品档案查询参数设置并查询
  511. */
  512. SQLFactory factory = new SQLFactory(this, "货品档案列表查询2", pageSize, pageNumber, sort);
  513. factory.addParameter("fagentnum", fagentnum);
  514. factory.addParameter("siteid", siteid);
  515. factory.addParameter_SQL("where", where);
  516. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  517. /**
  518. * 获取品号批查条件
  519. */
  520. String itemwhere = rows.getInWhere("fitemno");
  521. /**
  522. *商品图片查询参数设置,并将结果存放置map
  523. */
  524. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, rows.toArray("fitemno"));
  525. /**
  526. * 商品营销类别
  527. */
  528. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  529. saleclsnumsqlFactory.addParameter("siteid", siteid);
  530. saleclsnumsqlFactory.addParameter_in("fitemno", rows.toArray("fitemno"));
  531. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  532. /**
  533. *更新即时库存
  534. */
  535. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  536. /**
  537. * 获取商品相关信息
  538. */
  539. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  540. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  541. /**
  542. * 遍历货品档案,设置商品信息
  543. */
  544. for (Row itemrow : rows) {
  545. String fitemno = itemrow.getString("fitemno");
  546. titem titem = (titem) itemmap.get(fitemno);
  547. double foldprice = titem.getCardPriceByGrade("1");
  548. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  549. double ficqty = titem.getDouble("ficqty");
  550. //库存状态
  551. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  552. itemrow.put("ficqty", ficqty);
  553. //牌价
  554. itemrow.put("foldprice", foldprice);
  555. //销售价
  556. itemrow.put("fprice", foldprice);
  557. //图片
  558. itemrow.put("pics", picmap.get(fitemno));
  559. //营销分类
  560. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  561. }
  562. titemset.close();
  563. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  564. }
  565. /**
  566. * 简单商品查询
  567. * @return
  568. */
  569. public String query_simpleList() throws Exception {
  570. /**
  571. * 创建数据库连接
  572. */
  573. DBConnect drpConnect = new DBConnect();
  574. /**
  575. *排序条件设置
  576. */
  577. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  578. String sort = sortmsg[0];
  579. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  580. sort = content.getString("sort");
  581. }
  582. /**
  583. * 是否包含价格
  584. */
  585. boolean withprice = content.containsKey("withprice") && content.getString("withprice").equals("1");
  586. /**
  587. * 过滤条件设置
  588. */
  589. String where = " 1=1 ";
  590. if (content.containsKey("where")) {
  591. JSONObject whereObject = content.getJSONObject("where");
  592. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  593. where = where + " and(t1.fitemno like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  594. }
  595. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  596. where = where + " and t1.fspec like'%" + whereObject.getString("fspec") + "%'";
  597. }
  598. if (whereObject.containsKey("fmodel") && !"".equals(whereObject.getString("fmodel"))) {
  599. where = where + " and t1.fmodel like'%" + whereObject.getString("fmodel") + "%'";
  600. }
  601. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  602. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  603. }
  604. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  605. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  606. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  607. flongsaleslsFactory.addParameter("siteid", siteid);
  608. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  609. if (flongsaleslsRows.isEmpty()) {
  610. where = where + " and 1=2";
  611. } else {
  612. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  613. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  614. }
  615. }
  616. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  617. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  618. }
  619. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  620. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  621. }
  622. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  623. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  624. }
  625. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  626. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  627. }
  628. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  629. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  630. }
  631. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  632. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  633. }
  634. }
  635. /**
  636. * SQL货品档案查询参数设置并查询
  637. */
  638. SQLFactory factory = new SQLFactory(this, "简单货品档案列表查询", pageSize, pageNumber, sort);
  639. factory.addParameter("siteid", siteid);
  640. factory.addParameter_SQL("where", where);
  641. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  642. /**
  643. *商品图片查询参数设置,并将结果存放置map
  644. */
  645. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, rows.toArray("fitemno"));
  646. /**
  647. * 商品营销类别
  648. */
  649. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  650. saleclsnumsqlFactory.addParameter("siteid", siteid);
  651. saleclsnumsqlFactory.addParameter_in("fitemno", rows.toArray("fitemno"));
  652. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  653. HashMap<String, PaoRemote> itemmap = null;
  654. if (withprice) {
  655. /**
  656. * 获取商品相关信息
  657. */
  658. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + rows.getInWhere("fitemno") + " and siteid='" + siteid + "'");
  659. itemmap = getPaoMap(titemset, "fitemno");
  660. }
  661. /**
  662. * 遍历货品档案,设置商品信息
  663. */
  664. for (Row itemrow : rows) {
  665. String fitemno = itemrow.getString("fitemno");
  666. //图片
  667. itemrow.put("pics", picmap.get(fitemno));
  668. if (withprice) {
  669. titem titem = (titem) itemmap.get(fitemno);
  670. if (content.containsKey("fprojectnum") && !content.getString("fprojectnum").equals("")) {
  671. titem.fprojectnum = content.getString("fprojectnum");
  672. }
  673. double foldprice = titem.getCardPriceByAagentnum(fagentnum);
  674. double fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  675. //牌价
  676. itemrow.put("foldprice", foldprice);
  677. //销售价
  678. itemrow.put("fprice", fprice);
  679. //营销分类
  680. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  681. }
  682. }
  683. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  684. }
  685. /**
  686. * 项目订单商品选择
  687. * @return
  688. */
  689. public String query_projectitemList() throws Exception {
  690. /**
  691. * 创建数据库连接
  692. */
  693. DBConnect drpConnect = new DBConnect();
  694. /**
  695. *排序条件设置
  696. */
  697. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  698. String sort = sortmsg[0];
  699. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  700. sort = content.getString("sort");
  701. }
  702. /**
  703. * 是否包含价格
  704. */
  705. boolean withprice = content.containsKey("withprice") && content.getString("withprice").equals("1");
  706. String fprojectnum = content.getString("fprojectnum");//项目编号
  707. /**
  708. * 过滤条件设置
  709. */
  710. String where = " 1=1 ";
  711. if (content.containsKey("where")) {
  712. JSONObject whereObject = content.getJSONObject("where");
  713. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  714. where = where + " and(t1.fitemno like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  715. }
  716. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  717. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  718. }
  719. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  720. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  721. }
  722. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  723. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  724. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  725. flongsaleslsFactory.addParameter("siteid", siteid);
  726. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  727. if (flongsaleslsRows.isEmpty()) {
  728. where = where + " and 1=2";
  729. } else {
  730. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  731. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  732. }
  733. }
  734. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  735. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  736. }
  737. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  738. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  739. }
  740. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  741. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  742. }
  743. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  744. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  745. }
  746. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  747. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  748. }
  749. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  750. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  751. }
  752. }
  753. /**
  754. * SQL货品档案查询参数设置并查询
  755. */
  756. SQLFactory factory = new SQLFactory(this, "项目订单货品档案列表查询", pageSize, pageNumber, sort);
  757. factory.addParameter("fprojectnum", fprojectnum);
  758. factory.addParameter("siteid", siteid);
  759. factory.addParameter_SQL("where", where);
  760. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  761. /**
  762. *商品图片查询参数设置,并将结果存放置map
  763. */
  764. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, rows.toArray("fitemno"));
  765. /**
  766. * 商品营销类别
  767. */
  768. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  769. saleclsnumsqlFactory.addParameter("siteid", siteid);
  770. saleclsnumsqlFactory.addParameter_in("fitemno", rows.toArray("fitemno"));
  771. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  772. HashMap<String, PaoRemote> itemmap = null;
  773. if (withprice) {
  774. /**
  775. * 获取商品相关信息
  776. */
  777. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + rows.getInWhere("fitemno") + " and siteid='" + siteid + "'");
  778. itemmap = getPaoMap(titemset, "fitemno");
  779. }
  780. /**
  781. * 遍历货品档案,设置商品信息
  782. */
  783. for (Row itemrow : rows) {
  784. String fitemno = itemrow.getString("fitemno");
  785. //图片
  786. itemrow.put("pics", picmap.get(fitemno));
  787. if (withprice) {
  788. titem titem = (titem) itemmap.get(fitemno);
  789. if (content.containsKey("fprojectnum") && !content.getString("fprojectnum").equals("")) {
  790. titem.fprojectnum = content.getString("fprojectnum");
  791. }
  792. double foldprice = titem.getCardPriceByAagentnum(fagentnum);
  793. double fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  794. //牌价
  795. itemrow.put("foldprice", foldprice);
  796. //销售价
  797. itemrow.put("fprice", fprice);
  798. //营销分类
  799. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  800. }
  801. }
  802. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  803. }
  804. public String query_saler() throws Exception {
  805. /**
  806. * 创建数据库连接
  807. */
  808. DBConnect drpConnect = new DBConnect();
  809. /**
  810. *排序条件设置
  811. */
  812. String[] sortmsg = {"t1.fitemno", "t1.fitemname", "t1.fspec"};
  813. String sort = sortmsg[0];
  814. if (content.containsKey("sort") && Arrays.asList(sortmsg).contains(content.getString("sort"))) {
  815. sort = content.getString("sort");
  816. }
  817. /**
  818. * 过滤条件设置
  819. */
  820. String where = " 1=1 ";
  821. if (content.containsKey("where")) {
  822. JSONObject whereObject = content.getJSONObject("where");
  823. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  824. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  825. }
  826. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  827. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  828. }
  829. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  830. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  831. }
  832. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  833. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  834. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  835. flongsaleslsFactory.addParameter("siteid", siteid);
  836. Rows flongsaleslsRows = drpConnect.runSqlQuery(flongsaleslsFactory.getSQL());
  837. if (flongsaleslsRows.isEmpty()) {
  838. where = where + " and 1=2";
  839. } else {
  840. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  841. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  842. }
  843. }
  844. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  845. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  846. }
  847. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  848. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  849. }
  850. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  851. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  852. }
  853. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  854. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  855. }
  856. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  857. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  858. }
  859. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  860. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  861. }
  862. if (whereObject.containsKey("fvalue8") && whereObject.getBoolean("fvalue8")) {
  863. //如果是中线碟阀
  864. where = where + " and t1.fvalue8=1";
  865. }
  866. if (whereObject.containsKey("fvalue7") && !"".equals(whereObject.getString("fvalue7"))) {
  867. where = where + " and t1.fvalue7 ='" + whereObject.getString("fvalue7") + "'";
  868. }
  869. if (whereObject.containsKey("fvalue6") && !"".equals(whereObject.getString("fvalue6"))) {
  870. where = where + " and t1.fvalue6 ='" + whereObject.getString("fvalue6") + "'";
  871. }
  872. if (whereObject.containsKey("fvalue5") && !"".equals(whereObject.getString("fvalue5"))) {
  873. where = where + " and t1.fvalue5 ='" + whereObject.getString("fvalue5") + "'";
  874. }
  875. if (whereObject.containsKey("fvalue4") && !"".equals(whereObject.getString("fvalue4"))) {
  876. where = where + " and t1.fvalue4 ='" + whereObject.getString("fvalue4") + "'";
  877. }
  878. if (whereObject.containsKey("fvalue3") && !"".equals(whereObject.getString("fvalue3"))) {
  879. where = where + " and t1.fvalue3 ='" + whereObject.getString("fvalue3") + "'";
  880. }
  881. if (whereObject.containsKey("fvalue2") && !"".equals(whereObject.getString("fvalue2"))) {
  882. where = where + " and t1.fvalue2 ='" + whereObject.getString("fvalue2") + "'";
  883. }
  884. if (whereObject.containsKey("fvalue1") && !"".equals(whereObject.getString("fvalue1"))) {
  885. where = where + " and t1.fvalue1 ='" + whereObject.getString("fvalue1") + "'";
  886. }
  887. }
  888. /**
  889. * SQL货品档案查询参数设置并查询
  890. */
  891. SQLFactory factory = new SQLFactory(this, "货品档案列表查询_业务员", pageSize, pageNumber, sort);
  892. factory.addParameter("siteid", siteid);
  893. factory.addParameter_SQL("where", where);
  894. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  895. /**
  896. * 获取品号批查条件
  897. */
  898. String itemwhere = rows.getInWhere("fitemno");
  899. String[] itemarray = rows.toArray("fitemno");
  900. /**
  901. *商品图片查询参数设置,并将结果存放置map
  902. */
  903. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  904. /**
  905. *商品产品样册查询参数设置,并将结果存放置map
  906. */
  907. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  908. /**
  909. *商品说明书查询参数设置,并将结果存放置map
  910. */
  911. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  912. /**
  913. *商品安装教程查询参数设置,并将结果存放置map
  914. */
  915. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  916. /**
  917. * 商品营销类别
  918. */
  919. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  920. saleclsnumsqlFactory.addParameter("siteid", siteid);
  921. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  922. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  923. /**
  924. *更新即时库存
  925. */
  926. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  927. /**
  928. * 获取商品相关信息
  929. */
  930. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  931. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  932. /**
  933. * 遍历货品档案,设置商品信息
  934. */
  935. for (Row itemrow : rows) {
  936. String fitemno = itemrow.getString("fitemno");
  937. titem titem = (titem) itemmap.get(fitemno);
  938. double foldprice = titem.getCardPriceByGrade("1");
  939. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  940. double ficqty = titem.getDouble("ficqty");
  941. //库存状态
  942. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  943. //库存数量
  944. itemrow.put("ficqty", ficqty);
  945. //牌价
  946. itemrow.put("foldprice", foldprice);
  947. //销售价
  948. itemrow.put("fprice", foldprice);
  949. //图片
  950. itemrow.put("pics", picmap.get(fitemno));
  951. //产品样册
  952. itemrow.put("samplebook", samplebookmap.get(fitemno));
  953. //产品说明书
  954. itemrow.put("instructions", instructionsmap.get(fitemno));
  955. //安装教程
  956. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  957. //营销分类
  958. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  959. }
  960. titemset.close();
  961. return getReturnObject_suc_page(rows, true, 1, sortmsg).toString();
  962. }
  963. public String queryone() throws P2Exception {
  964. /**
  965. * 创建数据库连接
  966. */
  967. DBConnect drpConnect = new DBConnect();
  968. /**
  969. * 过滤条件设置
  970. */
  971. String where = " 1=1 ";
  972. if (content.containsKey("where")) {
  973. JSONObject whereObject = content.getJSONObject("where");
  974. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  975. }
  976. /**
  977. * SQL货品档案查询参数设置并查询
  978. */
  979. SQLFactory factory = new SQLFactory(this, "货品档案列表查询");
  980. factory.addParameter("fagentnum", fagentnum);
  981. factory.addParameter("siteid", siteid);
  982. factory.addParameter_SQL("where", where);
  983. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  984. /**
  985. * 获取品号批查条件
  986. */
  987. String itemwhere = rows.getInWhere("fitemno");
  988. String[] itemarray = rows.toArray("fitemno");
  989. /**
  990. *商品图片查询参数设置,并将结果存放置map
  991. */
  992. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  993. /**
  994. *商品产品样册查询参数设置,并将结果存放置map
  995. */
  996. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  997. /**
  998. *商品说明书查询参数设置,并将结果存放置map
  999. */
  1000. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  1001. /**
  1002. *商品安装教程查询参数设置,并将结果存放置map
  1003. */
  1004. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  1005. /**
  1006. * 商品营销类别
  1007. */
  1008. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  1009. saleclsnumsqlFactory.addParameter("siteid", siteid);
  1010. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  1011. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  1012. /**
  1013. *更新即时库存
  1014. */
  1015. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  1016. /**
  1017. * 获取商品相关信息
  1018. */
  1019. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  1020. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  1021. /**
  1022. * 遍历货品档案,设置商品信息
  1023. */
  1024. for (Row itemrow : rows) {
  1025. String fitemno = itemrow.getString("fitemno");
  1026. titem titem = (titem) itemmap.get(fitemno);
  1027. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  1028. double ficqty = titem.getDouble("ficqty");
  1029. double foldprice = 0;
  1030. double fprice = 0;
  1031. if ("业务员".equals(usertype) && ("".equals(fagentnum) || fagentnum == null)) {
  1032. PaoSetRemote titemsaleprice = titem.getPaoSet("titemsaleprice");
  1033. if (!titemsaleprice.isEmpty()) {
  1034. foldprice = titemsaleprice.getPao(0).getDouble("fprice");
  1035. }
  1036. fprice = foldprice;
  1037. } else {
  1038. foldprice = titem.getCardPriceByAagentnum(fagentnum);
  1039. fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  1040. }
  1041. //库存状态
  1042. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  1043. itemrow.put("ficqty", ficqty);
  1044. //牌价
  1045. itemrow.put("foldprice", foldprice);
  1046. //销售价
  1047. itemrow.put("fprice", fprice);
  1048. //图片
  1049. itemrow.put("pics", picmap.get(fitemno));
  1050. //产品样册
  1051. itemrow.put("samplebook", samplebookmap.get(fitemno));
  1052. //产品说明书
  1053. itemrow.put("instructions", instructionsmap.get(fitemno));
  1054. //安装教程
  1055. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  1056. //营销分类
  1057. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  1058. }
  1059. titemset.close();
  1060. return getReturnObject_suc(rows, true).toString();
  1061. }
  1062. public String queryone_saler() throws P2Exception {
  1063. /**
  1064. * 创建数据库连接
  1065. */
  1066. DBConnect drpConnect = new DBConnect();
  1067. /**
  1068. * 过滤条件设置
  1069. */
  1070. String where = " 1=1 ";
  1071. if (content.containsKey("where")) {
  1072. JSONObject whereObject = content.getJSONObject("where");
  1073. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  1074. }
  1075. /**
  1076. * SQL货品档案查询参数设置并查询
  1077. */
  1078. SQLFactory factory = new SQLFactory(this, "货品档案列表查询_业务员");
  1079. factory.addParameter("fagentnum", fagentnum);
  1080. factory.addParameter("siteid", siteid);
  1081. factory.addParameter_SQL("where", where);
  1082. Rows rows = drpConnect.runSqlQuery(factory.getSQL());
  1083. /**
  1084. * 获取品号批查条件
  1085. */
  1086. String itemwhere = rows.getInWhere("fitemno");
  1087. String[] itemarray = rows.toArray("fitemno");
  1088. /**
  1089. *商品图片查询参数设置,并将结果存放置map
  1090. */
  1091. RowsMap picmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_PIC, itemarray);
  1092. /**
  1093. *商品产品样册查询参数设置,并将结果存放置map
  1094. */
  1095. RowsMap samplebookmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_SAMPLEBOOK, itemarray);
  1096. /**
  1097. *商品说明书查询参数设置,并将结果存放置map
  1098. */
  1099. RowsMap instructionsmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTRUCTIONS, itemarray);
  1100. /**
  1101. *商品安装教程查询参数设置,并将结果存放置map
  1102. */
  1103. RowsMap installationtutorialmap = RowsPool.getRowsMap(siteid, RowsPool.GroupName.ITEM_INSTALLATIONTUTORIAL, itemarray);
  1104. /**
  1105. * 商品营销类别
  1106. */
  1107. SQLFactory saleclsnumsqlFactory = new SQLFactory(this, "货品营销类别查询");
  1108. saleclsnumsqlFactory.addParameter("siteid", siteid);
  1109. saleclsnumsqlFactory.addParameter_in("fitemno", itemarray);
  1110. RowsMap saleclsnumRowsMap = drpConnect.runSqlQuery(saleclsnumsqlFactory.getSQL()).toRowsMap("fitemno");
  1111. /**
  1112. *更新即时库存
  1113. */
  1114. new icinvbalMsg().caculate(siteid, rows.toArray("fitemno"), false);
  1115. /**
  1116. * 获取商品相关信息
  1117. */
  1118. PaoSetRemote titemset = getP2ServerPaoSet("titem", hrid, "fitemno in " + itemwhere + " and siteid='" + siteid + "'");
  1119. HashMap<String, PaoRemote> itemmap = getPaoMap(titemset, "fitemno");
  1120. /**
  1121. * 遍历货品档案,设置商品信息
  1122. */
  1123. for (Row itemrow : rows) {
  1124. String fitemno = itemrow.getString("fitemno");
  1125. titem titem = (titem) itemmap.get(fitemno);
  1126. String fsaorderstockstatus = titem.getString("fsaorderstockstatus");
  1127. double ficqty = titem.getDouble("ficqty");
  1128. double foldprice = 0;
  1129. double fprice = 0;
  1130. if ("业务员".equals(usertype) && ("".equals(fagentnum) || fagentnum == null)) {
  1131. PaoSetRemote titemsaleprice = titem.getPaoSet("titemsaleprice");
  1132. if (!titemsaleprice.isEmpty()) {
  1133. foldprice = titemsaleprice.getPao(0).getDouble("fprice");
  1134. }
  1135. fprice = foldprice;
  1136. } else {
  1137. foldprice = titem.getCardPriceByAagentnum(fagentnum);
  1138. fprice = titem.getAgentSalePrice(foldprice, fagentnum);
  1139. }
  1140. //库存状态
  1141. itemrow.put("fsaorderstockstatus", fsaorderstockstatus);
  1142. itemrow.put("ficqty", ficqty);
  1143. //牌价
  1144. itemrow.put("foldprice", foldprice);
  1145. //销售价
  1146. itemrow.put("fprice", fprice);
  1147. //图片
  1148. itemrow.put("pics", picmap.get(fitemno));
  1149. //产品样册
  1150. itemrow.put("samplebook", samplebookmap.get(fitemno));
  1151. //产品说明书
  1152. itemrow.put("instructions", instructionsmap.get(fitemno));
  1153. //安装教程
  1154. itemrow.put("installationtutorial", installationtutorialmap.get(fitemno));
  1155. //营销分类
  1156. itemrow.put("saleclsnum", saleclsnumRowsMap.get(fitemno));
  1157. }
  1158. titemset.close();
  1159. return getReturnObject_suc(rows, true).toString();
  1160. }
  1161. /**
  1162. * 查询商品图片
  1163. * @return
  1164. */
  1165. public String query_itempic() {
  1166. Rows picrows = RowsPool.getRows(siteid, RowsPool.GroupName.ITEM_PIC, content.getString("fitemno"));
  1167. return getReturnObject_suc(picrows, true).toString();
  1168. }
  1169. /**
  1170. * 商品收藏
  1171. * @return
  1172. */
  1173. public String collection() throws Exception {
  1174. // 商品编号
  1175. String fitemno = content.getString("fitemno");
  1176. //是否收藏
  1177. int fiscollection = content.getInt("fiscollection");
  1178. PaoSetRemote tfavorites = getP2ServerPaoSet("tfavorites", hrid, "fagentnum='" + fagentnum + "' and fitemno='" + fitemno + "'");
  1179. PaoRemote pao = null;
  1180. if (tfavorites.isEmpty()) {
  1181. pao = tfavorites.addAtEnd();
  1182. pao.setValue("fitemno", fitemno, 11L);
  1183. pao.setValue("fagentnum", fagentnum, 11L);
  1184. } else {
  1185. pao = tfavorites.getPao(0);
  1186. }
  1187. pao.setValue("fiscollection", fiscollection == 1, 11L);
  1188. tfavorites.save();
  1189. tfavorites.close();
  1190. return getReturnObject_suc().toString();
  1191. }
  1192. /**
  1193. * 商品定制信息查询
  1194. * @return
  1195. */
  1196. public String query_Customized() {
  1197. /**
  1198. * 创建数据库连接
  1199. */
  1200. DBConnect connect = new DBConnect();
  1201. /**
  1202. * SQL定制信息列表查询参数设置并查询
  1203. */
  1204. SQLFactory factory = new SQLFactory(this, "定制信息列表查询");
  1205. factory.addParameter("fitemno", content.getString("fitemno"));
  1206. factory.addParameter("siteid", siteid);
  1207. Rows rows = connect.runSqlQuery(factory.getSQL());
  1208. for (Row row : rows) {
  1209. SQLFactory detailfac = new SQLFactory(this, "定制信息列表选项查询");
  1210. detailfac.addParameter("titem_customizedid", row.getString("titem_customizedid"));
  1211. Rows optionsRows = connect.runSqlQuery(detailfac.getSQL());
  1212. row.put("options", optionsRows.toJsonArray("fvalue"));
  1213. }
  1214. return getReturnObject_suc(rows, true).toString();
  1215. }
  1216. /**
  1217. * 商品品牌查询
  1218. * @return
  1219. */
  1220. public String query_BrandList() {
  1221. /**
  1222. * 创建数据库连接
  1223. */
  1224. DBConnect connect = new DBConnect();
  1225. /**
  1226. * SQL定制信息列表查询参数设置并查询
  1227. */
  1228. SQLFactory factory = new SQLFactory(this, "品牌列表查询");
  1229. factory.addParameter("siteid", siteid);
  1230. Rows rows = connect.runSqlQuery(factory.getSQL());
  1231. return getReturnObject_suc(rows, true).toString();
  1232. }
  1233. public String query_itemvalueclass() {
  1234. DBConnect connect = new DBConnect();
  1235. /**
  1236. * 过滤条件设置
  1237. */
  1238. String where = " 1=1 ";
  1239. if (content.containsKey("where")) {
  1240. JSONObject whereObject = content.getJSONObject("where");
  1241. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  1242. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  1243. }
  1244. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  1245. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  1246. }
  1247. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  1248. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  1249. }
  1250. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  1251. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  1252. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  1253. flongsaleslsFactory.addParameter("siteid", siteid);
  1254. Rows flongsaleslsRows = connect.runSqlQuery(flongsaleslsFactory.getSQL());
  1255. if (flongsaleslsRows.isEmpty()) {
  1256. where = where + " and 1=2";
  1257. } else {
  1258. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  1259. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  1260. }
  1261. }
  1262. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  1263. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  1264. }
  1265. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  1266. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  1267. }
  1268. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  1269. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  1270. }
  1271. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  1272. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  1273. }
  1274. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  1275. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  1276. }
  1277. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  1278. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  1279. }
  1280. if (whereObject.containsKey("fvalue8") && whereObject.getBoolean("fvalue8")) {
  1281. //如果是中线碟阀
  1282. where = where + " and t1.fvalue8=1";
  1283. }
  1284. if (whereObject.containsKey("fvalue7") && !"".equals(whereObject.getString("fvalue7"))) {
  1285. where = where + " and t1.fvalue7 ='" + whereObject.getString("fvalue7") + "'";
  1286. }
  1287. if (whereObject.containsKey("fvalue6") && !"".equals(whereObject.getString("fvalue6"))) {
  1288. where = where + " and t1.fvalue6 ='" + whereObject.getString("fvalue6") + "'";
  1289. }
  1290. if (whereObject.containsKey("fvalue5") && !"".equals(whereObject.getString("fvalue5"))) {
  1291. where = where + " and t1.fvalue5 ='" + whereObject.getString("fvalue5") + "'";
  1292. }
  1293. if (whereObject.containsKey("fvalue4") && !"".equals(whereObject.getString("fvalue4"))) {
  1294. where = where + " and t1.fvalue4 ='" + whereObject.getString("fvalue4") + "'";
  1295. }
  1296. if (whereObject.containsKey("fvalue3") && !"".equals(whereObject.getString("fvalue3"))) {
  1297. where = where + " and t1.fvalue3 ='" + whereObject.getString("fvalue3") + "'";
  1298. }
  1299. if (whereObject.containsKey("fvalue2") && !"".equals(whereObject.getString("fvalue2"))) {
  1300. where = where + " and t1.fvalue2 ='" + whereObject.getString("fvalue2") + "'";
  1301. }
  1302. if (whereObject.containsKey("fvalue1") && !"".equals(whereObject.getString("fvalue1"))) {
  1303. where = where + " and t1.fvalue1 ='" + whereObject.getString("fvalue1") + "'";
  1304. }
  1305. }
  1306. SQLFactory sqlFactory = new SQLFactory(this, "商品档案选项查询");
  1307. sqlFactory.addParameter("fagentnum", fagentnum);
  1308. sqlFactory.addParameter("siteid", siteid);
  1309. sqlFactory.addParameter_SQL("where", where);
  1310. System.err.println(sqlFactory.getSQL());
  1311. RowsMap rowsMap = connect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("field");
  1312. JSONObject fieldobject = new JSONObject();
  1313. for (String field : rowsMap.keySet()) {
  1314. fieldobject.put(field, rowsMap.get(field).toJsonArray("value"));
  1315. }
  1316. return getReturnObject_suc(fieldobject, true).toString();
  1317. }
  1318. public String query_itemvalueclass_saler() {
  1319. DBConnect connect = new DBConnect();
  1320. /**
  1321. * 过滤条件设置
  1322. */
  1323. String where = " 1=1 ";
  1324. if (content.containsKey("where")) {
  1325. JSONObject whereObject = content.getJSONObject("where");
  1326. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  1327. where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
  1328. }
  1329. if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
  1330. where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
  1331. }
  1332. if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
  1333. where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
  1334. }
  1335. if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
  1336. SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
  1337. flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
  1338. flongsaleslsFactory.addParameter("siteid", siteid);
  1339. Rows flongsaleslsRows = connect.runSqlQuery(flongsaleslsFactory.getSQL());
  1340. if (flongsaleslsRows.isEmpty()) {
  1341. where = where + " and 1=2";
  1342. } else {
  1343. //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
  1344. where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
  1345. }
  1346. }
  1347. if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
  1348. where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
  1349. }
  1350. if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
  1351. where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
  1352. }
  1353. if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
  1354. where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
  1355. }
  1356. if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
  1357. where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
  1358. }
  1359. if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
  1360. where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
  1361. }
  1362. if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
  1363. where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
  1364. }
  1365. if (whereObject.containsKey("fvalue8") && whereObject.getBoolean("fvalue8")) {
  1366. //如果是中线碟阀
  1367. where = where + " and t1.fvalue8=1";
  1368. }
  1369. if (whereObject.containsKey("fvalue7") && !"".equals(whereObject.getString("fvalue7"))) {
  1370. where = where + " and t1.fvalue7 ='" + whereObject.getString("fvalue7") + "'";
  1371. }
  1372. if (whereObject.containsKey("fvalue6") && !"".equals(whereObject.getString("fvalue6"))) {
  1373. where = where + " and t1.fvalue6 ='" + whereObject.getString("fvalue6") + "'";
  1374. }
  1375. if (whereObject.containsKey("fvalue5") && !"".equals(whereObject.getString("fvalue5"))) {
  1376. where = where + " and t1.fvalue5 ='" + whereObject.getString("fvalue5") + "'";
  1377. }
  1378. if (whereObject.containsKey("fvalue4") && !"".equals(whereObject.getString("fvalue4"))) {
  1379. where = where + " and t1.fvalue4 ='" + whereObject.getString("fvalue4") + "'";
  1380. }
  1381. if (whereObject.containsKey("fvalue3") && !"".equals(whereObject.getString("fvalue3"))) {
  1382. where = where + " and t1.fvalue3 ='" + whereObject.getString("fvalue3") + "'";
  1383. }
  1384. if (whereObject.containsKey("fvalue2") && !"".equals(whereObject.getString("fvalue2"))) {
  1385. where = where + " and t1.fvalue2 ='" + whereObject.getString("fvalue2") + "'";
  1386. }
  1387. if (whereObject.containsKey("fvalue1") && !"".equals(whereObject.getString("fvalue1"))) {
  1388. where = where + " and t1.fvalue1 ='" + whereObject.getString("fvalue1") + "'";
  1389. }
  1390. }
  1391. SQLFactory sqlFactory = new SQLFactory(this, "商品档案选项查询_业务员");
  1392. sqlFactory.addParameter("siteid", siteid);
  1393. sqlFactory.addParameter_SQL("where", where);
  1394. System.err.println(sqlFactory.getSQL());
  1395. RowsMap rowsMap = connect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("field");
  1396. JSONObject fieldobject = new JSONObject();
  1397. for (String field : rowsMap.keySet()) {
  1398. fieldobject.put(field, rowsMap.get(field).toJsonArray("value"));
  1399. }
  1400. return getReturnObject_suc(fieldobject, true).toString();
  1401. }
  1402. }