|
|
@@ -89,11 +89,29 @@ public class performancetargetboard extends Controller {
|
|
|
@API(title = "查询业务员月度指标", apiversion = R.ID2025103010192003.v1.class)
|
|
|
public String queryperformancetarget_month() throws YosException {
|
|
|
//long hrid= content.getLong("hrid");
|
|
|
- long sa_saleareaid= content.getLong("sa_saleareaid");
|
|
|
+ //long sa_saleareaid= content.getLong("sa_saleareaid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr","name","hrid");
|
|
|
+ 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 arearows = querySQL.query();
|
|
|
+ Rows arearows1=new Rows();
|
|
|
+
|
|
|
+ ArrayList<Long> saleareaidlist = new ArrayList<>();
|
|
|
+ for (Row row : arearows) {
|
|
|
+ saleareaidlist.add(row.getLong("sa_saleareaid"));
|
|
|
+ }
|
|
|
+ arearows1 =getSubSaleAreas(this,saleareaidlist);
|
|
|
+ arearows.addAll(arearows1);
|
|
|
+
|
|
|
+
|
|
|
long year= content.getLong("year");
|
|
|
long month= content.getLong("month");
|
|
|
String monthstr = String.format("%02d", month);
|
|
|
- JSONObject jsonObject =new JSONObject();
|
|
|
|
|
|
BigDecimal gcproportion =BigDecimal.ZERO;
|
|
|
BigDecimal zzproportion =BigDecimal.ZERO;
|
|
|
@@ -111,311 +129,422 @@ public class performancetargetboard extends Controller {
|
|
|
}
|
|
|
SQLFactory personnelsqlFactory = new SQLFactory(this, "人员-目标详情列表");
|
|
|
personnelsqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- personnelsqlFactory.addParameter_SQL("where", " t.sa_saleareaid="+sa_saleareaid);
|
|
|
+ personnelsqlFactory.addParameter_SQL("where", " 1=1 ");
|
|
|
personnelsqlFactory.addParameter("siteid", siteid);
|
|
|
Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
|
|
|
- BigDecimal rw_month=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");
|
|
|
- }else{
|
|
|
- jsonObject.put("rw_month",BigDecimal.ZERO);
|
|
|
- }
|
|
|
+ RowsMap salestargetrowsMap = salestargetrows.toRowsMap("sa_saleareaid");
|
|
|
|
|
|
- ArrayList<Long> list = new ArrayList<>();
|
|
|
- list.add(sa_saleareaid);
|
|
|
- list.addAll(getSubSaleAreaIds(this,list));
|
|
|
|
|
|
SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
|
|
|
paymentsqlFactory.addParameter("year", year);
|
|
|
- paymentsqlFactory.addParameter_in("sa_saleareaids", list);
|
|
|
paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
paymentsqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
- RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ Rows paymentRows_All = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
+ //RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
|
|
|
SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
|
|
|
rebatesqlFactory.addParameter("year", year);
|
|
|
- rebatesqlFactory.addParameter_in("sa_saleareaids", list);
|
|
|
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;
|
|
|
+ Rows rebateRows_All = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
|
|
|
+ //RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
+
|
|
|
+ for(Row row :arearows){
|
|
|
+ BigDecimal rw_month=BigDecimal.ZERO;
|
|
|
+ if(salestargetrowsMap.containsKey(row.getString("sa_saleareaid"))){
|
|
|
+ //月度任务(万)
|
|
|
+ row.put("rw_month",salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+month+"l"));
|
|
|
+ rw_month=salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+month+"l");
|
|
|
+ }else{
|
|
|
+ row.put("rw_month",BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ ArrayList<Long> list = new ArrayList<>();
|
|
|
+ list.add(row.getLong("sa_saleareaid"));
|
|
|
+ list.addAll(getSubSaleAreaIds(this,list));
|
|
|
+ Rows paymentRows =new Rows();
|
|
|
+ Rows rebateRows =new Rows();
|
|
|
+ for(Row paymentRow :paymentRows_All){
|
|
|
+ if(list.contains(paymentRow.getLong("sa_saleareaid"))){
|
|
|
+ paymentRows.add(paymentRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ for(Row rebateRow :rebateRows_All){
|
|
|
+ if(list.contains(rebateRow.getLong("sa_saleareaid"))){
|
|
|
+ rebateRows.add(rebateRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
|
|
|
- //回款完成额
|
|
|
- jsonObject.put("completedamount",xainjin.add(huodong).add(fanli));
|
|
|
+ BigDecimal xainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).sum("amount"):BigDecimal.ZERO;
|
|
|
|
|
|
- BigDecimal previousexceed=BigDecimal.ZERO;
|
|
|
- BigDecimal completedamountexceed100=BigDecimal.ZERO;
|
|
|
- for(int i=1;i<=month;i++){
|
|
|
- previousexceed=completedamountexceed100;
|
|
|
+ //回款完成额
|
|
|
+ row.put("completedamount",xainjin.add(huodong).add(fanli));
|
|
|
|
|
|
- BigDecimal looprw_month=salestargetrows.isNotEmpty()?salestargetrows.get(0).getBigDecimal("m"+i+"l"):BigDecimal.ZERO;
|
|
|
- BigDecimal loopxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("现金账户").toRowsMap("month").get(String.format("%02d", i)).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- BigDecimal loophuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(String.format("%02d", i)).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- BigDecimal loopfanli=rebateRowsMap.containsKey(String.format("%02d", i))?rebateRowsMap.get(String.format("%02d", i)).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
|
|
|
+ BigDecimal previousexceed=BigDecimal.ZERO;
|
|
|
+ BigDecimal completedamountexceed100=BigDecimal.ZERO;
|
|
|
+ for(int i=1;i<=month;i++){
|
|
|
+ previousexceed=completedamountexceed100;
|
|
|
+ BigDecimal looprw_month=salestargetrowsMap.get(row.getString("sa_saleareaid")).isNotEmpty()?salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+i+"l"):BigDecimal.ZERO;
|
|
|
+ BigDecimal loopxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("现金账户").toRowsMap("month").get(String.format("%02d", i)).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loophuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(String.format("%02d", i)).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loopfanli=rebateRowsMap.containsKey(String.format("%02d", i))?rebateRowsMap.get(String.format("%02d", i)).sum("amount"):BigDecimal.ZERO;
|
|
|
|
|
|
- BigDecimal loopgcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(String.format("%02d", i)).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- BigDecimal loopzzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(String.format("%02d", i)).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loopgcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(String.format("%02d", i)).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loopzzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(String.format("%02d", i))?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(String.format("%02d", i)).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
|
|
|
- completedamountexceed100=loopxainjin.add(loophuodong).add(loopfanli).add(previousexceed)
|
|
|
- .add(loopgcgc.max(looprw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))))
|
|
|
- .add(loopzzgc.max(looprw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))))
|
|
|
- .subtract(looprw_month.multiply(BigDecimal.valueOf(10000)));
|
|
|
+ completedamountexceed100=loopxainjin.add(loophuodong).add(loopfanli).add(previousexceed)
|
|
|
+ .add(loopgcgc.min(looprw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))))
|
|
|
+ .add(loopzzgc.min(looprw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))))
|
|
|
+ .subtract(looprw_month.multiply(BigDecimal.valueOf(10000)));
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //上月完成额超出部分
|
|
|
- jsonObject.put("previousexceed",previousexceed.compareTo(BigDecimal.ZERO)>0?previousexceed:0);
|
|
|
-
|
|
|
- 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).multiply(BigDecimal.valueOf(10000))));
|
|
|
- //GC工程超出部分
|
|
|
- jsonObject.put("gccompletedamountexceed",gcgc.subtract(rw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))).compareTo(BigDecimal.ZERO)>0?gcgc.subtract(rw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))):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).multiply(BigDecimal.valueOf(10000))));
|
|
|
- //整装工程超出部分
|
|
|
- jsonObject.put("zzcompletedamountexceed",zzgc.subtract(rw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))).compareTo(BigDecimal.ZERO)>0?zzgc.subtract(rw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))):0);
|
|
|
-
|
|
|
- //完成额超出100%部分
|
|
|
- jsonObject.put("completedamountexceed100",completedamountexceed100.compareTo(BigDecimal.ZERO)>0?completedamountexceed100:0);
|
|
|
- //实际完成额
|
|
|
- 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));
|
|
|
+ //上月完成额超出部分
|
|
|
+ row.put("previousexceed",previousexceed.compareTo(BigDecimal.ZERO)>0?previousexceed:0);
|
|
|
+
|
|
|
+ BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ //GC工程完成额
|
|
|
+ row.put("gccompletedamount",gcgc.min(rw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))));
|
|
|
+ //GC工程超出部分
|
|
|
+ row.put("gccompletedamountexceed",gcgc.subtract(rw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))).compareTo(BigDecimal.ZERO)>0?gcgc.subtract(rw_month.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))):0);
|
|
|
+
|
|
|
+ BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ //整装工程完成额
|
|
|
+ row.put("zzcompletedamount",zzgc.min(rw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))));
|
|
|
+ //整装工程超出部分
|
|
|
+ row.put("zzcompletedamountexceed",zzgc.subtract(rw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))).compareTo(BigDecimal.ZERO)>0?zzgc.subtract(rw_month.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))):0);
|
|
|
+
|
|
|
+ //完成额超出100%部分
|
|
|
+ row.put("completedamountexceed100",completedamountexceed100.compareTo(BigDecimal.ZERO)>0?completedamountexceed100:0);
|
|
|
+ //实际完成额
|
|
|
+ row.put("actualcompletedamount",row.getBigDecimal("completedamount").add(row.getBigDecimal("gccompletedamount")).add(row.getBigDecimal("zzcompletedamount")));
|
|
|
+ //实际完成百分比
|
|
|
+ if(rw_month.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ row.put("actualcompletedpercentage",0);
|
|
|
+ }else{
|
|
|
+ row.put("actualcompletedpercentage", (row.getBigDecimal("completedamount").add(row.getBigDecimal("previousexceed")).add(row.getBigDecimal("gccompletedamount")).add(row.getBigDecimal("zzcompletedamount"))).divide((rw_month.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Rows arearows_quarter= queryperformancetarget_quarter(month,arearows,salestargetrowsMap,paymentRows_All,rebateRows_All);
|
|
|
+ System.err.println(arearows_quarter.get(0).getString("sa_saleareaid")+":"+arearows_quarter.get(0).getBigDecimal("completedamount"));
|
|
|
+ RowsMap arearowsMap_quarter=arearows_quarter.toRowsMap("sa_saleareaid");
|
|
|
+ Rows arearows_total= queryperformancetarget_total(month,arearows,salestargetrowsMap,paymentRows_All,rebateRows_All);
|
|
|
+ RowsMap arearowsMap_total=arearows_total.toRowsMap("sa_saleareaid");
|
|
|
+ for(Row row : arearows){
|
|
|
+ if(arearowsMap_quarter.containsKey(row.getString("sa_saleareaid"))){
|
|
|
+ row.put("rw_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("rw_quarter"));
|
|
|
+ row.put("actualcompletedamount_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("actualcompletedamount_quarter"));
|
|
|
+ row.put("zzcompletedamount_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("zzcompletedamount_quarter"));
|
|
|
+ row.put("gccompletedamount_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("gccompletedamount_quarter"));
|
|
|
+ row.put("actualcompletedpercentage_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("actualcompletedpercentage_quarter"));
|
|
|
+ System.err.println(row.getString("sa_saleareaid")+":"+arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("completedamount_quarter"));
|
|
|
+ row.put("completedamount_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("completedamount_quarter"));
|
|
|
+ row.put("previousexceed_quarter",arearowsMap_quarter.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("previousexceed_quarter"));
|
|
|
+ }else{
|
|
|
+ row.put("rw_quarter",0);
|
|
|
+ row.put("actualcompletedamount_quarter",0);
|
|
|
+ row.put("zzcompletedamount_quarter",0);
|
|
|
+ row.put("gccompletedamount_quarter",0);
|
|
|
+ row.put("actualcompletedpercentage_quarter",0);
|
|
|
+ row.put("completedamount_quarter",0);
|
|
|
+ row.put("previousexceed_quarter",0);
|
|
|
+ }
|
|
|
+ if(arearowsMap_total.containsKey(row.getString("sa_saleareaid"))){
|
|
|
+ row.put("rw_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("rw_total"));
|
|
|
+ row.put("actualcompletedamount_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("actualcompletedamount_total"));
|
|
|
+ row.put("zzcompletedamount_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("zzcompletedamount_total"));
|
|
|
+ row.put("gccompletedamount_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("gccompletedamount_total"));
|
|
|
+ row.put("actualcompletedpercentage_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("actualcompletedpercentage_total"));
|
|
|
+ row.put("differenceamount_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("differenceamount_total"));
|
|
|
+ row.put("completedamount_total",arearowsMap_total.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("completedamount_total"));
|
|
|
+ }else{
|
|
|
+ row.put("rw_total",0);
|
|
|
+ row.put("actualcompletedamount_total",0);
|
|
|
+ row.put("zzcompletedamount_total",0);
|
|
|
+ row.put("gccompletedamount_total",0);
|
|
|
+ row.put("actualcompletedpercentage_total",0);
|
|
|
+ row.put("differenceamount_total",0);
|
|
|
+ row.put("completedamount_total",0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- return getSucReturnObject().setData(jsonObject).toString();
|
|
|
+ return getSucReturnObject().setData(arearows).toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "查询业务员季度指标", apiversion = R.ID2025103010193903.v1.class)
|
|
|
- public String queryperformancetarget_quarter() throws YosException {
|
|
|
+ /**
|
|
|
+ * 查询业务员季度指标
|
|
|
+ * @param selectmonth
|
|
|
+ * @param arearows
|
|
|
+ * @param salestargetrowsMap
|
|
|
+ * @param paymentRows_All
|
|
|
+ * @param rebateRows_All
|
|
|
+ * @return
|
|
|
+ * @throws YosException
|
|
|
+ */
|
|
|
+ public Rows queryperformancetarget_quarter(long selectmonth,Rows arearows,RowsMap salestargetrowsMap,Rows paymentRows_All,Rows rebateRows_All) throws YosException {
|
|
|
// long hrid= content.getLong("hrid");
|
|
|
- long sa_saleareaid= content.getLong("sa_saleareaid");
|
|
|
- long year= content.getLong("year");
|
|
|
- int selectmonth= content.getIntValue("month");
|
|
|
- JSONObject jsonObject =new JSONObject();
|
|
|
+ //long sa_saleareaid= content.getLong("sa_saleareaid");
|
|
|
|
|
|
- Rows salestargetbillrows =dbConnect.runSqlQuery("select * from sa_salestargetbill where siteid='"+siteid+"' and year="+year+" and targettype='人员目标'");
|
|
|
- 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(selectmonth);
|
|
|
- List<Integer> previousmonths =getPreviousQuarterMonthsCalendar(selectmonth);
|
|
|
- if(salestargetrows.isNotEmpty()){
|
|
|
- for(int month : months){
|
|
|
- rw_quarter=rw_quarter.add(salestargetrows.get(0).getBigDecimal("m"+month+"l"));
|
|
|
+// Rows salestargetbillrows =dbConnect.runSqlQuery("select * from sa_salestargetbill where siteid='"+siteid+"' and year="+year+" and targettype='人员目标'");
|
|
|
+// 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", " 1=1 ");
|
|
|
+// personnelsqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
|
|
|
+// RowsMap salestargetrowsMap = salestargetrows.toRowsMap("sa_saleareaid");
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> months = getCurrentQuarterMonths((int)selectmonth);
|
|
|
+ List<Integer> previousmonths =getPreviousQuarterMonthsCalendar((int)selectmonth);
|
|
|
+
|
|
|
+
|
|
|
+// SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
|
|
|
+// paymentsqlFactory.addParameter("year", year);
|
|
|
+// paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
+// paymentsqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows paymentRows_All = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
+// RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+
|
|
|
+// SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
|
|
|
+// rebatesqlFactory.addParameter("year", year);
|
|
|
+// rebatesqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
+// rebatesqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows rebateRows_All = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
|
|
|
+// RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
+
|
|
|
+ Rows arearowsResult =new Rows();
|
|
|
+ for(Row row :arearows){
|
|
|
+ Row arearowResult =new Row();
|
|
|
+ arearowResult.put("sa_saleareaid",row.getLong("sa_saleareaid"));
|
|
|
+ BigDecimal rw_quarter=BigDecimal.ZERO;
|
|
|
+ BigDecimal rw_previousquarter=BigDecimal.ZERO;
|
|
|
+ BigDecimal completedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal gcgccompletedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal zzgccompletedamount=BigDecimal.ZERO;
|
|
|
+ if(salestargetrowsMap.containsKey(row.getString("sa_saleareaid"))){
|
|
|
+ for(int month : months){
|
|
|
+ rw_quarter=rw_quarter.add(salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+month+"l"));
|
|
|
+ }
|
|
|
+ for(int previousmonth : previousmonths){
|
|
|
+ rw_previousquarter=rw_previousquarter.add(salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+previousmonth+"l"));
|
|
|
+ }
|
|
|
}
|
|
|
- for(int previousmonth : previousmonths){
|
|
|
- rw_previousquarter=rw_previousquarter.add(salestargetrows.get(0).getBigDecimal("m"+previousmonth+"l"));
|
|
|
+ //季度任务(万)
|
|
|
+ arearowResult.put("rw_quarter",rw_quarter);
|
|
|
+ ArrayList<Long> list = new ArrayList<>();
|
|
|
+ list.add(row.getLong("sa_saleareaid"));
|
|
|
+ list.addAll(getSubSaleAreaIds(this,list));
|
|
|
+
|
|
|
+ Rows paymentRows =new Rows();
|
|
|
+ Rows rebateRows =new Rows();
|
|
|
+ for(Row paymentRow :paymentRows_All){
|
|
|
+ if(list.contains(paymentRow.getLong("sa_saleareaid"))){
|
|
|
+ paymentRows.add(paymentRow);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- ArrayList<Long> list = new ArrayList<>();
|
|
|
- list.add(sa_saleareaid);
|
|
|
- list.addAll(getSubSaleAreaIds(this,list));
|
|
|
- //季度任务(万)
|
|
|
- jsonObject.put("rw_quarter",rw_quarter);
|
|
|
- SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
|
|
|
- paymentsqlFactory.addParameter("year", year);
|
|
|
- paymentsqlFactory.addParameter_in("sa_saleareaids",list);
|
|
|
- paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
- paymentsqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
- RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ for(Row rebateRow :rebateRows_All){
|
|
|
+ if(list.contains(rebateRow.getLong("sa_saleareaid"))){
|
|
|
+ rebateRows.add(rebateRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
|
|
|
- SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
|
|
|
- rebatesqlFactory.addParameter("year", year);
|
|
|
- rebatesqlFactory.addParameter_in("sa_saleareaids",list);
|
|
|
- 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);
|
|
|
- }
|
|
|
+ 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).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).sum("amount"):BigDecimal.ZERO;
|
|
|
+ BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ gcgccompletedamount=gcgccompletedamount.add(gcgc);
|
|
|
+ zzgccompletedamount=zzgccompletedamount.add(zzgc);
|
|
|
+ completedamount=completedamount.add(xainjin).add(huodong).add(fanli);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- BigDecimal previousexceed=BigDecimal.ZERO;
|
|
|
- BigDecimal completedamountexceed100=BigDecimal.ZERO;
|
|
|
- int quarter = getQuarterByMonth(selectmonth);
|
|
|
- for(int i=1;i<=quarter;i++){
|
|
|
- previousexceed=completedamountexceed100;
|
|
|
- List<Integer> loopmonths = getCurrentQuarterMonths(i*3-2);
|
|
|
- BigDecimal looprw_quarter=BigDecimal.ZERO;
|
|
|
- BigDecimal loopcompletedamount=BigDecimal.ZERO;
|
|
|
- BigDecimal loopgcgccompletedamount=BigDecimal.ZERO;
|
|
|
- BigDecimal loopzzgccompletedamount=BigDecimal.ZERO;
|
|
|
- if(salestargetrows.isNotEmpty()){
|
|
|
+ BigDecimal previousexceed=BigDecimal.ZERO;
|
|
|
+ BigDecimal completedamountexceed100=BigDecimal.ZERO;
|
|
|
+ int quarter = getQuarterByMonth((int)selectmonth);
|
|
|
+ for(int i=1;i<=quarter;i++){
|
|
|
+ previousexceed=completedamountexceed100;
|
|
|
+ List<Integer> loopmonths = getCurrentQuarterMonths(i*3-2);
|
|
|
+ BigDecimal looprw_quarter=BigDecimal.ZERO;
|
|
|
+ BigDecimal loopcompletedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal loopgcgccompletedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal loopzzgccompletedamount=BigDecimal.ZERO;
|
|
|
+ if(salestargetrowsMap.get(row.getString("sa_saleareaid")).isNotEmpty()){
|
|
|
+ for(int month : loopmonths){
|
|
|
+ looprw_quarter=looprw_quarter.add(salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+month+"l"));
|
|
|
+ }
|
|
|
+ }
|
|
|
for(int month : loopmonths){
|
|
|
- looprw_quarter=looprw_quarter.add(salestargetrows.get(0).getBigDecimal("m"+month+"l"));
|
|
|
+ String monthstr = String.format("%02d", month);
|
|
|
+ BigDecimal loopxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loophuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loopfanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).sum("amount"):BigDecimal.ZERO;
|
|
|
+ BigDecimal loopgcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal loopzzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ loopgcgccompletedamount=loopgcgccompletedamount.add(loopgcgc);
|
|
|
+ loopzzgccompletedamount=loopzzgccompletedamount.add(loopzzgc);
|
|
|
+ loopcompletedamount=loopcompletedamount.add(loopxainjin).add(loophuodong).add(loopfanli);
|
|
|
}
|
|
|
- }
|
|
|
- for(int month : loopmonths){
|
|
|
- String monthstr = String.format("%02d", month);
|
|
|
- BigDecimal loopxainjin=paymentRowsMap.containsKey("现金账户")?paymentRowsMap.get("现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- BigDecimal loophuodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- BigDecimal loopfanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO;
|
|
|
- BigDecimal loopgcgc=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 loopzzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).get(0).getBigDecimal("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
- loopgcgccompletedamount=loopgcgccompletedamount.add(loopgcgc);
|
|
|
- loopzzgccompletedamount=loopzzgccompletedamount.add(loopzzgc);
|
|
|
- loopcompletedamount=loopcompletedamount.add(loopxainjin).add(loophuodong).add(loopfanli);
|
|
|
- }
|
|
|
|
|
|
- completedamountexceed100=loopcompletedamount.add(previousexceed).add(loopgcgccompletedamount)
|
|
|
- .add(loopzzgccompletedamount).subtract(looprw_quarter.multiply(BigDecimal.valueOf(10000)));
|
|
|
+ completedamountexceed100=loopcompletedamount.add(previousexceed).add(loopgcgccompletedamount)
|
|
|
+ .add(loopzzgccompletedamount).subtract(looprw_quarter.multiply(BigDecimal.valueOf(10000)));
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //回款完成额
|
|
|
- jsonObject.put("completedamount",completedamount);
|
|
|
- //上季完成额超出部分
|
|
|
- jsonObject.put("previousexceed",previousexceed.compareTo(BigDecimal.ZERO)>0?previousexceed:0);
|
|
|
- //GC工程完成额
|
|
|
- jsonObject.put("gccompletedamount",gcgccompletedamount);
|
|
|
- //整装工程完成额
|
|
|
- jsonObject.put("zzcompletedamount",zzgccompletedamount);
|
|
|
- //季度完成额
|
|
|
- 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));
|
|
|
+ //回款完成额
|
|
|
+ arearowResult.put("completedamount_quarter",completedamount);
|
|
|
+ //上季完成额超出部分
|
|
|
+ arearowResult.put("previousexceed_quarter",previousexceed.compareTo(BigDecimal.ZERO)>0?previousexceed:0);
|
|
|
+ //GC工程完成额
|
|
|
+ arearowResult.put("gccompletedamount_quarter",gcgccompletedamount);
|
|
|
+ //整装工程完成额
|
|
|
+ arearowResult.put("zzcompletedamount_quarter",zzgccompletedamount);
|
|
|
+ //季度完成额
|
|
|
+ arearowResult.put("actualcompletedamount_quarter",arearowResult.getBigDecimal("completedamount_quarter").add(arearowResult.getBigDecimal("previousexceed_quarter")).add(arearowResult.getBigDecimal("gccompletedamount_quarter")).add(arearowResult.getBigDecimal("zzcompletedamount_quarter")));
|
|
|
+ //季度百分比
|
|
|
+ if(rw_quarter.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ arearowResult.put("actualcompletedpercentage_quarter",0);
|
|
|
+ }else{
|
|
|
+ arearowResult.put("actualcompletedpercentage_quarter",arearowResult.getBigDecimal("actualcompletedamount_quarter").divide((rw_quarter.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ arearowsResult.add(arearowResult);
|
|
|
}
|
|
|
- return getSucReturnObject().setData(jsonObject).toString();
|
|
|
+ return arearowsResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
- @API(title = "查询业务员总指标", apiversion = R.ID2025103010195403.v1.class)
|
|
|
- public String queryperformancetarget_total() throws YosException {
|
|
|
- //long hrid= content.getLong("hrid");
|
|
|
- long sa_saleareaid= content.getLong("sa_saleareaid");
|
|
|
- long year= content.getLong("year");
|
|
|
- JSONArray months = content.getJSONArray("months");
|
|
|
- JSONObject jsonObject =new JSONObject();
|
|
|
+ /**
|
|
|
+ * 查询业务员总指标
|
|
|
+ * @param selectmonth
|
|
|
+ * @param arearows
|
|
|
+ * @param salestargetrowsMap
|
|
|
+ * @param paymentRows_All
|
|
|
+ * @param rebateRows_All
|
|
|
+ * @return
|
|
|
+ * @throws YosException
|
|
|
+ */
|
|
|
+ public Rows queryperformancetarget_total(long selectmonth,Rows arearows,RowsMap salestargetrowsMap,Rows paymentRows_All,Rows rebateRows_All) throws YosException {
|
|
|
|
|
|
+ JSONArray months =new JSONArray();
|
|
|
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 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");
|
|
|
+ for(int i=1;i<=selectmonth;i++){
|
|
|
+ if(rows.get(0).getJSONArray("statistics_months").contains(i)){
|
|
|
+ months.add(i);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- 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"));
|
|
|
+// 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", " 1=1 ");
|
|
|
+// personnelsqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows salestargetrows = dbConnect.runSqlQuery(personnelsqlFactory.getSQL());
|
|
|
+// RowsMap salestargetrowsMap = salestargetrows.toRowsMap("sa_saleareaid");
|
|
|
+
|
|
|
+
|
|
|
+// SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
|
|
|
+// paymentsqlFactory.addParameter("year", year);
|
|
|
+// paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
+// paymentsqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows paymentRows_All = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
+// RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+
|
|
|
+// SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
|
|
|
+// rebatesqlFactory.addParameter("year", year);
|
|
|
+// rebatesqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
+// rebatesqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows rebateRows_All = dbConnect.runSqlQuery(rebatesqlFactory.getSQL());
|
|
|
+// RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
+ Rows arearowsResult =new Rows();
|
|
|
+ for(Row row :arearows){
|
|
|
+ Row arearowResult =new Row();
|
|
|
+ arearowResult.put("sa_saleareaid",row.getLong("sa_saleareaid"));
|
|
|
+ BigDecimal rw_all=BigDecimal.ZERO;
|
|
|
+ BigDecimal rw_year=BigDecimal.ZERO;
|
|
|
+ BigDecimal completedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal gcgccompletedamount=BigDecimal.ZERO;
|
|
|
+ BigDecimal zzgccompletedamount=BigDecimal.ZERO;
|
|
|
+ if(salestargetrowsMap.get(row.getString("sa_saleareaid")).isNotEmpty()){
|
|
|
+ for(Object month : months){
|
|
|
+ rw_all=rw_all.add(salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("m"+ (Integer)month+"l"));
|
|
|
+ }
|
|
|
+ rw_year=salestargetrowsMap.get(row.getString("sa_saleareaid")).get(0).getBigDecimal("y1l");
|
|
|
}
|
|
|
- rw_year=salestargetrows.get(0).getBigDecimal("y1l");
|
|
|
- }
|
|
|
- ArrayList<Long> list = new ArrayList<>();
|
|
|
- list.add(sa_saleareaid);
|
|
|
- list.addAll(getSubSaleAreaIds(this,list));
|
|
|
- //总任务(万)
|
|
|
- jsonObject.put("rw_all",rw_year);
|
|
|
- SQLFactory paymentsqlFactory = new SQLFactory(this, "账户回款统计");
|
|
|
- paymentsqlFactory.addParameter("year", year);
|
|
|
- paymentsqlFactory.addParameter_in("sa_saleareaids", list);
|
|
|
- paymentsqlFactory.addParameter_SQL("where"," 1=1 ");
|
|
|
- paymentsqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows paymentRows = dbConnect.runSqlQuery(paymentsqlFactory.getSQL());
|
|
|
- RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ ArrayList<Long> list = new ArrayList<>();
|
|
|
+ list.add(row.getLong("sa_saleareaid"));
|
|
|
+ list.addAll(getSubSaleAreaIds(this,list));
|
|
|
|
|
|
- SQLFactory rebatesqlFactory = new SQLFactory(this, "账户返利统计");
|
|
|
- rebatesqlFactory.addParameter("year", year);
|
|
|
- rebatesqlFactory.addParameter_in("sa_saleareaids", list);
|
|
|
- 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).multiply(BigDecimal.valueOf(10000))));
|
|
|
- //整装工程完成额
|
|
|
- jsonObject.put("zzcompletedamount",zzgccompletedamount.max(rw_all.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))));
|
|
|
- //总完成额
|
|
|
- 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));
|
|
|
+ Rows paymentRows =new Rows();
|
|
|
+ Rows rebateRows =new Rows();
|
|
|
+ for(Row paymentRow :paymentRows_All){
|
|
|
+ if(list.contains(paymentRow.getLong("sa_saleareaid"))){
|
|
|
+ paymentRows.add(paymentRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RowsMap paymentRowsMap =paymentRows.toRowsMap("accountname");
|
|
|
+ for(Row rebateRow :rebateRows_All){
|
|
|
+ if(list.contains(rebateRow.getLong("sa_saleareaid"))){
|
|
|
+ rebateRows.add(rebateRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RowsMap rebateRowsMap =rebateRows.toRowsMap("month");
|
|
|
+
|
|
|
+ //总任务(万)
|
|
|
+ arearowResult.put("rw_total",rw_year);
|
|
|
+
|
|
|
+ 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).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal huodong=paymentRowsMap.containsKey("活动预存账户")?paymentRowsMap.get("活动预存账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("活动预存账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal fanli=rebateRowsMap.containsKey(monthstr)?rebateRowsMap.get(monthstr).sum("amount"):BigDecimal.ZERO;
|
|
|
+ BigDecimal gcgc=paymentRowsMap.containsKey("GC工程现金账户")?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("GC工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ BigDecimal zzgc=paymentRowsMap.containsKey("整装工程现金账户")?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").containsKey(monthstr)?paymentRowsMap.get("整装工程现金账户").toRowsMap("month").get(monthstr).sum("amount"):BigDecimal.ZERO:BigDecimal.ZERO;
|
|
|
+ gcgccompletedamount=gcgccompletedamount.add(gcgc);
|
|
|
+ zzgccompletedamount=zzgccompletedamount.add(zzgc);
|
|
|
+ completedamount=completedamount.add(xainjin).add(huodong).add(fanli);
|
|
|
+ }
|
|
|
+ //回款完成额
|
|
|
+ arearowResult.put("completedamount_total",completedamount);
|
|
|
+ //GC工程完成额
|
|
|
+ arearowResult.put("gccompletedamount_total",gcgccompletedamount.min(rw_all.multiply(gcproportion).multiply(BigDecimal.valueOf(10000))));
|
|
|
+ //整装工程完成额
|
|
|
+ arearowResult.put("zzcompletedamount_total",zzgccompletedamount.min(rw_all.multiply(zzproportion).multiply(BigDecimal.valueOf(10000))));
|
|
|
+ //总完成额
|
|
|
+ arearowResult.put("actualcompletedamount_total",arearowResult.getBigDecimal("completedamount_total").add(arearowResult.getBigDecimal("gccompletedamount_total")).add(arearowResult.getBigDecimal("zzcompletedamount_total")));
|
|
|
+ //百分比
|
|
|
+ if(rw_all.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ arearowResult.put("actualcompletedpercentage_total",0);
|
|
|
+ }else{
|
|
|
+ arearowResult.put("actualcompletedpercentage_total",arearowResult.getBigDecimal("actualcompletedamount_total").divide((rw_all.multiply(BigDecimal.valueOf(10000))),4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ //和年度任务的差额
|
|
|
+ BigDecimal differenceamount=rw_all.multiply(BigDecimal.valueOf(7000)).subtract(arearowResult.getBigDecimal("actualcompletedamount_total"));
|
|
|
+ arearowResult.put("differenceamount_total",differenceamount.compareTo(BigDecimal.ZERO)>0?differenceamount:0);
|
|
|
+ arearowsResult.add(arearowResult);
|
|
|
}
|
|
|
- //和年度任务的差额
|
|
|
- BigDecimal differenceamount=rw_all.multiply(BigDecimal.valueOf(7000)).subtract(jsonObject.getBigDecimal("actualcompletedamount"));
|
|
|
- jsonObject.put("differenceamount",differenceamount.compareTo(BigDecimal.ZERO)>0?differenceamount:0);
|
|
|
|
|
|
- return getSucReturnObject().setData(jsonObject).toString();
|
|
|
+ return arearowsResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -494,6 +623,8 @@ public class performancetargetboard extends Controller {
|
|
|
|
|
|
@API(title = "回款明细", apiversion = R.ID2025103015304303.v1.class)
|
|
|
public String querypaymentdetail() throws YosException {
|
|
|
+ long month =content.getLong("month");
|
|
|
+ String monthstr = String.format("%02d", month);
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr","name","hrid");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sa_salearea_hr", "t2", "t1.siteid = t2.siteid and t1.hrid = t2.hrid");
|
|
|
@@ -522,9 +653,10 @@ public class performancetargetboard extends Controller {
|
|
|
where.append(" and (t4.areaname3 ='").append(whereObject.getString("areaname3")).append("' or t4.areaname2 ='").append(whereObject.getString("areaname3")).append("' )");
|
|
|
}
|
|
|
}
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "回款明细");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "回款明细_新");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("year", year);
|
|
|
+ sqlFactory.addParameter("period", monthstr);
|
|
|
sqlFactory.addParameter_in("sa_saleareaids", list);
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|