1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
| private void setSubTableMap(Map<String, Object> oldDataMap, Map<String, Object> newDataMap, String key, SysDictExtendProperty extpro, String key_index) { if (oldDataMap.containsKey(key) && oldDataMap.get(key) instanceof ArrayList && oldDataMap.containsKey(key_index) && oldDataMap.get(key_index) instanceof Map) { ArrayList subtableMapList = (ArrayList)oldDataMap.get(key); Map newSubtableMap = (Map)newDataMap.get(key_index); Map oldSubtableMap_index = (Map)oldDataMap.get(key_index);
for(Object subTableObj : subtableMapList) { if (subTableObj instanceof Map) { Map oldSubTableMap = (Map)subTableObj; this.putDefaultValue(newSubtableMap, extpro.getName()); oldSubtableMap_index.put(extpro.getName(), newSubtableMap.get(extpro.getName())); oldSubTableMap.put(extpro.getName(), newSubtableMap.get(extpro.getName())); } } }
}
private void setSubTableValue(Map<String, SysDictCommonProperty> propertyMap, Map<String, Object> oldDataMap, Map<String, Object> newDataMap, String key) { if (propertyMap.containsKey(key) && propertyMap.get(key) instanceof SysDictExtendSubTableProperty) { SysDictExtendSubTableProperty property = (SysDictExtendSubTableProperty)propertyMap.get(key); if (property.getElementDictExtendModel() == null) { return; }
SysDictExtendModel model = property.getElementDictExtendModel(); if (model.getPropertyList() == null) { return; }
for(SysDictCommonProperty compro : model.getPropertyList()) { if (compro instanceof SysDictExtendElementProperty || compro instanceof SysDictExtendSimpleProperty) { SysDictExtendProperty extpro = (SysDictExtendProperty)compro; String key_index = key + "_index_"; if ("datetime".equals(extpro.getBusinessType()) && StringUtil.isNotNull(extpro.getDefaultValue())) { this.setSubTableMap(oldDataMap, newDataMap, key, extpro, key_index); } else if ("new_address".equals(extpro.getBusinessType()) && StringUtil.isNotNull(extpro.getDefaultValue())) { this.setSubTableMap(oldDataMap, newDataMap, key, extpro, key_index); } else if ("address".equals(extpro.getBusinessType()) && StringUtil.isNotNull(extpro.getDefaultValue())) { this.setSubTableMap(oldDataMap, newDataMap, key, extpro, key_index); } else if (oldDataMap.containsKey(key) && oldDataMap.get(key) instanceof ArrayList && oldDataMap.containsKey(key_index) && oldDataMap.get(key_index) instanceof Map) { ArrayList subtableMapList = (ArrayList)oldDataMap.get(key); Map newSubtableMap = (Map)newDataMap.get(key_index);
for(Object subTableObj : subtableMapList) { if (subTableObj instanceof Map) { this.putDefaultValue(newSubtableMap, extpro.getName()); } } } } } }
}
private void removeEnumValue(Map<String, Object> formData, Map<String, SysDictCommonProperty> propertyMap, Map<String, Object> oldDataMap) { for(Object key : new ArrayList(formData.keySet())) { if (propertyMap.containsKey(key) && propertyMap.get(key) instanceof SysDictExtendSubTableProperty) { SysDictExtendSubTableProperty property = (SysDictExtendSubTableProperty)propertyMap.get(key); if (property.getElementDictExtendModel() != null) { SysDictExtendModel model = property.getElementDictExtendModel(); if (model.getPropertyList() != null) { Map<String, SysDictCommonProperty> subPropertyMap = model.getPropertyMap();
for(Object o : (ArrayList)formData.get(key)) { HashMap<String, Object> hashMap = (HashMap)o; Iterator<String> iterator = hashMap.keySet().iterator();
while(iterator.hasNext()) { String subKey = (String)iterator.next(); if (subPropertyMap.containsKey(subKey) && (subPropertyMap.get(subKey) instanceof SysDictExtendElementProperty || subPropertyMap.get(subKey) instanceof SysDictExtendSimpleProperty)) { SysDictExtendProperty subProperty = (SysDictExtendProperty)subPropertyMap.get(subKey); if (StringUtil.isNotNull(subProperty.getEnumValues())) { String[] enumValues = subProperty.getEnumValues().split(";"); String oldVal = hashMap.get(subKey).toString(); oldVal = StringUtil.XMLUnEscape(oldVal); String[] olds = oldVal.split(";"); List<String> list = new ArrayList();
for(String enumValue : enumValues) { String[] values = enumValue.split("\\|"); if (values.length == 2) { list.add(values[1]); } }
boolean isHave = true;
for(String old : olds) { if (!list.contains(old)) { isHave = false; break; } }
if (!isHave) { iterator.remove(); } } } } } } } } else if (propertyMap.containsKey(key) && (propertyMap.get(key) instanceof SysDictExtendElementProperty || propertyMap.get(key) instanceof SysDictExtendSimpleProperty)) { SysDictExtendProperty property = (SysDictExtendProperty)propertyMap.get(key); if (StringUtil.isNotNull(property.getEnumValues())) { String[] enumValues = property.getEnumValues().split(";"); boolean isHave = true; List<String> list = new ArrayList();
for(String enumValue : enumValues) { String[] values = enumValue.split("\\|"); if (values.length == 2) { list.add(values[1]); } }
String oldVal = formData.get(key).toString(); oldVal = StringUtil.XMLUnEscape(oldVal); String[] split = oldVal.split(";");
for(String old : split) { if (!list.contains(old)) { isHave = false; break; } }
if (!isHave) { formData.remove(key); } } } }
}
private boolean isNull(Object obj) { if (obj == null) { return true; } else if (obj instanceof String) { return StringUtil.isNull((String)obj); } else if (obj instanceof Collection) { return ((Collection)obj).size() == 0; } else if (obj instanceof Map) { return ((Map)obj).size() == 0; } else { return true; } }
private void putDefaultValue(Map<String, Object> newDataMap, String key) { if (newDataMap.get(key) != null) { newDataMap.put(key + "_NoCopy", newDataMap.get(key)); }
}
private boolean isNotCopy(Map<String, SysDictCommonProperty> propertyMap, String key) { if (propertyMap.containsKey(key) && (propertyMap.get(key) instanceof SysDictExtendElementProperty || propertyMap.get(key) instanceof SysDictExtendSimpleProperty)) { SysDictExtendProperty property = (SysDictExtendProperty)propertyMap.get(key); if ("datetime".equals(property.getBusinessType()) && StringUtil.isNotNull(property.getDefaultValue())) { return true; }
if ("new_address".equals(property.getBusinessType()) && StringUtil.isNotNull(property.getDefaultValue())) { return true; }
if ("address".equals(property.getBusinessType()) && StringUtil.isNotNull(property.getDefaultValue())) { return true; } }
return false; }
private String checkTemplateUpdate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, Map<String, Object> newDataMap) throws Exception { ((IFsscInvoicePayableService) getServiceImp(request)).initFormSetting((IExtendForm)form, new RequestContext(request)); FsscInvoicePayableForm newForm = (FsscInvoicePayableForm)form; String invoiceId = request.getParameter("invoiceId"); FsscInvoicePayableForm copyForm = null; FsscInvoicePayable fsscInvoicePayable = (FsscInvoicePayable)this.getServiceImp(request).findByPrimaryKey(invoiceId); if (fsscInvoicePayable != null) { copyForm = (FsscInvoicePayableForm)this.getServiceImp(request).convertModelToForm(new FsscInvoicePayableForm(), fsscInvoicePayable, new RequestContext()); }
if (newDataMap != null) { newDataMap.putAll(newForm.getExtendDataFormInfo().getFormData()); }
return this.isUpdate(newForm, copyForm); }
private String isUpdate(FsscInvoicePayableForm newForm, FsscInvoicePayableForm copyForm) { String isUpdate = "false"; String newFilePath = newForm.getExtendDataFormInfo().getExtendFilePath(); String copyFilePath = copyForm.getExtendDataFormInfo().getExtendFilePath(); if (StringUtil.isNotNull(newFilePath)) { if (!newFilePath.equals(copyFilePath)) { isUpdate = "true"; } } else if (StringUtil.isNotNull(copyFilePath)) { isUpdate = "true"; }
return isUpdate; }
public void checkTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { response.getWriter().print(this.checkTemplateUpdate(mapping, form, request, response, (Map)null)); response.getWriter().flush(); response.getWriter().close(); }
|