|
|
@@ -8,8 +8,11 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.malk.sdzl.entity.AccountingSubjectEntity;
|
|
|
+import com.malk.sdzl.entity.AssessmentSubjectEntity;
|
|
|
import com.malk.sdzl.entity.Attachment;
|
|
|
import com.malk.sdzl.entity.CustomerInfoEntity;
|
|
|
+import com.malk.sdzl.entity.FormPageResponse;
|
|
|
import com.malk.sdzl.entity.SupplierInfoEntity;
|
|
|
import com.malk.sdzl.entity.commission.master.*;
|
|
|
import com.malk.sdzl.entity.commission.son.*;
|
|
|
@@ -17,6 +20,7 @@ import com.malk.sdzl.enums.AttachmentTypeEnum;
|
|
|
import com.malk.sdzl.service.CommissionService;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.server.common.McR;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.service.aliwork.YDService;
|
|
|
@@ -1702,6 +1706,22 @@ public class CommissionServiceImpl implements CommissionService {
|
|
|
return McR.success(customerInfoEntities);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public McR getAccountingSubjectPage(Map data) {
|
|
|
+ return McR.success(querySubjectPage(data,
|
|
|
+ "FORM-EF3C69C1DF73486D906D64B4B99EC2E8Y6PJ",
|
|
|
+ new String[]{"textField_mpz8iyhy", "textField_mpz8iyhz", "textField_mtv60q1t"},
|
|
|
+ this::toAccountingSubjectEntity));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR getAssessmentSubjectPage(Map data) {
|
|
|
+ return McR.success(querySubjectPage(data,
|
|
|
+ "FORM-B7FA79332E484F78945135A6C297DF12QRG2",
|
|
|
+ new String[]{"textField_mpz8iyhy", "textField_mpz8iyhz", "textField_mr4b6dtt", "textField_mr4b6dtv"},
|
|
|
+ this::toAssessmentSubjectEntity));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Object getFormTask(Map data) {
|
|
|
String userId = "603864663125953014";
|
|
|
@@ -2095,22 +2115,96 @@ public class CommissionServiceImpl implements CommissionService {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ private <T> FormPageResponse<T> querySubjectPage(Map data, String formUuid, String[] fieldIds,
|
|
|
+ java.util.function.Function<Map, T> converter) {
|
|
|
+ int currentPage = UtilMap.getInt(data, "currentPage");
|
|
|
+ if (currentPage <= 0) {
|
|
|
+ currentPage = 1;
|
|
|
+ }
|
|
|
+ int pageSize = UtilMap.getInt(data, "pageSize");
|
|
|
+ if (pageSize <= 0) {
|
|
|
+ pageSize = 100;
|
|
|
+ }
|
|
|
+ if (pageSize > 100) {
|
|
|
+ pageSize = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> searchMap = new HashMap<>();
|
|
|
+ for (String fieldId : fieldIds) {
|
|
|
+ String fieldValue = UtilMap.getString(data, fieldId);
|
|
|
+ if (!fieldValue.isEmpty()) {
|
|
|
+ searchMap.put(fieldId, fieldValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .appType(appType)
|
|
|
+ .systemToken(systemToken)
|
|
|
+ .formUuid(formUuid)
|
|
|
+ .currentPage(currentPage)
|
|
|
+ .pageSize(pageSize)
|
|
|
+ .searchFieldJson(JSON.toJSONString(searchMap))
|
|
|
+ .build();
|
|
|
+ DDR_New queryResult = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form);
|
|
|
+
|
|
|
+ List<Map> records = (List<Map>) queryResult.getData();
|
|
|
+ List<T> dataList = new ArrayList<>();
|
|
|
+ if (records != null) {
|
|
|
+ dataList = records.stream().map(item -> {
|
|
|
+ Map formData = (Map) item.get("formData");
|
|
|
+ Map result = formData == null ? new HashMap() : new HashMap(formData);
|
|
|
+ result.put("formInstanceId", item.get("formInstanceId"));
|
|
|
+ return converter.apply(result);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ FormPageResponse<T> result = new FormPageResponse<>();
|
|
|
+ result.setCurrentPage(currentPage);
|
|
|
+ result.setPageSize(pageSize);
|
|
|
+ result.setTotalCount(queryResult.getTotalCount());
|
|
|
+ result.setData(dataList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private AccountingSubjectEntity toAccountingSubjectEntity(Map formData) {
|
|
|
+ AccountingSubjectEntity entity = new AccountingSubjectEntity();
|
|
|
+ entity.setFormInstanceId(UtilMap.getString(formData, "formInstanceId"));
|
|
|
+ entity.setAccountingSubject(UtilMap.getString(formData, "textField_mpz8iyhy"));
|
|
|
+ entity.setAccountingSubjectCode(UtilMap.getString(formData, "textField_mpz8iyhz"));
|
|
|
+ entity.setFullName(UtilMap.getString(formData, "textField_mtv60q1t"));
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ private AssessmentSubjectEntity toAssessmentSubjectEntity(Map formData) {
|
|
|
+ AssessmentSubjectEntity entity = new AssessmentSubjectEntity();
|
|
|
+ entity.setFormInstanceId(UtilMap.getString(formData, "formInstanceId"));
|
|
|
+ entity.setAssessmentSubject(UtilMap.getString(formData, "textField_mpz8iyhy"));
|
|
|
+ entity.setAssessmentSubjectCode(UtilMap.getString(formData, "textField_mpz8iyhz"));
|
|
|
+ entity.setCostCenter(UtilMap.getString(formData, "textField_mr4b6dtt"));
|
|
|
+ entity.setCostCenterCode(UtilMap.getString(formData, "textField_mr4b6dtv"));
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
private List<Map> searchGetFormData(Map<String, Object> searchMap, int currentPage, int pageSize, String formUuid){
|
|
|
- YDParam ydParam = YDParam.builder().build();
|
|
|
-// ydParam.setPageSize(1);
|
|
|
-// long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
- // 轮询累计数据
|
|
|
- ydParam.setCurrentPage(currentPage);
|
|
|
- ydParam.setPageSize(pageSize);
|
|
|
- ydParam.setSearchFieldJson(JSON.toJSONString(searchMap));
|
|
|
- ydParam.setFormUuid(formUuid);
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .appType(appType)
|
|
|
+ .systemToken(systemToken)
|
|
|
+ .formUuid(formUuid)
|
|
|
+ .currentPage(currentPage)
|
|
|
+ .pageSize(pageSize)
|
|
|
+ .searchFieldJson(JSON.toJSONString(searchMap))
|
|
|
+ .build();
|
|
|
List<Map> dataList = new ArrayList<>();
|
|
|
- dataList.addAll((List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData());
|
|
|
+ List<Map> records = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ if (records != null) {
|
|
|
+ dataList.addAll(records);
|
|
|
+ }
|
|
|
return dataList.stream().map(item -> {
|
|
|
Map formData = (Map) item.get("formData");
|
|
|
- formData.put("instanceId", item.get("formInstanceId"));
|
|
|
- formData.put("formInstanceId", item.get("formInstanceId"));
|
|
|
- return formData;
|
|
|
+ Map result = formData == null ? new HashMap() : new HashMap(formData);
|
|
|
+ result.put("instanceId", item.get("formInstanceId"));
|
|
|
+ result.put("formInstanceId", item.get("formInstanceId"));
|
|
|
+ return result;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
}
|