Jelajahi Sumber

cucu业绩目标逻辑优化

hu 1 bulan lalu
induk
melakukan
d95fcd4f75

+ 17 - 17
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-目标详情列表.sql

@@ -45,23 +45,23 @@ with sa_salestarget as (
            m12.target_l as m12l,
            m12.target_h as m12h
     from sa_salestargethr t1
-             left join sa_salestarget y1 on t1.hrid = y1.hrid and y1.type = '年' and y1.point = 1
-             left join sa_salestarget s1 on t1.hrid = s1.hrid and s1.type = '季' and s1.point = 1
-             left join sa_salestarget s2 on t1.hrid = s2.hrid and s2.type = '季' and s2.point = 2
-             left join sa_salestarget s3 on t1.hrid = s3.hrid and s3.type = '季' and s3.point = 3
-             left join sa_salestarget s4 on t1.hrid = s4.hrid and s4.type = '季' and s4.point = 4
-             left join sa_salestarget m1 on t1.hrid = m1.hrid and m1.type = '月' and m1.point = 1
-             left join sa_salestarget m2 on t1.hrid = m2.hrid and m2.type = '月' and m2.point = 2
-             left join sa_salestarget m3 on t1.hrid = m3.hrid and m3.type = '月' and m3.point = 3
-             left join sa_salestarget m4 on t1.hrid = m4.hrid and m4.type = '月' and m4.point = 4
-             left join sa_salestarget m5 on t1.hrid = m5.hrid and m5.type = '月' and m5.point = 5
-             left join sa_salestarget m6 on t1.hrid = m6.hrid and m6.type = '月' and m6.point = 6
-             left join sa_salestarget m7 on t1.hrid = m7.hrid and m7.type = '月' and m7.point = 7
-             left join sa_salestarget m8 on t1.hrid = m8.hrid and m8.type = '月' and m8.point = 8
-             left join sa_salestarget m9 on t1.hrid = m9.hrid and m9.type = '月' and m9.point = 9
-             left join sa_salestarget m10 on t1.hrid = m10.hrid and m10.type = '月' and m10.point = 10
-             left join sa_salestarget m11 on t1.hrid = m11.hrid and m11.type = '月' and m11.point = 11
-             left join sa_salestarget m12 on t1.hrid = m12.hrid and m12.type = '月' and m12.point = 12
+             left join sa_salestarget y1 on t1.sa_saleareaid = y1.sa_saleareaid and y1.type = '年' and y1.point = 1
+             left join sa_salestarget s1 on t1.sa_saleareaid = s1.sa_saleareaid and s1.type = '季' and s1.point = 1
+             left join sa_salestarget s2 on t1.sa_saleareaid = s2.sa_saleareaid and s2.type = '季' and s2.point = 2
+             left join sa_salestarget s3 on t1.sa_saleareaid = s3.sa_saleareaid and s3.type = '季' and s3.point = 3
+             left join sa_salestarget s4 on t1.sa_saleareaid = s4.sa_saleareaid and s4.type = '季' and s4.point = 4
+             left join sa_salestarget m1 on t1.sa_saleareaid = m1.sa_saleareaid and m1.type = '月' and m1.point = 1
+             left join sa_salestarget m2 on t1.sa_saleareaid = m2.sa_saleareaid and m2.type = '月' and m2.point = 2
+             left join sa_salestarget m3 on t1.sa_saleareaid = m3.sa_saleareaid and m3.type = '月' and m3.point = 3
+             left join sa_salestarget m4 on t1.sa_saleareaid = m4.sa_saleareaid and m4.type = '月' and m4.point = 4
+             left join sa_salestarget m5 on t1.sa_saleareaid = m5.sa_saleareaid and m5.type = '月' and m5.point = 5
+             left join sa_salestarget m6 on t1.sa_saleareaid = m6.sa_saleareaid and m6.type = '月' and m6.point = 6
+             left join sa_salestarget m7 on t1.sa_saleareaid = m7.sa_saleareaid and m7.type = '月' and m7.point = 7
+             left join sa_salestarget m8 on t1.sa_saleareaid = m8.sa_saleareaid and m8.type = '月' and m8.point = 8
+             left join sa_salestarget m9 on t1.sa_saleareaid = m9.sa_saleareaid and m9.type = '月' and m9.point = 9
+             left join sa_salestarget m10 on t1.sa_saleareaid = m10.sa_saleareaid and m10.type = '月' and m10.point = 10
+             left join sa_salestarget m11 on t1.sa_saleareaid = m11.sa_saleareaid and m11.type = '月' and m11.point = 11
+             left join sa_salestarget m12 on t1.sa_saleareaid = m12.sa_saleareaid and m12.type = '月' and m12.point = 12
     where t1.sa_salestargetbillid = $sa_salestargetbillid$
 )
 select *

+ 5 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/通用-区域范围查询.sql

@@ -0,0 +1,5 @@
+select t1.areaname,t1.sa_saleareaid,0 hrid,'' name,0 departmentid,'' depname
+FROM  sa_salearea t1
+where not exists (select * from sa_salearea where parentid=t1.sa_saleareaid) and t1.parentid!=0
+      and t1.siteid = $siteid$
+      and t1.sa_saleareaid not in (SELECT sa_saleareaid FROM sa_salestargethr WHERE sa_salestargetbillid = $sa_salestargetbillid$ AND siteid = $siteid$)

+ 1 - 1
src/custom/restcontroller/webmanage/sale/salestarget_cucu/personnel.java

@@ -60,7 +60,7 @@ public class personnel extends Controller {
 
 
             //获取所有启用业务员
-            SQLFactory saleareahrsqlFactory = new SQLFactory(this, "通用-人员范围查询");
+            SQLFactory saleareahrsqlFactory = new SQLFactory(this, "通用-区域范围查询");
             saleareahrsqlFactory.addParameter("siteid", siteid);
             saleareahrsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             String sql = saleareahrsqlFactory.getSQL();