|
|
@@ -3,7 +3,6 @@ package nckd.jxccl.sit.hcsi.business.datacomparison;
|
|
|
|
|
|
import kd.bos.algo.DataSet;
|
|
|
import kd.bos.algo.JoinDataSet;
|
|
|
-import kd.bos.algo.JoinHint;
|
|
|
import kd.bos.algo.JoinType;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
@@ -14,6 +13,7 @@ import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
|
|
|
+import nckd.jxccl.sit.hcsi.common.constant.SitConstant;
|
|
|
import nckd.jxccl.sit.hcsi.utils.ReportUtils;
|
|
|
|
|
|
import java.util.List;
|
|
|
@@ -26,7 +26,8 @@ import java.util.stream.Collectors;
|
|
|
public class DataComparisonQueryService {
|
|
|
private static final Log logger = LogFactory.getLog(DataComparisonQueryService.class);
|
|
|
private static final String SINSURTASK = "hcsi_sinsurtask";
|
|
|
- String[] leftFields = new String[]{"welfarepayer", "welfaretypeid", "empnumber", "empname", "empidcard", "employee", "type", "personSysValue", "personSysValuea", "companySysValue", "companySysValuea"};
|
|
|
+ String[] mapFields = new String[]{"welfarepayer", "welfaretypeid", "empnumber", "empname", "empidcard", "employee"};
|
|
|
+ String[] leftFields = new String[]{"type", "personSysValue", "personSysValuea", "companySysValue", "companySysValuea"};
|
|
|
String[] rightFields = new String[]{"personOutValue", "personOutValuea","companyOutValue", "companyOutValuea"};
|
|
|
IDataModel model = null;
|
|
|
IFormView view = null;
|
|
|
@@ -44,6 +45,8 @@ public class DataComparisonQueryService {
|
|
|
logger.info("Tyx begin DataComparisonQueryService.doQuery");
|
|
|
// 查询任务ID
|
|
|
List<Long> taskIds = queryTask();
|
|
|
+ // Map数据集,用于获取全量人员+险种数据,用于最后join的底表用
|
|
|
+ DataSet dataSetMap = queryAllCalPersonAndWelfareTypeByTaskId(taskIds);
|
|
|
// 根据计算任务Id+险种获取到计算结果明细数据
|
|
|
DataSet calPersonDataSet = queryCalPersonDetail(taskIds);
|
|
|
// 按照个人和单位分组汇总 type = 1为个人,type = 2为单位,这里仅为系统内数据
|
|
|
@@ -52,9 +55,8 @@ public class DataComparisonQueryService {
|
|
|
DataSet outsidePersonDetail = queryOutsidePersonDetail();
|
|
|
// 按照个人和单位分组汇总 type = 1为个人,type = 2为单位,这里仅为系统外数据
|
|
|
DataSet groupDataSetOut = groupCalPersonDetailOut(outsidePersonDetail);
|
|
|
-
|
|
|
// 再join
|
|
|
- DataSet finalDataSet = joinFinallyDataSet(groupDataSet, groupDataSetOut);
|
|
|
+ DataSet finalDataSet = joinFinallyDataSet(dataSetMap, groupDataSet, groupDataSetOut);
|
|
|
return finalDataSet;
|
|
|
}
|
|
|
|
|
|
@@ -82,15 +84,55 @@ public class DataComparisonQueryService {
|
|
|
return cols;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据任务ID获取所有核算人员+险种的笛卡尔积
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public DataSet queryAllCalPersonAndWelfareTypeByTaskId(List<Long> taskIds) {
|
|
|
+ // 获取核算任务下的所有人
|
|
|
+ QFilter filter = new QFilter("sinsurtask.id", QCP.in, taskIds);
|
|
|
+ String selectFields = "welfarepayer.id as welfarepayer, empnumberdb as empnumber,namedb as empname,percre.number as empidcard,employee.id as employee, '1' as flag ";
|
|
|
+ DataSet dataSet1 = SitConstant.CALPERSON_HELPER.queryDataSet("queryAllCalPerson", selectFields, filter.toArray());
|
|
|
+
|
|
|
+ // 获取所有险种
|
|
|
+ DataSet dataSet2 = getWelfAreTypeIdsDataSet();
|
|
|
+
|
|
|
+ DataSet dataSetMap = dataSet1.fullJoin(dataSet2).on("flag", "flag").select(new String[]{"welfarepayer", "empnumber", "empname", "empidcard", "employee"}, new String[]{"id as welfaretypeid"}).finish();
|
|
|
+ return dataSetMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取人员计算详情数据-系统内数据
|
|
|
* @param taskIds
|
|
|
* @return
|
|
|
*/
|
|
|
public DataSet queryCalPersonDetail(List<Long> taskIds) {
|
|
|
+ List<Long> welfareTypeIds = getWelfAreTypeIds();
|
|
|
+ return ReportUtils.queryCalPersonDetail(welfareTypeIds, taskIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取险种ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Long> getWelfAreTypeIds() {
|
|
|
DynamicObjectCollection welfareTypeCols = (DynamicObjectCollection)model.getValue("nckd_welfaretype");
|
|
|
List<Long> welfareTypeIds = welfareTypeCols.stream().map(obj -> obj.getDynamicObject("fbasedataid").getLong("id")).collect(Collectors.toList());
|
|
|
- return ReportUtils.queryCalPersonDetail(welfareTypeIds, taskIds);
|
|
|
+ return welfareTypeIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回险种的DataSet
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public DataSet getWelfAreTypeIdsDataSet() {
|
|
|
+ List<Long> welfareTypeIds = getWelfAreTypeIds();
|
|
|
+ QFilter filter = new QFilter("id", QCP.in, welfareTypeIds);
|
|
|
+ return SitConstant.WELFARETYPE_HELPER.queryDataSet("queryWelfAreType", "id, '1' as flag", filter.toArray());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -143,10 +185,16 @@ public class DataComparisonQueryService {
|
|
|
return dataSet;
|
|
|
}
|
|
|
|
|
|
- public DataSet joinFinallyDataSet (DataSet groupDataSet, DataSet groupDataSetOut) {
|
|
|
- DataSet finalDataSet = groupDataSet.join(groupDataSetOut, JoinType.LEFT).on("welfarepayer", "welfarepayer").on("welfaretypeid", "welfaretypeid").
|
|
|
+ public DataSet joinFinallyDataSet (DataSet dataSetMap, DataSet groupDataSet, DataSet groupDataSetOut) {
|
|
|
+ // 中间过度用DataSet
|
|
|
+ DataSet midDataSet = dataSetMap.leftJoin(groupDataSet).on("welfarepayer", "welfarepayer").on("welfaretypeid", "welfaretypeid").
|
|
|
+ on("empname", "empname").
|
|
|
+ on("empidcard", "empidcard").select(mapFields, leftFields).finish();
|
|
|
+ // 最终返回DataSet
|
|
|
+ DataSet finalDataSet = midDataSet.leftJoin(groupDataSetOut).on("welfarepayer", "welfarepayer").on("welfaretypeid", "welfaretypeid").
|
|
|
on("empname", "empname").
|
|
|
- on("empidcard", "empidcard").select(leftFields, rightFields).finish();
|
|
|
+ on("empidcard", "empidcard").select(midDataSet.getRowMeta().getFieldNames(), rightFields).finish();
|
|
|
+
|
|
|
return finalDataSet;
|
|
|
}
|
|
|
|