| | |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | public class InterfaceServiceImpl implements InterfaceService { |
| | | |
| | | private static Logger logger = Logger.getLogger(ApiAction.class); |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private OpeUseFlowService opeUseFlowService; |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | SysLaboratoryContainerService sysLaboratoryContainer; |
| | | @Resource |
| | | SysLaboratoryService sysLaboratoryService; |
| | | |
| | | @Value("${message.url}") |
| | | String url; |
| | |
| | | // containerRight 对应 DB character_right |
| | | // createTimestamp 对应 DB create_time |
| | | |
| | | System.out.println("1111111111111111111111111"); |
| | | // 注册接口没有之前的关系 |
| | | // |
| | | // //清除之前的记录,然后关联现在的关系 |
| | |
| | | }else{ |
| | | sysUser = sysUserDao.getSysUser(userID); |
| | | // 如果是管理员也可以开柜 |
| | | if(sysUser.getSeeFlag() == SeeFlag.MANAGE){ |
| | | if(sysUser.getSeeFlag() == SeeFlag.MANAGE||sysUser.getSeeFlag() == SeeFlag.LEADING){ |
| | | return "1"; |
| | | } else { |
| | | // 不可以打开柜子 |
| | |
| | | SysUser user = sysUserDao.getSysUserByIdCard(idcard); |
| | | |
| | | LinkedHashMap params = new LinkedHashMap(); |
| | | if (user == null) { |
| | | throw new ApiException(ApiStatus.PARAM_ERR,"无相关人员卡号"); |
| | | } |
| | | params.put("userId", user.getId()); |
| | | params.put("realstatus", realstatus); |
| | | params.put("reagentCode", reagentCode); |
| | |
| | | logger.error("The containerCode has not been exists!"); |
| | | continue; |
| | | } |
| | | } else if (status.equals(2)){ |
| | | } |
| | | else if (status.equals(2)){ |
| | | /*SysWarehouseContainer container = sysWarehouseContainerDao |
| | | .getSysWarehouseContainerByContainerCode(containerCode); |
| | | if (Objects.isNull(container) == false) { |
| | |
| | | if (status.equals(-1)){ |
| | | continue; |
| | | } |
| | | opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | |
| | | int i = opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | if (i < 1){ |
| | | opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //货柜预警接口 |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public void alarm(JSONObject jsonObject) throws ApiException { |
| | |
| | | String containerCode = dataJson.getString("containerCode"); |
| | | |
| | | //check containerCode是否存在 |
| | | SysLaboratoryContainer sysLaboratoryContainer = sysLaboratoryContainerDao |
| | | SysLaboratoryContainer LaboratoryContainer = sysLaboratoryContainerDao |
| | | .getSysLaboratoryContainerByContainerCode(containerCode); |
| | | if (Objects.isNull(sysLaboratoryContainer) == true) { |
| | | SysWarehouseContainer container = sysWarehouseContainerDao |
| | |
| | | } catch (ParseException e) { |
| | | throw new ApiException(ApiStatus.PARAM_ERR); |
| | | } |
| | | |
| | | //判断是否重复 |
| | | logger.info("测试"); |
| | | if (sysAlarmDao.selectOne(containerCode, controllerCode, sysAlarm.getWarningId(), sysAlarm.getWarningTime()) > 0) { |
| | | continue; |
| | | } |
| | | sysAlarmDao.insertSysAlarm(sysAlarm); |
| | | try { |
| | | if (enable && "01".equals(warningId)) { |
| | | SysLaboratory sysLaboratory = sysLaboratoryService.getSysLaboratory(LaboratoryContainer.getLaboratoryId()); |
| | | String project = sysLaboratory.getProject(); |
| | | //2.根据Lab的课题组判断人员 |
| | | List<Map> personsInCharge = null; |
| | | if (StringUtils.isBlank(project)) { |
| | | //没有课题组就是实验室部门下的负责人 |
| | | personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode); |
| | | } else { |
| | | //有课题组就是 所有课题组下的人员负责人 |
| | | personsInCharge = sysLaboratoryService.getPersonInChargeByProjects(project); |
| | | } |
| | | |
| | | Map param = new HashMap(); |
| | | param.put("groupId", "securityManager"); |
| | | List<BaseMeta> managers = baseMetaDao.getBaseMetaList(param); |
| | | StringBuffer phones = new StringBuffer(); |
| | | |
| | | //实验室负责人手机号 |
| | | if (personsInCharge != null && personsInCharge.size() > 0) { |
| | | personsInCharge.forEach(person -> { |
| | | Object phone = person.get("phone"); |
| | | if (phone != null && !"".equals(phone)) { |
| | | phones.append(phone); |
| | | phones.append(","); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | //所及负责人手机号 |
| | | if (managers != null && managers.size() > 0) { |
| | | managers.forEach(manager -> { |
| | | String phone = manager.getMetaValue(); |
| | | if (phone != null && !"".equals(phone)) { |
| | | phones.append(phone); |
| | | phones.append(","); |
| | | } |
| | | }); |
| | | } |
| | | if (phones.length() > 0) { |
| | | phones.deleteCharAt(phones.length() - 1); |
| | | |
| | | } |
| | | |
| | | Map location = sysLaboratoryContainer.selectLocationByContainerCode(containerCode); |
| | | String messageFormat = "名称:%s,具体地点:%s,柜号:%s,"; |
| | | String content = String.format(messageFormat, location.get("name"),location.get("location"), containerCode); |
| | | |
| | | String suffix = String.format("?head=%s&signature=%s&content=%s&telnumber=%s", head, signature, content + baseMetaList.get(0).getMetaValue(), phones.toString().replace(" ", "")); |
| | | CloseableHttpClient client = HttpClients.createDefault(); |
| | | HttpPost post = new HttpPost(url + suffix); |
| | | post.setHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | CloseableHttpResponse response = client.execute(post); |
| | | String resData = EntityUtils.toString(response.getEntity(), "UTF-8"); |
| | | client.close(); |
| | | JSONObject res = JSONObject.parseObject(resData); |
| | | if ("200".equals(res.getString("code")) && phones.length() > 0) { |
| | | String memo = String.format("短信已发送[%s]", phones); |
| | | } |
| | | logger.info(resData); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | logger.warn(e); |
| | | } |
| | | //增加发送短信接口 key:01 value:主电掉电,备电工作 |
| | | |
| | | |
| | | |
| | | // |
| | | // Integer warningPoint = dataJson.getInteger("warningPoint"); |
| | | // if(warningPoint == null){ |
| | |
| | | Integer warningPoint = dataJson.getInteger("warningPoint"); |
| | | |
| | | SysUser user = sysUserDao.getSysUserByIdCard(idcard); |
| | | System.out.println("====="+user); |
| | | if(user==null){ |
| | | System.out.println(idcard.length()); |
| | | if(idcard.length()==20){ |
| | |
| | | } |
| | | |
| | | if(enable && "2".equals(warningId) ) { |
| | | List<Map> personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode); |
| | | //1.根据containerCode获取lab |
| | | SysLaboratoryContainer container = sysLaboratoryContainer.getSysLaboratoryContainerByContainerCode(containerCode); |
| | | SysLaboratory sysLaboratory = sysLaboratoryService.getSysLaboratory(container.getLaboratoryId()); |
| | | String project = sysLaboratory.getProject(); |
| | | //2.根据Lab的课题组判断人员 |
| | | List<Map> personsInCharge = null; |
| | | if (StringUtils.isBlank(project)) { |
| | | //没有课题组就是实验室部门下的负责人 |
| | | personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode); |
| | | } else { |
| | | //有课题组就是 所有课题组下的人员负责人 |
| | | personsInCharge = sysLaboratoryService.getPersonInChargeByProjects(project); |
| | | } |
| | | |
| | | Map param = new HashMap(); |
| | | param.put("groupId", "securityManager"); |
| | | List<BaseMeta> managers = baseMetaDao.getBaseMetaList(param); |
| | |
| | | |
| | | } |
| | | sysAlarmPersonDao.insertSysAlarmPerson(sysAlarmPerson); |
| | | // 将人员扣分更新到人员表 |
| | | if (warningPoint == null) { |
| | | warningPoint = 0; |
| | | } |
| | | // SysUser user = sysUserDao.getSysUser(userId); |
| | | if (user != null) { |
| | | sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId()); |
| | | } |
| | | } |
| | | // 将人员扣分更新到人员表 |
| | | if (warningPoint == null) { |
| | | warningPoint = 0; |
| | | } |
| | | // SysUser user = sysUserDao.getSysUser(userId); |
| | | if (user != null) { |
| | | sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId()); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | String updateTime = dataJson.getString("updateTime"); |
| | | BigDecimal remainder = dataJson.getBigDecimal("remainder"); |
| | | String operateState = dataJson.getString("operateState"); |
| | | BigDecimal volume = dataJson.getBigDecimal("volume"); |
| | | |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | |
| | | opeUseFlow.setRemainder(remainder); |
| | | opeUseFlow.setOperateState(baseMetaList.get(0).getId()); |
| | | opeUseFlow.setCreateTime(new java.sql.Timestamp(createtime.getTime())); |
| | | opeUseFlow.setVolume(volume); |
| | | |
| | | // <!--0:个人领用 1:在仓库sys_warehouse_container |
| | | // 2:在实验室sys_laboratory_container 3:报废--> |
| | |
| | | continue; |
| | | } |
| | | } |
| | | int count = opeUseFlowService.getOpeUseFlow(opeUseFlow); |
| | | if (count < 1) { |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | } |
| | | } |
| | | } |
| | | |