ÎļþÃû´Ó igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java ÐÞ¸Ä |
| | |
| | | import com.ld.igds.camera.data.ApiCameraData; |
| | | import com.ld.igds.camera.data.ApiCameraResp; |
| | | import com.ld.igds.camera.data.ApiSnapReq; |
| | | import com.ld.igds.constant.BizType; |
| | | import com.ld.igds.data.SnapImgDto; |
| | | import com.ld.igds.file.CoreFileService; |
| | | import com.ld.igds.inout.ApiInoutManager; |
| | | import com.ld.igds.inout.InoutConstant; |
| | | import com.ld.igds.inout.dto.ApiInoutData; |
| | | import com.ld.igds.inout.dto.InoutCameraDto; |
| | | import com.ld.igds.inout.dto.InoutData; |
| | | import com.ld.igds.inout.ApiInoutService; |
| | | import com.ld.igds.inout.InoutConstant; |
| | | import com.ld.igds.inout.dto.*; |
| | | import com.ld.igds.inout.service.InoutService; |
| | | import com.ld.igds.io.constant.ProtocolEnum; |
| | | import com.ld.igds.m.service.InoutCommonService; |
| | | import com.ld.igds.models.InoutConf; |
| | | import com.ld.igds.models.SnapSer; |
| | | import com.ld.igds.util.ContextUtil; |
| | | import com.ld.igds.util.NumberUtil; |
| | | import com.ld.igds.view.service.SnapSerService; |
| | | import com.ld.igds.websocket.WebSocketPacket; |
| | | import com.ld.igds.websocket.WebSocketServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | |
| | | /** |
| | | * @Desc: åºå
¥åºç¸å
³è®¾å¤æä½ï¼ä¸å¡é»è¾å
æ¬æå头æä½ï¼å°ç£
ï¼æ¦æ ·æºçææè®¾å¤ |
| | | * @Desc: åºå
¥åºè¿ç¨ä¸ï¼é对æµç¨ç¸å
³ç设å¤è卿§å¶å
æ¬ï¼å°ç£
ãæ¦æ ·æºã读å¡å¨ã鏿ºãLED对æ¥ç |
| | | * <p> |
| | | * 注æï¼å½åç±»ä¸äºä»¶ç±»æ¹æ³å使ç¨å¼æ¥æ¹å¼å®ç° |
| | | * @author: Andy |
| | | * @update-time: 2022/11/24 |
| | | * @update-time: 2023/7/4 éæ°ä¼å |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class InoutDeviceManager { |
| | | public class InoutEventControlManager { |
| | | |
| | | @Resource |
| | | private SnapSerService snapSerService; |
| | | @Resource |
| | | private InoutCommonService inoutCommonService; |
| | | @Resource |
| | | private InoutService inoutService; |
| | | @Resource |
| | | private CoreFileService fileService; |
| | | @Resource |
| | |
| | | private ApiCameraManager apiCameraManager; |
| | | |
| | | |
| | | /** |
| | | * 页é¢è·å车çè¯å« |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public ApiInoutData getPlateNum(ApiInoutData param) { |
| | | |
| | | //å¦æä½¿ç¨çæ¯å°ç£
æä»¶è·åï¼åéè¦è°æ´è®¾å¤ä¸ºå°ç£
æä»¶ä¿¡æ¯ |
| | |
| | | return param; |
| | | } |
| | | |
| | | ApiInoutData pluginWeight = new ApiInoutData(); |
| | | pluginWeight = param; |
| | | pluginWeight.setIp(conf.getIp()); |
| | | pluginWeight.setPort(conf.getPort()); |
| | | pluginWeight.setProtocol(conf.getProtocol()); |
| | | |
| | | return apiInoutManager.getApiService(param.getProtocol()).getPlateNum(pluginWeight); |
| | | param.setIp(conf.getIp()); |
| | | param.setPort(conf.getPort()); |
| | | param.setProtocol(conf.getProtocol()); |
| | | |
| | | return apiInoutManager.getApiService(param.getProtocol()).getPlateNum(param); |
| | | |
| | | } |
| | | |
| | | |
| | | return apiInoutManager.getApiService(param.getProtocol()).getPlateNum(param); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åæºæ
§å¡ç»æ |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public ApiInoutData getIcCardNum(ApiInoutData param) { |
| | | |
| | | return apiInoutManager.getApiService(param.getProtocol()).getIcCardNum(param); |
| | | } |
| | | |
| | | /** |
| | | * è·åç§°éæä»¶é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param companyId |
| | | * @param deptId |
| | | * @param sort |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public InoutConf getInoutConf(String companyId, String deptId, String sort, String type) { |
| | | |
| | | // è·ååºå
¥åºé
ç½®ä¿¡æ¯ |
| | | List<InoutConf> listInoutConf = inoutCommonService.getCacheInoutConf(companyId, deptId); |
| | | |
| | | if (null == listInoutConf) return null; |
| | | |
| | | InoutConf result = null; |
| | | |
| | | for (InoutConf conf : listInoutConf) { |
| | | if (sort.equals(conf.getSort()) && type.equals(conf.getType())) { |
| | | result = conf; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (null == result) return null; |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åå§å车çè¯å« |
| | | * åºå
¥åºç»è®°åå§å |
| | | * |
| | | * @param conf |
| | | * @param lpr 车çè¯å«é
ç½®ä¿¡æ¯ |
| | | */ |
| | | public void initLpr(InoutConf conf) { |
| | | @Async |
| | | public void initInoutRegister(InoutConf lpr) { |
| | | |
| | | if (null == conf) return; |
| | | if (null == lpr) return; |
| | | |
| | | ApiInoutData lprData = new ApiInoutData(conf); |
| | | ApiInoutData lprData = new ApiInoutData(lpr); |
| | | |
| | | apiInoutManager.getApiService(conf.getProtocol()).initLpr(lprData); |
| | | apiInoutManager.getApiService(lpr.getProtocol()).initLpr(lprData); |
| | | } |
| | | |
| | | |
| | |
| | | public SnapImgDto snapImg(SnapImgDto param) { |
| | | try { |
| | | InoutConf conf; |
| | | |
| | | //ç»è®°æ¶åææ |
| | | if (InoutConstant.PROGRESS_REGISTER.equals(param.getProgress())) { |
| | | this.noticeGatewayAddWhitePlate(param); |
| | | } |
| | | |
| | | //ç¹å»ç§°é宿 |
| | | if (InoutConstant.PROGRESS_WEIGHT_TAG.equals(param.getProgress()) |
| | | || InoutConstant.PROGRESS_WEIGHT_FULL.equals(param.getProgress()) || |
| | | InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(param.getProgress())) { |
| | | |
| | | this.noticeGatewayWeightInfo(param); |
| | | } |
| | | |
| | | SnapSer ser = snapSerService.getCacheByDeptId(param.getDeptId()); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getId1())) { |
| | | conf = inoutCommonService.getCacheInoutConf(param.getCompanyId(), param.getDeptId(), param.getId1()); |
| | | param.setFileName1(this.snapImgByConf(conf, param, ser)); |
| | | Thread.sleep(600); |
| | | Thread.sleep(500); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getId2())) { |
| | | conf = inoutCommonService.getCacheInoutConf(param.getCompanyId(), param.getDeptId(), param.getId2()); |
| | | param.setFileName2(this.snapImgByConf(conf, param, ser)); |
| | | Thread.sleep(600); |
| | | Thread.sleep(500); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getId3())) { |
| | | conf = inoutCommonService.getCacheInoutConf(param.getCompanyId(), param.getDeptId(), param.getId3()); |
| | | param.setFileName3(this.snapImgByConf(conf, param, ser)); |
| | |
| | | apiData.setMsg("ç§°é已宿"); |
| | | |
| | | // apiInoutManager.getApiService(apiData.getProtocol()).noticeWeightDone(apiData); |
| | | apiInoutManager.getApiService(apiData.getProtocol()).noticeRadio(apiData); |
| | | // apiInoutManager.getApiService(apiData.getProtocol()).noticeRadio(apiData); |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * åºå
¥åºç»è®°å®æè§¦åäºä»¶ï¼é»è®¤ä¸ºå¼æ¥å¤ç |
| | | * |
| | | * @param data |
| | | */ |
| | | @Async |
| | | public void onInoutRegister(InoutData data) { |
| | | |
| | | //DO Nothing |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®åºå
¥åºä¿¡æ¯ï¼æ§å¶åºå
¥åºæ§å¶å¨ |
| | | * åºå
¥åºç§°é宿ï¼äºä»¶ |
| | | * |
| | | * @param data |
| | | * @param curProgress |
| | | * @param nextProgress |
| | | */ |
| | | public void controlWeight(InoutData data, String curProgress, String nextProgress) { |
| | | @Async |
| | | public void onInoutWeight(InoutData data, String curProgress, String nextProgress) { |
| | | |
| | | //TODO |
| | | //1ãéç¥ç§°éæ¾ç¤ºå± |
| | | |
| | | //2ãè¯é³éç¥ |
| | | |
| | | //3ãå¼é¸æº |
| | | |
| | | //4ãå¼çº¢ç»¿ç¯ |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¼ä»å®æï¼äºä»¶ |
| | | * |
| | | * @param data |
| | | * @param curProgress |
| | | * @param nextProgress |
| | | */ |
| | | @Async |
| | | public void onInoutHandle(InoutData data, String curProgress, String nextProgress) { |
| | | |
| | | //DO Nothing |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¦æ ·å®æï¼äºä»¶ |
| | | * |
| | | * @param data |
| | | */ |
| | | @Async |
| | | public void onInSimple(InoutCheckData data) { |
| | | //DO Nothing |
| | | } |
| | | |
| | | /** |
| | | * è´¨æ£å®æï¼äºä»¶ |
| | | * |
| | | * @param data |
| | | * @param curProgress |
| | | * @param nextProgress |
| | | */ |
| | | @Async |
| | | public void onInCheck(InoutCheckData data, String curProgress, String nextProgress) { |
| | | //1ãè´¨æ£å¤§å±æ¾ç¤º |
| | | } |
| | | |
| | | /** |
| | | * æµç¨å®æï¼äºä»¶ |
| | | * |
| | | * @param data |
| | | */ |
| | | @Async |
| | | public void onInoutComplete(InoutData data) { |
| | | //DO Nothing |
| | | } |
| | | |
| | | /** |
| | | * åå§åå¤§å± |
| | | * |
| | | * @param companyId ç»ç»ç¼ç |
| | | * @param deptId ååºç¼ç |
| | | * @param progress æµç¨ç¯è |
| | | */ |
| | | @Async |
| | | public void initInoutScreen(String companyId, String deptId, String progress) { |
| | | if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN |
| | | .getCode())) { |
| | | WebSocketServer.contextOnLineMap.put(BizType.SCREEN.getCode(), |
| | | false); |
| | | } |
| | | if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT |
| | | .getCode())) { |
| | | WebSocketServer.contextOnLineMap.put( |
| | | BizType.SCREEN_INOUT.getCode(), false); |
| | | } |
| | | if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK |
| | | .getCode())) { |
| | | WebSocketServer.contextOnLineMap.put( |
| | | BizType.SCREEN_CHECK.getCode(), false); |
| | | } |
| | | |
| | | if (WebSocketServer.contextOnLineMap.get(BizType.SCREEN.getCode()) |
| | | || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT |
| | | .getCode()) |
| | | || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK |
| | | .getCode())) { |
| | | |
| | | |
| | | // æ¨éå°å¤§å± |
| | | List<InoutData> curList = inoutService.getListInoutCache(deptId); |
| | | |
| | | List<InoutData> completeList = inoutService.getCompleteListInoutCache(deptId); |
| | | |
| | | notifyInoutScreen(companyId, deptId, curList, completeList); |
| | | } |
| | | } |
| | | |
| | | private void notifyInoutScreen(String companyId, String deptId, List<InoutData> curList, List<InoutData> completeList) { |
| | | InoutSumDto dto = new InoutSumDto(); |
| | | if (null != curList) { |
| | | for (InoutData data : curList) { |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | dto.setInSumNum(dto.getInSumNum() + 1); |
| | | } |
| | | if (InoutConstant.TYPE_OUT.equals(data.getType())) { |
| | | dto.setOutSumNum(dto.getOutSumNum() + 1); |
| | | } |
| | | dto.setCompanyId(companyId); |
| | | dto.setDeptId(deptId); |
| | | } |
| | | } |
| | | |
| | | if (null != completeList) { |
| | | for (InoutData data : completeList) { |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | dto.setInSumNum(dto.getInSumNum() + 1); |
| | | dto.setInComplateNum(dto.getInComplateNum() + 1); |
| | | } |
| | | if (InoutConstant.TYPE_OUT.equals(data.getType())) { |
| | | dto.setOutSumNum(dto.getOutSumNum() + 1); |
| | | dto.setOutComplateNum(dto.getOutComplateNum() + 1); |
| | | } |
| | | dto.setCompanyId(data.getCompanyId()); |
| | | dto.setDeptId(data.getDeptId()); |
| | | } |
| | | } |
| | | |
| | | // è°æ´å°è£
|
| | | if (dto.getInSumNum() > 0) { |
| | | dto.setPerInComplate(dto.getInComplateNum() / Double.valueOf(dto.getInSumNum())); |
| | | dto.setPerInComplate(NumberUtil.keepPrecision( |
| | | dto.getPerInComplate() * 100, 1)); |
| | | } |
| | | |
| | | if (dto.getOutSumNum() > 0) { |
| | | dto.setPerOutComplate(dto.getOutComplateNum() / Double.valueOf(dto.getOutSumNum())); |
| | | dto.setPerOutComplate(NumberUtil.keepPrecision( |
| | | dto.getPerOutComplate() * 100, 1)); |
| | | } |
| | | |
| | | if (null == dto.getCompanyId()) { |
| | | dto.setCompanyId(ContextUtil.getDefaultCompanyId()); |
| | | } |
| | | |
| | | // æ¨é综å管çå¤§å± |
| | | WebSocketPacket packet = new WebSocketPacket(); |
| | | packet.setBizId("IN_OUT_SUMMARY"); |
| | | packet.setCompanyId(dto.getCompanyId()); |
| | | packet.setDeptId(dto.getDeptId()); |
| | | packet.setBizType(BizType.SCREEN.getCode()); |
| | | packet.setData(dto); |
| | | WebSocketServer.sendByBizTag(packet); |
| | | |
| | | // æ¨éåºå
¥åºå¤§å± |
| | | dto.setCurList(curList); |
| | | dto.setComplateList(completeList); |
| | | packet.setBizType(BizType.SCREEN.getCode()); |
| | | packet.setBizTag(WebSocketPacket.BIZ_TAG_SCREEN_INOUT); |
| | | WebSocketServer.sendByBizTag(packet); |
| | | |
| | | // æ¨éåéªå¤§å± |
| | | packet.setBizType(BizType.SCREEN.getCode()); |
| | | packet.setBizTag(WebSocketPacket.BIZ_TAG_SCREEN_CHECK); |
| | | WebSocketServer.sendByBizTag(packet); |
| | | } |
| | | |
| | | /** |
| | | * è·åç§°éæä»¶é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param companyId |
| | | * @param deptId |
| | | * @param sort |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public InoutConf getInoutConf(String companyId, String deptId, String sort, String type) { |
| | | |
| | | // è·ååºå
¥åºé
ç½®ä¿¡æ¯ |
| | | List<InoutConf> listInoutConf = inoutCommonService.getCacheInoutConf(companyId, deptId); |
| | | |
| | | if (null == listInoutConf) return null; |
| | | |
| | | InoutConf result = null; |
| | | |
| | | for (InoutConf conf : listInoutConf) { |
| | | if (sort.equals(conf.getSort()) && type.equals(conf.getType())) { |
| | | result = conf; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (null == result) return null; |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |