GetLogoData.ashx 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <%@ WebHandler Language="C#" Class="GetLogoData" %>
  2. using System;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.SessionState;
  7. using System.Web.Configuration;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Collections.Specialized;
  11. using System.Configuration;
  12. using Newtonsoft.Json;
  13. using Newtonsoft.Json.Linq;
  14. using Curtain.DataAccess;
  15. using Curtain.Log;
  16. using DK.XuWei.WebMes;
  17. /// <summary>
  18. /// 获取 当前产品的可变商标
  19. /// xuwei 2020-06-11
  20. /// </summary>
  21. public class GetLogoData : IHttpHandler, IReadOnlySessionState
  22. {
  23. public void ProcessRequest(HttpContext context)
  24. {
  25. using (IDataAccess conn = DataAccess.Create())
  26. {
  27. DataTable planData = conn.ExecuteDatatable(@"
  28. SELECT PP.GOODSID,PP.LOGOID,PP.QUANTITY,GDD.MATERIALCODE,PP.BEGINTIME,PP.ENDTIME
  29. FROM TP_PM_PRODUCTION_PLAN PP
  30. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD ON PP.GOODSID = GDD.GOODSID
  31. WHERE GDD.BARCODE = @BARCODE@
  32. AND PP.BEGINTIME <= SYSDATE
  33. AND PP.VALUEFLAG = 1
  34. AND PP.CONTROLRANGE = 1
  35. AND PP.ENDTIME > SYSDATE ",
  36. new CDAParameter("BARCODE", context.Request["barCode"])
  37. );
  38. if (planData != null && planData.Rows.Count > 0)
  39. {
  40. DataTable planFlag = conn.ExecuteDatatable(@"
  41. SELECT PLANFLAG FROM TP_MST_User WHERE USERID = @USERID@ ",
  42. new CDAParameter("USERID", HttpContext.Current.Session["userid"])
  43. );
  44. if (planFlag != null && planFlag.Rows.Count > 0 && planFlag.Rows[0]["PLANFLAG"].ToString() == "0")
  45. {
  46. //低级权限
  47. //DataTable plansTable = conn.ExecuteDatatable(@"
  48. // SELECT l.logoid AS id
  49. // ,CASE
  50. // WHEN linshi.residuequantity IS NOT NULL THEN
  51. // l.logoname || '[' || t2.materialcode || ']' || ' 剩余[' || linshi.residuequantity || ']'
  52. // ELSE
  53. // l.logoname || '[' || t2.materialcode || ']'
  54. // END AS NAME
  55. // ,t2.materialcode
  56. // ,nvl(gdd.valueflag, '0') AS iscurrentlogo
  57. // ,1 AS ISCONTROL
  58. // FROM tp_mst_logo l
  59. // INNER JOIN (SELECT DISTINCT t.goodsid,t.logoid,t.materialcode
  60. // FROM (SELECT g.goodsid,g.logoid,g.materialcode
  61. // FROM tp_mst_goods g
  62. // UNION ALL
  63. // SELECT s.goodsid,s.logoid,s.materialcode
  64. // FROM tp_mst_goodslogosap s) t
  65. // WHERE EXISTS (SELECT 1 FROM tp_pm_groutingdailydetail g
  66. // WHERE g.goodsid = t.goodsid AND g.barcode = @BARCODE@)) t2 ON t2.logoid = l.logoid
  67. // LEFT JOIN tp_pm_groutingdailydetail gdd ON gdd.logoid = l.logoid
  68. // AND gdd.barcode = @BARCODE@
  69. // RIGHT JOIN (
  70. // SELECT case when t.goodsid is null then tt.goodsid else t.goodsid end as goodsid
  71. // ,case when t.logoid is null then tt.logoid else t.logoid end as logoid
  72. // ,case when t.changenum is null then sum(0) else SUM(t.changenum) end as changenum
  73. // ,tt.quantity
  74. // ,case when t.changenum is null then tt.quantity else tt.quantity - SUM(t.changenum) end as residuequantity
  75. // FROM (
  76. // --在装配环节变更数量
  77. // SELECT ip.goodsid,ip.logoid,COUNT(distinct l.barcode) changenum
  78. // FROM tp_pm_logochangedrecord l
  79. // right JOIN tp_pm_groutingdailydetail ip ON l.barcode = ip.barcode
  80. // LEFT JOIN tp_pc_procedure p ON l.procedureid = p.procedureid
  81. // LEFT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  82. // FROM tp_pm_production_plan pp
  83. // LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  84. // WHERE gdd.barcode = @BARCODE@
  85. // AND pp.begintime <= SYSDATE
  86. // AND pp.endtime > SYSDATE and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) plans ON plans.goodsid = ip.goodsid AND plans.logoid = ip.logoid
  87. // WHERE l.createtime >= plans.begintime
  88. // AND l.createtime < plans.endtime
  89. // AND ip.goodsid = @GOODSID@
  90. // and ip.logoid = l.newlogoid
  91. // AND l.oldlogoid <> l.newlogoid
  92. // AND p.modeltype = '-5'
  93. // AND p.procedureid not in(126,152)
  94. // AND NOT EXISTS (SELECT s.barcode FROM tp_pm_scrapproduct s
  95. // WHERE s.barcode = l.barcode AND s.valueflag = 1 AND s.createtime >= l.createtime)
  96. // GROUP BY ip.goodsid,ip.logoid
  97. // UNION ALL
  98. // --生产数据该产品商标在装配环节保存的数量(装配环节没有变更商标)
  99. // SELECT pd.goodsid ,pd.logoid ,COUNT(distinct pd.barcode) changenum
  100. // FROM tp_pm_productiondata pd
  101. // LEFT JOIN tp_pc_procedure p ON pd.procedureid = p.procedureid
  102. // left join (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  103. // FROM tp_pm_production_plan pp
  104. // LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  105. // WHERE gdd.barcode = @BARCODE@
  106. // AND pp.begintime <= SYSDATE
  107. // AND pp.endtime > SYSDATE AND pp.CONTROLRANGE = 1 AND pp.VALUEFLAG = 1 ) plans1 on plans1.goodsid = pd.goodsid and plans1.logoid = pd.logoid
  108. // WHERE pd.createtime >= plans1.begintime
  109. // and pd.createtime < plans1.endtime
  110. // and pd.valueflag = 1
  111. // and p.modeltype = '-5'
  112. // and p.procedureid not in(126,152)
  113. // AND NOT EXISTS (SELECT s.barcode
  114. // FROM tp_pm_logochangedrecord s
  115. // LEFT JOIN tp_pc_procedure p ON s.procedureid = p.procedureid
  116. // WHERE s.barcode = pd.barcode
  117. // AND p.modeltype = '-5'
  118. // and p.procedureid not in(126,152)
  119. // --AND s.oldlogoid = pd.logoid
  120. // AND s.oldlogoid <> s.newlogoid)
  121. // GROUP BY pd.goodsid,pd.logoid) t
  122. // RIGHT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity
  123. // FROM tp_pm_production_plan pp
  124. // LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  125. // WHERE gdd.barcode = @BARCODE@
  126. // AND pp.begintime <= SYSDATE
  127. // AND pp.endtime > SYSDATE
  128. // and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) tt
  129. // ON t.logoid = tt.logoid
  130. // GROUP BY t.goodsid,tt.goodsid,t.logoid,tt.logoid,tt.quantity ,t.changenum
  131. // ) linshi ON linshi.logoid = l.logoid
  132. // WHERE l.valueflag = '1' AND l.accountid = @ACCOUNTID@
  133. // ORDER BY l.displayno",
  134. // new CDAParameter("BARCODE", context.Request["barCode"]),
  135. // new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]),
  136. // new CDAParameter("GOODSID", planData.Rows[0]["GOODSID"].ToString())
  137. // );
  138. DataTable plansTable = conn.ExecuteDatatable(@"
  139. SELECT l.logoid AS id
  140. ,CASE
  141. WHEN linshi.residuequantity IS NOT NULL AND linshi.quantity IS NOT NULL THEN
  142. l.logoname || '[' || t2.materialremark || ']' || ' 剩余[' || linshi.residuequantity || ']'
  143. WHEN linshi.residuequantity IS NULL AND linshi.quantity IS NOT NULL THEN
  144. l.logoname || '[' || t2.materialremark || ']' || ' 剩余[' || linshi.quantity || ']'
  145. ELSE
  146. l.logoname || '[' || t2.materialremark || ']'
  147. END AS NAME
  148. ,t2.materialcode
  149. ,nvl(gdd.valueflag, '0') AS iscurrentlogo
  150. ,1 AS ISCONTROL
  151. FROM tp_mst_logo l
  152. INNER JOIN (SELECT DISTINCT t.goodsid,t.logoid,t.materialcode,
  153. case when instr( t.materialremark ,'智能一体机陶瓷体')= 1 then substr(t.materialremark,9,length(t.materialremark))
  154. when instr( t.materialremark ,'落地式坐便器')= 1 then substr(t.materialremark,7,length(t.materialremark))
  155. when instr( t.materialremark ,'智能一体机')= 1 then substr(t.materialremark,6,length(t.materialremark))
  156. when instr( t.materialremark ,'电控一体机')= 1 then substr(t.materialremark,6,length(t.materialremark))
  157. else t.materialremark end as materialremark
  158. FROM (SELECT g.goodsid,g.logoid,g.materialcode,g.materialremark
  159. FROM tp_mst_goods g
  160. UNION ALL
  161. SELECT s.goodsid,s.logoid,s.materialcode,s.materialremark
  162. FROM tp_mst_goodslogosap s) t
  163. WHERE EXISTS (SELECT 1 FROM tp_pm_groutingdailydetail g
  164. WHERE g.goodsid = t.goodsid AND g.barcode = @BARCODE@)) t2 ON t2.logoid = l.logoid
  165. LEFT JOIN tp_pm_groutingdailydetail gdd ON gdd.logoid = l.logoid
  166. AND gdd.barcode = @BARCODE@
  167. RIGHT JOIN (
  168. SELECT case when t.goodsid is null then tt.goodsid else t.goodsid end as goodsid
  169. ,case when t.logoid is null then tt.logoid else t.logoid end as logoid
  170. , SUM(t.changenum) as changenum
  171. ,tt.quantity
  172. , tt.quantity - SUM(t.changenum) residuequantity
  173. FROM (
  174. --在装配环节变更数量
  175. SELECT ip.goodsid,ip.logoid,COUNT(distinct l.barcode) changenum
  176. FROM tp_pm_logochangedrecord l
  177. right JOIN tp_pm_groutingdailydetail ip ON l.barcode = ip.barcode
  178. LEFT JOIN tp_pc_procedure p ON l.procedureid = p.procedureid
  179. LEFT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  180. FROM tp_pm_production_plan pp
  181. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  182. WHERE gdd.barcode = @BARCODE@
  183. AND pp.begintime <= SYSDATE
  184. AND pp.endtime > SYSDATE and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) plans ON plans.goodsid = ip.goodsid AND plans.logoid = ip.logoid
  185. WHERE l.createtime >= plans.begintime
  186. AND l.createtime < plans.endtime
  187. AND ip.goodsid = @GOODSID@
  188. and ip.logoid = l.newlogoid
  189. AND l.oldlogoid <> l.newlogoid
  190. AND p.modeltype = '-5'
  191. AND p.procedureid not in(126,152)
  192. AND NOT EXISTS (SELECT s.barcode FROM tp_pm_scrapproduct s
  193. WHERE s.barcode = l.barcode AND s.valueflag = 1 AND s.createtime >= l.createtime)
  194. GROUP BY ip.goodsid,ip.logoid
  195. UNION ALL
  196. --生产数据该产品商标在装配环节保存的数量(装配环节没有变更商标)
  197. SELECT pd.goodsid ,pd.logoid ,COUNT(distinct pd.barcode) changenum
  198. FROM TP_PM_FINISHEDPRODUCT pd
  199. -- LEFT JOIN tp_pc_procedure p ON pd.procedureid = p.procedureid
  200. left join (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  201. FROM tp_pm_production_plan pp
  202. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  203. WHERE gdd.barcode = @BARCODE@
  204. AND pp.begintime <= SYSDATE
  205. AND pp.endtime > SYSDATE AND pp.CONTROLRANGE = 1 AND pp.VALUEFLAG = 1 ) plans1 on plans1.goodsid = pd.goodsid and plans1.logoid = pd.logoid
  206. WHERE pd.valueflag = 1
  207. and pd.goodsid =@GOODSID@
  208. -- and p.modeltype = '-5'
  209. -- and p.procedureid not in(126,152)
  210. and pd.FHTIME >= trunc(plans1.begintime)
  211. and pd.FHTIME < trunc(plans1.endtime)
  212. AND NOT EXISTS (SELECT s.barcode
  213. FROM tp_pm_logochangedrecord s
  214. LEFT JOIN tp_pc_procedure p ON s.procedureid = p.procedureid
  215. WHERE s.barcode = pd.barcode
  216. AND p.modeltype = '-5'
  217. and p.procedureid not in(126,152)
  218. --AND s.oldlogoid = pd.logoid
  219. AND s.oldlogoid <> s.newlogoid)
  220. AND EXISTS (SELECT pdd.barcode
  221. FROM tp_pm_productiondata pdd
  222. LEFT JOIN tp_pc_procedure p ON pdd.procedureid = p.procedureid
  223. WHERE pdd.barcode = pd.barcode
  224. AND p.modeltype = '-5'
  225. AND pdd.valueflag = 1
  226. and p.procedureid not in(126,152)
  227. and pdd.createtime >=plans1.begintime )
  228. GROUP BY pd.goodsid,pd.logoid
  229. ) t
  230. RIGHT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity
  231. FROM tp_pm_production_plan pp
  232. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  233. WHERE gdd.barcode = @BARCODE@
  234. AND pp.begintime <= SYSDATE
  235. AND pp.endtime > SYSDATE
  236. and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) tt
  237. ON t.logoid = tt.logoid
  238. GROUP BY t.goodsid,tt.goodsid,t.logoid,tt.logoid,tt.quantity
  239. ) linshi ON linshi.logoid = l.logoid
  240. WHERE l.valueflag = '1' AND l.accountid = @ACCOUNTID@
  241. ORDER BY l.displayno",
  242. new CDAParameter("BARCODE", context.Request["barCode"]),
  243. new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]),
  244. new CDAParameter("GOODSID", planData.Rows[0]["GOODSID"].ToString())
  245. );
  246. context.Response.Write(new JsonResult() { success = true, message = "操作成功!", rows = plansTable }.ToJson());
  247. }
  248. else
  249. {
  250. DataTable plansTable = conn.ExecuteDatatable(@"
  251. SELECT l.logoid AS id
  252. ,CASE
  253. WHEN linshi.residuequantity IS NOT NULL AND linshi.quantity IS NOT NULL THEN
  254. l.logoname || '[' || t2.materialremark || ']' || ' 剩余[' || linshi.residuequantity || ']'
  255. WHEN linshi.residuequantity IS NULL AND linshi.quantity IS NOT NULL THEN
  256. l.logoname || '[' || t2.materialremark || ']' || ' 剩余[' || linshi.quantity || ']'
  257. ELSE
  258. l.logoname || '[' || t2.materialremark || ']'
  259. END AS NAME
  260. ,t2.materialcode
  261. ,nvl(gdd.valueflag, '0') AS iscurrentlogo
  262. ,0 AS ISCONTROL
  263. FROM tp_mst_logo l
  264. INNER JOIN (SELECT DISTINCT t.goodsid,t.logoid,t.materialcode,
  265. case when instr( t.materialremark ,'智能一体机陶瓷体')= 1 then substr(t.materialremark,9,length(t.materialremark))
  266. when instr( t.materialremark ,'落地式坐便器')= 1 then substr(t.materialremark,7,length(t.materialremark))
  267. when instr( t.materialremark ,'智能一体机')= 1 then substr(t.materialremark,6,length(t.materialremark))
  268. when instr( t.materialremark ,'电控一体机')= 1 then substr(t.materialremark,6,length(t.materialremark))
  269. else t.materialremark end as materialremark
  270. FROM (SELECT g.goodsid,g.logoid,g.materialcode,g.materialremark
  271. FROM tp_mst_goods g
  272. UNION ALL
  273. SELECT s.goodsid,s.logoid,s.materialcode,s.materialremark
  274. FROM tp_mst_goodslogosap s) t
  275. WHERE EXISTS (SELECT 1 FROM tp_pm_groutingdailydetail g
  276. WHERE g.goodsid = t.goodsid AND g.barcode = @BARCODE@)) t2 ON t2.logoid = l.logoid
  277. LEFT JOIN tp_pm_groutingdailydetail gdd ON gdd.logoid = l.logoid
  278. AND gdd.barcode = @BARCODE@
  279. LEFT JOIN (
  280. SELECT case when t.goodsid is null then tt.goodsid else t.goodsid end as goodsid
  281. ,case when t.logoid is null then tt.logoid else t.logoid end as logoid
  282. , SUM(t.changenum) as changenum
  283. ,tt.quantity
  284. , tt.quantity - SUM(t.changenum) as residuequantity
  285. FROM (SELECT ip.goodsid,ip.logoid,COUNT(distinct l.barcode) changenum
  286. FROM tp_pm_logochangedrecord l
  287. right JOIN tp_pm_groutingdailydetail ip ON l.barcode = ip.barcode
  288. LEFT JOIN tp_pc_procedure p ON l.procedureid = p.procedureid
  289. LEFT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  290. FROM tp_pm_production_plan pp
  291. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  292. WHERE gdd.barcode = @BARCODE@
  293. AND pp.begintime <= SYSDATE
  294. AND pp.endtime > SYSDATE and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) plans ON plans.goodsid = ip.goodsid AND plans.logoid = ip.logoid
  295. WHERE l.createtime >= plans.begintime
  296. AND l.createtime < plans.endtime
  297. AND ip.goodsid = @GOODSID@
  298. and ip.logoid = l.newlogoid
  299. AND l.oldlogoid <> l.newlogoid
  300. AND p.modeltype = '-5'
  301. AND p.procedureid not in(126,152)
  302. AND NOT EXISTS (SELECT s.barcode FROM tp_pm_scrapproduct s
  303. WHERE s.barcode = l.barcode AND s.valueflag = 1 AND s.createtime >= l.createtime)
  304. GROUP BY ip.goodsid,ip.logoid
  305. UNION ALL
  306. --生产数据该产品商标在装配环节保存的数量(装配环节没有变更商标)
  307. SELECT pd.goodsid ,pd.logoid ,COUNT(distinct pd.barcode) changenum
  308. FROM TP_PM_FINISHEDPRODUCT pd
  309. -- LEFT JOIN tp_pc_procedure p ON pd.procedureid = p.procedureid
  310. left join (SELECT pp.goodsid,pp.logoid,pp.quantity,gdd.materialcode,pp.begintime ,pp.endtime
  311. FROM tp_pm_production_plan pp
  312. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  313. WHERE gdd.barcode = @BARCODE@
  314. AND pp.begintime <= SYSDATE
  315. AND pp.endtime > SYSDATE AND pp.CONTROLRANGE = 1 AND pp.VALUEFLAG = 1 ) plans1 on plans1.goodsid = pd.goodsid and plans1.logoid = pd.logoid
  316. WHERE pd.valueflag = 1
  317. and pd.goodsid =@GOODSID@
  318. -- and p.modeltype = '-5'
  319. -- and p.procedureid not in(126,152)
  320. and pd.FHTIME >= trunc(plans1.begintime)
  321. and pd.FHTIME < trunc(plans1.endtime)
  322. AND NOT EXISTS (SELECT s.barcode
  323. FROM tp_pm_logochangedrecord s
  324. LEFT JOIN tp_pc_procedure p ON s.procedureid = p.procedureid
  325. WHERE s.barcode = pd.barcode
  326. AND p.modeltype = '-5'
  327. and p.procedureid not in(126,152)
  328. --AND s.oldlogoid = pd.logoid
  329. AND s.oldlogoid <> s.newlogoid)
  330. AND EXISTS (SELECT pdd.barcode
  331. FROM tp_pm_productiondata pdd
  332. LEFT JOIN tp_pc_procedure p ON pdd.procedureid = p.procedureid
  333. WHERE pdd.barcode = pd.barcode
  334. AND p.modeltype = '-5'
  335. AND pdd.valueflag = 1
  336. and p.procedureid not in(126,152)
  337. and pdd.createtime >=plans1.begintime )
  338. GROUP BY pd.goodsid,pd.logoid
  339. ) t
  340. RIGHT JOIN (SELECT pp.goodsid,pp.logoid,pp.quantity
  341. FROM tp_pm_production_plan pp
  342. LEFT JOIN tp_pm_groutingdailydetail gdd ON pp.goodsid = gdd.goodsid
  343. WHERE gdd.barcode = @BARCODE@
  344. AND pp.begintime <= SYSDATE
  345. AND pp.endtime > SYSDATE
  346. and pp.valueflag = 1 AND pp.CONTROLRANGE = 1) tt
  347. ON t.logoid = tt.logoid
  348. GROUP BY t.goodsid,tt.goodsid,t.logoid,tt.logoid,tt.quantity
  349. ) linshi ON linshi.logoid = l.logoid
  350. WHERE l.valueflag = '1' AND l.accountid = @ACCOUNTID@
  351. ORDER BY l.displayno",
  352. new CDAParameter("BARCODE", context.Request["barCode"]),
  353. new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]),
  354. new CDAParameter("GOODSID", planData.Rows[0]["GOODSID"].ToString())
  355. );
  356. context.Response.Write(new JsonResult() { success = true, message = "操作成功!", rows = plansTable }.ToJson());
  357. }
  358. }
  359. else
  360. {
  361. DataTable dtLogo = conn.ExecuteDatatable(@"
  362. SELECT L.LOGOID AS ID,
  363. L.LOGONAME || '[' || case when instr( T2.materialremark ,'智能一体机陶瓷体')= 1 then substr(T2.materialremark,9,length(T2.materialremark))
  364. when instr( T2.materialremark ,'落地式坐便器')= 1 then substr(T2.materialremark,7,length(T2.materialremark))
  365. when instr( T2.materialremark ,'智能一体机')= 1 then substr(T2.materialremark,6,length(T2.materialremark))
  366. when instr( T2.materialremark ,'电控一体机')= 1 then substr(T2.materialremark,6,length(T2.materialremark))
  367. else T2.materialremark end || ']' AS NAME,
  368. T2.MATERIALCODE,
  369. NVL(GDD.VALUEFLAG, '0') AS ISCURRENTLOGO
  370. ,0 AS ISCONTROL
  371. FROM TP_MST_LOGO L
  372. INNER JOIN (SELECT DISTINCT T.GOODSID,
  373. T.LOGOID,
  374. T.MATERIALCODE,
  375. T.materialremark
  376. FROM (SELECT G.GOODSID,
  377. G.LOGOID,
  378. G.MATERIALCODE,
  379. G.materialremark
  380. FROM TP_MST_GOODS G
  381. UNION ALL
  382. SELECT S.GOODSID,
  383. S.LOGOID,
  384. S.MATERIALCODE,
  385. S.materialremark
  386. FROM TP_MST_GOODSLOGOSAP S) T
  387. WHERE EXISTS (SELECT 1
  388. FROM TP_PM_GROUTINGDAILYDETAIL G
  389. WHERE G.GOODSID = T.GOODSID
  390. AND G.BARCODE = @BARCODE@)) T2
  391. ON T2.LOGOID = L.LOGOID
  392. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD
  393. ON GDD.LOGOID = L.LOGOID
  394. AND GDD.BARCODE = @BARCODE@
  395. WHERE L.VALUEFLAG = '1'
  396. AND L.ACCOUNTID = @ACCOUNTID@
  397. ORDER BY L.DISPLAYNO ",
  398. new CDAParameter("BARCODE", context.Request["barCode"]),
  399. new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"])
  400. );
  401. context.Response.Write(new JsonResult() { success = true, message = "操作成功!", rows = dtLogo }.ToJson());
  402. }
  403. }
  404. }
  405. public bool IsReusable
  406. {
  407. get
  408. {
  409. return false;
  410. }
  411. }
  412. }