Browse Source

修改bug优化功能

master
xia 2 years ago
parent
commit
875a85127b
  1. 40
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
  2. 52
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  3. 2
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java
  4. 2
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java
  5. 9
      storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceSpecParamRepository.java
  6. 16
      storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceSpecParamImpl.java
  7. 1
      storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/impl/DisplayConfigImpl.java
  8. 5
      system/src/main/java/com/storeroom/modules/system/controller/JobController.java
  9. 4
      system/src/main/java/com/storeroom/modules/system/controller/RoleController.java
  10. 3
      system/src/main/java/com/storeroom/modules/system/service/JobService.java
  11. 4
      system/src/main/java/com/storeroom/modules/system/service/impl/JobServiceImpl.java

40
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java

@ -98,6 +98,46 @@ public interface ArchivesSummaryRepository extends JpaRepository<ArchivesSummary
ArchivesSummary findByTagNo(String tid); ArchivesSummary findByTagNo(String tid);
@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 di.storeroom_code = ?1 and ace.folder_location like ?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 di.storeroom_code = ?1 and ace.folder_location like ?2 ")
Page<Map<String,Object>> 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<Map<String,Object>> externalGetc(Integer datatype, String data, PageRequest page);
@Query(nativeQuery = true, @Query(nativeQuery = true,
countQuery = "SELECT count(1) FROM archives_summary asy " + 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_cartoning acc on asy.archives_id = acc.parent_id " +

52
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 " entityManager.createNativeQuery("update "+archivesTypeP.getEnName()+" set child = (select count(1) from "
+archivesType.getEnName()+" where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate(); +archivesType.getEnName()+" where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate();
entityManager.createNativeQuery("update archives_summary set child = (select count(1) from " 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object delete(ArchivesDTO dto) { public Object delete(ArchivesDTO dto) {
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get();
List<String> ids = dto.getIds(); List<String> ids = dto.getIds();
@ -700,10 +702,10 @@ public class ArchivesServiceImpl implements ArchivesService {
ArchivesType archivesTypeP = optional.get(); ArchivesType archivesTypeP = optional.get();
String updateChild = "update " + archivesTypeP.getEnName() + " set child = (select count(1) from " + archivesType.getEnName() 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 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() 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 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(updateChild).executeUpdate();
entityManager.createNativeQuery(updateChild2).executeUpdate(); entityManager.createNativeQuery(updateChild2).executeUpdate();
} }
@ -821,10 +823,10 @@ public class ArchivesServiceImpl implements ArchivesService {
ArchivesType archivesTypeP = optional.get(); ArchivesType archivesTypeP = optional.get();
String updateChild = "update "+archivesTypeP.getEnName()+" set child = (select count(1) from "+archivesType.getEnName() 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 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() 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 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(updateChild).executeUpdate();
entityManager.createNativeQuery(updateChild2).executeUpdate(); entityManager.createNativeQuery(updateChild2).executeUpdate();
} }
@ -1161,17 +1163,45 @@ public class ArchivesServiceImpl implements ArchivesService {
public JSONObject externalGet(ArchivesExternalGetDTO dto) { public JSONObject externalGet(ArchivesExternalGetDTO dto) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
PageRequest page = PageRequest.of(dto.getPn()-1,dto.getPs()); 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(); String data = dto.getData();
if(dto.getDatatype() == 0){
data = StringUtils.isEmpty(data) ? "%%": "%"+data+"%";
Integer dataType = dto.getDatatype();
Page<Map<String,Object>> 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<Map<String,Object>> pageMap = archivesSummaryRepository.externalGet(dto.getStoreCode(),quCol,dto.getDatatype(),data,page);
json.put("protocal",1001); json.put("protocal",1001);
json.put("code",0); json.put("code",0);
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
List<Map<String,Object>> resultMap = pageMap.getContent();
List<Map<String,Object>> resultMap = new ArrayList<>();
if(pageMap != null){
resultMap = pageMap.getContent();
}
for(Map<String,Object> map : resultMap){ for(Map<String,Object> map : resultMap){
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
resultJson.put("filename",map.get("filename")); resultJson.put("filename",map.get("filename"));

2
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -130,7 +130,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
dynamicTableService.DeleteTable(tableName1); dynamicTableService.DeleteTable(tableName1);
archivesTypeRepository.deleteById(thisType.getId()); archivesTypeRepository.deleteById(thisType.getId());
archivesDictionaryRepository.deleteByCategoryId(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); dynamicTableService.DeleteTable("file_"+tableName1);
} }
} }

2
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.setIsSystem(j.getIsSystem());
archivesDictionaryDTO.setIsColumnType(j.getIsType()); archivesDictionaryDTO.setIsColumnType(j.getIsType());
archivesDictionaryDTO.setIsInput(true); archivesDictionaryDTO.setIsInput(true);
archivesDictionaryDTO.setIsInputClass(j.getIsDataType()==2?"number":"text");
archivesDictionaryDTO.setEditLength(196);
newList.add(archivesDictionaryDTO); newList.add(archivesDictionaryDTO);
} }

9
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 com.storeroom.modules.device.domain.DeviceSpecParam;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -43,4 +45,11 @@ public interface DeviceSpecParamRepository extends JpaRepository<DeviceSpecParam
* @return * @return
*/ */
DeviceSpecParam findByDisplayConfigId(String id); DeviceSpecParam findByDisplayConfigId(String id);
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(nativeQuery = true,value = "delete from device_spec_param where display_config_id = ?1")
void deleteByConfigId(String configId);
DeviceSpecParam findFirstByDeviceInfoId(String deviceId);
} }

16
storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceSpecParamImpl.java

@ -73,11 +73,17 @@ public class DeviceSpecParamImpl implements DeviceSpecParamService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void bindMac(DeviceMacDto deviceMacDto) { public void bindMac(DeviceMacDto deviceMacDto) {
DeviceInfo deviceInfo = deviceInfoRepository.findById(deviceMacDto.getDeviceId()).orElseGet(DeviceInfo::new); DeviceInfo deviceInfo = deviceInfoRepository.findById(deviceMacDto.getDeviceId()).orElseGet(DeviceInfo::new);
DeviceSpecParam deviceSpecParam = new DeviceSpecParam();
deviceSpecParam.setId(NanoIdUtils.randomNanoId());
deviceSpecParam.setMacAddress(deviceMacDto.getMacAddress());
deviceSpecParam.setDeviceInfoId(deviceInfo.getId());
deviceSpecParamRepository.save(deviceSpecParam);
String mac = deviceMacDto.getMacAddress();
String deviceId = deviceInfo.getDeviceId();
DeviceSpecParam deviceSpecParam = deviceSpecParamRepository.findFirstByDeviceInfoId(deviceId);
if(null == deviceSpecParam){
deviceSpecParam.setId(NanoIdUtils.randomNanoId());
deviceSpecParam.setDeviceInfoId(deviceId);
deviceSpecParam.setMacAddress(mac);
deviceSpecParam = deviceSpecParamRepository.save(deviceSpecParam);
}
deviceInfo.setDeviceSpecParamId(deviceSpecParam);
deviceInfoRepository.saveAndFlush(deviceInfo);
} }
@Override @Override

1
storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/impl/DisplayConfigImpl.java

@ -60,6 +60,7 @@ public class DisplayConfigImpl implements DisplayConfigService {
config.setDeviceInfo(null); config.setDeviceInfo(null);
config.setDeviceSpecParams(null); config.setDeviceSpecParams(null);
displayConfigRepository.saveAndFlush(config); displayConfigRepository.saveAndFlush(config);
deviceSpecParamRepository.deleteByConfigId(config.getId());
} }
} }

5
system/src/main/java/com/storeroom/modules/system/controller/JobController.java

@ -7,6 +7,7 @@ import com.storeroom.modules.system.domain.Job;
import com.storeroom.modules.system.service.JobService; import com.storeroom.modules.system.service.JobService;
import com.storeroom.modules.system.service.dto.JobQueryCriteria; import com.storeroom.modules.system.service.dto.JobQueryCriteria;
import com.storeroom.utils.ApiResponse; import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.PageUtil;
import com.storeroom.utils.enums.ResponseStatus; import com.storeroom.utils.enums.ResponseStatus;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -39,8 +40,8 @@ public class JobController {
@ApiOperation("查询岗位") @ApiOperation("查询岗位")
@GetMapping @GetMapping
public ResponseEntity<Object> queryJob(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(jobService.queryAll(criteria, pageable), HttpStatus.OK);
public ApiResponse<Object> queryJob(JobQueryCriteria criteria, Pageable pageable){
return ApiResponse.success(PageUtil.toPage(jobService.queryAll(criteria, pageable)));
} }
@Log("新增岗位") @Log("新增岗位")

4
system/src/main/java/com/storeroom/modules/system/controller/RoleController.java

@ -77,13 +77,13 @@ public class RoleController {
@ApiOperation("新增角色") @ApiOperation("新增角色")
@PostMapping @PostMapping
@PreAuthorize("@ys.check('roles:add')") @PreAuthorize("@ys.check('roles:add')")
public ResponseEntity<Object> createRole(@Validated @RequestBody Role resources){
public ApiResponse<Object> createRole(@Validated @RequestBody Role resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BaseException("A new "+ ENTITY_NAME +" cannot already have an ID"); throw new BaseException("A new "+ ENTITY_NAME +" cannot already have an ID");
} }
getLevels(resources.getLevel()); getLevels(resources.getLevel());
roleService.create(resources); roleService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
return ApiResponse.success(HttpStatus.CREATED);
} }
//@Log("修改角色") //@Log("修改角色")

3
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.domain.Job;
import com.storeroom.modules.system.service.dto.JobDto; import com.storeroom.modules.system.service.dto.JobDto;
import com.storeroom.modules.system.service.dto.JobQueryCriteria; import com.storeroom.modules.system.service.dto.JobQueryCriteria;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -45,7 +46,7 @@ public interface JobService {
* @param pageable 分页参数 * @param pageable 分页参数
* @return / * @return /
*/ */
Map<String,Object> queryAll(JobQueryCriteria criteria, Pageable pageable);
Page<Job> queryAll(JobQueryCriteria criteria, Pageable pageable);
/** /**
* 查询全部数据 * 查询全部数据

4
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; private final UserRepository userRepository;
@Override @Override
public Map<String,Object> queryAll(JobQueryCriteria criteria, Pageable pageable) {
public Page<Job> queryAll(JobQueryCriteria criteria, Pageable pageable) {
Page<Job> page = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<Job> 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 @Override

Loading…
Cancel
Save