diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java index 8e15478..9299ce7 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java @@ -98,6 +98,46 @@ public interface ArchivesSummaryRepository extends JpaRepository> externalGetb(String storeCode, String quCol, PageRequest page); + + @Query(nativeQuery = true, + countQuery = "SELECT count(1) FROM archives_summary asy " + + "INNER JOIN archives_case_cartoning acc on asy.archives_id = acc.parent_id " + + "INNER JOIN archives_case ace on acc.case_id = ace.id " + + "INNER JOIN device_archives_tag dat on ace.folder_location = dat.position " + + "INNER JOIN device_info di on dat.device_info_id = di.id " + + "INNER JOIN storeroom room on room.id = di.storeroom_id " + + "WHERE if(?1 = 0,(asy.maintitle like ?2 or asy.archive_no like ?2),(asy.maintitle = ?2 or asy.archive_no = ?2)) group by asy.archives_id ", + value = "SELECT DISTINCT asy.archives_id,di.storeroom_code as storeCode,asy.maintitle AS filename,asy.archive_no as fileno,asy.create_time as makedate,asy.category_id as filetype," + + "asy.barcode as filecode,asy.retention as keepday,ace.folder_location_details as position," + + "ace.folder_location as location,asy.create_by as editdate,ace.storage_type as storageType,asy.child as enclosure " + + "FROM archives_summary asy " + + "INNER JOIN archives_case_cartoning acc on asy.archives_id = acc.parent_id " + + "INNER JOIN archives_case ace on acc.case_id = ace.id " + + "INNER JOIN device_archives_tag dat on ace.folder_location = dat.position " + + "INNER JOIN device_info di on dat.device_info_id = di.id " + + "INNER JOIN storeroom room on room.id = di.storeroom_id " + + "WHERE if(?1 = 0,(asy.maintitle like ?2 or asy.archive_no like ?2),(asy.maintitle = ?2 or asy.archive_no = ?2))") + Page> externalGetc(Integer datatype, String data, PageRequest page); + @Query(nativeQuery = true, countQuery = "SELECT count(1) FROM archives_summary asy " + "INNER JOIN archives_case_cartoning acc on asy.archives_id = acc.parent_id " + diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java index 721c69c..c4f99af 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java @@ -466,7 +466,7 @@ public class ArchivesServiceImpl implements ArchivesService { entityManager.createNativeQuery("update "+archivesTypeP.getEnName()+" set child = (select count(1) from " +archivesType.getEnName()+" where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate(); entityManager.createNativeQuery("update archives_summary set child = (select count(1) from " - +archivesType.getEnName()+" where parent_id ='"+dto.getParentsId()+"') where archives_id = '"+dto.getParentsId()+"'").executeUpdate(); + +archivesType.getEnName()+" where parent_id ='"+dto.getParentsId()+"' and is_delete_time is not null) where archives_id = '"+dto.getParentsId()+"'").executeUpdate(); } } @@ -652,6 +652,8 @@ public class ArchivesServiceImpl implements ArchivesService { @Override @Transactional(rollbackFor = Exception.class) public Object delete(ArchivesDTO dto) { + + ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); List ids = dto.getIds(); @@ -700,10 +702,10 @@ public class ArchivesServiceImpl implements ArchivesService { ArchivesType archivesTypeP = optional.get(); String updateChild = "update " + archivesTypeP.getEnName() + " set child = (select count(1) from " + archivesType.getEnName() + " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id - + "')) where id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; + + "') and is_delete_time is not null) where id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; String updateChild2 = "update archives_summary set child = (select count(1) from " + archivesType.getEnName() + " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id - + "')) where archives_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; + + "') and is_delete_time is not null) where archives_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; entityManager.createNativeQuery(updateChild).executeUpdate(); entityManager.createNativeQuery(updateChild2).executeUpdate(); } @@ -821,10 +823,10 @@ public class ArchivesServiceImpl implements ArchivesService { ArchivesType archivesTypeP = optional.get(); String updateChild = "update "+archivesTypeP.getEnName()+" set child = (select count(1) from "+archivesType.getEnName() +" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id - +"')) where id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; + +"') and is_delete_time is not null) where id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; String updateChild2 = "update archives_summary set child = (select count(1) from "+archivesType.getEnName() +" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id - +"')) where archives_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; + +"') and is_delete_time is not null) where archives_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; entityManager.createNativeQuery(updateChild).executeUpdate(); entityManager.createNativeQuery(updateChild2).executeUpdate(); } @@ -1161,17 +1163,45 @@ public class ArchivesServiceImpl implements ArchivesService { public JSONObject externalGet(ArchivesExternalGetDTO dto) { JSONObject json = new JSONObject(); PageRequest page = PageRequest.of(dto.getPn()-1,dto.getPs()); - String quCol = dto.getQuNo() +"-"+dto.getColNo()+"-%"; + String storeCode = dto.getStoreCode(); + Integer quNo = dto.getQuNo(); + Integer colNo = dto.getColNo(); String data = dto.getData(); - if(dto.getDatatype() == 0){ - data = StringUtils.isEmpty(data) ? "%%": "%"+data+"%"; + Integer dataType = dto.getDatatype(); + + Page> pageMap = null; + + //有条件查询 + if(!StringUtils.isEmpty(storeCode) && quNo != null && dataType != null){ + data = data ==null ? "":data; + if(dataType==0) + data = "%"+data+"%"; + String quNos = quNo+"%"; + pageMap = archivesSummaryRepository.externalGet(storeCode,quNos,dataType,data,page); + //无条件(单列)查询 + }else if(!StringUtils.isEmpty(storeCode) && quNo != null && colNo!=null){ + String quNos = quNo+"-"+colNo+"%"; + pageMap = archivesSummaryRepository.externalGetb(storeCode,quNos,page); + //无条件(跨区)查询 + }else if(dataType != null){ + data = data ==null ? "":data; + if(dataType==0) + data = "%"+data+"%"; + pageMap = archivesSummaryRepository.externalGetc(dataType,data,page); + //无条件查询 + }else if(!StringUtils.isEmpty(storeCode) && quNo != null){ + String quNos = quNo+"%"; + pageMap = archivesSummaryRepository.externalGetb(storeCode,quNos,page); } - //分页查询 - Page> pageMap = archivesSummaryRepository.externalGet(dto.getStoreCode(),quCol,dto.getDatatype(),data,page); + json.put("protocal",1001); json.put("code",0); JSONArray jsonArray = new JSONArray(); - List> resultMap = pageMap.getContent(); + List> resultMap = new ArrayList<>(); + if(pageMap != null){ + resultMap = pageMap.getContent(); + } + for(Map map : resultMap){ JSONObject resultJson = new JSONObject(); resultJson.put("filename",map.get("filename")); diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java index 422693e..752d841 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java @@ -130,7 +130,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { dynamicTableService.DeleteTable(tableName1); archivesTypeRepository.deleteById(thisType.getId()); archivesDictionaryRepository.deleteByCategoryId(thisType.getId()); - if(archivesType.getIsType()==ArchivesTypeEnum.files.getCode() || archivesType.getIsType() == ArchivesTypeEnum.inChive.getCode()) + if(thisType.getIsType()==ArchivesTypeEnum.files.getCode() || thisType.getIsType() == ArchivesTypeEnum.inChive.getCode()) dynamicTableService.DeleteTable("file_"+tableName1); } } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java index 53ed2ac..c723a2b 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java @@ -143,6 +143,8 @@ public class DynamicTableImpl implements DynamicTableService { archivesDictionaryDTO.setIsSystem(j.getIsSystem()); archivesDictionaryDTO.setIsColumnType(j.getIsType()); archivesDictionaryDTO.setIsInput(true); + archivesDictionaryDTO.setIsInputClass(j.getIsDataType()==2?"number":"text"); + archivesDictionaryDTO.setEditLength(196); newList.add(archivesDictionaryDTO); } diff --git a/storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceSpecParamRepository.java b/storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceSpecParamRepository.java index 2e34532..aa9a205 100644 --- a/storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceSpecParamRepository.java +++ b/storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceSpecParamRepository.java @@ -4,7 +4,9 @@ import com.storeroom.modules.device.domain.DeviceInfo; import com.storeroom.modules.device.domain.DeviceSpecParam; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -43,4 +45,11 @@ public interface DeviceSpecParamRepository extends JpaRepository queryJob(JobQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(jobService.queryAll(criteria, pageable), HttpStatus.OK); + public ApiResponse queryJob(JobQueryCriteria criteria, Pageable pageable){ + return ApiResponse.success(PageUtil.toPage(jobService.queryAll(criteria, pageable))); } @Log("新增岗位") diff --git a/system/src/main/java/com/storeroom/modules/system/controller/RoleController.java b/system/src/main/java/com/storeroom/modules/system/controller/RoleController.java index 10b6037..aaaa350 100644 --- a/system/src/main/java/com/storeroom/modules/system/controller/RoleController.java +++ b/system/src/main/java/com/storeroom/modules/system/controller/RoleController.java @@ -77,13 +77,13 @@ public class RoleController { @ApiOperation("新增角色") @PostMapping @PreAuthorize("@ys.check('roles:add')") - public ResponseEntity createRole(@Validated @RequestBody Role resources){ + public ApiResponse createRole(@Validated @RequestBody Role resources){ if (resources.getId() != null) { throw new BaseException("A new "+ ENTITY_NAME +" cannot already have an ID"); } getLevels(resources.getLevel()); roleService.create(resources); - return new ResponseEntity<>(HttpStatus.CREATED); + return ApiResponse.success(HttpStatus.CREATED); } //@Log("修改角色") diff --git a/system/src/main/java/com/storeroom/modules/system/service/JobService.java b/system/src/main/java/com/storeroom/modules/system/service/JobService.java index f2f8733..efd37c3 100644 --- a/system/src/main/java/com/storeroom/modules/system/service/JobService.java +++ b/system/src/main/java/com/storeroom/modules/system/service/JobService.java @@ -3,6 +3,7 @@ package com.storeroom.modules.system.service; import com.storeroom.modules.system.domain.Job; import com.storeroom.modules.system.service.dto.JobDto; import com.storeroom.modules.system.service.dto.JobQueryCriteria; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; @@ -45,7 +46,7 @@ public interface JobService { * @param pageable 分页参数 * @return / */ - Map queryAll(JobQueryCriteria criteria, Pageable pageable); + Page queryAll(JobQueryCriteria criteria, Pageable pageable); /** * 查询全部数据 diff --git a/system/src/main/java/com/storeroom/modules/system/service/impl/JobServiceImpl.java b/system/src/main/java/com/storeroom/modules/system/service/impl/JobServiceImpl.java index 61c0126..075d9f7 100644 --- a/system/src/main/java/com/storeroom/modules/system/service/impl/JobServiceImpl.java +++ b/system/src/main/java/com/storeroom/modules/system/service/impl/JobServiceImpl.java @@ -33,9 +33,9 @@ public class JobServiceImpl implements JobService { private final UserRepository userRepository; @Override - public Map queryAll(JobQueryCriteria criteria, Pageable pageable) { + public Page queryAll(JobQueryCriteria criteria, Pageable pageable) { Page page = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(jobMapper::toDto).getContent(),page.getTotalElements()); + return page; } @Override