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 40a0a2f..9dfaebb 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 @@ -1,9 +1,13 @@ package com.storeroom.modules.archives.controller; +import com.alibaba.fastjson.JSONObject; import com.storeroom.annotaion.rest.AnonymousPostMapping; +import com.storeroom.modules.archives.service.ArchivesCaseService; import com.storeroom.modules.archives.service.ArchivesService; import com.storeroom.modules.archives.service.dto.ArchivesDTO; import com.storeroom.modules.archives.service.dto.ArchivesExternalGetDTO; +import com.storeroom.modules.device.domain.AlarmDeseCaBinetLog; +import com.storeroom.modules.device.service.DeviceService; import com.storeroom.utils.ApiResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -24,6 +28,8 @@ import java.util.Map; public class ExternalArchivesController { private final ArchivesService archivesService; + private final ArchivesCaseService caseService; + private final DeviceService deviceService; @ApiOperation("1.从系统服务获取档案信息") @AnonymousPostMapping("/get") @@ -33,6 +39,60 @@ public class ExternalArchivesController { return archivesService.externalGet(dto); } + @ApiOperation("2.获取密集架当前区在库不在库数量") + @AnonymousPostMapping("/getArchivesCount") + public Object externalGetArchivesCount( + @Validated @RequestBody ArchivesExternalGetDTO dto + ){ + return archivesService.externalGetArchivesCount(dto); + } + + @ApiOperation("3.获取密集架当前左边右边的总数量") + @AnonymousPostMapping("/getColumnInfo") + public Object externalGetColumnInfo( + @Validated @RequestBody ArchivesExternalGetDTO dto + ){ + return archivesService.externalGetColumnInfo(dto); + } + + @ApiOperation("5.任务管理页面任务的使用") + @AnonymousPostMapping("/externalCallback") + public ApiResponse externalCallback( + @Validated @RequestBody String json + ){ + JSONObject jsonObject = JSONObject.parseObject(json); + String caseId = jsonObject.get("id") +""; + caseService.externalCallback(caseId); + return ApiResponse.success("{\"success\":\"0\"}"); + } + @ApiOperation("6.移动列网格列表页面进入目录详情页面") + @AnonymousPostMapping("/GetArchivesByZy") + public Object externalGetArchivesByZy( + @Validated @RequestBody ArchivesExternalGetDTO dto + ){ + 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) { + + deviceService.upLoadAlarmLog(alarmDeseCaBinetLog); + Map objectMap = new HashMap<>(); + objectMap.put("code", ""); + objectMap.put("errorinfo", ""); + objectMap.put("protocal", 1004); + objectMap.put("result", ""); + return objectMap; + } } 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 9598f8e..a4fc08a 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 @@ -293,8 +293,7 @@ public class StorageController { ){ JSONObject jsonObject = JSONObject.parseObject(json); String caseId = jsonObject.get("id") +""; - String storageType = jsonObject.get("type")+""; - return ApiResponse.success(caseService.externalCallback(caseId,storageType)); + return ApiResponse.success(caseService.externalCallback(caseId)); } @ApiOperation("出入库记录") 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 ec2f963..563486f 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 @@ -86,8 +86,8 @@ public interface ArchivesSummaryRepository extends JpaRepository> externalGet(String storeCode, String quCol, Integer datatype, String data, PageRequest page); + @Query(nativeQuery = true, + value = "SELECT asy.archives_id 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 " + + "and ace.storage_type !=0 and ace.storage_type !=1 " + + "and ace.folder_location is not null group by asy.archives_id;") + List getInStore(String storeCode,String quNo); + + @Query(nativeQuery = true, + value = "SELECT ba.archives_id FROM borrow_archives ba " + + "INNER JOIN archives_summary asy on ba.archives_id = asy.archives_id " + + "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 ba.borrow_type = 3 and di.storeroom_code = ?1 and ace.folder_location like ?2 " + + "and ace.storage_type !=0 and ace.storage_type !=1 " + + "and ace.folder_location is not null group by ba.archives_id;") + List getIsBorrow(String storeCode,String quNo); + + @Query(nativeQuery = true, + value = "select c.leNo,c.divNo,count(c.divNo) as archivesStorageNum,sum(c.isBorrow) as archivesBorrowNum " + + "from (SELECT t.archives_id,t.position,t.leNo,t.divNo," + + "(select count(1) from borrow_archives ba where ba.borrow_type < 3 and archives_id = t.archives_id) as isBorrow FROM (" + + "SELECT DISTINCT asy.archives_id,dat.position,dat.part_No as leNo,dat.row_No as divNo " + + "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 LENGTH(dat.position)-LENGTH(REPLACE(dat.position,'-','')) = 4 " + + "and di.storeroom_code = ?1 " + + "and dat.position like ?2 ) t ) c " + + "group by c.leNo,c.divNo order by c.leNo asc,c.divNo asc") + List> externalGetColumnInfoResult(String storeCode,String quColZy); + + @Modifying + @Transactional(rollbackFor = Exception.class) + @Query(nativeQuery = true,value = "update archives_summary set folder_location = null,folder_location_details=null where case_no like ?1") + void cleanLocationByCaseId(String caseId); + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java index ef04d42..31c968c 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java @@ -78,5 +78,5 @@ public interface ArchivesCaseService { //根据id集合获取出入库列表 List initStorageLogList(List logs); //第三方回调 - Integer externalCallback(String caseId,String storageType); + Integer externalCallback(String caseId); } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java index 9acd1e0..17ecd88 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java @@ -62,4 +62,12 @@ public interface ArchivesService { //第三方接口 //从系统服务获取档案信息 JSONObject externalGet(ArchivesExternalGetDTO dto); + //获取密集架当前区在库不在库数量 + JSONObject externalGetArchivesCount(ArchivesExternalGetDTO dto); + //获取密集架当前左边右边的总数量 + JSONObject externalGetColumnInfo(ArchivesExternalGetDTO dto); + //移动列网格列表页面进入目录详情页面 + JSONObject externalGetArchivesByZy(ArchivesExternalGetDTO dto); + //移动列查询档案数据 + JSONObject externalMoveColumnGetFiles(ArchivesExternalGetDTO dto); } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java b/archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java index 79f3a13..62fecf2 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java @@ -18,6 +18,12 @@ public class ArchivesExternalGetDTO { private Integer quNo; @ApiModelProperty("列编号") private Integer colNo; + @ApiModelProperty("节编号") + private Integer leNo; + @ApiModelProperty("层编号") + private Integer divNo; + @ApiModelProperty("0 左边右边数量都返回 1 返回左边数量 2 返回右边数量") + private Integer zyNo; @ApiModelProperty("模糊查询档案(名称、档案号)") private String data; @ApiModelProperty("当模糊查询时赋值为 0") 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 1a4e296..0813074 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 @@ -460,6 +460,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } @Override + @Transactional public List collect(boolean isCallback, List dtos) { List cases = new ArrayList<>(); Set archices = new HashSet<>(); @@ -509,6 +510,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } @Override + @Transactional public Object rfidCollect(List dtos) { List cases = new ArrayList<>(); Set archices = new HashSet<>(); @@ -565,6 +567,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } @Override + @Transactional public List> readyCollectConfirm(List caseIds) { return caseRepository.readyCollectConfirm(caseIds); } @@ -596,6 +599,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } @Override + @Transactional public Integer grant(boolean isCallback, String caseId) { ArchivesCase archivesCase = caseRepository.findById(caseId).get(); Integer deviceType = archivesCase.getFolderLocation().split("-").length == 5?1:2; @@ -708,17 +712,25 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } @Override - public Integer externalCallback(String caseId, String type) { - Integer storageType = "1".equals(type)? 2:0; + @Transactional + public Integer externalCallback(String caseId) { ArchivesCase archivesCase = caseRepository.findCaseById(caseId); if(null == archivesCase) return 0; + Integer type = archivesCase.getStorageType() == 1 ? 1 : 3; + Integer storageType = type == 1 ? 2:0; + //入库回调 - if("1".equals(type)){ + if(type == 1){ archivesCase.setStorageType(storageType); //出库回调 }else{ + archivesCase.setFolderLocation(null); + archivesCase.setFolderLocationDetails(null); + archivesCase.setStorageType(storageType); + //查询档案和关联的档案 + archivesSummaryRepository.cleanLocationByCaseId("%"+archivesCase.getId()+"%"); } caseRepository.saveAndFlush(archivesCase); return null; @@ -727,6 +739,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { //添加出入库日志 + @Transactional public StorageLog recordStorage(ArchivesCase thisCase,Integer StorageType){ StorageLog log = new StorageLog(); log.setCaseId(thisCase.getId()); 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 d3532fa..d135b3a 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 @@ -973,7 +973,7 @@ 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 quCol = dto.getQuNo() +"-"+dto.getColNo()+"-%"; String data = dto.getData(); if(dto.getDatatype() == 0){ data = StringUtils.isEmpty(data) ? "%%": "%"+data+"%"; @@ -1031,4 +1031,191 @@ public class ArchivesServiceImpl implements ArchivesService { json.put("errorinfo",null); return json; } + + @Override + public JSONObject externalGetArchivesCount(ArchivesExternalGetDTO dto) { + String quNo = dto.getQuNo()+"-%"; + List inStoreId = archivesSummaryRepository.getInStore(dto.getStoreCode(),quNo); + List isBorrowId = archivesSummaryRepository.getIsBorrow(dto.getStoreCode(),quNo); + JSONObject json = new JSONObject(); + JSONObject data = new JSONObject(); + data.put("in",inStoreId.size()-isBorrowId.size()); + data.put("out",isBorrowId.size()); + + json.put("data",data); + json.put("msg","success"); + json.put("ret",true); + return json; + } + + @Override + public JSONObject externalGetColumnInfo(ArchivesExternalGetDTO dto) { + JSONObject json = new JSONObject(); + + String quColZy = dto.getQuNo()+"-"+dto.getColNo()+"-"+"%-%"; + if(dto.getZyNo()!=0){ + quColZy = quColZy + "-"+dto.getZyNo(); + } + List> resultList = archivesSummaryRepository.externalGetColumnInfoResult(dto.getStoreCode(),quColZy); + List result = new ArrayList(); + JSONObject jsonResult = new JSONObject(); + Integer leNos = 0; + List> divList = new ArrayList<>(); + for(int i = 0;i map = resultList.get(i); + Map thisDiv = new HashMap<>(); + Integer thisLeNos = Integer.parseInt(map.get("leNo")+""); + Integer thisDisNo = Integer.parseInt(map.get("divNo")+""); + Integer archivesStorageNum = Integer.parseInt(map.get("archivesStorageNum")+""); + Integer archivesBorrowNum = Integer.parseInt(map.get("archivesBorrowNum")+""); + //新列 + if(leNos!=thisLeNos){ + if(divList.size()!=0){ + jsonResult.put("divList",divList); + jsonResult.put("leNo",leNos); + result.add(jsonResult); + jsonResult = new JSONObject(); + } + divList = new ArrayList<>(); + leNos = thisLeNos; + } + thisDiv.put("archivesBorrowNum",archivesBorrowNum); + thisDiv.put("archivesStorageNum",archivesStorageNum); + thisDiv.put("divNo",thisDisNo); + divList.add(thisDiv); + + //如果是最后一次循环 + if(i==resultList.size()-1){ + jsonResult.put("divList",divList); + jsonResult.put("leNo",leNos); + result.add(jsonResult); + } + } + + json.put("code",0); + json.put("errorinfo",""); + json.put("protocal",1005); + json.put("result",result); + return json; + } + + @Override + public JSONObject externalGetArchivesByZy(ArchivesExternalGetDTO dto) { + JSONObject json = new JSONObject(); + PageRequest page = PageRequest.of(dto.getPn()-1,dto.getPs()); + String quCol = dto.getQuNo() +"-"+dto.getColNo()+"-"+dto.getLeNo()+"-"+dto.getDivNo()+"-"+dto.getZyNo(); + //分页查询 + Page> pageMap = archivesSummaryRepository.externalGet(dto.getStoreCode(),quCol,0,"%%",page); + json.put("protocal",1001); + json.put("code",0); + JSONArray jsonArray = new JSONArray(); + List> resultMap = pageMap.getContent(); + for(Map map : resultMap){ + JSONObject resultJson = new JSONObject(); + resultJson.put("filename",map.get("filename")); + resultJson.put("fileno",map.get("fileno")); + resultJson.put("makedate",map.get("makedate")); + resultJson.put("filetype",map.get("filetype")); + resultJson.put("filecode",map.get("filecode")); + resultJson.put("keepday",map.get("keepday")); + resultJson.put("position",map.get("position").toString().replaceAll("-"," ")); + resultJson.put("storeCode",map.get("storeCode")); + resultJson.put("editdate",map.get("editdate")); + resultJson.put("enclosure",map.get("enclosure")); + + Integer filestatus = map.get("filestatus") == null ? 0 : Integer.parseInt(map.get("filestatus").toString()); + Integer inputFilestatus = 8; + if(filestatus==1){ + inputFilestatus = 2; + }else if(filestatus==2){ + inputFilestatus = 4; + }else if(filestatus == 3){ + inputFilestatus = 6; + } + resultJson.put("filestatus",inputFilestatus); + String[] splitPostion = map.get("location").toString().split("-"); + resultJson.put("quNo",splitPostion[0]); + resultJson.put("colNo",splitPostion[1]); + resultJson.put("leNo",splitPostion[2]); + resultJson.put("divNo",splitPostion[3]); + resultJson.put("zyNo",splitPostion[4]); + + JSONObject positionKeyJson = new JSONObject(); + positionKeyJson.put("quNo",splitPostion[0]); + positionKeyJson.put("colNo",splitPostion[1]); + positionKeyJson.put("leNo",splitPostion[2]); + positionKeyJson.put("divNo",splitPostion[3]); + positionKeyJson.put("zyNo",splitPostion[4]); + positionKeyJson.put("storeCode",map.get("storeCode")); + resultJson.put("positionKey",positionKeyJson); + jsonArray.add(resultJson); + } + JSONObject jsonContext = new JSONObject(); + jsonContext.put("list",jsonArray); + jsonContext.put("count",jsonArray.size()); + json.put("result",jsonContext); + json.put("errorinfo",null); + return json; + } + + @Override + public JSONObject externalMoveColumnGetFiles(ArchivesExternalGetDTO dto) { + JSONObject json = new JSONObject(); + PageRequest page = PageRequest.of(dto.getPn()-1,dto.getPs()); + String quCol = "%-%-%-%-%"; + String data = StringUtils.isEmpty(dto.getData()) ? "%%": "%"+dto.getData()+"%";; + //分页查询 + Page> pageMap = archivesSummaryRepository.externalGet(dto.getStoreCode(),quCol,0,data,page); + json.put("protocal",1001); + json.put("code",0); + JSONArray jsonArray = new JSONArray(); + List> resultMap = pageMap.getContent(); + for(Map map : resultMap){ + JSONObject resultJson = new JSONObject(); + resultJson.put("filename",map.get("filename")); + resultJson.put("fileno",map.get("fileno")); + resultJson.put("makedate",map.get("makedate")); + resultJson.put("filetype",map.get("filetype")); + resultJson.put("filecode",map.get("filecode")); + resultJson.put("keepday",map.get("keepday")); + resultJson.put("position",map.get("position").toString().replaceAll("-"," ")); + resultJson.put("storeCode",map.get("storeCode")); + resultJson.put("editdate",map.get("editdate")); + resultJson.put("enclosure",map.get("enclosure")); + + Integer filestatus = map.get("filestatus") == null ? 0 : Integer.parseInt(map.get("filestatus").toString()); + Integer inputFilestatus = 8; + if(filestatus==1){ + inputFilestatus = 2; + }else if(filestatus==2){ + inputFilestatus = 4; + }else if(filestatus == 3){ + inputFilestatus = 6; + } + resultJson.put("filestatus",inputFilestatus); + String[] splitPostion = map.get("location").toString().split("-"); + resultJson.put("quNo",splitPostion[0]); + resultJson.put("colNo",splitPostion[1]); + resultJson.put("leNo",splitPostion[2]); + resultJson.put("divNo",splitPostion[3]); + resultJson.put("zyNo",splitPostion[4]); + + JSONObject positionKeyJson = new JSONObject(); + positionKeyJson.put("quNo",splitPostion[0]); + positionKeyJson.put("colNo",splitPostion[1]); + positionKeyJson.put("leNo",splitPostion[2]); + positionKeyJson.put("divNo",splitPostion[3]); + positionKeyJson.put("zyNo",splitPostion[4]); + positionKeyJson.put("storeCode",map.get("storeCode")); + resultJson.put("positionKey",positionKeyJson); + jsonArray.add(resultJson); + } + JSONObject jsonContext = new JSONObject(); + jsonContext.put("list",jsonArray); + jsonContext.put("count",jsonArray.size()); + jsonContext.put("currentPages",dto.getPn()); + json.put("result",jsonContext); + json.put("errorinfo",null); + return json; + } }