Browse Source

Merge branch 'master' of http://120.76.47.59:3000/liu_li/yxk_StoreroomSystem

# Conflicts:
#	archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
master
刘力 3 years ago
parent
commit
316554a162
  1. 38
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  2. 7
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

38
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java

@ -44,6 +44,7 @@ public class ArchivesServiceImpl implements ArchivesService {
return "未查询到到门类信息!";
ArchivesType archivesType = optional.get();
List<String> queryFields = archivesDictionaryRepository.findDisPlayField(categoryId);
List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findDisPlay(categoryId);
String queryField = queryFields.stream().map(String::valueOf).collect(Collectors.joining(","));
String queryTable = archivesType.getEnName();
String quertOrder = "";
@ -59,7 +60,7 @@ public class ArchivesServiceImpl implements ArchivesService {
List<Object[]> list = entityManager.createNativeQuery("select "+queryField+" from "+queryTable+additional+quertOrder).getResultList();
JSONObject json = new JSONObject();
json.put("queryFields",queryFields);
json.put("queryFields",queryShow);
json.put("showlist",list);
return json;
}
@ -95,7 +96,7 @@ public class ArchivesServiceImpl implements ArchivesService {
public Object edit(ArchivesDTO dto) {
dto = new ArchivesDTO();
dto.setJsonString("{'category_name':'测试111','remarks':'这是一个备注2'}");
String dtoId = "42DA07A3174510955C5635";
String dtoId = "42DA07A3174510955C5636";
// String dtoId = null;
JSONObject json = new JSONObject(dto.getJsonString());
String categoryId = "FFAFBB1647D459C82080A";
@ -105,27 +106,42 @@ public class ArchivesServiceImpl implements ArchivesService {
String insertValue = "";
String updateValue = "";
for(ArchivesDictionary archivesDictionary:showFiled){
//是否必填
if(archivesDictionary.getIsRequired()){
if(null == json.get(archivesDictionary.getFieldName()) || "".equals(json.get(archivesDictionary.getFieldName()))){
return archivesDictionary.getFieldName()+"不可为空!";
}
}
//是否重复
if(archivesDictionary.getIsRepeat()){
//判断是否为空
if(null != json.get(archivesDictionary.getFieldName()) && !"".equals(json.get(archivesDictionary.getFieldName()))){
String thissql = "select id,"+archivesDictionary.getFieldName()+" from "+archivesType.getEnName()+" where "+
archivesDictionary.getFieldName() +" = '"+json.get(archivesDictionary.getFieldName())+"'";
List<Object[]> list = entityManager.createNativeQuery(thissql).getResultList();
if(list.size()!=0){
for(Object[] objs:list){
if(json.get(archivesDictionary.getFieldName()).equals(objs[1])){
if(!dtoId.equals(objs[0])){
return archivesDictionary.getFieldName()+"不可重复";
}
}
}
}
}
}
if(StringUtils.isEmpty(dtoId)){
insertFiled +=archivesDictionary.getFieldName()+",";
insertValue += archivesDictionary.getIsDataType() == 1 ?
null == json.get(archivesDictionary.getFieldName()) ? null+"," : "'"+json.get(archivesDictionary.getFieldName())+"',"
: json.get(archivesDictionary.getFieldName()) +",";
String thisValue =
archivesDictionary.getIsDataType() == 1 ?
json.get(archivesDictionary.getFieldName()) == null ? null : "'"+json.get(archivesDictionary.getFieldName())+"'"
:json.get(archivesDictionary.getFieldName())+"";
updateValue += archivesDictionary.getFieldName() + "=" + thisValue +",";
}else {
String thisValue = archivesDictionary.getIsDataType() == 1 ?
json.get(archivesDictionary.getFieldName()) == null ? null : "'" + json.get(archivesDictionary.getFieldName()) + "'"
: json.get(archivesDictionary.getFieldName()) + "";
updateValue += archivesDictionary.getFieldName() + "=" + thisValue + ",";
}
}
insertFiled = insertFiled.length() != 0 ? insertFiled.substring(0,insertFiled.length()-1) : "";
insertValue = insertValue.length() != 0 ? insertValue.substring(0,insertValue.length()-1) : "";

7
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

@ -13,6 +13,7 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
value = "select field_name from archives_dictionary where category_id = ?1 and is_display is true order by is_displayorder asc")
List<String> findDisPlayField(String categoryId);
<<<<<<< HEAD
List<ArchivesDictionary> findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(String categoryId, boolean isInput);
@Query(value = "INSERT INTO yxk_storeroom.archives_dictionary(id,category_id,field_name,field_cn_name,dictionary_id,is_data_type,is_data_type_details,is_column_length,is_sequence,is_type,is_system VALUES ())", nativeQuery = true)
@ -21,5 +22,11 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
String isDefaultValue,Integer isDataType,
String isDataTypeDetails,String isColumnLength,
Integer isSequence,Integer isType,Integer isSystem);
=======
@Query(value = "from ArchivesDictionary where categoryId = ?1 and isDisplay = true order by isDisplayorder asc")
List<ArchivesDictionary> findDisPlay(String categoryId);
List<ArchivesDictionary> findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(String categoryId,boolean isInput);
>>>>>>> fa78bdc2fdf2d68321b9dcc6920bfce2ed1faa85
}
Loading…
Cancel
Save