| | |
| | | import com.zy.asrs.wcs.system.entity.OperationRecord; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import com.zy.asrs.wcs.system.service.OperationRecordService; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.*; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | |
| | | // 记录异常信息 |
| | | if (e != null) { |
| | | record.setResult(0); |
| | | record.setErr(Utils.sub(e.toString(), MAX_LENGTH)); |
| | | record.setErr(CommonUtils.sub(e.toString(), MAX_LENGTH)); |
| | | } else { |
| | | record.setResult(1); |
| | | } |
| | |
| | | } |
| | | // 记录请求参数 |
| | | if (ol.param() && request != null) { |
| | | record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH)); |
| | | record.setRequest(CommonUtils.sub(getParams(joinPoint, request), MAX_LENGTH)); |
| | | } |
| | | // 记录请求结果 |
| | | if (ol.result() && result != null) { |
| | | record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH)); |
| | | record.setResponse(CommonUtils.sub(JSON.toJSONString(result), MAX_LENGTH)); |
| | | } |
| | | operationRecordService.saveAsync(record); |
| | | } |
| | |
| | | |
| | | Map<String, String[]> map = Collections.unmodifiableMap(request.getParameterMap()); |
| | | for (Map.Entry<String, String[]> entry : map.entrySet()) { |
| | | paramsMap.put(entry.getKey(), Utils.join(entry.getValue(), ",")); |
| | | paramsMap.put(entry.getKey(), CommonUtils.join(entry.getValue(), ",")); |
| | | } |
| | | |
| | | if (paramsMap.keySet().size() > 0) { |
| | |
| | | package com.zy.asrs.wcs.common.config; |
| | | |
| | | import com.zy.asrs.wcs.common.constant.Constants; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor; |
| | |
| | | return new AsyncHandlerInterceptor(){ |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | Utils.cors(response); |
| | | CommonUtils.cors(response); |
| | | return true; |
| | | } |
| | | }; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Modifier; |
| | |
| | | if (null != list) { |
| | | key = key.replaceAll("Range", ""); |
| | | if (this.isToUnderlineCase) { |
| | | key = Utils.toSymbolCase(key, '_'); |
| | | key = CommonUtils.toSymbolCase(key, '_'); |
| | | } |
| | | queryWrapper.ge(key, DateUtils.convert(list.get(0))); |
| | | queryWrapper.le(key, DateUtils.convert(list.get(1))); |
| | | } |
| | | } else { |
| | | if (this.isToUnderlineCase) { |
| | | key = Utils.toSymbolCase(key, '_'); |
| | | key = CommonUtils.toSymbolCase(key, '_'); |
| | | } |
| | | if (like) { |
| | | queryWrapper.like(key, val); |
| | |
| | | fields = Cools.getAllFields(cls); |
| | | for (Field field : fields) { |
| | | if ("createTime".equals(field.getName())) { |
| | | queryWrapper.orderByDesc(Utils.toSymbolCase(field.getName(), '_')); |
| | | queryWrapper.orderByDesc(CommonUtils.toSymbolCase(field.getName(), '_')); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | String column = Utils.toSymbolCase(field.getName(), '_'); |
| | | String column = CommonUtils.toSymbolCase(field.getName(), '_'); |
| | | columns.add(column); |
| | | } |
| | | if (!columns.isEmpty()) { |
| | |
| | | |
| | | private String locSts; |
| | | |
| | | public LocVo(String locNo, String locSts) { |
| | | this.locNo = locNo; |
| | | this.locSts = locSts; |
| | | } |
| | | private String zpallet = "-"; |
| | | |
| | | private Boolean enable = false; |
| | | |
| | | } |
| | |
| | | |
| | | private String currentCode = "-"; |
| | | |
| | | private String currentLocNo = "-"; |
| | | |
| | | private String batteryPower = "-"; |
| | | |
| | | private String batteryVoltage = "-"; |
| | |
| | | |
| | | private String errorCode = "-"; |
| | | |
| | | private String zpallet = "-"; |
| | | |
| | | private Boolean pakMk = false; |
| | | |
| | | private Boolean enable = false; |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.common.domain.enums.DictType; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.map.controller.param.MapDataParam; |
| | | import com.zy.asrs.wcs.core.map.controller.param.MapQueryParam; |
| | |
| | | import com.zy.asrs.wcs.core.map.controller.result.LocVo; |
| | | import com.zy.asrs.wcs.core.map.controller.result.ShuttleVo; |
| | | import com.zy.asrs.wcs.core.map.entity.MapItem; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.LocStsType; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.service.LocStsService; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | | import com.zy.asrs.wcs.system.service.DictService; |
| | | import com.zy.asrs.wcs.system.service.UserService; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private LocService locService; |
| | | @Autowired |
| | | private LocStsService locStsService; |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | |
| | | public String getMapFloorList(Long userId) { |
| | | String floorKey = "floor-list"; |
| | |
| | | int bay = Utils.getBay(locNo); |
| | | List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getRow, row).eq(Loc::getBay, bay).orderByAsc(Loc::getLev)); |
| | | for (Loc loc : locList) { |
| | | locVos.add(new LocVo(loc.getLocNo(), loc.getLocStsFlag())); |
| | | LocVo locVo = new LocVo(); |
| | | locVo.setLocNo(loc.getLocNo()); |
| | | locVo.setLocSts(loc.getLocStsFlag()); |
| | | locVo.setZpallet(loc.getZpallet()); |
| | | locVo.setEnable(CommonUtils.getStatusBool(loc.getStatus())); |
| | | locVos.add(locVo); |
| | | } |
| | | return locVos; |
| | | } |
| | |
| | | public ShuttleVo getShuttleInfo(String shuttleNo) { |
| | | ShuttleVo vo = new ShuttleVo(); |
| | | vo.setShuttleNo(shuttleNo); |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>().eq(DeviceType::getFlag, SlaveType.Shuttle.toString())); |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>().eq(Device::getDeviceType, deviceType.getId()).eq(Device::getDeviceNo, shuttleNo)); |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getDeviceNo, shuttleNo) |
| | | ); |
| | | if (null == device) { |
| | | return vo; |
| | | } |
| | | ShuttleThread thread = (ShuttleThread)SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (null == thread) { |
| | | BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, device.getId())); |
| | | if (null == basShuttle || Cools.isEmpty(basShuttle.getProtocol())) { |
| | | return vo; |
| | | } |
| | | ShuttleProtocol protocol = thread.getStatus(); |
| | | if (null == protocol) { |
| | | return vo; |
| | | } |
| | | ShuttleProtocol protocol = JSON.parseObject(basShuttle.getProtocol(), ShuttleProtocol.class); |
| | | // ShuttleThread thread = (ShuttleThread)SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | // if (null == thread) { |
| | | // return vo; |
| | | // } |
| | | // ShuttleProtocol protocol = thread.getStatus(); |
| | | // if (null == protocol) { |
| | | // return vo; |
| | | // } |
| | | vo.setTaskNo(String.valueOf(protocol.getTaskNo())); |
| | | vo.setStatus(protocol.getProtocolStatusType().desc); |
| | | vo.setOriginLocNo(protocol.getSourceLocNo()); |
| | | vo.setDestLocNo(protocol.getLocNo()); |
| | | vo.setCurrentCode(protocol.getCurrentCode()); |
| | | vo.setCurrentLocNo(protocol.getCurrentLocNo()); |
| | | vo.setBatteryPower(protocol.getBatteryPower()); |
| | | vo.setErrorCode(protocol.getErrorCode()); |
| | | vo.setBatteryTemp(protocol.getBatteryTemp()); |
| | |
| | | vo.setHasPallet(protocol.getHasPallet()); |
| | | vo.setHasCharge(protocol.getHasCharge()); |
| | | vo.setBatteryVoltage(String.valueOf(protocol.getBatteryVoltage())); |
| | | // vo.setZpallet(); |
| | | vo.setPakMk(protocol.getPakMk()); |
| | | vo.setEnable(CommonUtils.getStatusBool(basShuttle.getStatus())); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | import com.zy.asrs.wcs.system.service.UserLoginService; |
| | | import com.zy.asrs.wcs.system.service.UserService; |
| | | import com.zy.asrs.wcs.utils.JwtUtil; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | @GetMapping("/auth/menu") |
| | | public R userMenu() { |
| | | List<Menu> menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU); |
| | | return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | return R.ok().add(CommonUtils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | } |
| | | |
| | | @GetMapping("/auth/host") |
| | |
| | | import com.zy.asrs.wcs.system.service.DeptService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import com.zy.asrs.wcs.utils.NodeUtils; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | // PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class); |
| | | // QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | List<Dept> deptList = deptService.list(new LambdaQueryWrapper<Dept>().orderByAsc(Dept::getSort)); |
| | | List<Dept> treeData = Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren); |
| | | List<Dept> treeData = CommonUtils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | CommonUtils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | CommonUtils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | } |
| | | return R.ok().add(treeData); |
| | | } |
| | |
| | | import com.zy.asrs.wcs.system.service.MenuService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import com.zy.asrs.wcs.utils.NodeUtils; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import com.zy.asrs.wcs.utils.CommonUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | // List<Menu> menus = menuService.list(wrapper); |
| | | // return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | List<Menu> menuList = menuService.list(new LambdaQueryWrapper<Menu>().orderByAsc(Menu::getSort)); |
| | | List<Menu> treeData = Utils.toTreeData(menuList, 0L, Menu::getParentId, Menu::getId, Menu::setChildren); |
| | | List<Menu> treeData = CommonUtils.toTreeData(menuList, 0L, Menu::getParentId, Menu::getId, Menu::setChildren); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Menu::getName, Menu::getChildren); |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Menu::getName, Menu::getChildren); |
| | | CommonUtils.treeRemove(treeData, String.valueOf(map.get("condition")), Menu::getName, Menu::getChildren); |
| | | CommonUtils.treeRemove(treeData, String.valueOf(map.get("condition")), Menu::getName, Menu::getChildren); |
| | | } |
| | | return R.ok().add(treeData); |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/Utils.java |
| | |
| | | /** |
| | | * Created by vincent on 2023/3/14 |
| | | */ |
| | | public class Utils { |
| | | public class CommonUtils { |
| | | |
| | | /** |
| | | * List转为树形结构 |
| | |
| | | } |
| | | } |
| | | |
| | | public static Boolean getStatusBool(Integer status) { |
| | | if (null == status) { |
| | | return true; |
| | | } |
| | | return status == 1; |
| | | } |
| | | |
| | | public static void cors(HttpServletResponse response){ |
| | | // 跨域设置 |
| | | response.setHeader("Access-Control-Max-Age", "3600"); |
| | |
| | | |
| | | public static void build(Workbook workbook, HttpServletResponse response) { |
| | | response.reset(); |
| | | Utils.cors(response); |
| | | CommonUtils.cors(response); |
| | | response.setContentType("application/octet-stream; charset=utf-8"); |
| | | try { |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("export", "UTF-8")); |
| | |
| | | String access_token = request.getHeader(Constants.TOKEN_HEADER_NAME); |
| | | if (!Cools.isEmpty(access_token)) { |
| | | if (access_token.startsWith(Constants.TOKEN_TYPE)) { |
| | | access_token = Utils.removePrefix(access_token, Constants.TOKEN_TYPE).trim(); |
| | | access_token = CommonUtils.removePrefix(access_token, Constants.TOKEN_TYPE).trim(); |
| | | } |
| | | } else { |
| | | access_token = request.getParameter(Constants.TOKEN_PARAM_NAME); |