|
@@ -1,6 +1,7 @@
|
|
|
package com.malk.zhixingtongde.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -11,6 +12,7 @@ import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.utils.UtilEnv;
|
|
|
import com.malk.utils.UtilExcel;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
+import com.malk.zhixingtongde.entity.Accounts;
|
|
|
import com.malk.zhixingtongde.entity.Profit;
|
|
|
import com.malk.zhixingtongde.service.ZxtdReportService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -32,6 +34,15 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
private static String[] PROFIT_CLASSIFYS={"收入","销售费用","管理费用","研发费用","财务费用"};// 分类
|
|
|
private static int[] PROFIT_NUMBERS={15,25,25,25,10};// 报表默认长度
|
|
|
|
|
|
+ private static String[] RECEIVABLE_CLASSIFYS ={"平台服务费","技术服务费","其他"};// 应收账款表子科目
|
|
|
+ private static int[] RECEIABLE_NUMBERS ={30,30,30};// 应收账款表默认长度
|
|
|
+
|
|
|
+ private static String[] OTHER_RECEIVABLE_CLASSIFYS ={"房屋押金","员工借款(备用金)","往来"};// 其他应收款表子科目
|
|
|
+ private static int[] OTHER_RECEIABLE_NUMBERS ={15,15,15};// 其他应收款表默认长度
|
|
|
+
|
|
|
+ private static String[] OTHER_PAYABLE_CLASSIFYS ={"往来"};// 其他应付款表子科目
|
|
|
+ private static int[] OTHER_PAYABLE_NUMBERS ={15};// 其他应付款表默认长度
|
|
|
+
|
|
|
String _matchFormUuid(String code) {
|
|
|
Map<String, String> formUuid = UtilMap.empty();
|
|
|
if (UtilEnv.getActiveProfile().equals(UtilEnv.ENV_PROD)) {
|
|
@@ -39,6 +50,9 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
formUuid.put("DOMAIN", "https://nxcyz4.aliwork.com/"); // 宜搭域名
|
|
|
formUuid.put("BUDGET","FORM-A0B077B5775341869605B2EB7E79356A7ZX7");// 成本费用预算编制中间表
|
|
|
formUuid.put("INCOME_BUDGET","FORM-3563C85B564345C4B2931CB27AE768C6CE73");// 收入预算编制中间表
|
|
|
+ formUuid.put("RECEIVABLE","FORM-F5ADEDFE47C749BF8109BFC4174E70483716");// 应收账款表
|
|
|
+ formUuid.put("OTHER_RECEIVABLE","FORM-FAD22D32A4524658B85C8A8482FDDFD0CEW0");// 其他应收账款表
|
|
|
+ formUuid.put("OTHER_PAYABLE","FORM-48CCA085CFDF4DC3B036A880F77842ED273S");// 其他应付账款表
|
|
|
} else {
|
|
|
formUuid.put("DOMAIN", "https://nxcyz4.aliwork.com/");
|
|
|
}
|
|
@@ -47,6 +61,14 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
|
|
|
@Override
|
|
|
public void exportProfit(HttpServletResponse response,String year) {
|
|
|
+ Map profit = getProfit(year);
|
|
|
+ List<Profit> dataList = (List<Profit>) profit.get("dataList");
|
|
|
+ Map mainData = (Map) profit.get("mainData");
|
|
|
+
|
|
|
+ UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Profit.class, "利润", "Template_profit.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map getProfit(String year) {
|
|
|
// 1.获取宜搭数据
|
|
|
Profit[] PROFIT_SUM=new Profit[5];// 分类小计数据
|
|
|
List<Profit> dataList=getData(year,PROFIT_SUM);
|
|
@@ -70,11 +92,25 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
}
|
|
|
mainData.put("payTotalAmtTotal",payTotalAmtTotal);
|
|
|
mainData.put("netProfitTotal",netProfitTotal);
|
|
|
- UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Profit.class, "利润", "Template_profit.xlsx");
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+
|
|
|
+ map.put("dataList",dataList);
|
|
|
+ map.put("mainData",mainData);
|
|
|
+
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void exportQuarterProfit(HttpServletResponse response, String year) {
|
|
|
+ Map quarter = getQuarter(year);
|
|
|
+ List<Profit> dataList = (List<Profit>) quarter.get("dataList");
|
|
|
+ Map mainData = (Map) quarter.get("mainData");
|
|
|
+
|
|
|
+ UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Profit.class, "季度利润", "Quarter_Template_profit.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map getQuarter(String year) {
|
|
|
// 1.获取宜搭数据
|
|
|
Profit[] PROFIT_SUM=new Profit[5];// 分类小计数据
|
|
|
List<Profit> dataList=getQuarterData(year,PROFIT_SUM);
|
|
@@ -111,7 +147,411 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
mainData.put("payBudgetQuarterTotalAmtTotal",payBudgetQuarterTotalAmtTotal);
|
|
|
mainData.put("netQuarterProfitTotal",netQuarterProfitTotal);
|
|
|
mainData.put("netBudgetQuarterProfitTotal",netBudgetQuarterProfitTotal);
|
|
|
- UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Profit.class, "季度利润", "Quarter_Template_profit.xlsx");
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+
|
|
|
+ map.put("dataList",dataList);
|
|
|
+ map.put("mainData",mainData);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportReceivableDetails(HttpServletResponse response, String year) {
|
|
|
+ Map receivable = getReceivable(year);
|
|
|
+ List<Accounts> dataList = (List<Accounts>) receivable.get("dataList");
|
|
|
+ Map mainData = (Map) receivable.get("mainData");
|
|
|
+
|
|
|
+ UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Accounts.class, "应收账款表", "Template_receivable.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map getReceivable(String year) {
|
|
|
+ // 1.获取宜搭数据
|
|
|
+ Accounts[] ACCOUNTS_SUM=new Accounts[3];// 分类小计数据
|
|
|
+ List<Accounts> dataList=getReceivableData(year,ACCOUNTS_SUM);
|
|
|
+ // 2.计算主数据
|
|
|
+ Map mainData=new HashMap();
|
|
|
+ mainData.put("year",year);
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("mainData",mainData);
|
|
|
+ map.put("dataList",dataList);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportOtherReceivableDetails(HttpServletResponse response, String year) {
|
|
|
+ Map otherReceivable = getOtherReceivable(year);
|
|
|
+ List<Accounts> dataList = (List<Accounts>) otherReceivable.get("dataList");
|
|
|
+ Map mainData = (Map) otherReceivable.get("mainData");
|
|
|
+
|
|
|
+ UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Accounts.class, "其他应收款表", "Template_other_receivable.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map getOtherReceivable(String year) {
|
|
|
+ // 1.获取宜搭数据
|
|
|
+ Accounts[] ACCOUNTS_SUM=new Accounts[3];// 分类小计数据
|
|
|
+ List<Accounts> dataList=getOtherReceivableData(year,ACCOUNTS_SUM);
|
|
|
+ // 2.计算主数据
|
|
|
+ Map mainData=new HashMap();
|
|
|
+ mainData.put("year",year);
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("mainData",mainData);
|
|
|
+ map.put("dataList",dataList);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportOtherPayableDetails(HttpServletResponse response, String year) {
|
|
|
+ Map otherPayable = getOtherPayable(year);
|
|
|
+ List<Accounts> dataList = (List<Accounts>) otherPayable.get("dataList");
|
|
|
+ Map mainData = (Map) otherPayable.get("mainData");
|
|
|
+
|
|
|
+ UtilExcel.exportMapAndListByTemplate(response,mainData,dataList, Accounts.class, "其他应付款表", "Template_other_payable.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map getOtherPayable(String year) {
|
|
|
+ // 1.获取宜搭数据
|
|
|
+ Accounts[] ACCOUNTS_SUM=new Accounts[1];// 分类小计数据
|
|
|
+ List<Accounts> dataList=getOtherPayableData(year,ACCOUNTS_SUM);
|
|
|
+ // 2.计算主数据
|
|
|
+ Map mainData=new HashMap();
|
|
|
+ mainData.put("year",year);
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("mainData",mainData);
|
|
|
+ map.put("dataList",dataList);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportAll(HttpServletResponse response, String year) {
|
|
|
+ //利润表
|
|
|
+ Map map1 = getProfit(year);
|
|
|
+
|
|
|
+ //季度核算表
|
|
|
+ Map map2 = getQuarter(year);
|
|
|
+
|
|
|
+ //应收账款表
|
|
|
+ Map map3 = getReceivable(year);
|
|
|
+
|
|
|
+ //其他应收款表
|
|
|
+ Map map4 = getOtherReceivable(year);
|
|
|
+
|
|
|
+ //其他应付款表
|
|
|
+ Map map5 = getOtherPayable(year);
|
|
|
+
|
|
|
+ List<Object> dataMainList = new ArrayList<>();
|
|
|
+ dataMainList.add(map1.get("mainData"));
|
|
|
+ dataMainList.add(map2.get("mainData"));
|
|
|
+ dataMainList.add(map3.get("mainData"));
|
|
|
+ dataMainList.add(map4.get("mainData"));
|
|
|
+ dataMainList.add(map5.get("mainData"));
|
|
|
+
|
|
|
+ List<List> dataLists = new ArrayList<>();
|
|
|
+ dataLists.add((List)map1.get("dataList"));
|
|
|
+ dataLists.add((List)map2.get("dataList"));
|
|
|
+ dataLists.add((List)map3.get("dataList"));
|
|
|
+ dataLists.add((List)map4.get("dataList"));
|
|
|
+ dataLists.add((List)map5.get("dataList"));
|
|
|
+
|
|
|
+ UtilExcel.exportAllSheetByTemplate(response,dataMainList,dataLists,"全部","Template_all.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Accounts> getOtherPayableData(String year, Accounts[] ACCOUNTS_SUM) {
|
|
|
+ String dateParam = getDateParam(year);
|
|
|
+
|
|
|
+ // 查询宜搭底表数据
|
|
|
+ List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(_matchFormUuid("OTHER_PAYABLE")).searchCondition(
|
|
|
+ JSONObject.toJSONString(UtilMap.map("dateField_lqyx5k0n",dateParam))
|
|
|
+ ).build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
|
|
|
+ Map<String,Map<String,Accounts>> dataMap=new HashMap<>();
|
|
|
+ // 数据预处理
|
|
|
+ for (Map map:list){
|
|
|
+ JSONObject formData=JSONObject.parseObject(String.valueOf(map.get("formData")));
|
|
|
+ String subject = formData.getString("textField_lqyx5k16") ;// 科目
|
|
|
+
|
|
|
+ if (ArrayUtil.contains(OTHER_PAYABLE_CLASSIFYS,subject)){
|
|
|
+ //获取其他应收款明细子表单数据
|
|
|
+ List<Map> detailList = (List<Map>) formData.get("tableField_lqyx5k0c");
|
|
|
+ Map<String,Accounts> accountsMap = new HashMap<>();
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ Accounts accounts = new Accounts();
|
|
|
+ accounts.setCustomerName(detail.get("textField_lqyx5k0f").toString().isEmpty() ? "--" : detail.get("textField_lqyx5k0f").toString());// 客户名称
|
|
|
+ accounts.setInitialAmt(detail.get("numberField_lqyx5k0o") == null ? "" : detail.get("numberField_lqyx5k0o").toString());// 期初余额
|
|
|
+ accounts.setAmt1(detail.get("numberField_lqyx5k0q") == null ? "0" : detail.get("numberField_lqyx5k0q").toString());// 1月金额
|
|
|
+ accounts.setAmt2(detail.get("numberField_lqyx5k0r") == null ? "0" : detail.get("numberField_lqyx5k0r").toString()); // 2月金额
|
|
|
+ accounts.setAmt3(detail.get("numberField_lqyx5k0s") == null ? "0" : detail.get("numberField_lqyx5k0s").toString()); // 3月金额
|
|
|
+ accounts.setAmt4(detail.get("numberField_lqyx5k0t") == null ? "0" : detail.get("numberField_lqyx5k0t").toString()); // 4月金额
|
|
|
+ accounts.setAmt5(detail.get("numberField_lqyx5k0u") == null ? "0" : detail.get("numberField_lqyx5k0u").toString()); // 5月金额
|
|
|
+ accounts.setAmt6(detail.get("numberField_lqyx5k0v") == null ? "0" : detail.get("numberField_lqyx5k0v").toString()); // 6月金额
|
|
|
+ accounts.setAmt7(detail.get("numberField_lqyx5k0w") == null ? "0" : detail.get("numberField_lqyx5k0w").toString()); // 7月金额
|
|
|
+ accounts.setAmt8(detail.get("numberField_lqyx5k0x") == null ? "0" : detail.get("numberField_lqyx5k0x").toString()); // 8月金额
|
|
|
+ accounts.setAmt9(detail.get("numberField_lqyx5k0y") == null ? "0" : detail.get("numberField_lqyx5k0y").toString()); // 9月金额
|
|
|
+ accounts.setAmt10(detail.get("numberField_lqyx5k0z") == null ? "0" : detail.get("numberField_lqyx5k0z").toString()); // 10月金额
|
|
|
+ accounts.setAmt11(detail.get("numberField_lqyx5k10") == null ? "0" : detail.get("numberField_lqyx5k10").toString()); // 11月金额
|
|
|
+ accounts.setAmt12(detail.get("numberField_lqyx5k11") == null ? "0" : detail.get("numberField_lqyx5k11").toString()); // 12月金额
|
|
|
+ //获取原始客户应收账款明细
|
|
|
+ Accounts oldAccounts = accountsMap.get(accounts.getCustomerName());
|
|
|
+ if (Objects.nonNull(oldAccounts)){
|
|
|
+ accounts.add(oldAccounts);
|
|
|
+ }
|
|
|
+ accountsMap.put(accounts.getCustomerName(),accounts);
|
|
|
+ }
|
|
|
+ Map<String, Accounts> oldAccountsMap = dataMap.get(subject);
|
|
|
+ if (Objects.nonNull(oldAccountsMap)){
|
|
|
+ //找出accountsMap和oldAccountsMap相同的key
|
|
|
+ Set<String> customerSet = accountsMap.keySet();
|
|
|
+ for (String oldCustomer : oldAccountsMap.keySet()) {
|
|
|
+ if (customerSet.contains(oldCustomer)){
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer).add(accountsMap.get(oldCustomer)));
|
|
|
+ }else {
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataMap.put(subject,accountsMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Accounts> accountsList=new ArrayList<>();
|
|
|
+ Accounts nullAccounts=new Accounts();
|
|
|
+ Accounts totalAccounts = new Accounts();
|
|
|
+ // 根据 子科目 处理数据
|
|
|
+ for (int i = 0; i < OTHER_PAYABLE_CLASSIFYS.length; i++) {
|
|
|
+ List<Accounts> list1=new ArrayList<>();
|
|
|
+ Accounts subTotalAccounts=new Accounts();
|
|
|
+ if(dataMap.containsKey(OTHER_PAYABLE_CLASSIFYS[i])){
|
|
|
+ for (String str:dataMap.get(OTHER_PAYABLE_CLASSIFYS[i]).keySet()){
|
|
|
+ Accounts accountsTemp = dataMap.get(OTHER_PAYABLE_CLASSIFYS[i]).get(str);
|
|
|
+ list1.add(accountsTemp);
|
|
|
+ subTotalAccounts.setInitialAmt(NumberUtil.add(subTotalAccounts.getInitialAmt(),accountsTemp.getInitialAmt()).toString());
|
|
|
+ for (int j = 1; j < 13; j++) {
|
|
|
+ String amtTemp=ReflectUtil.invoke(accountsTemp,"getAmt"+j);
|
|
|
+ String amt=ReflectUtil.invoke(subTotalAccounts,"getAmt"+j);
|
|
|
+ ReflectUtil.invoke(subTotalAccounts, "setAmt"+j, NumberUtil.add(amt,amtTemp).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 补充空数据
|
|
|
+ for (int j = list1.size(); j < OTHER_PAYABLE_NUMBERS[i]; j++) {
|
|
|
+ list1.add(nullAccounts);
|
|
|
+ }
|
|
|
+ // 添加小计
|
|
|
+ ACCOUNTS_SUM[i]=subTotalAccounts;
|
|
|
+ list1.add(ACCOUNTS_SUM[i]);
|
|
|
+ totalAccounts.add(subTotalAccounts);
|
|
|
+ if (i == OTHER_PAYABLE_NUMBERS.length - 1){
|
|
|
+ //添加合计
|
|
|
+ list1.add(totalAccounts);
|
|
|
+ }
|
|
|
+ accountsList.addAll(list1);
|
|
|
+ }
|
|
|
+ return accountsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Accounts> getOtherReceivableData(String year, Accounts[] ACCOUNTS_SUM) {
|
|
|
+ String dateParam = getDateParam(year);
|
|
|
+
|
|
|
+ // 查询宜搭底表数据
|
|
|
+ List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(_matchFormUuid("OTHER_RECEIVABLE")).searchCondition(
|
|
|
+ JSONObject.toJSONString(UtilMap.map("dateField_lqyx5k0n",dateParam))
|
|
|
+ ).build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
|
|
|
+ Map<String,Map<String,Accounts>> dataMap=new HashMap<>();
|
|
|
+ // 数据预处理
|
|
|
+ for (Map map:list){
|
|
|
+ JSONObject formData=JSONObject.parseObject(String.valueOf(map.get("formData")));
|
|
|
+ String subject = formData.getString("textField_lqyx5k16") ;// 科目
|
|
|
+
|
|
|
+ if (ArrayUtil.contains(OTHER_RECEIVABLE_CLASSIFYS,subject)){
|
|
|
+ //获取其他应收款明细子表单数据
|
|
|
+ List<Map> detailList = (List<Map>) formData.get("tableField_lqyx5k0c");
|
|
|
+ Map<String,Accounts> accountsMap = new HashMap<>();
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ Accounts accounts = new Accounts();
|
|
|
+ accounts.setCustomerName(detail.get("textField_lqyx5k0f").toString().isEmpty() ? "--" : detail.get("textField_lqyx5k0f").toString());// 客户名称
|
|
|
+ accounts.setInitialAmt(detail.get("numberField_lqyx5k0o") == null ? "" : detail.get("numberField_lqyx5k0o").toString());// 期初余额
|
|
|
+ accounts.setAmt1(detail.get("numberField_lqyx5k0q") == null ? "0" : detail.get("numberField_lqyx5k0q").toString());// 1月金额
|
|
|
+ accounts.setAmt2(detail.get("numberField_lqyx5k0r") == null ? "0" : detail.get("numberField_lqyx5k0r").toString()); // 2月金额
|
|
|
+ accounts.setAmt3(detail.get("numberField_lqyx5k0s") == null ? "0" : detail.get("numberField_lqyx5k0s").toString()); // 3月金额
|
|
|
+ accounts.setAmt4(detail.get("numberField_lqyx5k0t") == null ? "0" : detail.get("numberField_lqyx5k0t").toString()); // 4月金额
|
|
|
+ accounts.setAmt5(detail.get("numberField_lqyx5k0u") == null ? "0" : detail.get("numberField_lqyx5k0u").toString()); // 5月金额
|
|
|
+ accounts.setAmt6(detail.get("numberField_lqyx5k0v") == null ? "0" : detail.get("numberField_lqyx5k0v").toString()); // 6月金额
|
|
|
+ accounts.setAmt7(detail.get("numberField_lqyx5k0w") == null ? "0" : detail.get("numberField_lqyx5k0w").toString()); // 7月金额
|
|
|
+ accounts.setAmt8(detail.get("numberField_lqyx5k0x") == null ? "0" : detail.get("numberField_lqyx5k0x").toString()); // 8月金额
|
|
|
+ accounts.setAmt9(detail.get("numberField_lqyx5k0y") == null ? "0" : detail.get("numberField_lqyx5k0y").toString()); // 9月金额
|
|
|
+ accounts.setAmt10(detail.get("numberField_lqyx5k0z") == null ? "0" : detail.get("numberField_lqyx5k0z").toString()); // 10月金额
|
|
|
+ accounts.setAmt11(detail.get("numberField_lqyx5k10") == null ? "0" : detail.get("numberField_lqyx5k10").toString()); // 11月金额
|
|
|
+ accounts.setAmt12(detail.get("numberField_lqyx5k11") == null ? "0" : detail.get("numberField_lqyx5k11").toString()); // 12月金额
|
|
|
+ //获取原始客户应收账款明细
|
|
|
+ Accounts oldAccounts = accountsMap.get(accounts.getCustomerName());
|
|
|
+ if (Objects.nonNull(oldAccounts)){
|
|
|
+ accounts.add(oldAccounts);
|
|
|
+ }
|
|
|
+ accountsMap.put(accounts.getCustomerName(),accounts);
|
|
|
+ }
|
|
|
+ Map<String, Accounts> oldAccountsMap = dataMap.get(subject);
|
|
|
+ if (Objects.nonNull(oldAccountsMap)){
|
|
|
+ //找出accountsMap和oldAccountsMap相同的key
|
|
|
+ Set<String> customerSet = accountsMap.keySet();
|
|
|
+ for (String oldCustomer : oldAccountsMap.keySet()) {
|
|
|
+ if (customerSet.contains(oldCustomer)){
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer).add(accountsMap.get(oldCustomer)));
|
|
|
+ }else {
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataMap.put(subject,accountsMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Accounts> accountsList=new ArrayList<>();
|
|
|
+ Accounts nullAccounts=new Accounts();
|
|
|
+ Accounts totalAccounts = new Accounts();
|
|
|
+ // 根据 子科目 处理数据
|
|
|
+ for (int i = 0; i < OTHER_RECEIVABLE_CLASSIFYS.length; i++) {
|
|
|
+ List<Accounts> list1=new ArrayList<>();
|
|
|
+ Accounts subTotalAccounts=new Accounts();
|
|
|
+ if(dataMap.containsKey(OTHER_RECEIVABLE_CLASSIFYS[i])){
|
|
|
+ for (String str:dataMap.get(OTHER_RECEIVABLE_CLASSIFYS[i]).keySet()){
|
|
|
+ Accounts accountsTemp = dataMap.get(OTHER_RECEIVABLE_CLASSIFYS[i]).get(str);
|
|
|
+ list1.add(accountsTemp);
|
|
|
+ subTotalAccounts.setInitialAmt(NumberUtil.add(subTotalAccounts.getInitialAmt(),accountsTemp.getInitialAmt()).toString());
|
|
|
+ for (int j = 1; j < 13; j++) {
|
|
|
+ String amtTemp=ReflectUtil.invoke(accountsTemp,"getAmt"+j);
|
|
|
+ String amt=ReflectUtil.invoke(subTotalAccounts,"getAmt"+j);
|
|
|
+ ReflectUtil.invoke(subTotalAccounts, "setAmt"+j, NumberUtil.add(amt,amtTemp).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 补充空数据
|
|
|
+ for (int j = list1.size(); j < OTHER_RECEIABLE_NUMBERS[i]; j++) {
|
|
|
+ list1.add(nullAccounts);
|
|
|
+ }
|
|
|
+ // 添加小计
|
|
|
+ ACCOUNTS_SUM[i]=subTotalAccounts;
|
|
|
+ list1.add(ACCOUNTS_SUM[i]);
|
|
|
+ totalAccounts.add(subTotalAccounts);
|
|
|
+ if (i == OTHER_RECEIABLE_NUMBERS.length - 1){
|
|
|
+ //添加合计
|
|
|
+ list1.add(totalAccounts);
|
|
|
+ }
|
|
|
+ accountsList.addAll(list1);
|
|
|
+ }
|
|
|
+ return accountsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Accounts> getReceivableData(String year, Accounts[] ACCOUNTS_SUM) {
|
|
|
+ String dateParam = getDateParam(year);
|
|
|
+
|
|
|
+ // 查询宜搭底表数据
|
|
|
+ List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(_matchFormUuid("RECEIVABLE")).searchCondition(
|
|
|
+ JSONObject.toJSONString(UtilMap.map("dateField_lqyx5k0n",dateParam))
|
|
|
+ ).build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
|
|
|
+ Map<String,Map<String,Accounts>> dataMap=new HashMap<>();
|
|
|
+ // 数据预处理
|
|
|
+ for (Map map:list){
|
|
|
+ JSONObject formData=JSONObject.parseObject(String.valueOf(map.get("formData")));
|
|
|
+ String subject = formData.getString("textField_lqyx5k16") ;// 科目
|
|
|
+ if (!"平台服务费".equals(subject) && !"技术服务费".equals(subject)){
|
|
|
+ subject = "其他";
|
|
|
+ }
|
|
|
+ //获取应收账款明细子表单数据
|
|
|
+ List<Map> detailList = (List<Map>) formData.get("tableField_lqyx5k0c");
|
|
|
+ Map<String,Accounts> accountsMap = new HashMap<>();
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ Accounts accounts = new Accounts();
|
|
|
+ accounts.setCustomerName(detail.get("textField_lqyx5k0f").toString().isEmpty() ? "--" : detail.get("textField_lqyx5k0f").toString());// 客户名称
|
|
|
+ accounts.setInitialAmt(detail.get("numberField_lqyx5k0o") == null ? "" : detail.get("numberField_lqyx5k0o").toString());// 期初余额
|
|
|
+ accounts.setAmt1(detail.get("numberField_lqyx5k0q") == null ? "0" : detail.get("numberField_lqyx5k0q").toString());// 1月金额
|
|
|
+ accounts.setAmt2(detail.get("numberField_lqyx5k0r") == null ? "0" : detail.get("numberField_lqyx5k0r").toString()); // 2月金额
|
|
|
+ accounts.setAmt3(detail.get("numberField_lqyx5k0s") == null ? "0" : detail.get("numberField_lqyx5k0s").toString()); // 3月金额
|
|
|
+ accounts.setAmt4(detail.get("numberField_lqyx5k0t") == null ? "0" : detail.get("numberField_lqyx5k0t").toString()); // 4月金额
|
|
|
+ accounts.setAmt5(detail.get("numberField_lqyx5k0u") == null ? "0" : detail.get("numberField_lqyx5k0u").toString()); // 5月金额
|
|
|
+ accounts.setAmt6(detail.get("numberField_lqyx5k0v") == null ? "0" : detail.get("numberField_lqyx5k0v").toString()); // 6月金额
|
|
|
+ accounts.setAmt7(detail.get("numberField_lqyx5k0w") == null ? "0" : detail.get("numberField_lqyx5k0w").toString()); // 7月金额
|
|
|
+ accounts.setAmt8(detail.get("numberField_lqyx5k0x") == null ? "0" : detail.get("numberField_lqyx5k0x").toString()); // 8月金额
|
|
|
+ accounts.setAmt9(detail.get("numberField_lqyx5k0y") == null ? "0" : detail.get("numberField_lqyx5k0y").toString()); // 9月金额
|
|
|
+ accounts.setAmt10(detail.get("numberField_lqyx5k0z") == null ? "0" : detail.get("numberField_lqyx5k0z").toString()); // 10月金额
|
|
|
+ accounts.setAmt11(detail.get("numberField_lqyx5k10") == null ? "0" : detail.get("numberField_lqyx5k10").toString()); // 11月金额
|
|
|
+ accounts.setAmt12(detail.get("numberField_lqyx5k11") == null ? "0" : detail.get("numberField_lqyx5k11").toString()); // 12月金额
|
|
|
+ //获取原始客户应收账款明细
|
|
|
+ Accounts oldAccounts = accountsMap.get(accounts.getCustomerName());
|
|
|
+ if (Objects.nonNull(oldAccounts)){
|
|
|
+ accounts.add(oldAccounts);
|
|
|
+ }
|
|
|
+ accountsMap.put(accounts.getCustomerName(),accounts);
|
|
|
+ }
|
|
|
+ Map<String, Accounts> oldAccountsMap = dataMap.get(subject);
|
|
|
+ if (Objects.nonNull(oldAccountsMap)){
|
|
|
+ //找出accountsMap和oldAccountsMap相同的key
|
|
|
+ Set<String> customerSet = accountsMap.keySet();
|
|
|
+ for (String oldCustomer : oldAccountsMap.keySet()) {
|
|
|
+ if (customerSet.contains(oldCustomer)){
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer).add(accountsMap.get(oldCustomer)));
|
|
|
+ }else {
|
|
|
+ accountsMap.put(oldCustomer,oldAccountsMap.get(oldCustomer));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataMap.put(subject,accountsMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Accounts> accountsList=new ArrayList<>();
|
|
|
+ Accounts nullAccounts=new Accounts();
|
|
|
+ Accounts totalAccounts = new Accounts();
|
|
|
+ // 根据 子科目 处理数据
|
|
|
+ for (int i = 0; i < RECEIVABLE_CLASSIFYS.length; i++) {
|
|
|
+ List<Accounts> list1=new ArrayList<>();
|
|
|
+ Accounts subTotalAccounts=new Accounts();
|
|
|
+ if(dataMap.containsKey(RECEIVABLE_CLASSIFYS[i])){
|
|
|
+ for (String str:dataMap.get(RECEIVABLE_CLASSIFYS[i]).keySet()){
|
|
|
+ Accounts accountsTemp = dataMap.get(RECEIVABLE_CLASSIFYS[i]).get(str);
|
|
|
+ list1.add(accountsTemp);
|
|
|
+ subTotalAccounts.setInitialAmt(NumberUtil.add(subTotalAccounts.getInitialAmt(),accountsTemp.getInitialAmt()).toString());
|
|
|
+ for (int j = 1; j < 13; j++) {
|
|
|
+ String amtTemp=ReflectUtil.invoke(accountsTemp,"getAmt"+j);
|
|
|
+ String amt=ReflectUtil.invoke(subTotalAccounts,"getAmt"+j);
|
|
|
+ ReflectUtil.invoke(subTotalAccounts, "setAmt"+j, NumberUtil.add(amt,amtTemp).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 补充空数据
|
|
|
+ for (int j = list1.size(); j < RECEIABLE_NUMBERS[i]; j++) {
|
|
|
+ list1.add(nullAccounts);
|
|
|
+ }
|
|
|
+ // 添加小计
|
|
|
+ ACCOUNTS_SUM[i]=subTotalAccounts;
|
|
|
+ list1.add(ACCOUNTS_SUM[i]);
|
|
|
+ totalAccounts.add(subTotalAccounts);
|
|
|
+ if (i > 0){
|
|
|
+ //添加合计
|
|
|
+ list1.add(totalAccounts);
|
|
|
+ totalAccounts = new Accounts();
|
|
|
+ }
|
|
|
+ accountsList.addAll(list1);
|
|
|
+ }
|
|
|
+ return accountsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getDateParam(String year) {
|
|
|
+ //获取year时间戳区间
|
|
|
+ Date yearDate;
|
|
|
+ try {
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ yearDate = dateFormat.parse(year + "-01-01");
|
|
|
+ }catch (ParseException e){
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ long beginDate = DateUtil.beginOfYear(yearDate).getTime();
|
|
|
+ long endDate = DateUtil.endOfYear(yearDate).getTime();
|
|
|
+ String dateParam = "[" + beginDate + "," + endDate + "]";
|
|
|
+ return dateParam;
|
|
|
}
|
|
|
|
|
|
// 按月获取利润表数据
|
|
@@ -224,16 +664,7 @@ public class ZxtdReportServiceImpl implements ZxtdReportService {
|
|
|
if(dataMap.containsKey(PROFIT_CLASSIFYS[i])){
|
|
|
for (String str:dataMap.get(PROFIT_CLASSIFYS[i]).keySet()){
|
|
|
List<Map> budgetList = new ArrayList<>();
|
|
|
- Date date = new Date();
|
|
|
- try {
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- date = dateFormat.parse(year + "-01-01");
|
|
|
- }catch (ParseException e){
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- long beginDate = DateUtil.beginOfYear(date).getTime();
|
|
|
- long endDate = DateUtil.endOfYear(date).getTime();
|
|
|
- String dateParam = "[" + beginDate + "," + endDate + "]";
|
|
|
+ String dateParam = getDateParam(year);
|
|
|
Integer quarterBudgetAmt = 0;
|
|
|
int index = 1;
|
|
|
if ("收入".equals(PROFIT_CLASSIFYS[i])){
|