|
@@ -597,6 +597,72 @@ public class McYdServiceImpl implements McYdService {
|
|
return McR.success();
|
|
return McR.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public McR batchUpdateSpecifiedQuantityData(Map map) {
|
|
|
|
+ String formInstId = UtilMap.getString(map, "formInstId");//当前表实例id
|
|
|
|
+
|
|
|
|
+ //查询当前表formData
|
|
|
|
+ Map formData = ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formInstanceId(formInstId)
|
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
+
|
|
|
|
+ //目标表筛选字段唯一标识
|
|
|
|
+ String[] searchFields = UtilMap.getString(map, "searchFieldStr").split(",");
|
|
|
|
+ //目标表筛选字段值
|
|
|
|
+ String[] searchFieldValues = UtilMap.getString(map, "searchFieldValueStr").split(",");
|
|
|
|
+
|
|
|
|
+ Map searchCondition = new HashMap();
|
|
|
|
+
|
|
|
|
+ if (searchFields.length == searchFieldValues.length){
|
|
|
|
+ for (int i = 0; i < searchFields.length; i++) {
|
|
|
|
+ searchCondition.put(searchFields[i],searchFieldValues[i]);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return McR.errorUnknown("筛选字段和筛选值数量不一致");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int quantity = UtilMap.getInt(map, "quantity");//指定更新数量
|
|
|
|
+ if (quantity > 100){
|
|
|
|
+ return McR.errorUnknown("更新数量不能大于100");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String formUuid = UtilMap.getString(map, "formUuid");//目标表uuid
|
|
|
|
+
|
|
|
|
+ List<Map> data = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
|
+ .searchCondition(JSONObject.toJSONString(searchCondition))
|
|
|
|
+ .formUuid(formUuid)
|
|
|
|
+ .pageSize(quantity)
|
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //目标表更新字段唯一标识
|
|
|
|
+ String[] fieldStrs = UtilMap.getString(map, "fieldStr").split(",");
|
|
|
|
+ //当前表字段唯一标识
|
|
|
|
+ String[] currentFieldStrs = UtilMap.getString(map, "currentFieldStrs").split(",");
|
|
|
|
+
|
|
|
|
+ Map updateFormData = new HashMap();
|
|
|
|
+
|
|
|
|
+ if (fieldStrs.length == currentFieldStrs.length){
|
|
|
|
+ for (int i = 0; i < fieldStrs.length; i++) {
|
|
|
|
+ updateFormData.put(fieldStrs[i],YDConf.getDataByCompId(formData,currentFieldStrs[i]));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return McR.errorUnknown("更新字段和当前表字段数量不一致");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Map datum : data) {
|
|
|
|
+ String formInstanceId = UtilMap.getString(datum, "formInstanceId");
|
|
|
|
+
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(updateFormData))
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return McR.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private static void extractOperatorIds(JSONArray array, List<String> result) {
|
|
private static void extractOperatorIds(JSONArray array, List<String> result) {
|
|
for (Object item : array) {
|
|
for (Object item : array) {
|