Browse Source

楚楚业绩目标

hu 6 months ago
parent
commit
76d6e5d2b5
21 changed files with 2459 additions and 0 deletions
  1. 17 0
      src/custom/beans/salearea/SQL/下级区域获取.sql
  2. 17 0
      src/custom/beans/salearea/SQL/下级区域获取_批量.sql
  3. 23 0
      src/custom/beans/salearea/SaleArea.java
  4. 85 0
      src/custom/restcontroller/R.java
  5. 5 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-删除人员范围.sql
  6. 5 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-删除目标明细.sql
  7. 7 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-查询可导入员工信息.sql
  8. 4 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-目标明细新增.sql
  9. 17 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-目标详情.sql
  10. 109 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-目标详情列表.sql
  11. 8 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员范围新增.sql
  12. 4 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/创建新年度.sql
  13. 581 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/回款明细.sql
  14. 14 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/年度目标列表.sql
  15. 12 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/更新新年度.sql
  16. 12 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户回款统计.sql
  17. 14 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户返利统计.sql
  18. 8 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/通用-人员范围查询.sql
  19. 453 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/performancetargetboard.java
  20. 645 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/personnel.java
  21. 419 0
      src/custom/restcontroller/webmanage/sale/salestarget_cucu/personnelexcel.java

+ 17 - 0
src/custom/beans/salearea/SQL/下级区域获取.sql

@@ -0,0 +1,17 @@
+with recursive salearea as (
+    select t1.sa_saleareaid,t1.areaname,t2.name
+    from sa_salearea t1
+    left join ((select t2.sa_saleareaid,GROUP_CONCAT(t3.name) name from sa_salearea_hr t2
+                   left join sys_hr t3 on t2.siteid = t3.siteid and t2.hrid = t3.hrid group by t2.sa_saleareaid)) t2 on t1.sa_saleareaid=t2.sa_saleareaid
+    where t1.siteid = $siteid$
+      and t1.sa_saleareaid = $sa_saleareaid$
+    union all
+    select t2.sa_saleareaid,t2.areaname,t3.name
+    from salearea t1
+             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid = $siteid$
+             left join ((select t2.sa_saleareaid,GROUP_CONCAT(t3.name) name from sa_salearea_hr t2
+                            left join sys_hr t3 on t2.siteid = t3.siteid and t2.hrid = t3.hrid group by t2.sa_saleareaid)) t3 on t2.sa_saleareaid=t3.sa_saleareaid
+
+)
+select sa_saleareaid,areaname,name
+from salearea

+ 17 - 0
src/custom/beans/salearea/SQL/下级区域获取_批量.sql

@@ -0,0 +1,17 @@
+with recursive salearea as (
+    select t1.sa_saleareaid,t1.areaname,t2.name
+    from sa_salearea t1
+    left join ((select t2.sa_saleareaid,GROUP_CONCAT(t3.name) name from sa_salearea_hr t2
+                   left join sys_hr t3 on t2.siteid = t3.siteid and t2.hrid = t3.hrid group by t2.sa_saleareaid)) t2 on t1.sa_saleareaid=t2.sa_saleareaid
+    where t1.siteid = $siteid$
+      and t1.sa_saleareaid in $sa_saleareaid$
+    union all
+    select t2.sa_saleareaid,t2.areaname,t3.name
+    from salearea t1
+             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid = $siteid$
+             left join ((select t2.sa_saleareaid,GROUP_CONCAT(t3.name) name from sa_salearea_hr t2
+                            left join sys_hr t3 on t2.siteid = t3.siteid and t2.hrid = t3.hrid group by t2.sa_saleareaid)) t3 on t2.sa_saleareaid=t3.sa_saleareaid
+
+)
+select sa_saleareaid,areaname,name
+from salearea

+ 23 - 0
src/custom/beans/salearea/SaleArea.java

@@ -34,6 +34,29 @@ public class SaleArea extends BaseClass {
         return rows.toArrayList("sa_saleareaid", new ArrayList<>());
     }
 
+    public static Rows getSubSaleAreas(Controller controller, long sa_saleareaid) throws YosException {
+        SQLFactory sqlFactory = new SQLFactory(new SaleArea(), "下级区域获取");
+        sqlFactory.addParameter("siteid", controller.siteid);
+        sqlFactory.addParameter("sa_saleareaid", sa_saleareaid);
+        Rows rows = controller.dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return rows;
+    }
+
+    /**
+     * 根据指定的区域id获取下级区域id
+     *
+     * @param controller
+     * @param sa_saleareaids
+     * @throws YosException
+     */
+    public static Rows getSubSaleAreas(Controller controller, ArrayList<Long> sa_saleareaids) throws YosException {
+        SQLFactory sqlFactory = new SQLFactory(new SaleArea(), "下级区域获取_批量");
+        sqlFactory.addParameter("siteid", controller.siteid);
+        sqlFactory.addParameter_in("sa_saleareaid", sa_saleareaids);
+        Rows rows = controller.dbConnect.runSqlQuery(sqlFactory.getSQL(false));
+        return rows;
+    }
+
     /**
      * 根据指定的区域id获取下级区域id
      *

+ 85 - 0
src/custom/restcontroller/R.java

@@ -5667,6 +5667,91 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025102913575103 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102914322803 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102914324303 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102915295803 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102915300903 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102915303303 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102915540403 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025102915541403 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103009445603 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103010165903 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103010192003 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103010193903 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103010195403 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103015304303 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103015481203 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103015485403 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025103015494803 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 5 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-删除人员范围.sql

@@ -0,0 +1,5 @@
+DELETE
+FROM sa_salestargethr
+WHERE hrid IN $hrid$
+  AND sa_salestargetbillid = $sa_salestargetbillid$
+  AND siteid = $siteid$

+ 5 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-删除目标明细.sql

@@ -0,0 +1,5 @@
+DELETE
+FROM sa_salestarget
+WHERE hrid IN $hrid$
+  AND sa_salestargetbillid = $sa_salestargetbillid$
+  AND siteid = $siteid$

+ 7 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-查询可导入员工信息.sql

@@ -0,0 +1,7 @@
+SELECT t1.hrid,t1.name,t5.areaname,t5.sa_saleareaid,t2.departmentid,t2.depname
+FROM  sys_hr t1
+          left join sys_department t2 on t1.siteid = t2.siteid and t1.departmentid = t2.departmentid
+          inner join sa_salearea_hr t4 on t1.siteid = t4.siteid and t1.hrid = t4.hrid
+          left join sa_salearea t5 on t4.siteid = t5.siteid and t4.sa_saleareaid = t5.sa_saleareaid
+WHERE t1.name IN $name$
+  AND t1.siteid = $siteid$

+ 4 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员-目标明细新增.sql

@@ -0,0 +1,4 @@
+insert into sa_salestarget (siteid, sa_salestargetid, type, point, target_l, target_h, targettype, sa_saleareaid,
+                            sa_salestargetbillid, year, sa_projectid, createby, createdate,hrid)
+values ($siteid$, $sa_salestargetid$, $type$, $point$, $target_l$, $target_h$, $targettype$, $sa_saleareaid$,
+        $sa_salestargetbillid$, $year$, $sa_projectid$, $createby$, current_time,$hrid$);

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

@@ -0,0 +1,17 @@
+SELECT t1.sa_salestargetbillid,
+       t1.createby,
+       t1.createdate,
+       t1.targettype,
+       t1.year,
+       t1.assessmentindicators,
+       t1.statisticaldimension,
+       t1.sa_accountclassids,
+       t1.`status`,
+       t1.changeby,
+       t1.changedate,
+       t1.checkdate,
+       t1.checkby,
+       (SELECT count(*) FROM sa_salestargethr WHERE sa_salestargetbillid = t1.sa_salestargetbillid) peoplecount
+from sa_salestargetbill t1
+WHERE siteid = $siteid$
+  AND sa_salestargetbillid = $sa_salestargetbillid$

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

@@ -0,0 +1,109 @@
+with sa_salestarget as (
+    select sa_saleareaid,hrid, type, point, target_l, target_h from sa_salestarget where sa_salestargetbillid =$sa_salestargetbillid$ and targettype = '人员目标' and siteid =$siteid$
+)
+   , hrtarget as (
+    select  t1.sa_saleareaid,
+			t1.areaname,
+            t1.hrid,
+            t1.name,
+           m1.target_l + m2.target_l + m3.target_l + m4.target_l + m5.target_l + m6.target_l +
+           m7.target_l + m8.target_l + m9.target_l + m10.target_l + m11.target_l +
+           m12.target_l                               y1l,
+           m1.target_h + m2.target_h + m3.target_h + m4.target_h + m5.target_h + m6.target_h +
+           m7.target_h + m8.target_h + m9.target_h + m10.target_h + m11.target_h +
+           m12.target_h                               y1h,
+           m1.target_l + m2.target_l + m3.target_l    s1l,
+           m1.target_h + m2.target_h + m3.target_h    s1h,
+           m4.target_l + m5.target_l + m6.target_l    s2l,
+           m4.target_h + m5.target_h + m6.target_h    s2h,
+           m7.target_l + m8.target_l + m9.target_l    s3l,
+           m7.target_h + m8.target_h + m9.target_h    s3h,
+           m10.target_l + m11.target_l + m12.target_l s4l,
+           m10.target_h + m11.target_h + m12.target_h s4h,
+           m1.target_l  as m1l,
+           m1.target_h  as m1h,
+           m2.target_l  as m2l,
+           m2.target_h  as m2h,
+           m3.target_l  as m3l,
+           m3.target_h  as m3h,
+           m4.target_l  as m4l,
+           m4.target_h  as m4h,
+           m5.target_l  as m5l,
+           m5.target_h  as m5h,
+           m6.target_l  as m6l,
+           m6.target_h  as m6h,
+           m7.target_l  as m7l,
+           m7.target_h  as m7h,
+           m8.target_l  as m8l,
+           m8.target_h  as m8h,
+           m9.target_l  as m9l,
+           m9.target_h  as m9h,
+           m10.target_l as m10l,
+           m10.target_h as m10h,
+           m11.target_l as m11l,
+           m11.target_h as m11h,
+           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
+    where t1.sa_salestargetbillid = $sa_salestargetbillid$
+)
+select *
+from (
+         select t1.areaname,
+				t1.sa_saleareaid,
+                t1.hrid,
+                t1.name,
+                y1l,
+                y1h,
+                s1l,
+                s1h,
+                s2l,
+                s2h,
+                s3l,
+                s3h,
+                s4l,
+                s4h,
+                m1l,
+                m1h,
+                m2l,
+                m2h,
+                m3l,
+                m3h,
+                m4l,
+                m4h,
+                m5l,
+                m5h,
+                m6l,
+                m6h,
+                m7l,
+                m7h,
+                m8l,
+                m8h,
+                m9l,
+                m9h,
+                m10l,
+                m10h,
+                m11l,
+                m11h,
+                m12l,
+                m12h
+         from hrtarget t1
+) t
+where $where$

+ 8 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/人员范围新增.sql

@@ -0,0 +1,8 @@
+insert into sa_salestargethr (siteid, sa_salestargethrid, hrid, position, areaname,sa_saleareaid , sa_salestargetbillid, depname,
+                              departmentid, name)
+select $siteid$, $sa_salestargethrid$, $hrid$, $position$, $areaname$,$sa_saleareaid$, $sa_salestargetbillid$, $depname$,
+        $departmentid$, $name$
+FROM dual
+WHERE not exists(SELECT 1
+                 FROM sa_salestargethr
+                 WHERE siteid = $siteid$ and sa_saleareaid = $sa_saleareaid$ AND sa_salestargetbillid = $sa_salestargetbillid$ )

+ 4 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/创建新年度.sql

@@ -0,0 +1,4 @@
+insert into sa_salestargetbill (siteid, sa_salestargetbillid, createby, createdate, changeuserid, changeby, changedate,
+                                targettype, year, status,sys_enterpriseid,tradefield,assessmentindicators,statisticaldimension,sa_accountclassids)
+values ($siteid$, $sa_salestargetbillid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $targettype$, $year$,
+        '新建',$sys_enterpriseid$,$tradefield$,$assessmentindicators$,$statisticaldimension$,$sa_accountclassids$);

+ 581 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/回款明细.sql

@@ -0,0 +1,581 @@
+with cashbill as (select sys_enterpriseid,
+                         sa_accountclassid,
+                         substring(t1.period, 6, 2)                period,
+                         sum(if(type = 0, 0 - amount, 0 + amount)) amount
+                  from sa_cashbill t1
+                  where ((t1.type = 1 and t1.class in ('货款', '物流赔偿')) or
+                         (t1.type = 0 and t1.subclass = '拨款'))
+                    and t1.status = '审核'
+                    and t1.siteid = $siteid$
+                    and substring(t1.period, 1, 4) =$year$
+                  group by sys_enterpriseid, sa_accountclassid, substring(t1.period, 6, 2)),
+     cashbill1 as (select t1.sys_enterpriseid, sum(amount) amount, substring(t1.period, 6, 2) period
+                   from sa_cashbill t1
+                            left join sa_agents t2
+                                      on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
+                   where t1.type = 1
+                     and t1.status = '审核'
+                     and t1.siteid = $siteid$
+                     and IF(t2.agentnum in ('D1001', 'DY01', '2314', '2315', '2316', '2701'), 1 = 1, t1.sa_accountclassid != 96)
+                     and substring(t1.period, 1, 4) =$year$
+                     and t1.subclass in ('广告费', '上样补贴', '装修补贴','内购返点', '年终返利')
+                   group by sys_enterpriseid, substring(t1.period, 6, 2)),
+     orders as (select t.sys_enterpriseid, submitdate, sum(t.amount) amount
+                from (select t1.sys_enterpriseid, t2.amount, date_format(t1.checkdate, '%m') submitdate
+                      from sa_order t1
+                               inner join sa_orderitems t2
+                                          on t1.siteid = t2.siteid and t1.sa_orderid = t2.sa_orderid
+                               inner join plm_item t3
+                                          on t2.siteid = t3.siteid and t2.itemid = t3.itemid
+                               left join sa_agents t4
+                                         on t1.siteid = t4.siteid and t1.sys_enterpriseid = t4.sys_enterpriseid
+                      where t1.siteid = $siteid$
+                                and t1.status in ('审核', '关闭','手工关闭') and t3.financeclasstype='木制品'
+                                and year(t1.checkdate) =$year$
+
+union all
+select t1.sys_enterpriseid, 0 - (t2.undeliqty * t2.price) , date_format(t1.closedate, '%m')
+from sa_order t1
+         inner join sa_orderitems t2
+                    on t1.siteid = t2.siteid and t1.sa_orderid = t2.sa_orderid
+         inner join plm_item t3
+                    on t2.siteid = t3.siteid and t2.itemid = t3.itemid
+         left join sa_agents t4
+                   on t1.siteid = t4.siteid and t1.sys_enterpriseid = t4.sys_enterpriseid
+where t1.siteid = $siteid$
+          and t1.status = '手工关闭' and t3.financeclasstype='木制品'
+          and year(t1.closedate) =$year$
+
+union all
+select t1.sys_enterpriseid, -t2.amount, date_format(t1.recheckdate, '%m')
+from sa_aftersalesmag t1
+         inner join sa_aftersalesmag_items t2
+                    on t1.siteid = t2.siteid and t1.sa_aftersalesmagid = t2.sa_aftersalesmagid
+         left join sa_agents t4
+                   on t1.siteid = t4.siteid and t1.sys_enterpriseid = t4.sys_enterpriseid
+where t1.siteid = $siteid$
+          and t1.status = '复核' and t2.reason='木制品退货'
+          and year(t1.recheckdate) =$year$) t
+group by sys_enterpriseid, submitdate)
+select distinct t1.enterprisename,
+                t1.siteid,
+                t1.province,
+                t2.agentnum,
+                t4.areaname2,
+                t4.areaname3,
+                cast(cast(t5.amount1 as float) as char)                                amount11,
+                cast(cast(t5.amount2 as float) as char)                                amount12,
+                cast(cast(t5.amount3 as float) as char)                                amount13,
+                cast(cast(t5.amount4 as float) as char)                                amount14,
+                cast(cast(t5.amount5 as float) as char)                                amount15,
+                cast(cast((t5.amount1 + t5.amount5 + t5.amount3) as float) as char)    sum1,
+                cast(cast(t6.amount1 as float) as char)                                amount21,
+                cast(cast(t6.amount2 as float) as char)                                amount22,
+                cast(cast(t6.amount3 as float) as char)                                amount23,
+                cast(cast(t6.amount4 as float) as char)                                amount24,
+                cast(cast(t6.amount5 as float) as char)                                amount25,
+                cast(cast((t6.amount1 + t6.amount5 + t6.amount3) as float) as char)    sum2,
+                cast(cast(t7.amount1 as float) as char)                                amount31,
+                cast(cast(t7.amount2 as float) as char)                                amount32,
+                cast(cast(t7.amount3 as float) as char)                                amount33,
+                cast(cast(t7.amount4 as float) as char)                                amount34,
+                cast(cast(t7.amount5 as float) as char)                                amount35,
+                cast(cast((t7.amount1 + t7.amount5 + t7.amount3) as float) as char)    sum3,
+                cast(cast(t8.amount1 as float) as char)                                amount41,
+                cast(cast(t8.amount2 as float) as char)                                amount42,
+                cast(cast(t8.amount3 as float) as char)                                amount43,
+                cast(cast(t8.amount4 as float) as char)                                amount44,
+                cast(cast(t8.amount5 as float) as char)                                amount45,
+                cast(cast((t8.amount1 + t8.amount5 + t8.amount3) as float) as char)    sum4,
+                cast(cast(t9.amount1 as float) as char)                                amount51,
+                cast(cast(t9.amount2 as float) as char)                                amount52,
+                cast(cast(t9.amount3 as float) as char)                                amount53,
+                cast(cast(t9.amount4 as float) as char)                                amount54,
+                cast(cast(t9.amount5 as float) as char)                                amount55,
+                cast(cast((t9.amount1 + t9.amount5 +  t9.amount3) as float) as char)    sum5,
+                cast(cast(t10.amount1 as float) as char)                               amount61,
+                cast(cast(t10.amount2 as float) as char)                               amount62,
+                cast(cast(t10.amount3 as float) as char)                               amount63,
+                cast(cast(t10.amount4 as float) as char)                               amount64,
+                cast(cast(t10.amount5 as float) as char)                               amount65,
+                cast(cast((t10.amount1 + t10.amount5 + t10.amount3) as float) as char) sum6,
+                cast(cast(t11.amount1 as float) as char)                               amount71,
+                cast(cast(t11.amount2 as float) as char)                               amount72,
+                cast(cast(t11.amount3 as float) as char)                               amount73,
+                cast(cast(t11.amount4 as float) as char)                               amount74,
+                cast(cast(t11.amount5 as float) as char)                               amount75,
+                cast(cast((t11.amount1 + t11.amount5 + t11.amount3) as float) as char) sum7,
+                cast(cast(t12.amount1 as float) as char)                               amount81,
+                cast(cast(t12.amount2 as float) as char)                               amount82,
+                cast(cast(t12.amount3 as float) as char)                               amount83,
+                cast(cast(t12.amount4 as float) as char)                               amount84,
+                cast(cast(t12.amount5 as float) as char)                               amount85,
+                cast(cast((t12.amount1 + t12.amount5 + t12.amount3) as float) as char) sum8,
+                cast(cast(t13.amount1 as float) as char)                               amount91,
+                cast(cast(t13.amount2 as float) as char)                               amount92,
+                cast(cast(t13.amount3 as float) as char)                               amount93,
+                cast(cast(t13.amount4 as float) as char)                               amount94,
+                cast(cast(t13.amount5 as float) as char)                               amount95,
+                cast(cast((t13.amount1 + t13.amount5 + t13.amount3) as float) as char) sum9,
+                cast(cast(t14.amount1 as float) as char)                               amount101,
+                cast(cast(t14.amount2 as float) as char)                               amount102,
+                cast(cast(t14.amount3 as float) as char)                               amount103,
+                cast(cast(t14.amount4 as float) as char)                               amount104,
+                cast(cast(t14.amount5 as float) as char)                               amount105,
+                cast(cast((t14.amount1 + t14.amount5 + t14.amount3) as float) as char) sum10,
+                cast(cast(t15.amount1 as float) as char)                               amount111,
+                cast(cast(t15.amount2 as float) as char)                               amount112,
+                cast(cast(t15.amount3 as float) as char)                               amount113,
+                cast(cast(t15.amount4 as float) as char)                               amount114,
+                cast(cast(t15.amount5 as float) as char)                               amount115,
+                cast(cast((t15.amount1 + t15.amount5 + t15.amount3) as float) as char) sum11,
+                cast(cast(t16.amount1 as float) as char)                               amount121,
+                cast(cast(t16.amount2 as float) as char)                               amount122,
+                cast(cast(t16.amount3 as float) as char)                               amount123,
+                cast(cast(t16.amount4 as float) as char)                               amount124,
+                cast(cast(t16.amount5 as float) as char)                               amount125,
+                cast(cast((t16.amount1 + t16.amount5 + t16.amount3) as float) as char) sum12,
+                cast(cast(t17.amount1 as float) as char)                               count1,
+                cast(cast(t17.amount2 as float) as char)                               count2,
+                cast(cast(t17.amount3 as float) as char)                               count3,
+                cast(cast(t17.amount4 as float) as char)                               count4,
+                cast(cast(t17.amount5 as float) as char)                               count5,
+                cast(cast((t17.amount1 + t17.amount5 + t17.amount3) as float) as char) count6
+from sys_enterprise t1
+         left join sa_agents t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
+         left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid
+         left join (select t1.sa_saleareaid, t3.areaname areaname1, t2.areaname areaname2, t1.areaname areaname3
+                    from sa_salearea t1
+                             inner join sa_salearea t2
+                                        on t1.siteid = t2.siteid and t1.parentid = t2.sa_saleareaid and t2.level = 2
+                             inner join sa_salearea t3
+                                        on t1.siteid = t2.siteid and t2.parentid = t3.sa_saleareaid and t3.level = 1
+                    where t1.siteid = $siteid$
+                    union all
+                    select t1.sa_saleareaid, t2.areaname, t1.areaname, null
+                    from sa_salearea t1
+                             inner join sa_salearea t2
+                                        on t1.siteid = t2.siteid and t1.parentid = t2.sa_saleareaid and t2.level = 1
+                    where t1.siteid = $siteid$
+                    union all
+                    select t1.sa_saleareaid, t1.areaname, null, null
+                    from sa_salearea t1
+                    where t1.level = 1
+                      and t1.siteid = $siteid$) t4 on t3.sa_saleareaid = t4.sa_saleareaid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '01'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '01'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '01'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '01') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '01'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t5
+                   on t1.sys_enterpriseid = t5.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '02'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '02'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '02'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '02') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '02'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t6
+                   on t1.sys_enterpriseid = t6.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '03'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '03'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '03'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '03') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '03'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t7
+                   on t1.sys_enterpriseid = t7.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '04'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '04'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '04'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '04') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '04'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t8
+                   on t1.sys_enterpriseid = t8.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '05'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '05'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '05'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '05') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '05'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t9
+                   on t1.sys_enterpriseid = t9.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '06'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '06'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '06'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '06') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '06'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t10
+                   on t1.sys_enterpriseid = t10.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '07'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '07'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '07'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '07') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '07'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t11
+                   on t1.sys_enterpriseid = t11.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '08'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '08'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '08'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '08') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '08'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t12
+                   on t1.sys_enterpriseid = t12.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '09'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '09'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '09'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '09') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '09'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t13
+                   on t1.sys_enterpriseid = t13.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '10'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '10'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '10'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '10') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '10'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t14
+                   on t1.sys_enterpriseid = t14.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '11'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '11'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '11'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '11') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '11'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t15
+                   on t1.sys_enterpriseid = t15.sys_enterpriseid
+         left join (select t5.sys_enterpriseid,
+                           ifnull(t1.amount, 0) amount1,
+                           ifnull(t2.amount, 0) amount2,
+                           ifnull(t3.amount, 0) amount3,
+                           ifnull(t4.amount, 0) amount4,
+                           ifnull(t6.amount, 0) amount5
+                    from sys_enterprise t5
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 67
+                                          and t1.period = '12'
+                                        group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 69
+                                          and t1.period = '12'
+                                        group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill1 t1
+                                        where t1.period = '12'
+                                        group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                             left join (select t.sys_enterpriseid, t.amount
+                                        from orders t
+                                        where t.submitdate = '12') t4
+                                       on t5.sys_enterpriseid = t4.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 98
+                                          and t1.period = '12'
+                                        group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                    where t5.siteid = $siteid$) t16
+                   on t1.sys_enterpriseid = t16.sys_enterpriseid
+         inner join (select t5.sys_enterpriseid,
+                            ifnull(t1.amount, 0) amount1,
+                            ifnull(t2.amount, 0) amount2,
+                            ifnull(t3.amount, 0) amount3,
+                            ifnull(t4.amount, 0) amount4,
+                            ifnull(t6.amount, 0) amount5
+                     from sys_enterprise t5
+                              left join (select sys_enterpriseid, sum(amount) amount
+                                         from cashbill t1
+                                         where t1.sa_accountclassid = 67
+                                         group by sys_enterpriseid) t1 on t5.sys_enterpriseid = t1.sys_enterpriseid
+                              left join (select sys_enterpriseid, sum(amount) amount
+                                         from cashbill t1
+                                         where t1.sa_accountclassid = 69
+                                         group by sys_enterpriseid) t2 on t5.sys_enterpriseid = t2.sys_enterpriseid
+                              left join (select sys_enterpriseid, sum(amount) amount
+                                         from cashbill1 t1
+                                         group by sys_enterpriseid) t3 on t5.sys_enterpriseid = t3.sys_enterpriseid
+                              left join (select t.sys_enterpriseid, sum(t.amount) amount
+                                         from orders t
+                                         group by t.sys_enterpriseid) t4
+                                        on t5.sys_enterpriseid = t4.sys_enterpriseid
+                              left join (select sys_enterpriseid, sum(amount) amount
+                                         from cashbill t1
+                                         where t1.sa_accountclassid = 98
+                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                     where t5.siteid = $siteid$
+                         and (t1.amount>=0 or t2.amount>= 0 or t3.amount>= 0 or
+                              t4.amount>= 0) or t6.amount>= 0) t17 on t1.sys_enterpriseid = t17.sys_enterpriseid
+where t1.siteid = $siteid$
+  and t1.sys_enterpriseid not in (9116, 9117)
+  and $where$
+

+ 14 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/年度目标列表.sql

@@ -0,0 +1,14 @@
+SELECT t1.sa_salestargetbillid,
+       t1.createby,
+       t1.createdate,
+       t1.targettype,
+       t1.assessmentindicators,
+       t1.statisticaldimension,
+       t1.sa_accountclassids,
+       t1.year,
+       t1.`status`,
+       (SELECT count(*) FROM sa_salestargethr WHERE sa_salestargetbillid = t1.sa_salestargetbillid) peoplecount
+from sa_salestargetbill t1
+WHERE siteid = $siteid$
+  AND targettype = $targettype$
+  AND $where$

+ 12 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/更新新年度.sql

@@ -0,0 +1,12 @@
+UPDATE sa_salestargetbill
+SET
+    assessmentindicators = $assessmentindicators$,
+    sa_accountclassids=$sa_accountclassids$,
+    statisticaldimension=$statisticaldimension$,
+    changeuserid=$userid$,
+    changeby=$username$
+WHERE sa_salestargetbillid = $sa_salestargetbillid$ and siteid=$siteid$
+
+
+
+

+ 12 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户回款统计.sql

@@ -0,0 +1,12 @@
+select t3.accountname,substring(t1.period, 6, 2) month,sum(if(t1.type = 0, 0 - amount, 0 + amount)) amount
+from sa_cashbill t1
+         left join sys_enterprise_tradefield t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid
+         left join sa_accountclass t3 on t3.sa_accountclassid=t1.sa_accountclassid and t3.siteid=t1.siteid
+where ((t1.type = 1 and t1.class in ('货款', '物流赔偿')) or
+       (t1.type = 0 and t1.subclass = '拨款'))
+  and t1.status = '审核'
+  and t1.siteid = $siteid$
+  and substring(t1.period, 1, 4) =  $year$
+  and t2.sa_saleareaid in $sa_saleareaids$
+  and $where$
+group by t3.accountname, substring(t1.period, 6, 2)

+ 14 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户返利统计.sql

@@ -0,0 +1,14 @@
+select  sum(amount) amount, substring(t1.period, 6, 2) month
+from sa_cashbill t1
+         left join sa_agents t2
+                   on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
+         left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid
+where t1.type = 1
+  and t1.status = '审核'
+  and t1.siteid = $siteid$
+  and IF(t2.agentnum in ('D1001', 'DY01', '2314', '2315', '2316', '2701'), 1 = 1, t1.sa_accountclassid != 96)
+  and substring(t1.period, 1, 4) =  $year$
+  and t1.subclass in ('广告费', '上样补贴', '装修补贴','内购返点', '年终返利')
+  and t3.sa_saleareaid in $sa_saleareaids$
+  and $where$
+group by substring(t1.period, 6, 2)

+ 8 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/通用-人员范围查询.sql

@@ -0,0 +1,8 @@
+select t5.sa_saleareaid,t5.areaname,t1.hrid,t1.name,t2.departmentid,t2.depname
+from sys_hr t1
+         left join sys_department t2 on t1.siteid = t2.siteid and t1.departmentid = t2.departmentid
+         inner join sa_salearea_hr t4 on t1.siteid = t4.siteid and t1.hrid = t4.hrid
+         inner join sa_salearea t5 on t4.siteid = t5.siteid and t4.sa_saleareaid = t5.sa_saleareaid
+where not exists (select * from sa_salearea where parentid=t5.sa_saleareaid) and t5.parentid!=0
+      and t1.siteid = $siteid$
+      and t1.hrid not in (SELECT hrid FROM sa_salestargethr WHERE sa_salestargetbillid = $sa_salestargetbillid$ AND siteid = $siteid$)

+ 453 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/performancetargetboard.java

@@ -0,0 +1,453 @@
+package restcontroller.webmanage.sale.salestarget_cucu;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+import restcontroller.webmanage.sale.salestarget.personnel;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.ConcurrentModificationException;
+import java.util.List;
+
+import static beans.salearea.SaleArea.getSubSaleAreaIds;
+import static beans.salearea.SaleArea.getSubSaleAreas;
+
+@API(title = "业绩目标看板")
+public class performancetargetboard extends Controller {
+
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public performancetargetboard(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "获取当前业务员区域", apiversion = R.ID2025103010165903.v1.class)
+    public String querycurrentAreaList() throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr","name");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_salearea_hr", "t2", "t1.siteid = t2.siteid and t1.hrid = t2.hrid");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_salearea", "t3", " t3.siteid = t2.siteid and t3.sa_saleareaid = t2.sa_saleareaid", "sa_saleareaid","areaname");
+
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t1.hrid", hrid);
+
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "获取当前业务员区域及其下属区域", apiversion = R.ID2025103009445603.v1.class)
+    public String querySalerAreaList() throws YosException {
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_salearea_hr", "t2", "t1.siteid = t2.siteid and t1.hrid = t2.hrid");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_salearea", "t3", " t3.siteid = t2.siteid and t3.sa_saleareaid = t2.sa_saleareaid", "sa_saleareaid");
+
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t1.hrid", hrid);
+
+        Rows rows = querySQL.query();
+        Rows arearows=new Rows();
+
+        ArrayList<Long> list = new ArrayList<>();
+
+        for (Row row : rows) {
+            list.add(row.getLong("sa_saleareaid"));
+        }
+
+        if(rows.isNotEmpty()){
+             arearows =getSubSaleAreas(this,list);
+        }
+        return getSucReturnObject().setData(arearows).toString();
+
+    }
+
+    @API(title = "查询业务员月度指标", apiversion = R.ID2025103010192003.v1.class)
+    public String queryperformancetarget_month() throws YosException {
+        long sa_saleareaid= content.getLong("sa_saleareaid");
+        long year= content.getLong("year");
+        long month= content.getLong("month");
+        String monthstr = String.format("%02d", month);
+        String previousmonthstr = String.format("%02d", month-1);
+        JSONObject jsonObject =new JSONObject();
+
+        BigDecimal gcproportion =BigDecimal.ZERO;
+        BigDecimal zzproportion =BigDecimal.ZERO;
+
+        Rows salestargetbillrows =dbConnect.runSqlQuery("select * from sa_salestargetbill where siteid='"+siteid+"' and year="+year+" and targettype='人员目标'");
+        Rows rows = dbConnect.runSqlQuery("select * from sys_site_parameter where siteid='" + siteid + "'");
+        if(rows.isNotEmpty()){
+            gcproportion=rows.get(0).getBigDecimal("gcproportion").divide(BigDecimal.valueOf(100));
+            zzproportion=rows.get(0).getBigDecimal("zzproportion").divide(BigDecimal.valueOf(100));
+        }
+
+        long sa_salestargetbillid=0;
+        if(salestargetbillrows.isNotEmpty()){
+            sa_salestargetbillid=salestargetbillrows.get(0).getLong("sa_salestargetbillid");
+        }
+        SQLFactory personnelsqlFactory = new SQLFactory(this, "人员-目标详情列表");
+        personnelsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        personnelsqlFactory.addParameter_SQL("where", " t.sa_saleareaid="+sa_saleareaid);
+        personnelsqlFactory.addParameter("siteid", siteid);
+        Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
+        BigDecimal rw_month=BigDecimal.ZERO;
+        BigDecimal rw_previousmonth=BigDecimal.ZERO;
+        if(salestargetrows.isNotEmpty()){
+            //月度任务(万)
+            jsonObject.put("rw_month",salestargetrows.get(0).getBigDecimal("m"+month+"l"));
+            rw_month=salestargetrows.get(0).getBigDecimal("m"+month+"l");
+            rw_previousmonth=salestargetrows.get(0).getBigDecimal("m"+(month-1)+"l");
+        }else{
+            jsonObject.put("rw_month",BigDecimal.ZERO);
+        }
+        SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
+        paymentsqlFactory.addParameter("year", year);
+        paymentsqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
+        paymentsqlFactory.addParameter("siteid", siteid);
+        Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
+        RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
+
+        SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
+        rebatesqlFactory.addParameter("year", year);
+        rebatesqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        rebatesqlFactory.addParameter_SQL("where"," 1=1 ");
+        rebatesqlFactory.addParameter("siteid", siteid);
+        Rows rebateRows = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
+        RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
+        BigDecimal xainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
+
+        BigDecimal previousxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(previousmonthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        BigDecimal previoushuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(previousmonthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        BigDecimal previousfanli=rebateRowsMap.containsKey(previousmonthstr)?rebateRowsMap.get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
+        //回款完成额
+        jsonObject.put("completedamount",xainjin.add(huodong).add(fanli));
+        //上月完成额超出部分
+        jsonObject.put("previousexceed",month==1?0:previousxainjin.add(previoushuodong).add(previousfanli).subtract(rw_previousmonth));
+
+        BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        //GC工程完成额
+        jsonObject.put("gccompletedamount",gcgc.max(rw_month.multiply(gcproportion)));
+        //GC工程超出部分
+        jsonObject.put("gccompletedamountexceed",gcgc.subtract(rw_month.multiply(gcproportion)).compareTo(BigDecimal.ZERO)>0?gcgc.subtract(rw_month.multiply(gcproportion)):0);
+
+        BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+        //整装工程完成额
+        jsonObject.put("zzcompletedamount",zzgc.max(rw_month.multiply(zzproportion)));
+        //整装工程超出部分
+        jsonObject.put("zzcompletedamountexceed",zzgc.subtract(rw_month.multiply(zzproportion)).compareTo(BigDecimal.ZERO)>0?zzgc.subtract(rw_month.multiply(zzproportion)):0);
+
+        //完成额超出100%部分
+        jsonObject.put("completedamountexceed100",jsonObject.getBigDecimal("completedamount").add(jsonObject.getBigDecimal("previousexceed")).add(jsonObject.getBigDecimal("gccompletedamount")).add(jsonObject.getBigDecimal("zzcompletedamount")).subtract(rw_month));
+        //实际完成额
+        jsonObject.put("actualcompletedamount",jsonObject.getBigDecimal("completedamount").add(jsonObject.getBigDecimal("gccompletedamount")).add(jsonObject.getBigDecimal("zzcompletedamount")));
+        //实际完成百分比
+        if(rw_month.compareTo(BigDecimal.ZERO)==0){
+            jsonObject.put("actualcompletedpercentage",0);
+        }else{
+            jsonObject.put("actualcompletedpercentage", (jsonObject.getBigDecimal("completedamount").add(jsonObject.getBigDecimal("previousexceed")).add(jsonObject.getBigDecimal("gccompletedamount")).add(jsonObject.getBigDecimal("zzcompletedamount"))).divide((rw_month.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
+        }
+
+
+        return getSucReturnObject().setData(jsonObject).toString();
+    }
+
+    @API(title = "查询业务员季度指标", apiversion = R.ID2025103010193903.v1.class)
+    public String queryperformancetarget_quarter() throws YosException {
+
+        long sa_saleareaid= content.getLong("sa_saleareaid");
+        long year= content.getLong("year");
+        JSONObject jsonObject =new JSONObject();
+
+        BigDecimal gcproportion =BigDecimal.ZERO;
+        BigDecimal zzproportion =BigDecimal.ZERO;
+
+        Rows salestargetbillrows =dbConnect.runSqlQuery("select * from sa_salestargetbill where siteid='"+siteid+"' and year="+year+" and targettype='人员目标'");
+        Rows rows = dbConnect.runSqlQuery("select * from sys_site_parameter where siteid='" + siteid + "'");
+        if(rows.isNotEmpty()){
+            gcproportion=rows.get(0).getBigDecimal("gcproportion").divide(BigDecimal.valueOf(100));
+            zzproportion=rows.get(0).getBigDecimal("zzproportion").divide(BigDecimal.valueOf(100));
+        }
+
+
+        long sa_salestargetbillid=0;
+        if(salestargetbillrows.isNotEmpty()){
+            sa_salestargetbillid=salestargetbillrows.get(0).getLong("sa_salestargetbillid");
+        }
+        SQLFactory personnelsqlFactory = new SQLFactory(this, "人员-目标详情列表");
+        personnelsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        personnelsqlFactory.addParameter_SQL("where", " t.sa_saleareaid="+sa_saleareaid);
+        personnelsqlFactory.addParameter("siteid", siteid);
+        Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
+        BigDecimal rw_quarter=BigDecimal.ZERO;
+        BigDecimal rw_previousquarter=BigDecimal.ZERO;
+        BigDecimal completedamount=BigDecimal.ZERO;
+        BigDecimal gcgccompletedamount=BigDecimal.ZERO;
+        BigDecimal zzgccompletedamount=BigDecimal.ZERO;
+        BigDecimal previouscompletedamount=BigDecimal.ZERO;
+        List<Integer> months = getCurrentQuarterMonths();
+        List<Integer> previousmonths =getPreviousQuarterMonthsCalendar();
+        if(salestargetrows.isNotEmpty()){
+            for(int month : months){
+                rw_quarter=rw_quarter.add(salestargetrows.get(0).getBigDecimal("m"+month+"l"));
+            }
+            for(int previousmonth : previousmonths){
+                rw_previousquarter=rw_previousquarter.add(salestargetrows.get(0).getBigDecimal("m"+previousmonth+"l"));
+            }
+        }
+        //季度任务(万)
+        jsonObject.put("rw_quarter",rw_quarter);
+        SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
+        paymentsqlFactory.addParameter("year", year);
+        paymentsqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
+        paymentsqlFactory.addParameter("siteid", siteid);
+        Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
+        RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
+
+        SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
+        rebatesqlFactory.addParameter("year", year);
+        rebatesqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        rebatesqlFactory.addParameter_SQL("where"," 1=1 ");
+        rebatesqlFactory.addParameter("siteid", siteid);
+        Rows rebateRows = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
+        RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
+        for(int month : months){
+            String monthstr = String.format("%02d", month);
+            BigDecimal xainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
+            BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            gcgccompletedamount=gcgccompletedamount.add(gcgc);
+            zzgccompletedamount=zzgccompletedamount.add(zzgc);
+            completedamount=completedamount.add(xainjin).add(huodong).add(fanli);
+        }
+        for(int previousmonth : previousmonths){
+            String previousmonthstr = String.format("%02d", previousmonth);
+            BigDecimal previousxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(previousmonthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal previoushuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(previousmonthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal previousfanli=rebateRowsMap.containsKey(previousmonthstr)?rebateRowsMap.get(previousmonthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
+            previouscompletedamount=previouscompletedamount.add(previousxainjin).add(previoushuodong).add(previousfanli);
+        }
+        //回款完成额
+        jsonObject.put("completedamount",completedamount);
+        //上季完成额超出部分
+        jsonObject.put("previousexceed",previouscompletedamount.subtract(rw_previousquarter));
+        //GC工程完成额
+        jsonObject.put("gccompletedamount",gcgccompletedamount.max(rw_quarter.multiply(gcproportion)));
+        //整装工程完成额
+        jsonObject.put("zzcompletedamount",zzgccompletedamount.max(rw_quarter.multiply(zzproportion)));
+        //季度完成额
+        jsonObject.put("actualcompletedamount",jsonObject.getBigDecimal("completedamount").add(jsonObject.getBigDecimal("previousexceed")).add(jsonObject.getBigDecimal("gccompletedamount")).add(jsonObject.getBigDecimal("zzcompletedamount")));
+        //季度百分比
+        if(rw_quarter.compareTo(BigDecimal.ZERO)==0){
+            jsonObject.put("actualcompletedpercentage",0);
+        }else{
+            jsonObject.put("actualcompletedpercentage",jsonObject.getBigDecimal("actualcompletedamount").divide((rw_quarter.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
+        }
+        return getSucReturnObject().setData(jsonObject).toString();
+
+    }
+
+    @API(title = "查询业务员总指标", apiversion = R.ID2025103010195403.v1.class)
+    public String queryperformancetarget_total() throws YosException {
+        long sa_saleareaid= content.getLong("sa_saleareaid");
+        long year= content.getLong("year");
+        JSONArray months = content.getJSONArray("months");
+        JSONObject jsonObject =new JSONObject();
+
+        BigDecimal gcproportion =BigDecimal.ZERO.divide(BigDecimal.valueOf(100));
+        BigDecimal zzproportion =BigDecimal.ZERO.divide(BigDecimal.valueOf(100));
+
+        Rows salestargetbillrows =dbConnect.runSqlQuery("select * from sa_salestargetbill where siteid='"+siteid+"' and year="+year+" and targettype='人员目标'");
+        Rows rows = dbConnect.runSqlQuery("select * from sys_site_parameter where siteid='" + siteid + "'");
+        if(rows.isNotEmpty()){
+            gcproportion=rows.get(0).getBigDecimal("gcproportion");
+            zzproportion=rows.get(0).getBigDecimal("zzproportion");
+            if(months.isEmpty()){
+                months=rows.get(0).getJSONArray("statistics_months");
+            }
+        }
+        long sa_salestargetbillid=0;
+        if(salestargetbillrows.isNotEmpty()){
+            sa_salestargetbillid=salestargetbillrows.get(0).getLong("sa_salestargetbillid");
+        }
+        SQLFactory personnelsqlFactory = new SQLFactory(this, "人员-目标详情列表");
+        personnelsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        personnelsqlFactory.addParameter_SQL("where", " t.sa_saleareaid="+sa_saleareaid);
+        personnelsqlFactory.addParameter("siteid", siteid);
+        Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
+        BigDecimal rw_all=BigDecimal.ZERO;
+        BigDecimal rw_year=BigDecimal.ZERO;
+        BigDecimal completedamount=BigDecimal.ZERO;
+        BigDecimal gcgccompletedamount=BigDecimal.ZERO;
+        BigDecimal zzgccompletedamount=BigDecimal.ZERO;
+        if(salestargetrows.isNotEmpty()){
+            for(Object month : months){
+                rw_all=rw_all.add(salestargetrows.get(0).getBigDecimal("m"+ (Integer)month+"l"));
+            }
+            rw_year=salestargetrows.get(0).getBigDecimal("y1l");
+        }
+        //总任务(万)
+        jsonObject.put("rw_all",rw_all);
+        SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
+        paymentsqlFactory.addParameter("year", year);
+        paymentsqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
+        paymentsqlFactory.addParameter("siteid", siteid);
+        Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
+        RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
+
+        SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
+        rebatesqlFactory.addParameter("year", year);
+        rebatesqlFactory.addParameter_in("sa_saleareaids", getSubSaleAreaIds(this,sa_saleareaid));
+        rebatesqlFactory.addParameter_SQL("where"," 1=1 ");
+        rebatesqlFactory.addParameter("siteid", siteid);
+        Rows rebateRows = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
+        RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
+        for(Object month : months){
+            String monthstr = String.format("%02d", (Integer)month);
+            BigDecimal xainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
+            BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
+            gcgccompletedamount=gcgccompletedamount.add(gcgc);
+            zzgccompletedamount=zzgccompletedamount.add(zzgc);
+            completedamount=completedamount.add(xainjin).add(huodong).add(fanli);
+        }
+        //回款完成额
+        jsonObject.put("completedamount",completedamount);
+        //GC工程完成额
+        jsonObject.put("gccompletedamount",gcgccompletedamount.max(rw_all.multiply(gcproportion)));
+        //整装工程完成额
+        jsonObject.put("zzcompletedamount",zzgccompletedamount.max(rw_all.multiply(zzproportion)));
+        //总完成额
+        jsonObject.put("actualcompletedamount",jsonObject.getBigDecimal("completedamount").add(jsonObject.getBigDecimal("gccompletedamount")).add(jsonObject.getBigDecimal("zzcompletedamount")));
+        //百分比
+        if(rw_all.compareTo(BigDecimal.ZERO)==0){
+            jsonObject.put("actualcompletedpercentage",0);
+        }else{
+            jsonObject.put("actualcompletedpercentage",jsonObject.getBigDecimal("actualcompletedamount").divide((rw_all.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
+        }
+        //和年度任务的差额
+        jsonObject.put("differenceamount",rw_year.subtract(jsonObject.getBigDecimal("actualcompletedamount")));
+
+        return getSucReturnObject().setData(jsonObject).toString();
+
+    }
+
+    @API(title = "大区查询", apiversion = R.ID2025103015481203.v1.class)
+    public String queryareaname2() throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_salearea ", "areaname");
+        querySQL.setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t1.level=2");
+        querySQL.setPage(pageSize, pageNumber);
+        pageSorting=" t1.sa_saleareaid asc";
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "区域查询", apiversion = R.ID2025103015485403.v1.class)
+    public String queryareaname3() throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_salearea ", "areaname");
+        querySQL.setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t1.level=3");
+        querySQL.setPage(pageSize, pageNumber);
+        pageSorting=" t1.sa_saleareaid asc";
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "省份查询", apiversion = R.ID2025103015494803.v1.class)
+    public String queryProvince() throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "t_province ", "province");
+        querySQL.setTableAlias("t1");
+        querySQL.setPage(pageSize, pageNumber);
+        pageSorting=" t1.provinceid asc";
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    @API(title = "回款明细", apiversion = R.ID2025103015304303.v1.class)
+    public String querypaymentdetail() throws YosException {
+        long year= content.getLong("year");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
+                where.append(" and t2.status ='").append(whereObject.getString("status")).append("' ");
+            }
+            if (whereObject.containsKey("areaname2") && !"".equals(whereObject.getString("areaname2"))) {
+                where.append(" and t4.areaname2 ='").append(whereObject.getString("areaname2")).append("' ");
+            }
+            if (whereObject.containsKey("areaname3") && !"".equals(whereObject.getString("areaname3"))) {
+                where.append(" and t4.areaname3 ='").append(whereObject.getString("areaname3")).append("' ");
+            }
+            if (whereObject.containsKey("province") && !"".equals(whereObject.getString("province"))) {
+                where.append(" and t1.province ='").append(whereObject.getString("province")).append("' ");
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "回款明细");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("year", year);
+        sqlFactory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    public List<Integer> getCurrentQuarterMonths() {
+        Calendar calendar = Calendar.getInstance();
+        int currentMonth = calendar.get(Calendar.MONTH) + 1; // 月份从0开始,需要+1
+        int quarterStartMonth = ((currentMonth - 1) / 3) * 3 + 1;
+
+        List<Integer> quarterMonths = new ArrayList<>();
+        for (int i = 0; i < 3; i++) {
+            quarterMonths.add(quarterStartMonth + i);
+        }
+
+        return quarterMonths;
+    }
+
+    public List<Integer> getPreviousQuarterMonthsCalendar() {
+        Calendar calendar = Calendar.getInstance();
+        int currentMonth = calendar.get(Calendar.MONTH) + 1; // 月份从0开始,需要+1
+        int currentYear = calendar.get(Calendar.YEAR);
+
+        int currentQuarter = (currentMonth - 1) / 3 + 1;
+        int lastQuarter = currentQuarter - 1;
+        int lastQuarterYear = currentYear;
+        List<Integer> quarterMonths = new ArrayList<>();
+        // 处理跨年情况
+        if (lastQuarter == 0) {
+            return quarterMonths;
+        }
+
+        int quarterStartMonth = (lastQuarter - 1) * 3 + 1;
+
+
+        for (int i = 0; i < 3; i++) {
+            quarterMonths.add(quarterStartMonth + i);
+        }
+
+        return quarterMonths;
+    }
+
+}

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

@@ -0,0 +1,645 @@
+package restcontroller.webmanage.sale.salestarget_cucu;
+
+import beans.datacontrllog.DataContrlLog;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.annotation.CACHEING_CLEAN;
+import common.data.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.xssf.usermodel.*;
+import restcontroller.R;
+import restcontroller.webmanage.saletool.orderclue.ExportExcel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+@API(title = "楚楚管理端-销售目标-人员目标")
+public class personnel extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public personnel(JSONObject content) throws YosException {
+        super(content);
+    }
+
+
+    @API(title = "新建年度或添加人员", apiversion = R.ID2025102913575103.v1.class)
+    @CACHEING_CLEAN(apiClass= {personnel.class})
+    public String insert() throws YosException {
+        Long year = content.getLong("year");
+        Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
+        JSONArray salesArray=new JSONArray();
+        ArrayList<String> sqlList = new ArrayList<>();
+        if (sa_salestargetbillid <= 0) {
+            //查询创建年度是否存在
+            if (dbConnect.runSqlQuery("SELECT 1 FROM sa_salestargetbill WHERE year = " + year + " AND targettype ='人员目标' AND siteid = '" + siteid + "'").isNotEmpty()) {
+                return getErrReturnObject().setErrMsg(year + "年度目标已存在,无法创建").toString();
+            }
+            sa_salestargetbillid = createTableID("sa_salestargetbill");
+            SQLFactory sqlFactory = new SQLFactory(this, "创建新年度");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            sqlFactory.addParameter("username", username);
+            sqlFactory.addParameter("sys_enterpriseid", "null");
+            sqlFactory.addParameter("userid", userid);
+            sqlFactory.addParameter("year", year);
+            sqlFactory.addParameter("assessmentindicators", "");
+            sqlFactory.addParameter("statisticaldimension", "");
+            sqlFactory.addParameter("sa_accountclassids", "");
+
+            sqlFactory.addParameter("targettype", "人员目标");
+            sqlFactory.addParameter("tradefield", "");
+            sqlList.add(sqlFactory.getSQL());
+            sqlList.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "人员目标新增", "人员目标新增"+year ).getSQL());
+
+
+            //获取所有启用业务员
+            SQLFactory saleareahrsqlFactory = new SQLFactory(this, "通用-人员范围查询");
+            saleareahrsqlFactory.addParameter("siteid", siteid);
+            saleareahrsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            String sql = saleareahrsqlFactory.getSQL();
+            Rows saleareahrrows = dbConnect.runSqlQuery(sql);
+            salesArray=saleareahrrows.toJsonArray();
+        }else{
+            SQLFactory sqlFactory = new SQLFactory(this, "更新新年度");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            sqlFactory.addParameter("username", username);
+            sqlFactory.addParameter("userid", userid);
+            sqlFactory.addParameter("assessmentindicators", "");
+            sqlFactory.addParameter("statisticaldimension", "");
+            sqlFactory.addParameter("sa_accountclassids", "");
+            sqlList.add(sqlFactory.getSQL());
+        }
+
+
+        String[] types = {"年", "季", "月"};
+
+        long[] ids = createTableID("sa_salestarget", salesArray.size() * 17);
+        int index = 1;
+
+        for (Object obj : salesArray) {
+            JSONObject saleObj = (JSONObject) obj;
+             System.out.println(saleObj.toString());
+            SQLFactory saleFactory = new SQLFactory(this, "人员范围新增");
+            saleFactory.addParameter("siteid", siteid);
+            saleFactory.addParameter("sa_salestargethrid", createTableID("sa_salestargethr"));
+            saleFactory.addParameter("hrid", saleObj.getLongValue("hrid"));
+            saleFactory.addParameter("position", saleObj.getStringValue("position"));
+
+            saleFactory.addParameter("sa_saleareaid", saleObj.getStringValue("sa_saleareaid"));
+            saleFactory.addParameter("areaname", saleObj.getStringValue("areaname"));
+            saleFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            saleFactory.addParameter("depname", saleObj.getStringValue("depname"));
+            saleFactory.addParameter("departmentid", saleObj.getLongValue("departmentid"));
+            saleFactory.addParameter("name", saleObj.getStringValue("name"));
+            sqlList.add(saleFactory.getSQL());
+
+            for (String type : types) {
+                int point;
+                if (type.equals("年")) {
+                    point = 1;
+                } else if (type.equals("季")) {
+                    point = 4;
+                } else if (type.equals("月")) {
+                    point = 12;
+                } else {
+                    point = 0;
+                }
+
+                for (int i = 0; i < point; i++) {
+                    SQLFactory targetFactory = new SQLFactory(this, "人员-目标明细新增");
+                    targetFactory.addParameter("siteid", siteid);
+                    targetFactory.addParameter("sa_salestargetid", ids[index - 1]);
+                    targetFactory.addParameter("type", type);
+                    targetFactory.addParameter("point", i + 1);
+                    targetFactory.addParameter("targettype", "人员目标");
+                    targetFactory.addParameter("sa_saleareaid", saleObj.getString("sa_saleareaid"));
+                    targetFactory.addParameter("hrid", saleObj.getString("hrid"));
+                    targetFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+                    targetFactory.addParameter("year", year);
+                    targetFactory.addParameter("sa_projectid", "null");
+                    targetFactory.addParameter("createby", username);
+                    targetFactory.addParameter("target_l", 0);
+                    targetFactory.addParameter("target_h", 0);
+                    sqlList.add(targetFactory.getSQL());
+                    index++;
+                }
+            }
+
+            sqlList.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "区域编辑", "添加区域" + saleObj.getStringValue("areaname")).getSQL());
+
+        }
+
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "删除人员", apiversion = R.ID2025102914322803.v1.class)
+    @CACHEING_CLEAN(apiClass= {personnel.class})
+    public String deletePeople() throws YosException {
+        Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
+        JSONArray salesArray = content.getJSONArray("hrid");
+        if (salesArray.size() <= 0) {
+            return getErrReturnObject().setErrMsg("请选择人员").toString();
+        }
+
+        String sql = "SELECT 1 FROM sa_salestarget WHERE hrid in " + salesArray + " and sa_salestargetbillid = " + sa_salestargetbillid + " and targettype = '人员目标' and (target_l  >0 or target_h >0)";
+        sql = sql.replace("[", "(").replace("]", ")");
+        if (dbConnect.runSqlQuery(sql).isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("存在已填写的数据,无法删除").toString();
+        }
+
+        ArrayList<String> sqlList = new ArrayList<>();
+        //删除人员范围
+        SQLFactory sqlFactory = new SQLFactory(this, "人员-删除人员范围");
+        sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_in("hrid", salesArray.toArray());
+        sqlList.add(sqlFactory.getSQL());
+        //删除人员目标
+        SQLFactory sqlFactory2 = new SQLFactory(this, "人员-删除目标明细");
+        sqlFactory2.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        sqlFactory2.addParameter("siteid", siteid);
+        sqlFactory2.addParameter_in("hrid", salesArray.toArray());
+        sqlList.add(sqlFactory2.getSQL());
+
+        //操作记录
+        for (Object obj : salesArray) {
+            Long hrid = Long.valueOf(obj.toString());
+            String name = "";
+            Rows rows = dbConnect.runSqlQuery("SELECT name from sys_hr WHERE hrid = " + hrid);
+            if (rows.isNotEmpty()) {
+                name = rows.get(0).getString("name");
+            }
+            sqlList.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "人员编辑", "移除人员" + name).getSQL());
+        }
+
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "年度目标列表", apiversion = R.ID2025102914324303.v1.class)
+    @CACHEING
+    public String queryList() throws YosException {
+         /*
+          过滤条件设置
+         */
+         String targettype =content.getString("targettype");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.year like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.createby like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
+                where.append(" and(");
+                where.append("t1.status like'%").append(whereObject.getString("status")).append("%' ");
+                where.append(")");
+            }
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "年度目标列表", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("targettype", targettype);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "目标详情", apiversion = R.ID2025102915295803.v1.class)
+    public String queryDetail() throws YosException {
+        Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "人员-目标详情");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Rows()).toString();
+    }
+
+
+
+    @API(title = "目标编辑", apiversion = R.ID2025102915300903.v1.class)
+    @CACHEING_CLEAN(apiClass= {personnel.class})
+    public String edit() throws YosException {
+        Long sa_salestargetbillid = content.getLongValue("sa_salestargetbillid");
+        Long hrid = content.getLong("hrid");
+        if (sa_salestargetbillid == 0) {
+            Long year = content.getLongValue("year");
+            Rows rows = dbConnect.runSqlQuery("SELECT DISTINCT sa_salestargetbillid from sa_salestarget WHERE year = " + year + " and hrid=" + hrid + " and targettype ='人员目标' and siteid='" + siteid + "'");
+            if (rows.isNotEmpty()) {
+                sa_salestargetbillid = rows.get(0).getLong("sa_salestargetbillid");
+            }
+        }
+        if (sa_salestargetbillid == 0) {
+            return getErrReturnObject().setErrMsg("年度目标不存在或该人员不在年度目标中,请先创建年度目标或添加相关人员到年度目标中").toString();
+        }
+
+        ArrayList<String> sqlList = new ArrayList<>();
+        String key_l = "y1l";
+        if (content.containsKey(key_l)) {
+            sqlList.add(getSql(content.getString(key_l), sa_salestargetbillid, hrid, "年", 1));
+        }
+        for (int i = 1; i < 5; i++) {
+            key_l = "s" + i + "l";
+
+            if (content.containsKey(key_l)) {
+                sqlList.add(getSql(content.getString(key_l), sa_salestargetbillid, hrid, "季", i));
+            }
+        }
+
+        for (int i = 1; i < 13; i++) {
+            key_l = "m" + i + "l";
+            if (content.containsKey(key_l)) {
+                sqlList.add(getSql(content.getString(key_l), sa_salestargetbillid, hrid, "月", i));
+            }
+        }
+
+        sqlList.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "编辑人员目标", "编辑人员目标").getSQL());
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+
+    public String getSql(String target_l, Long id, Long hrid, String type, int point) {
+
+        return " UPDATE sa_salestarget SET target_l=" + target_l + " WHERE sa_salestargetbillid =" + id + " and hrid =" + hrid + " and type ='" + type + "' AND point = " + point;
+    }
+
+    @API(title = "目标详情列表", apiversion = R.ID2025102915303303.v1.class)
+    @CACHEING
+    public String queryDetailList() throws YosException {
+        Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
+        /*
+          过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t.name like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t.depfullname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t.depname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t.position like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "人员-目标详情列表");
+        sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("siteid", siteid);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "人员目标导入模板", apiversion = R.ID2025102915540403.v1.class)
+    public String downloadExcel() throws YosException {
+
+        ExcelFactory excelFactory = new ExcelFactory("人员目标导入模板");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+        personnelexcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = ExportExcel.createBodyCellStyle(xssfFWorkbook);
+        personnelexcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
+
+        Rows aa = uploadExcelToObs(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+
+    }
+
+    @API(title = "人员目标导入", apiversion = R.ID2025102915541403.v1.class)
+    @CACHEING_CLEAN(apiClass= {personnel.class})
+    public String personnelTargetImport() throws YosException {
+
+        Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
+        Long year = content.getLong("year");
+        ExcelFactory e;
+
+        try {
+            if (content.getLong("attachmentid") > 0) {
+                e = getPostExcelFactory(content.getLong("attachmentid"));
+                // 本地
+                //e = getPostExcelFactory();
+            } else {
+                e = getPostExcelFactory();
+                // 本地
+                //e = getPostExcelFactory();
+            }
+
+
+            ArrayList<String> keys = new ArrayList<>();
+            ArrayList<String> sqllist = new ArrayList<>();
+
+            keys.add("name");
+            String keyl = "y1l";
+            keys.add(keyl);
+            for (int i = 1; i < 5; i++) {
+                keyl = "s" + i + "l";
+                keys.add(keyl);
+            }
+
+            for (int i = 1; i < 13; i++) {
+                keyl = "m" + i + "l";
+                keys.add(keyl);
+            }
+            Rows rows = e.getSheetRows(0, keys, 2);
+            ArrayList<String> hrnameList = new ArrayList<>();
+            for (Row row : rows) {
+                hrnameList.add(row.getString("name"));
+            }
+            //查询可导入的用户信息
+            SQLFactory sqlFactory = new SQLFactory(this, "人员-查询可导入员工信息");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter_in("name", hrnameList);
+            String sql = sqlFactory.getSQL();
+            RowsMap hrRowsMap = dbConnect.runSqlQuery(sql).toRowsMap("name");
+            String[] types = {"年", "季", "月"};
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+            // 手机号码的格式:第一位只能为1,第二位可以是3,4,5,7,8,第三位到第十一位可以为0-9中任意一个数字
+            String regex = "^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(166)|(17[3,5,6,7,8])|(18[0-9])|(19[1,8,9]))\\d{8}$";
+            for (Row row : rows) {
+                if (StringUtils.isBlank(row.getString("name"))) {
+                    iserr = true;
+                    row.put("msg", "错误信息:必填项名称不能为空");
+                    rowserr.add(row);
+                } else {
+
+                        if (hrRowsMap.containsKey(row.getString("name"))) {
+                            for (String type : types) {
+                                int point;
+                                if (type.equals("年")) {
+                                    point = 1;
+                                } else if (type.equals("季")) {
+                                    point = 4;
+                                } else if (type.equals("月")) {
+                                    point = 12;
+                                } else {
+                                    point = 0;
+                                }
+
+                                for (int i = 0; i < point; i++) {
+                                    if (type.equals("年")) {
+                                        if(!isNumeric(row.getString("y1l"))){
+                                            iserr = true;
+                                            row.put("msg", "年度目标不为数字格式,请检查");
+                                            rowserr.add(row);
+                                            break;
+                                        }
+                                    }
+                                    if (type.equals("季")) {
+                                        if(!isNumeric(row.getString("s" + (i + 1) + "l"))){
+                                            iserr = true;
+                                            row.put("msg", "第"+(i + 1)+"季度目标不为数字格式,请检查");
+                                            rowserr.add(row);
+                                            break;
+                                        }
+                                    }
+                                    if (type.equals("月")) {
+                                        if(!isNumeric(row.getString("m" + (i + 1) + "l"))){
+                                            iserr = true;
+                                            row.put("msg", "第"+(i + 1)+"月度目标不为数字格式,请检查");
+                                            rowserr.add(row);
+                                            break;
+                                        }
+                                    }
+                                }
+
+                            }
+                            if(StringUtils.isBlank(row.getString("msg"))){
+                                row.putAll(hrRowsMap.get(row.getString("name")).get(0));
+
+                                rowssuc.add(row);
+                            }
+                        } else {
+                            iserr = true;
+                            row.put("msg", "错误信息:数据已导入或人员名称不在数据库中");
+                            rowserr.add(row);
+                        }
+                }
+
+
+            }
+
+
+            System.out.println("rowssuc"+rowssuc.size());
+            long[] ids = createTableID("sa_salestarget", rowssuc.size() * 17);
+            int index = 1;
+
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    SQLFactory saleFactory = new SQLFactory(this, "人员范围新增");
+                    saleFactory.addParameter("siteid", siteid);
+                    saleFactory.addParameter("sa_salestargethrid", createTableID("sa_salestargethr"));
+                    saleFactory.addParameter("hrid",  row.getString("hrid"));
+                    saleFactory.addParameter("position", "");
+                    saleFactory.addParameter("sa_saleareaid", row.getString("sa_saleareaid"));
+                    saleFactory.addParameter("areaname", row.getString("areaname"));
+                    saleFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+                    saleFactory.addParameter("depname", row.getString("depname"));
+                    saleFactory.addParameter("departmentid",row.getString("departmentid"));
+                    saleFactory.addParameter("name",row.getString("name"));
+
+                    sqllist.add(saleFactory.getSQL());
+
+                    for (String type : types) {
+                        int point;
+                        if (type.equals("年")) {
+                            point = 1;
+                        } else if (type.equals("季")) {
+                            point = 4;
+                        } else if (type.equals("月")) {
+                            point = 12;
+                        } else {
+                            point = 0;
+                        }
+
+                        for (int i = 0; i < point; i++) {
+                            double target_l = 0L;
+                            double target_h = 0L;
+                            if (type.equals("年")) {
+                                target_l = row.getDouble("m1l")+row.getDouble("m2l")+row.getDouble("m3l")
+                                        +row.getDouble("m4l")+row.getDouble("m5l")+row.getDouble("m6l")
+                                        +row.getDouble("m7l")+row.getDouble("m8l")+row.getDouble("m9l")
+                                        +row.getDouble("m10l")+row.getDouble("m11l")+row.getDouble("m12l");
+                                target_h = row.getDouble("y1h");
+                            }
+                            if (type.equals("季")) {
+                                if(i==0){
+                                    target_l = row.getDouble("m1l")+row.getDouble("m2l")+row.getDouble("m3l");
+                                }else if(i==1){
+                                    target_l = row.getDouble("m4l")+row.getDouble("m5l")+row.getDouble("m6l");
+                                }else if(i==2){
+                                    target_l = row.getDouble("m7l")+row.getDouble("m8l")+row.getDouble("m9l");
+                                }else {
+                                    target_l = row.getDouble("m10l")+row.getDouble("m11l")+row.getDouble("m12l");
+                                }
+                                target_h = row.getDouble("s" + (i + 1) + "h");
+                            }
+                            if (type.equals("月")) {
+                                target_l = row.getDouble("m" + (i + 1) + "l");
+                                target_h = row.getDouble("m" + (i + 1) + "h");
+                            }
+
+
+                            SQLFactory targetFactory = new SQLFactory(this, "人员-目标明细新增");
+                            targetFactory.addParameter("siteid", siteid);
+                            targetFactory.addParameter("sa_salestargetid", ids[index - 1]);
+                            targetFactory.addParameter("type", type);
+                            targetFactory.addParameter("point", i + 1);
+                            targetFactory.addParameter("targettype", "人员目标");
+                            targetFactory.addParameter("hrid", row.getString("hrid"));
+                            targetFactory.addParameter("sa_saleareaid", row.getString("sa_saleareaid"));
+                            targetFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+                            targetFactory.addParameter("year", year);
+                            targetFactory.addParameter("sa_projectid", "null");
+                            targetFactory.addParameter("createby", username);
+                            targetFactory.addParameter("target_l", target_l);
+                            targetFactory.addParameter("target_h", target_h);
+
+                            sqllist.add(targetFactory.getSQL());
+                            index++;
+                        }
+                    }
+
+
+                }
+            }
+
+            if (sqllist != null && !sqllist.isEmpty()) {
+
+                dbConnect.runSqlUpdate("delete from sa_salestargethr where siteid='"+siteid+"' and sa_salestargetbillid="+sa_salestargetbillid+" and hrid in "+rowssuc.toArrayList("hrid").toString().replace("[", "(").replace("]", ")"));
+                dbConnect.runSqlUpdate("delete from sa_salestarget where siteid='"+siteid+"' and sa_salestargetbillid="+sa_salestargetbillid+" and hrid in "+rowssuc.toArrayList("hrid").toString().replace("[", "(").replace("]", ")"));
+
+                sqllist.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "导入", "导入人员目标").getSQL());
+                dbConnect.runSqlUpdate(sqllist);
+            }
+
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("人员目标导入错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("name");
+                String key_l = "y1l";
+                colNameList.add(key_l);
+                for (int a = 1; a < 5; a++) {
+                    key_l = "s" + a + "l";
+                    colNameList.add(key_l);
+                }
+                for (int a = 1; a < 13; a++) {
+                    key_l = "m" + a + "l";
+                    colNameList.add(key_l);
+                }
+                colNameList.add("msg");
+
+
+                keytypemap.put("name", String.class);
+                keytypemap.put("phonenumber", String.class);
+                key_l = "y1l";
+                keytypemap.put(key_l, String.class);
+                for (int a = 1; a < 5; a++) {
+                    key_l = "s" + a + "l";
+                    keytypemap.put(key_l, String.class);
+                }
+                for (int a = 1; a < 13; a++) {
+                    key_l = "m" + a + "l";
+                    keytypemap.put(key_l, String.class);
+                }
+
+
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                addSheet(excelFactory, "Sheet1", rowserr);
+
+                Rows aa = uploadExcelToObs(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+            }
+        } catch (Exception e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+            return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
+        }
+        return getSucReturnObject().toString();
+    }
+
+    public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        personnelexcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        personnelexcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 2);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger(keylist.get(i1)));
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong(keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat(keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble(keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString(keylist.get(i1)));
+                }
+                if (i1 == 18) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
+
+    public static boolean isNumeric(String strNum) {
+        if (strNum == null) {
+            return false;
+        }
+        return strNum.matches("-?\\d+(\\.\\d+)?");
+    }
+}

+ 419 - 0
src/custom/restcontroller/webmanage/sale/salestarget_cucu/personnelexcel.java

@@ -0,0 +1,419 @@
+package restcontroller.webmanage.sale.salestarget_cucu;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.YosException;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+public class personnelexcel {
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(导入模板)
+     **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        short width = 3500;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 20; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+
+    }
+
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(返回错误Excel的样式)
+     **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        short width = 3000;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 18; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+        sheet.setColumnWidth((short) 20, width * 2);
+
+    }
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));//2.申请年度单位
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("注意:①只需填写月度目标任务,年度和季度填0即可。导入后系统会自动计算年度和季度目标任务;②最多不超过5000行;③导入前,请记得删除示例行!");
+
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("人员名称");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("年度(基本)");
+
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("1季度(基本)");
+
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("2季度(基本)");
+
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("3季度(基本)");
+
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("4季度(基本)");
+
+
+        for (int i = 1; i < 13; i++) {
+            cell = row.createCell(i + 5);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(i + "月(基本)");
+
+        }
+
+
+
+
+
+        /*第三行塞值*/
+        row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("人员名称");
+
+        for (int i = 1; i < 18; i++) {
+            cell = row.createCell(i);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue("0");
+
+        }
+
+
+    }
+
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 18));//2.提示信息
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("注意:①只需填写月度目标任务,年度和季度填0即可。导入后系统会自动计算年度和季度目标任务;②最多不超过5000行;③导入前,请记得删除示例行!");
+
+
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("姓名(必填)");
+
+
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("年度(基本)");
+
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("1季度(基本)");
+
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("2季度(基本)");
+
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("3季度(基本)");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("4季度(基本)");
+
+
+        for (int i = 1; i < 13; i++) {
+            cell = row.createCell( i + 5);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(i + "月(基本)");
+        }
+
+        cell = row.createCell(18);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("错误信息");
+
+
+    }
+
+    public static void setBatchDetailSheetColumn3(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 700);
+        short width = 3500;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 19; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+
+    }
+
+    public static void batchDetailExport(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook, JSONArray dataArrays) throws YosException {
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+        //下边框
+        cellStyle2.setBorderBottom(BorderStyle.THIN);
+        //左边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);
+        //上边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);
+        //右边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);
+        cellStyle2.setAlignment(HorizontalAlignment.CENTER);
+        cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle2.setWrapText(true);
+
+        cellStyle3.setAlignment(HorizontalAlignment.CENTER);
+        cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle3.setWrapText(true);
+
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        // 创建一个字体
+        XSSFFont fontRed = workbook.createFont();
+        fontRed.setColor((short) 0xa); // 字体颜色
+        XSSFFont fontGreen = workbook.createFont();
+        fontGreen.setColor((short) 0xb); // 字体颜色
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setWrapText(true);
+
+
+        //第一行
+        row = sheet.createRow(0);
+        String[] title = {"部门", "人员", "职位", "目标/实际"};
+        for (int i = 0; i < title.length; i++) {
+            sheet.addMergedRegion(new CellRangeAddress(0, 1, i, i));
+            cell = row.createCell(i);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(title[i]);
+        }
+        String[] title2 =
+                {
+                        "年度(万元)",
+                        "第一季度(万元)", "一月(万元)", "二月(万元)", "三月(万元)",
+                        "第二季度(万元)", "四月(万元)", "五月(万元)", "六月(万元)",
+                        "第三季度(万元)", "七月(万元)", "八月(万元)", "九月(万元)",
+                        "第四季度(万元)", "十月(万元)", "十一月(万元)", "十二月(万元)"
+                };
+        for (int i = 0; i < title2.length; i++) {
+            sheet.addMergedRegion(new CellRangeAddress(0, 0, 2 * i + 4, 2 * i + 5));
+            cell = row.createCell(2 * i + 4);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(title2[i]);
+        }
+
+        //第二行
+        row = sheet.createRow(1);
+        for (int i = 0; i < 38; i++) {
+            cell = row.createCell(i);
+            cell.setCellStyle(cellStyle2);
+            if (i >= 4) {
+                cell.setCellValue("基本");
+                if (i % 2 == 1) {
+                    cell.setCellValue("挑战");
+                }
+            }
+        }
+
+        int rownum = 2;
+        for (Object data : dataArrays) {
+            JSONObject dataRow = (JSONObject) data;
+            //目标
+            row = sheet.createRow(rownum);
+            sheet.addMergedRegion(new CellRangeAddress(rownum, rownum + 1, 0, 0));
+            cell = row.createCell(0);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue(dataRow.getString("depfullname"));
+
+            sheet.addMergedRegion(new CellRangeAddress(rownum, rownum + 1, 1, 1));
+            cell = row.createCell(1);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue(dataRow.containsKey("name") ? dataRow.getString("name") : "");
+
+            sheet.addMergedRegion(new CellRangeAddress(rownum, rownum + 1, 2, 2));
+            cell = row.createCell(2);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue(dataRow.containsKey("position") ? dataRow.getString("position") : "");
+
+            cell = row.createCell(3);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue("目标");
+
+            String[] keys =
+                    {
+                            "y1l", "y1h",
+                            "s1l", "s1h",
+                            "m1l", "m1h", "m2l", "m2h", "m3l", "m3h",
+                            "s2l", "s2h",
+                            "m4l", "m4h", "m5l", "m5h", "m6l", "m6h",
+                            "s3l", "s3h",
+                            "m7l", "m7h", "m8l", "m8h", "m9l", "m9h",
+                            "s4l", "s4h",
+                            "m10l", "m10h", "m11l", "m11h", "m12l", "m12h",
+                    };
+
+            for (int i = 4; i < 38; i++) {
+                cell = row.createCell(i);
+                cell.setCellStyle(cellStyle3);
+                cell.setCellValue(dataRow.getString(keys[i - 4]));
+
+            }
+            /*第三行塞值*/
+            row = sheet.createRow(rownum + 1);
+
+            cell = row.createCell(0);
+            cell.setCellStyle(cellStyle3);
+
+            cell = row.createCell(1);
+            cell.setCellStyle(cellStyle3);
+
+            cell = row.createCell(2);
+            cell.setCellStyle(cellStyle3);
+
+            cell = row.createCell(3);
+            cell.setCellStyle(cellStyle3);
+            cell.setCellValue("实际");
+
+            String[] keys2 =
+                    {
+                            "y1a", "y1a",
+                            "s1a", "s1a",
+                            "m1a", "m1a", "m2a", "m2a", "m3a", "m3a",
+                            "s2a", "s2a",
+                            "m4a", "m4a", "m5a", "m5a", "m6a", "m6a",
+                            "s3a", "s3a",
+                            "m7a", "m7a", "m8a", "m8a", "m9a", "m9a",
+                            "s4a", "s4a",
+                            "m10a", "m10a", "m11a", "m11a", "m12a", "m12a",
+                    };
+            String[] keys3 =
+                    {
+                            "y1pl", "y1ph",
+                            "s1pl", "s1ph",
+                            "m1pl", "m1ph", "m2pl", "m2ph", "m3pl", "m3ph",
+                            "s2pl", "s2ph",
+                            "m4pl", "m4ph", "m5pl", "m5ph", "m6pl", "m6ph",
+                            "s3pl", "s3ph",
+                            "m7pl", "m7ph", "m8pl", "m8ph", "m9pl", "m9ph",
+                            "s4pl", "s4ph",
+                            "m10pl", "m10ph", "m11pl", "m11ph", "m12pl", "m12ph",
+                    };
+
+            for (int i = 4; i < 38; i++) {
+                cell = row.createCell(i);
+                String text1 = dataRow.getString(keys2[i - 4]);
+                String text2 = dataRow.getString(keys3[i - 4]);
+                String text = text1 + "\r\n" + "(" + text2 + "%)";
+                XSSFRichTextString hrt = workbook.getCreationHelper().createRichTextString(text);
+                if (text2.contains("-")) {
+                    hrt.applyFont(text1.length() + 2, text.length(), fontGreen);
+                } else if (text2.equals("0")) {
+
+                } else {
+                    hrt.applyFont(text1.length() + 2, text.length(), fontRed);
+                }
+
+                cell.setCellStyle(cellStyle);
+                cell.setCellValue(hrt);
+
+            }
+            rownum = rownum + 2;
+
+        }
+
+
+    }
+
+
+}