From 8d8ca052f408cceac9ba85dee690a11adf2b1659 Mon Sep 17 00:00:00 2001 From: xia Date: Thu, 1 Sep 2022 15:27:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AF=B9=E6=8E=A5=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=AF=86=E9=9B=86=E6=9E=B6=E6=8E=A5=E5=8F=A3=202.bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=203.=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CallExternalController.java | 65 ++++++++++++------- .../ExternalArchives1Controller.java | 30 +++++++++ .../ExternalArchivesController.java | 8 --- .../controller/StorageController.java | 56 ++++++++++------ .../archives/domain/vo/StorageDetailesVO.java | 1 + .../repository/ArchivesCaseRepository.java | 6 ++ .../repository/ArchivesSummaryRepository.java | 13 +++- .../repository/StorageLogRepository.java | 2 +- .../service/impl/ArchivesCaseServiceImpl.java | 5 +- .../service/impl/ArchivesServiceImpl.java | 53 +++++++++++++-- .../controller/ArchivesTypeController.java | 3 +- .../service/ArchivesTypeService.java | 2 +- .../service/impl/ArchivesTypeServiceImpl.java | 5 +- .../repository/StoreroomRepository.java | 4 ++ .../device/service/impl/StoreroomImpl.java | 2 +- .../controller/DisplayConfigController.java | 13 ++++ .../repository/DisplayConfigRepository.java | 3 + .../service/DisplayConfigService.java | 2 + .../service/impl/DisplayConfigImpl.java | 22 +++++++ 19 files changed, 227 insertions(+), 68 deletions(-) create mode 100644 archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchives1Controller.java diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/CallExternalController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/CallExternalController.java index 4193420..b9f3791 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/CallExternalController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/CallExternalController.java @@ -28,7 +28,7 @@ public class CallExternalController { @ApiOperation("打开架体具体某一列") @GetMapping("/openCol") - public ApiResponse openCol( + public Object openCol( String deviceId,Integer quNo, Integer colNo,Integer leNo, Integer divNo,Integer zyNo ){ String retust = ""; @@ -48,18 +48,20 @@ public class CallExternalController { try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/OpenCol", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/OpenCol", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/OpenCol", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("打开档案所在位置") @GetMapping("/findFiles") - public ApiResponse findFiles( + public Object findFiles( String deviceId,String fileName,String storeCode,Integer quNo, Integer colNo,Integer leNo, Integer divNo,Integer zyNo,String position,Integer type ){ String retust = ""; @@ -79,110 +81,121 @@ public class CallExternalController { try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/findFiles", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/findFiles", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/findFiles", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("获取密集架实时状态") @GetMapping("/reportStatus") - public ApiResponse reportStatus( + public Object reportStatus( String deviceId,String StoreCode,Integer quNo ){ String retust = ""; DeviceInfoDto device = deviceService.findById(deviceId); JSONObject json = new JSONObject(); - json.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); + json.put("StoreCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); json.put("QuNo",quNo); try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/ReportStatus", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/ReportStatus", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/ReportStatus", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("停止移动") @GetMapping("/stopMove") - public ApiResponse stopMove( + public Object stopMove( String deviceId,String StoreCode,Integer quNo ){ String retust = ""; DeviceInfoDto device = deviceService.findById(deviceId); JSONObject json = new JSONObject(); - json.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); + json.put("StoreCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); json.put("QuNo",quNo); try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/StopMove", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/StopMove", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/StopMove", "POST", map, null, json.toJSONString()); + retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("密集架通风") @GetMapping("/vent") - public ApiResponse vent( + public Object vent( String deviceId,String StoreCode,Integer quNo ){ String retust = ""; DeviceInfoDto device = deviceService.findById(deviceId); JSONObject json = new JSONObject(); - json.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); + json.put("StoreCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); json.put("QuNo",quNo); try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Vent", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Vent", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/Vent", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("密集架合架") @GetMapping("/reset") - public ApiResponse reset( + public Object reset( String deviceId,String StoreCode,Integer quNo ){ String retust = ""; DeviceInfoDto device = deviceService.findById(deviceId); JSONObject json = new JSONObject(); - json.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); + json.put("StoreCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); json.put("QuNo",quNo); try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Reset", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Reset", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/Reset", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } @ApiOperation("公告下发") @GetMapping("/getNotice") - public ApiResponse getNotice( + public Object getNotice( String deviceId,String notice ){ String retust = ""; @@ -193,13 +206,15 @@ public class CallExternalController { try { HashMap map = new HashMap<>(); map.put("Content-type", "application/json"); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/getNotice", +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/getNotice", +// "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/getNotice", "POST", map, null, json.toJSONString()); retust = EntityUtils.toString(response.getEntity()); }catch (Exception e){ retust = "连接失败"; } - return ApiResponse.success(retust); + return retust; } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchives1Controller.java b/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchives1Controller.java new file mode 100644 index 0000000..791e5b5 --- /dev/null +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchives1Controller.java @@ -0,0 +1,30 @@ +package com.storeroom.modules.archives.controller; + +import com.storeroom.annotaion.rest.AnonymousPostMapping; +import com.storeroom.modules.archives.service.ArchivesService; +import com.storeroom.modules.archives.service.dto.ArchivesExternalGetDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@Api(tags = "外部接口-档案") +@RequestMapping("/api/ArchiverDetails") +public class ExternalArchives1Controller { + + private final ArchivesService archivesService; + + @ApiOperation("7.移动列查询档案数据") + @AnonymousPostMapping("/MoveColumnGetFiles") + public Object externalMoveColumnGetFiles( + @Validated @RequestBody ArchivesExternalGetDTO dto + ){ + return archivesService.externalMoveColumnGetFiles(dto); + } + +} diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java index 9dfaebb..4ec9749 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java @@ -74,14 +74,6 @@ public class ExternalArchivesController { return archivesService.externalGetArchivesByZy(dto); } - @ApiOperation("7.移动列查询档案数据") - @AnonymousPostMapping("/MoveColumnGetFiles") - public Object externalMoveColumnGetFiles( - @Validated @RequestBody ArchivesExternalGetDTO dto - ){ - return archivesService.externalMoveColumnGetFiles(dto); - } - @ApiOperation("8.上传密集架报警信息") @AnonymousPostMapping("log") public Object deseCabinetAlarmLog(@RequestBody AlarmDeseCaBinetLog alarmDeseCaBinetLog) { diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java index 23838e1..efbf0c1 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java @@ -29,6 +29,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.data.domain.Pageable; import org.springframework.validation.annotation.Validated; @@ -142,10 +143,16 @@ public class StorageController { String[] shelf = thisCase.getFolderLocation().split("-"); JSONObject json = new JSONObject(); json.put("id",thisCase.getId()); - json.put("type",1); - json.put("title",thisCase.getCaseName()); - json.put("filebox",thisCase.getId()); + json.put("filecode",""); json.put("position",thisCase.getFolderLocation()); + json.put("title",thisCase.getCaseName()); + json.put("type",1); + json.put("starttime",""); +// json.put("filebox",thisCase.getId()); +// json.put("editdate",""); +// json.put("endtime",""); +// json.put("filetype",thisCase.getCaseType()); + JSONObject json1 = new JSONObject(); json1.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); json1.put("quNo",shelf[0]); @@ -154,9 +161,11 @@ public class StorageController { json1.put("divNo",shelf[3]); json1.put("zyNo",shelf[4]); json.put("positionKey",json1); - json.put("filetype",thisCase.getCaseType()); -// String reselt = HttpUtil.wlwHttpURLConnection(url,json,null,null,null); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Task", "POST", map, null, json.toJSONString()); + System.out.println(json.toJSONString()); +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Task", "POST", map, null, json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/Task", "POST", map, null, "{\"datas\":["+json.toJSONString()+"]}"); + String retust = EntityUtils.toString(response.getEntity()); + System.out.println(retust); }else{ } @@ -201,21 +210,30 @@ public class StorageController { // String url = "http://"+device.getDeviceIp()+":"+device.getDevicePort()+"IntelligentCabinetAPIServer/Task"; JSONObject json = new JSONObject(); json.put("id",caseId); - json.put("type",2); - json.put("title",thisCase.getCaseName()); - json.put("filebox",caseId); + json.put("filecode",""); json.put("position",thisCase.getFolderLocation()); - JSONObject json1 = new JSONObject(); - json1.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); - json1.put("quNo",shelf[0]); - json1.put("colNo",shelf[1]); - json1.put("leNo",shelf[2]); - json1.put("divNo",shelf[3]); - json1.put("zyNo",shelf[4]); - json.put("positionKey",json1); - json.put("filetype",thisCase.getCaseType()); + json.put("title",thisCase.getCaseName()); + json.put("type",2); + json.put("starttime",""); +// json.put("filebox",thisCase.getId()); +// json.put("editdate",""); +// json.put("endtime",""); +// json.put("filetype",thisCase.getCaseType()); + + JSONObject positionKey = new JSONObject(); + positionKey.put("storeCode", StringUtils.isEmpty(device.getStoreroomCode()) ? "12345678" : device.getStoreroomCode()); + positionKey.put("quNo",shelf[0]); + positionKey.put("colNo",shelf[1]); + positionKey.put("leNo",shelf[2]); + positionKey.put("divNo",shelf[3]); + positionKey.put("zyNo",shelf[4]); + json.put("positionKey",positionKey); // String reselt = HttpUtil.wlwHttpURLConnection(url,json,null,null,null); - HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Task", "POST", map, null, json.toJSONString()); +// HttpResponse response = HttpUtils.doPost("http://"+device.getDeviceIp()+":"+device.getDevicePort(), "/IntelligentCabinetAPIServer/Task", "POST", map, null, json.toJSONString()); + System.out.println(json.toJSONString()); + HttpResponse response = HttpUtils.doPost("https://y40495935z.oicp.vip", "/IntelligentCabinetAPIServer/Task", "POST", map, null, "{\"datas\":["+json.toJSONString()+"]}"); + String retust = EntityUtils.toString(response.getEntity()); + System.out.println(retust); }else{ } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/vo/StorageDetailesVO.java b/archives/src/main/java/com/storeroom/modules/archives/domain/vo/StorageDetailesVO.java index 6aa7600..3f88b56 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/vo/StorageDetailesVO.java +++ b/archives/src/main/java/com/storeroom/modules/archives/domain/vo/StorageDetailesVO.java @@ -14,5 +14,6 @@ public class StorageDetailesVO { private ArchivesCase archivesCase; private List archivesSummaries; + private List archivesBasics; } diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java index 1c7c11f..bf1fdf6 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java @@ -95,6 +95,12 @@ public interface ArchivesCaseRepository extends JpaRepository initCaseByArchives(String archivesId); + @Query(nativeQuery = true,value = "select count(1) from archives_case_cartoning where parent_id in ?1") + Integer findArchivesBoxedCount(List archivesIds); + + @Query(nativeQuery = true,value = "select count(1) from archives_case_cartoning where archives_id in ?1") + Integer findBottomBoxedCount(List archivesIds); + @Query(nativeQuery = true, value = "select ac.* from archives_case ac inner join archives_case_cartoning acc on ac.id=acc.case_id where acc.parent_id IN " + "(select in1.parent_id from archives_case_cartoning in1 where in1.case_id = ?1) group by ac.id ") 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 4a5f88d..8e15478 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 @@ -84,11 +84,18 @@ public interface ArchivesSummaryRepository extends JpaRepository findByCaseIds(String caseId); + @Query(nativeQuery = true, + value = "select * from archives_summary asy " + + "inner join archives_case_cartoning acc on asy.archives_id = acc.archives_id " + + "where acc.case_id = ?1 ") + List findBasicsByCaseIds(String caseId); + ArchivesSummary findByTagNo(String tid); @Query(nativeQuery = true, @@ -101,7 +108,7 @@ public interface ArchivesSummaryRepository extends JpaRepository value = "select * from storage_log where if(?1 is null,1=1,storage_type = ?1) " + "and if(?2 is null,1=1,case_name like ?2) " + "and if(?3 is null,1=1,tid like ?3) " + - "and if(?4 is null,1=1,barcode like ?4) ") + "and if(?4 is null,1=1,barcode like ?4) order by create_time desc") Page initStorageLogList(Integer storageType, String caseName, String tid, String barcode, Pageable page); @Query(nativeQuery = true, diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java index db7fb3c..0394e4a 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java @@ -770,6 +770,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { StorageDetailesVO vo = new StorageDetailesVO(); vo.setArchivesCase(caseRepository.findCaseById(caseId)); vo.setArchivesSummaries(archivesSummaryRepository.findByCaseIds(caseId)); + vo.setArchivesBasics(archivesSummaryRepository.findBasicsByCaseIds(caseId)); return vo; } @@ -807,7 +808,9 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { //查询档案和关联的档案 archivesSummaryRepository.cleanLocationByCaseId("%"+archivesCase.getId()+"%"); } - caseRepository.saveAndFlush(archivesCase); + + archivesCase = caseRepository.saveAndFlush(archivesCase); + this.recordStorage(archivesCase,type == 1 ? 1:2); return null; } 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 82d9d6f..721c69c 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 @@ -2,9 +2,11 @@ package com.storeroom.modules.archives.service.impl; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; +import com.storeroom.exception.BaseException; import com.storeroom.modules.archives.domain.ArchivesSearchLog; import com.storeroom.modules.archives.domain.ArchivesSummary; import com.storeroom.modules.archives.domain.vo.ArchivesDetailsVO; +import com.storeroom.modules.archives.repository.ArchivesCaseRepository; import com.storeroom.modules.archives.repository.ArchivesSearchLogRepository; import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; import com.storeroom.modules.archives.service.ArchivesService; @@ -35,6 +37,7 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import java.io.File; import java.sql.Timestamp; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -49,6 +52,7 @@ public class ArchivesServiceImpl implements ArchivesService { private final ArchivesDictionaryRepository archivesDictionaryRepository; private final ArchivesTypeService archivesTypeService; private final ArchivesSearchLogRepository archivesSearchLogRepository; + private final ArchivesCaseRepository caseRepository; @Value("${file.windows.path}") // @Value("${file.linux.path}") @@ -151,8 +155,13 @@ public class ArchivesServiceImpl implements ArchivesService { List countList = entityManager.createNativeQuery("select count(1) from (select "+queryField+appendQuery+isStorageQuery+isBorrowQuery+" from "+queryTable+additional+queryparentsId+") t "+queryTypeadd).getResultList(); Object count = countList.get(0); + Integer pageNumber = page.getPageNumber(); + Integer pageSize = page.getPageSize(); + String appendLimit = " "; + if(pageSize!=0 && null!=pageSize) + appendLimit = " limit "+pageNumber*pageSize+","+pageSize; List list = entityManager.createNativeQuery("select * from (select "+queryField+appendQuery+isStorageQuery+isBorrowQuery+" from "+queryTable+additional+queryparentsId+quertOrder - +") t "+queryTypeadd+" limit "+page.getPageNumber()*page.getPageSize()+","+page.getPageSize()).getResultList(); + +") t "+queryTypeadd+appendLimit).getResultList(); List returnlist = new ArrayList<>(); for(Object[] objs:list){ Map map = new HashMap(); @@ -645,6 +654,34 @@ public class ArchivesServiceImpl implements ArchivesService { public Object delete(ArchivesDTO dto) { ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); List ids = dto.getIds(); + + //判断是否装盒 + //当删除为项目级别 + if(archivesType.getIsType() == ArchivesTypeEnum.project.getCode()){ + //获取旗下案卷门类 + ArchivesType archivesType_3 = archivesTypeRepository.findByPid(archivesType.getId()); + if(null != archivesType_3){ + String getArchivesIdsSql = "select id from "+archivesType_3.getEnName() + +" where parent_id in ('"+ids.stream().map(String::valueOf).collect(Collectors.joining("','"))+"')"; + List list = entityManager.createNativeQuery(getArchivesIdsSql).getResultList(); + if(null != list && list.size() != 0){ + Integer count = caseRepository.findArchivesBoxedCount(list); + if(count!=0) + throw new BaseException("该项目下有档案已装盒,不可删除"); + } + } + //当删除为案卷级别 + }else if(archivesType.getIsType() == ArchivesTypeEnum.archives.getCode()){ + Integer count = caseRepository.findArchivesBoxedCount(ids); + if(count!=0) + throw new BaseException("删除档案已装盒,不可删除"); + //当删除为卷内/文件级别 + }else if(archivesType.getIsType() == ArchivesTypeEnum.inChive.getCode() || archivesType.getIsType() == ArchivesTypeEnum.files.getCode()){ + Integer count = caseRepository.findBottomBoxedCount(ids); + if(count!=0) + throw new BaseException("删除档案已装盒,不可删除"); + } + String queryTable = archivesType.getEnName(); String delTime = sdf.format(new Date()); String sql = "update " + queryTable + " set is_delete_time = '" +delTime+"',is_delete_man='"+dto.getDelMan() @@ -676,14 +713,14 @@ public class ArchivesServiceImpl implements ArchivesService { //获取档案表名 ArchivesType archivesType_3 = archivesTypeRepository.findByPid(archivesType.getId()); //获取该项目下所有案卷id - String query3sql = "select id from "+archivesType.getEnName()+" where parent_id in ('"+ids.stream().map(String::valueOf).collect(Collectors.joining("','"))+"')"; + String query3sql = "select id from "+archivesType_3.getEnName()+" where parent_id in ('"+ids.stream().map(String::valueOf).collect(Collectors.joining("','"))+"')"; List list3 = entityManager.createNativeQuery(query3sql).getResultList(); if(null != list3 && list3.size()!=0){ //删除案卷 - String update3sql = "update " + archivesType.getEnName() + " set is_delete_time = '" +delTime+"',is_delete_man='"+dto.getDelMan() + String update3sql = "update " + archivesType_3.getEnName() + " set is_delete_time = '" +delTime+"',is_delete_man='"+dto.getDelMan() +"' where id in ('"+list3.stream().map(String::valueOf).collect(Collectors.joining("','"))+"')"; //获取卷内表名 - String enName_4 = archivesTypeRepository.findEnNameByPid(archivesType.getId()); + String enName_4 = archivesTypeRepository.findEnNameByPid(archivesType_3.getId()); if(null == enName_4) return result; String query4sql = "select id from "+enName_4+" where parent_id in ('"+list3.stream().map(String::valueOf).collect(Collectors.joining("','"))+"')"; @@ -1139,7 +1176,13 @@ public class ArchivesServiceImpl implements ArchivesService { JSONObject resultJson = new JSONObject(); resultJson.put("filename",map.get("filename")); resultJson.put("fileno",map.get("fileno")); - resultJson.put("makedate",map.get("makedate")); + SimpleDateFormat datesdf = new SimpleDateFormat("YYYY/MM/dd HH:mm:ss"); + String makedate = map.get("makedate") == null?"":map.get("makedate")+""; + try { + resultJson.put("makedate",makedate == null?makedate:datesdf.format(sdf.parse(makedate))); + } catch (ParseException e) { + resultJson.put("makedate",null); + } resultJson.put("filetype",map.get("filetype")); resultJson.put("filecode",map.get("filecode")); resultJson.put("keepday",map.get("keepday")); diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java b/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java index acb34df..c92c669 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java @@ -62,8 +62,7 @@ public class ArchivesTypeController { if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) { throw new BaseException("名称不能为空"); } - archivesTypeService.create(archivesTypeDTO); - return ApiResponse.success("保存成功"); + return ApiResponse.success(archivesTypeService.create(archivesTypeDTO)); } @ApiOperation("修改门类") diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java index 53f3a55..6e8113f 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java @@ -17,7 +17,7 @@ public interface ArchivesTypeService { * 创建门类 * @param archivesTypeDTO */ - void create(ArchivesTypeDTO archivesTypeDTO); + ArchivesType create(ArchivesTypeDTO archivesTypeDTO); /** 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 20c9210..422693e 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 @@ -38,7 +38,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { @Override @Transactional(rollbackFor = Exception.class) - public void create(ArchivesTypeDTO archivesTypeDTO) { + public ArchivesType create(ArchivesTypeDTO archivesTypeDTO) { //#生成表名称 String tableName = "tb_"; ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO); @@ -50,12 +50,13 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { } archivesType.setId(NanoIdUtils.randomNanoId()); archivesType.setEnName(tableName); - archivesTypeRepository.save(archivesType); + archivesType = archivesTypeRepository.save(archivesType); dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); } else { throw new BaseException("门类名称不能重复"); } + return archivesType; } diff --git a/storeroom/src/main/java/com/storeroom/modules/device/repository/StoreroomRepository.java b/storeroom/src/main/java/com/storeroom/modules/device/repository/StoreroomRepository.java index 6faedf3..6c97a67 100644 --- a/storeroom/src/main/java/com/storeroom/modules/device/repository/StoreroomRepository.java +++ b/storeroom/src/main/java/com/storeroom/modules/device/repository/StoreroomRepository.java @@ -4,6 +4,7 @@ package com.storeroom.modules.device.repository; import com.storeroom.modules.device.domain.Storeroom; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; import java.util.List; @@ -17,4 +18,7 @@ public interface StoreroomRepository extends JpaRepository, Jp */ List findByName(String name); + @Query("from Storeroom order by sort asc") + List findAllDesc(); + } diff --git a/storeroom/src/main/java/com/storeroom/modules/device/service/impl/StoreroomImpl.java b/storeroom/src/main/java/com/storeroom/modules/device/service/impl/StoreroomImpl.java index 4827d00..789e66a 100644 --- a/storeroom/src/main/java/com/storeroom/modules/device/service/impl/StoreroomImpl.java +++ b/storeroom/src/main/java/com/storeroom/modules/device/service/impl/StoreroomImpl.java @@ -71,7 +71,7 @@ public class StoreroomImpl implements StoreroomService { @Override public List buildTree() { - List list = storeroomRepository.findAll(); + List list = storeroomRepository.findAllDesc(); return list.stream().filter(item -> item.getPid().equals("0")) .map(item -> item.setChildren(getChildren(item.getId(), list))) diff --git a/storeroom/src/main/java/com/storeroom/modules/storeroom3d/controller/DisplayConfigController.java b/storeroom/src/main/java/com/storeroom/modules/storeroom3d/controller/DisplayConfigController.java index d056664..6091880 100644 --- a/storeroom/src/main/java/com/storeroom/modules/storeroom3d/controller/DisplayConfigController.java +++ b/storeroom/src/main/java/com/storeroom/modules/storeroom3d/controller/DisplayConfigController.java @@ -37,6 +37,7 @@ public class DisplayConfigController { @AnonymousPostMapping("bind") @ApiOperation("绑定参数") public ApiResponse bind(@RequestBody DisplayConfig displayConfig) { + System.out.println(displayConfig.toString()); if (StringUtils.isEmpty(displayConfig.getId())) { throw new BaseException("id不为空"); } @@ -44,6 +45,18 @@ public class DisplayConfigController { return ApiResponse.success(ResponseStatus.SUCCESS); } + @AnonymousPostMapping("unbind") + @ApiOperation("解绑") + public ApiResponse unbind(@RequestBody DisplayConfig displayConfig) { + if (StringUtils.isEmpty(displayConfig.getId())) { + throw new BaseException("id不为空"); + } + displayConfigService.unbind(displayConfig.getId()); + return ApiResponse.success(ResponseStatus.SUCCESS); + } + + + @AnonymousGetMapping("list") @ApiOperation("获取列表") public ApiResponse queryList(@RequestParam String storeroomId) { diff --git a/storeroom/src/main/java/com/storeroom/modules/storeroom3d/repository/DisplayConfigRepository.java b/storeroom/src/main/java/com/storeroom/modules/storeroom3d/repository/DisplayConfigRepository.java index b43b666..ba222c9 100644 --- a/storeroom/src/main/java/com/storeroom/modules/storeroom3d/repository/DisplayConfigRepository.java +++ b/storeroom/src/main/java/com/storeroom/modules/storeroom3d/repository/DisplayConfigRepository.java @@ -29,4 +29,7 @@ public interface DisplayConfigRepository extends JpaRepository { @@ -41,6 +51,18 @@ public class DisplayConfigImpl implements DisplayConfigService { displayConfigRepository.save(displayConfig); } + @Override + @Transactional(rollbackFor = Exception.class) + public void unbind(String id) { + DisplayConfig config = displayConfigRepository.findConfigById(id); + if(null != config){ + config.setBindState(false); + config.setDeviceInfo(null); + config.setDeviceSpecParams(null); + displayConfigRepository.saveAndFlush(config); + } + } + @Override public List queryDevceInfo(String storeroomId) { Storeroom storeroom = storeroomRepository.findById(storeroomId).orElseGet(Storeroom::new);