New file |
| | |
| | | package com.zy.asrs.common.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class LocRangeDto { |
| | | |
| | | //起始排 |
| | | private Integer startRow; |
| | | |
| | | //结束排 |
| | | private Integer targetRow; |
| | | |
| | | //起始列 |
| | | private Integer startBay; |
| | | |
| | | //结束列 |
| | | private Integer targetBay; |
| | | |
| | | //起始层 |
| | | private Integer startLev; |
| | | |
| | | //结束层 |
| | | private Integer targetLev; |
| | | |
| | | } |
| | |
| | | // 轻重类型{0:未知,1:轻库位,2:重库位} |
| | | private Short locType3; |
| | | |
| | | //库位搜索范围 |
| | | private LocRangeDto locRangeDto; |
| | | |
| | | public LocTypeDto() { |
| | | } |
| | | |
| | |
| | | package com.zy.asrs.common.domain.param; |
| | | |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | |
| | | // 物料列表数据 |
| | | private List<MatCodeStore> list; |
| | | |
| | | //库位搜索范围 |
| | | private LocRangeDto locRangeDto; |
| | | |
| | | @Data |
| | | public static class MatCodeStore { |
| | | |
| | | // 物料编号 |
| | | private String matnr; |
| | | |
| | | // 序列码 |
| | | // 批号 |
| | | private String batch; |
| | | |
| | | // 物料数量 |
| | |
| | | package com.zy.asrs.common.domain.param; |
| | | |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | |
| | | private Long hostId; |
| | | |
| | | //库位搜索范围 |
| | | private LocRangeDto locRangeDto; |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.utils; |
| | | |
| | | import com.zy.asrs.common.wms.service.LocDirectionService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | |
| | | import java.security.SecureRandom; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/27 |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 获取库位组 |
| | | */ |
| | | public static List<String> getGroupLoc(String locNo, Long hostId) { |
| | | int row = getRow(locNo); |
| | | List<String> result = new ArrayList<>(); |
| | | LocDirectionService locDirectionService = SpringUtils.getBean(LocDirectionService.class); |
| | | List<ArrayList<Integer>> naturalList = locDirectionService.getNaturalList(hostId); |
| | | for (ArrayList<Integer> list : naturalList) { |
| | | if (list.contains(row)) { |
| | | for (Integer row0 : list) { |
| | | result.add(zerofill(String.valueOf(row0), 2) + locNo.substring(2)); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取外侧方向的库位组 |
| | | */ |
| | | public static List<String> getGroupOuterLoc(String locNo, Long hostId) { |
| | | int row = getRow(locNo); |
| | | List<String> result = new ArrayList<>(); |
| | | LocDirectionService locDirectionService = SpringUtils.getBean(LocDirectionService.class); |
| | | List<ArrayList<Integer>> outerList = locDirectionService.getOuterList(hostId); |
| | | for (ArrayList<Integer> list : outerList) { |
| | | if (list.contains(row)) { |
| | | for (Integer row0 : list) { |
| | | if (row0 == row) { |
| | | break; |
| | | } |
| | | result.add(zerofill(String.valueOf(row0), 2) + locNo.substring(2)); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取内侧方向的库位组 |
| | | */ |
| | | public static List<String> getGroupInnerLoc(String locNo, Long hostId) { |
| | | int row = getRow(locNo); |
| | | List<String> result = new ArrayList<>(); |
| | | LocDirectionService locDirectionService = SpringUtils.getBean(LocDirectionService.class); |
| | | List<ArrayList<Integer>> innerList = locDirectionService.getInnerList(hostId); |
| | | for (ArrayList<Integer> list : innerList) { |
| | | if (list.contains(row)) { |
| | | for (Integer row0 : list) { |
| | | if (row0 == row) { |
| | | break; |
| | | } |
| | | result.add(zerofill(String.valueOf(row0), 2) + locNo.substring(2)); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.utils; |
| | | |
| | | import com.zy.asrs.common.domain.dto.LocTypeDto; |
| | | import com.zy.asrs.common.wms.entity.LocMast; |
| | | |
| | | public class VersionUtils { |
| | | |
| | | /** |
| | | * 库位类型检测 |
| | | **/ |
| | | public static boolean checkLocType(LocMast loc, LocTypeDto dto){ |
| | | //库位类型必须和传入的库位信号一致 |
| | | if (loc.getLocType1().equals(dto.getLocType1())) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.wms.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.wms.entity.LocDirection; |
| | | import com.zy.asrs.common.wms.service.LocDirectionService; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.domain.KeyValueVo; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class LocDirectionController extends BaseController { |
| | | |
| | | @Autowired |
| | | private LocDirectionService locDirectionService; |
| | | |
| | | @RequestMapping(value = "/locDirection/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(locDirectionService.getById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDirection/page/auth") |
| | | @ManagerAuth |
| | | public R page(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam(required = false) String timeRange, |
| | | @RequestParam Map<String, Object> param) { |
| | | LambdaQueryWrapper<LocDirection> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(LocDirection::getHostId, getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(LocDirection::getId, condition); |
| | | } |
| | | return R.ok(locDirectionService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/locDirection/add/auth") |
| | | @ManagerAuth |
| | | public R add(LocDirection locDirection) { |
| | | locDirection.setHostId(getHostId()); |
| | | locDirectionService.save(locDirection); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDirection/update/auth") |
| | | @ManagerAuth |
| | | public R update(LocDirection locDirection){ |
| | | if (Cools.isEmpty(locDirection) || null==locDirection.getId()){ |
| | | return R.error(); |
| | | } |
| | | locDirectionService.updateById(locDirection); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDirection/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | locDirectionService.removeById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDirectionQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | LambdaQueryWrapper<LocDirection> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(LocDirection::getHostId, getHostId()); |
| | | wrapper.like(LocDirection::getId, condition); |
| | | Page<LocDirection> page = locDirectionService.page(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (LocDirection locDirection : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", locDirection.getId()); |
| | | map.put("value", locDirection.getId()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping("/locDirection/all/get/kv") |
| | | @ManagerAuth |
| | | public R getDataKV(@RequestParam(required = false) String condition) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<LocDirection> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(LocDirection::getHostId, getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(LocDirection::getId, condition); |
| | | } |
| | | locDirectionService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId()))); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.wms.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.common.sys.entity.User; |
| | | import com.zy.asrs.common.sys.entity.Host; |
| | | import com.zy.asrs.common.sys.service.UserService; |
| | | import com.zy.asrs.common.sys.service.HostService; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("common_loc_direction") |
| | | public class LocDirection implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 方向类型 |
| | | */ |
| | | @ApiModelProperty(value= "方向类型") |
| | | private String type; |
| | | |
| | | /** |
| | | * 排序数据 |
| | | */ |
| | | @ApiModelProperty(value= "排序数据") |
| | | private String data; |
| | | |
| | | /** |
| | | * 授权商户 |
| | | */ |
| | | @ApiModelProperty(value= "授权商户") |
| | | private Long hostId; |
| | | |
| | | public LocDirection() {} |
| | | |
| | | public LocDirection(String type,String data,Long hostId) { |
| | | this.type = type; |
| | | this.data = data; |
| | | this.hostId = hostId; |
| | | } |
| | | |
| | | // LocDirection locDirection = new LocDirection( |
| | | // null, // 方向类型 |
| | | // null, // 排序数据 |
| | | // null // 授权商户 |
| | | // ); |
| | | |
| | | public String getHostId$(){ |
| | | HostService service = SpringUtils.getBean(HostService.class); |
| | | Host host = service.getById(this.hostId); |
| | | if (!Cools.isEmpty(host)){ |
| | | return String.valueOf(host.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | List<ReportStockDto> getReportStockDto(Long hostId); |
| | | |
| | | List<String> selectSameDetl(@Param("matnr") String matnr, @Param("batch") String batch, @Param("hostId") Long hostId); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.wms.mapper; |
| | | |
| | | import com.zy.asrs.common.wms.entity.LocDirection; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface LocDirectionMapper extends BaseMapper<LocDirection> { |
| | | |
| | | } |
| | |
| | | @Select("select loc_no from common_loc_mast where 1=1 and loc_sts = 'O' and host_id = #{hostId}") |
| | | List<String> queryGroupEmptyStock(Long hostId); |
| | | |
| | | List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd, Long hostId); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.wms.mapper; |
| | | |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | List<WrkMast> selectToBeHistoryData(); |
| | | |
| | | List<WrkMast> selectSameLevMatnrs(@Param("matnr") String matnr, @Param("batch") String batch, @Param("locRangeDto") LocRangeDto locRangeDto, @Param("hostId") Long hostId); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.wms.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.domain.dto.LocTypeDto; |
| | | import com.zy.asrs.common.domain.dto.StartupDto; |
| | | import com.zy.asrs.common.domain.entity.StaDesc; |
| | | import com.zy.asrs.common.sys.service.StaDescService; |
| | | import com.zy.asrs.common.utils.VersionUtils; |
| | | import com.zy.asrs.common.wms.entity.*; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private LocRuleService locRuleService; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | * 检索库位号 |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, Long hostId, LocTypeDto locTypeDto, int times) { |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matnrs, String batch, Long hostId, LocTypeDto locTypeDto, int times) { |
| | | // 目标库位 |
| | | LocMast locMast = null; |
| | | |
| | | // 靠近摆放规则 --- 空托 |
| | | locMast = getLocNoStep4(staDescId, locTypeDto, sourceStaNo); |
| | | locMast = getLocNoEmptyPakIn(staDescId, locTypeDto, sourceStaNo, hostId); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | // //库位规则 |
| | | // locMast = getLocNoStepRule(matnr, locTypeDto, staDescId, sourceStaNo); |
| | | // if (locMast != null) { |
| | | // //找到库位,返回dto |
| | | // return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | // } |
| | | //库位规则 |
| | | locMast = getLocNoStepRule(matnrs, batch, locTypeDto, hostId); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | // // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | // locMast = getLocNoStep3(staDescId, matnr, batch, grade, locTypeDto, sourceStaNo); |
| | | // if (locMast != null) { |
| | | // //找到库位,返回dto |
| | | // return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | // } |
| | | // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | locMast = getLocNoNearPlace(staDescId, matnrs, batch, locTypeDto, sourceStaNo, hostId); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | //搜索整个空库位组 |
| | | locMast = getLocNoStepSingle(locTypeDto, staDescId, sourceStaNo, hostId); |
| | |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | |
| | | // /** |
| | | // * 库位规则 |
| | | // */ |
| | | // private LocMast getLocNoStepRule(String matnr, LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo) { |
| | | // LocMast locMast = null; |
| | | // |
| | | // // 库区锁定 |
| | | // List<LocRule> locRules = locRuleService.find(matnr); |
| | | // if (locRules == null || locRules.isEmpty()) { |
| | | // return null;//没有库位规则,跳出当前任务 |
| | | // } |
| | | // |
| | | // // 获取目标站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", staDescId) |
| | | // .eq("stn_no", sourceStaNo); |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (staDesc == null) { |
| | | // throw new CoolException("入库路径不存在"); |
| | | // } |
| | | // |
| | | // for (LocRule locRule : locRules) { |
| | | // if (locRule == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd(), staDesc.getCrnNo()); |
| | | // for (LocMast locMast0 : locMasts) { |
| | | // //预留空库位 |
| | | // if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | // return locMast0; |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // if (locRules.get(0).getKeepGo() == 0) { |
| | | // //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | // //找不到库位,抛出异常 |
| | | // throw new CoolException("规则区域没有空库位"); |
| | | // } |
| | | // |
| | | // return locMast; |
| | | // } |
| | | /** |
| | | * 库位规则 |
| | | */ |
| | | private LocMast getLocNoStepRule(List<String> matnrs, String batch, LocTypeDto locTypeDto, Long hostId) { |
| | | if (matnrs.size() != 1) { |
| | | return null; |
| | | } |
| | | String matnr = matnrs.get(0); |
| | | LambdaQueryWrapper<LocRule> wrapper = new LambdaQueryWrapper<LocRule>() |
| | | .eq(LocRule::getHostId, hostId) |
| | | .eq(LocRule::getMatnr, matnr); |
| | | if (batch != null) { |
| | | wrapper.eq(LocRule::getBatch, batch); |
| | | } |
| | | List<LocRule> locRules = locRuleService.list(wrapper); |
| | | if (locRules == null || locRules.isEmpty()) { |
| | | return null;//没有库位规则,跳出当前任务 |
| | | } |
| | | |
| | | // // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | // private LocMast getLocNoStep3(Integer staDescId, String matnr, String batch, String grade, LocTypeDto locTypeDto, Integer sourceStaNo) { |
| | | // LocMast locMast = null; |
| | | // if (staDescId == 1) { |
| | | // // 获取目标站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", staDescId) |
| | | // .eq("stn_no", sourceStaNo); |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (staDesc == null) { |
| | | // throw new CoolException("入库路径不存在"); |
| | | // } |
| | | // |
| | | // //先判断工作档,查找主档IOType=1, wrkSts < 10的工作明细,料号相同的明细库位 |
| | | // List<WrkMast> wrkMasts = wrkMastService.selectSameMatnrs(matnr, batch, grade, staDesc.getCrnNo()); |
| | | // for (WrkMast wrkMast : wrkMasts) { |
| | | // LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo()); |
| | | // if (null != locMast0) { |
| | | // // 浅库位符合尺寸检测 |
| | | // if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | // locMast = locMast0; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (Cools.isEmpty(locMast)) { |
| | | // //再判断库存明细档,料号相同的明细库位 |
| | | // List<String> locNos = locDetlService.getSameDetl(matnr, batch, grade, staDesc.getCrnNo()); |
| | | // for (String locNo : locNos) { |
| | | // LocMast locMast0 = locMastService.findNearloc(locNo); |
| | | // if (null != locMast0) { |
| | | // // 浅库位符合尺寸检测 |
| | | // if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | // locMast = locMast0; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // return locMast; |
| | | // } |
| | | for (LocRule locRule : locRules) { |
| | | if (locRule == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd(), hostId); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10, hostId)) { |
| | | return locMast0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (locRules.get(0).getKeepGo() == 0) { |
| | | //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("规则区域没有空库位"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | private LocMast getLocNoNearPlace(Integer staDescId, List<String> matnrs, String batch, LocTypeDto locTypeDto, Integer sourceStaNo, Long hostId) { |
| | | LocMast locMast = null; |
| | | if (staDescId == 1) { |
| | | // 获取目标站 |
| | | LambdaQueryWrapper<StaDesc> wrapper = new LambdaQueryWrapper<StaDesc>() |
| | | .eq(StaDesc::getTypeNo, staDescId) |
| | | .eq(StaDesc::getStnNo, sourceStaNo) |
| | | .eq(StaDesc::getHostId, hostId); |
| | | StaDesc staDesc = staDescService.getOne(wrapper); |
| | | if (staDesc == null) { |
| | | throw new CoolException("入库路径不存在"); |
| | | } |
| | | |
| | | String matnr = matnrs.get(0); |
| | | |
| | | //库位搜索范围 |
| | | LocRangeDto locRangeDto = locTypeDto.getLocRangeDto(); |
| | | |
| | | //先判断工作档,查找主档IOType=1, wrkSts < 10的工作明细,料号相同的明细库位 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectSameMatnrs(matnr, batch, locTypeDto.getLocRangeDto(), hostId); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo(), hostId, locRangeDto); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | } |
| | | } |
| | | } |
| | | if (Cools.isEmpty(locMast)) { |
| | | //再判断库存明细档,料号相同的明细库位 |
| | | List<String> locNos = locDetlService.getSameDetl(matnr, batch, hostId); |
| | | for (String locNo : locNos) { |
| | | LocMast locMast0 = locMastService.findNearloc(locNo, hostId, locRangeDto); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 空托 |
| | | private LocMast getLocNoStep4(Integer staDescId, LocTypeDto locTypeDto, Integer sourceStaNo) { |
| | | private LocMast getLocNoEmptyPakIn(Integer staDescId, LocTypeDto locTypeDto, Integer sourceStaNo, Long hostId) { |
| | | LocMast locMast = null; |
| | | // 靠近摆放规则 --- 空托 |
| | | if (staDescId == 10) { |
| | | // 获取目标站 |
| | | LambdaQueryWrapper<StaDesc> wrapper = new LambdaQueryWrapper<StaDesc>() |
| | | .eq(StaDesc::getTypeNo, staDescId) |
| | | .eq(StaDesc::getStnNo, sourceStaNo); |
| | | .eq(StaDesc::getStnNo, sourceStaNo) |
| | | .eq(StaDesc::getHostId,hostId); |
| | | StaDesc staDesc = staDescService.getOne(wrapper); |
| | | if (staDesc == null) { |
| | | throw new CoolException("入库路径不存在"); |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>() |
| | | LambdaQueryWrapper<LocMast> wrapper1 = new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocSts, "O") |
| | | .eq(LocMast::getLocType1, 1) |
| | | .eq(LocMast::getCrnNo, staDesc.getDeviceNo()) |
| | | .orderByAsc(LocMast::getLev1, LocMast::getBay1, LocMast::getRow1)); |
| | | .eq(LocMast::getHostId, hostId) |
| | | .orderByAsc(LocMast::getLev1, LocMast::getBay1, LocMast::getRow1); |
| | | |
| | | //库位搜索范围 |
| | | LocRangeDto locRangeDto = locTypeDto.getLocRangeDto(); |
| | | if (locRangeDto != null) { |
| | | wrapper1.ge(LocMast::getRow1, locRangeDto.getStartRow()); |
| | | wrapper1.le(LocMast::getRow1, locRangeDto.getTargetRow()); |
| | | wrapper1.ge(LocMast::getBay1, locRangeDto.getStartBay()); |
| | | wrapper1.le(LocMast::getBay1, locRangeDto.getTargetBay()); |
| | | wrapper1.ge(LocMast::getLev1, locRangeDto.getStartLev()); |
| | | wrapper1.le(LocMast::getLev1, locRangeDto.getTargetLev()); |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.list(wrapper1); |
| | | if (!locMasts.isEmpty()) { |
| | | for (LocMast loc : locMasts) { |
| | | // LocMast locMast0 = locMastService.findNearloc(loc.getLocNo()); |
| | | // if (null != locMast0) { |
| | | // locMast = locMast0; |
| | | // break; |
| | | // } |
| | | locMast = loc; |
| | | break; |
| | | LocMast locMast0 = locMastService.findNearloc(loc.getLocNo(), hostId, locRangeDto); |
| | | if (null != locMast0) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("入库路径不存在"); |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocSts, "O").eq(LocMast::getHostId, hostId));//搜索货物 |
| | | |
| | | if (locMasts == null) { |
| | | return null; |
| | | LambdaQueryWrapper<LocMast> wrapper1 = new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocSts, "O") |
| | | .eq(LocMast::getHostId, hostId); |
| | | //库位搜索范围 |
| | | LocRangeDto locRangeDto = locTypeDto.getLocRangeDto(); |
| | | if (locRangeDto != null) { |
| | | wrapper1.ge(LocMast::getRow1, locRangeDto.getStartRow()); |
| | | wrapper1.le(LocMast::getRow1, locRangeDto.getTargetRow()); |
| | | wrapper1.ge(LocMast::getBay1, locRangeDto.getStartBay()); |
| | | wrapper1.le(LocMast::getBay1, locRangeDto.getTargetBay()); |
| | | wrapper1.ge(LocMast::getLev1, locRangeDto.getStartLev()); |
| | | wrapper1.le(LocMast::getLev1, locRangeDto.getTargetLev()); |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.list(wrapper1);//搜索货物 |
| | | for (LocMast mast : locMasts) { |
| | | locMast = mast; |
| | | break; |
| | | if (VersionUtils.checkLocType(mast, locTypeDto)) { |
| | | locMast = mast; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |
| | |
| | | |
| | | List<ReportStockDto> getReportStockDto(Long hostId); |
| | | |
| | | /** |
| | | * 获取相同规格货物的深库位号 |
| | | */ |
| | | List<String> getSameDetl(String matnr, String batch, Long hostId); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.wms.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.wms.entity.LocDirection; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public interface LocDirectionService extends IService<LocDirection> { |
| | | |
| | | List<ArrayList<Integer>> getInnerList(Long hostId); |
| | | |
| | | List<ArrayList<Integer>> getOuterList(Long hostId); |
| | | |
| | | List<ArrayList<Integer>> getNaturalList(Long hostId); |
| | | |
| | | List<ArrayList<Integer>> parseData(List<LocDirection> origin); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.wms.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.wms.entity.LocMast; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | List<String> queryGroupEmptyStock(String sourceLocNo, Long hostId); |
| | | |
| | | /** |
| | | * 检索可用库位 |
| | | */ |
| | | List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd, Long hostId); |
| | | |
| | | /** |
| | | * 检查当前库位所属巷道的空库位数量 |
| | | */ |
| | | Boolean checkEmptyCount(LocMast locMast, int quaOfBlank, Long hostId); |
| | | |
| | | LocMast findNearloc(String locNo, Long hostId, LocRangeDto locRangeDto); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.common.wms.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | WrkMast selectByBarcode(String barcode, Long hostId); |
| | | |
| | | List<WrkMast> selectSameMatnrs(String matnr, String batch, LocRangeDto locRangeDto, Long hostId); |
| | | |
| | | } |
| | |
| | | public List<ReportStockDto> getReportStockDto(Long hostId) { |
| | | return this.baseMapper.getReportStockDto(hostId); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getSameDetl(String matnr, String batch, Long hostId) { |
| | | return this.baseMapper.selectSameDetl(matnr, batch, hostId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.wms.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.wms.mapper.LocDirectionMapper; |
| | | import com.zy.asrs.common.wms.entity.LocDirection; |
| | | import com.zy.asrs.common.wms.service.LocDirectionService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service("locDirectionService") |
| | | public class LocDirectionServiceImpl extends ServiceImpl<LocDirectionMapper, LocDirection> implements LocDirectionService { |
| | | |
| | | @Override |
| | | public List<ArrayList<Integer>> getInnerList(Long hostId) { |
| | | List<LocDirection> inner = this.list(new LambdaQueryWrapper<LocDirection>() |
| | | .eq(LocDirection::getHostId, hostId) |
| | | .eq(LocDirection::getType, "inner")); |
| | | return this.parseData(inner); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArrayList<Integer>> getOuterList(Long hostId) { |
| | | List<LocDirection> outer = this.list(new LambdaQueryWrapper<LocDirection>() |
| | | .eq(LocDirection::getHostId, hostId) |
| | | .eq(LocDirection::getType, "outer")); |
| | | return this.parseData(outer); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArrayList<Integer>> getNaturalList(Long hostId) { |
| | | List<LocDirection> natural = this.list(new LambdaQueryWrapper<LocDirection>() |
| | | .eq(LocDirection::getHostId, hostId) |
| | | .eq(LocDirection::getType, "natural")); |
| | | return this.parseData(natural); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArrayList<Integer>> parseData(List<LocDirection> origin) { |
| | | ArrayList<ArrayList<Integer>> data = new ArrayList<>(); |
| | | for (LocDirection direction : origin) { |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | String[] split = direction.getData().split(","); |
| | | for (String row : split) { |
| | | list.add(Integer.parseInt(row)); |
| | | } |
| | | data.add(list); |
| | | } |
| | | return data; |
| | | } |
| | | } |
| | |
| | | package com.zy.asrs.common.wms.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.utils.Utils; |
| | | import com.zy.asrs.common.wms.mapper.LocMastMapper; |
| | | import com.zy.asrs.common.wms.entity.LocMast; |
| | | import com.zy.asrs.common.wms.service.LocMastService; |
| | |
| | | return this.baseMapper.queryGroupEmptyStock(hostId); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd, Long hostId) { |
| | | return this.baseMapper.queryFreeLocMast2(locType1, rowBeg, rowEnd, bayBeg, bayEnd, levBeg, levEnd, hostId); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean checkEmptyCount(LocMast locMast, int quaOfBlank, Long hostId) { |
| | | if (locMast == null) { |
| | | return false; |
| | | } |
| | | int count = this.baseMapper.selectCount(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocSts, 'O') |
| | | // .eq(LocMast::getLocType3, locMast.getLocType3()) |
| | | .eq(LocMast::getLev1, locMast.getLev1()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | return count > quaOfBlank; |
| | | } |
| | | |
| | | @Override |
| | | public LocMast findNearloc(String locNo, Long hostId, LocRangeDto locRangeDto) { |
| | | LocMast locMast = null; |
| | | List<String> groupOuterLoc = Utils.getGroupOuterLoc(locNo, hostId); |
| | | if (!Cools.isEmpty(groupOuterLoc)) { |
| | | LambdaQueryWrapper<LocMast> wrapper = new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocSts, 'O') |
| | | .in(LocMast::getLocNo, groupOuterLoc) |
| | | .eq(LocMast::getHostId, hostId) |
| | | .orderByAsc(LocMast::getRow1); |
| | | //库位搜索范围 |
| | | if (locRangeDto != null) { |
| | | wrapper.ge(LocMast::getRow1, locRangeDto.getStartRow()); |
| | | wrapper.le(LocMast::getRow1, locRangeDto.getTargetRow()); |
| | | wrapper.ge(LocMast::getBay1, locRangeDto.getStartBay()); |
| | | wrapper.le(LocMast::getBay1, locRangeDto.getTargetBay()); |
| | | wrapper.ge(LocMast::getLev1, locRangeDto.getStartLev()); |
| | | wrapper.le(LocMast::getLev1, locRangeDto.getTargetLev()); |
| | | } |
| | | locMast = this.getOne(wrapper, false); |
| | | } |
| | | return locMast; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/6/11 |
| | |
| | | } |
| | | Date now = new Date(); |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), hostId, locTypeDto, 0); |
| | | locTypeDto.setLocRangeDto(param.getLocRangeDto()); |
| | | List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | String batch = param.getList().get(0).getBatch(); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), matnrs, batch, hostId, locTypeDto, 0); |
| | | // 生成工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | |
| | | package com.zy.asrs.common.wms.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.domain.dto.LocRangeDto; |
| | | import com.zy.asrs.common.wms.mapper.WrkMastMapper; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | | import com.zy.asrs.common.wms.service.WrkMastService; |
| | |
| | | } |
| | | return wrkMasts.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectSameMatnrs(String matnr, String batch, LocRangeDto locRangeDto, Long hostId) { |
| | | return this.baseMapper.selectSameLevMatnrs(matnr, batch, locRangeDto, hostId); |
| | | } |
| | | } |
| | |
| | | group by matnr,batch |
| | | </select> |
| | | |
| | | <select id="selectSameDetl" resultType="java.lang.String"> |
| | | SELECT |
| | | ld.loc_no |
| | | FROM wms_loc_detl ld |
| | | LEFT JOIN common_loc_mast lm ON ld.loc_no = lm.loc_no and ld.host_id = lm.host_id |
| | | LEFT JOIN ( |
| | | select |
| | | loc_no, |
| | | count(1) as count |
| | | from wms_loc_detl |
| | | where 1=1 |
| | | and host_id = #{hostId} |
| | | group by loc_no |
| | | ) dual on dual.loc_no = lm.loc_no |
| | | WHERE 1 = 1 |
| | | AND ld.matnr = #{matnr} |
| | | <if test="batch"> |
| | | AND ld.batch = #{batch} |
| | | </if> |
| | | AND (lm.loc_sts = 'F') |
| | | AND dual.count = 1 |
| | | AND lm.host_id = #{hostId} |
| | | ORDER BY lm.modi_time ASC |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.common.wms.mapper.LocDirectionMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.common.wms.mapper.LocMastMapper"> |
| | | |
| | | <select id="queryFreeLocMast2" resultType="com.zy.asrs.common.wms.entity.LocMast"> |
| | | select * |
| | | from common_loc_mast |
| | | where 1=1 |
| | | and loc_sts='O' |
| | | <if test="locType1 != null"> |
| | | and loc_type1 = #{locType1} |
| | | </if> |
| | | <if test="rowBeg != null"> |
| | | and row1 >= #{rowBeg} |
| | | </if> |
| | | <if test="rowEnd != null"> |
| | | and row1 <= #{rowEnd} |
| | | </if> |
| | | <if test="bayBeg != null"> |
| | | and bay1 >= #{bayBeg} |
| | | </if> |
| | | <if test="bayEnd != null"> |
| | | and bay1 <= #{bayEnd} |
| | | </if> |
| | | <if test="levBeg != null"> |
| | | and lev1 >= #{levBeg} |
| | | </if> |
| | | <if test="levEnd != null"> |
| | | and lev1 <= #{levEnd} |
| | | </if> |
| | | <if test="hostId != null"> |
| | | and host_id = #{hostId} |
| | | </if> |
| | | -- and loc_no not in ('0100101') |
| | | order by loc_sts desc ,lev1 asc,bay1 asc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | order by io_time,wrk_no asc |
| | | </select> |
| | | |
| | | <select id="selectSameLevMatnrs" resultType="com.zy.asrs.common.wms.entity.WrkMast"> |
| | | select m.loc_no |
| | | from wms_wrk_mast m, |
| | | wms_wrk_detl d, |
| | | common_loc_mast lm |
| | | where m.id = d.wrk_mast_id |
| | | and m.loc_no = lm.loc_no |
| | | and m.host_id = lm.host_id |
| | | and io_type = 1 |
| | | and wrk_sts < 99 |
| | | and d.matnr = #{matnr} |
| | | <if test="batch != null and batch != ''"> |
| | | and d.batch = #{batch} |
| | | </if> |
| | | <if test="hostId != null"> |
| | | and lm.host_id = #{hostId} |
| | | </if> |
| | | <if test="locRangeDto != null"> |
| | | <if test="locRangeDto.startRow"> |
| | | and lm.row1 >= #{locRangeDto.startRow} |
| | | </if> |
| | | <if test="locRangeDto.targetRow"> |
| | | and lm.row1 <= #{locRangeDto.targetRow} |
| | | </if> |
| | | <if test="locRangeDto.startBay"> |
| | | and lm.bay1 >= #{locRangeDto.startBay} |
| | | </if> |
| | | <if test="locRangeDto.targetBay"> |
| | | and lm.bay1 <= #{locRangeDto.targetBay} |
| | | </if> |
| | | <if test="locRangeDto.startLev"> |
| | | and lm.lev1 >= #{locRangeDto.startLev} |
| | | </if> |
| | | <if test="locRangeDto.targetLev"> |
| | | and lm.lev1 <= #{locRangeDto.targetLev} |
| | | </if> |
| | | </if> |
| | | ORDER BY m.wrk_no desc; |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getSourceStaNo(), true, hostId); |
| | | sourceStaNo.setLocType1(param.getLocType1()); |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | locTypeDto.setLocRangeDto(param.getLocRangeDto()); |
| | | |
| | | StartupDto dto = null; |
| | | switch (param.getIoType()) { |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true, hostId); |
| | | // 检索库位 |
| | | List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(1, devpNo, hostId, locTypeDto, 0); |
| | | String batch = waitPakins.get(0).getBatch(); |
| | | StartupDto dto = commonService.getLocNo(1, devpNo, matNos, batch, hostId, locTypeDto, 0); |
| | | int workNo = dto.getWorkNo(); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true, hostId); |
| | | // 检索库位 |
| | | StartupDto dto = commonService.getLocNo(10, devpNo, hostId, locTypeDto, 0); |
| | | StartupDto dto = commonService.getLocNo(10, devpNo, null, null, hostId, locTypeDto, 0); |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
New file |
| | |
| | | var pageCurr; |
| | | var pageCount = 0; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['table','laydate', 'form', 'admin', 'xmSelect'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | var xmSelect = layui.xmSelect; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#locDirection', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/locDirection/page/auth', |
| | | page: true, |
| | | limit: 15, |
| | | limits: [15, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | height: 'full-120', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{field: 'id', align: 'center',title: 'ID'} |
| | | ,{field: 'type', align: 'center',title: '方向类型'} |
| | | ,{field: 'data', align: 'center',title: '排序数据'} |
| | | ,{field: 'hostId$', align: 'center',title: '授权商户'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr;pageCount=count; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(locDirection)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: 1} |
| | | }); |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(locDirection)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id).data; |
| | | switch(obj.event) { |
| | | case 'addData': |
| | | showEditModel(); |
| | | break; |
| | | case 'deleteData': |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | | return d.id; |
| | | })); |
| | | break; |
| | | case 'exportData': |
| | | admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'locDirection': exportData, |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/locDirection/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(locDirection)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | case 'edit': |
| | | showEditModel(data); |
| | | break; |
| | | case "del": |
| | | del([data.id]); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | /* 弹窗 - 新增、修改 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | form.val('detail', mData); |
| | | layDateRender(mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/locDirection/"+(mData?'update':'add')+"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /* 删除 */ |
| | | function del(ids) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/locDirection/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | // 搜索 |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | tableReload(true); |
| | | }); |
| | | |
| | | // 重置 |
| | | form.on('submit(reset)', function (data) { |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | tableReload(true); |
| | | }); |
| | | |
| | | // 时间选择器 |
| | | function layDateRender(data) { |
| | | setTimeout(function () { |
| | | layDate.render({ |
| | | elem: '.layui-laydate-range' |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | }); |
| | | |
| | | }, 100); |
| | | } |
| | | layDateRender(); |
| | | |
| | | window.loadHostSel = function () { |
| | | return xmSelect.render({ |
| | | el: '#hostXmlSel', |
| | | autoRow: true, |
| | | filterable: true, |
| | | remoteSearch: true, |
| | | radio: true, |
| | | remoteMethod: function (val, cb, show) { |
| | | $.ajax({ |
| | | url: baseUrl + "/host/all/get/kv", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | condition: val |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | cb(res.data) |
| | | } else { |
| | | cb([]); |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload(search) { |
| | | if (pageCount === 0 || search) { |
| | | let searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: pageCurr} |
| | | }); |
| | | } else { |
| | | $(".layui-laypage-btn")[0].click(); |
| | | } |
| | | } |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title></title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | </head> |
| | | <body> |
| | | |
| | | <div class="layui-fluid"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <div class="layui-form toolbar" id="search-box"> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline" style="width: 300px"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input layui-laydate-range" name="timeRange" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline">  |
| | | <button class="layui-btn icon-btn" lay-filter="search" lay-submit> |
| | | <i class="layui-icon"></i>搜索 |
| | | </button> |
| | | <button class="layui-btn icon-btn" lay-filter="reset" lay-submit> |
| | | <i class="layui-icon"></i>重置 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <table class="layui-hide" id="locDirection" lay-filter="locDirection"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">新增</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">删除</button> |
| | | <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">导出</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/locDirection/locDirection.js" charset="utf-8"></script> |
| | | </body> |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editDialog"> |
| | | <div id="detail" lay-filter="detail" class="layui-form admin-form model-form"> |
| | | <input name="id" type="hidden"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">方向类型: </label> |
| | | <div class="layui-input-block"> |
| | | <select name="type"> |
| | | <option value="inner">inner</option> |
| | | <option value="outer">outer</option> |
| | | <option value="natural">natural</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">排序数据: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="data" placeholder="请输入排序数据"> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-form-item">--> |
| | | <!-- <label class="layui-form-label">授权商户: </label>--> |
| | | <!-- <div class="layui-input-block cool-auto-complete">--> |
| | | <!-- <input class="layui-input" name="hostId" placeholder="请输入授权商户" style="display: none">--> |
| | | <!-- <input id="hostId$" name="hostId$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入授权商户" onfocus=this.blur()>--> |
| | | <!-- <div class="cool-auto-complete-window">--> |
| | | <!-- <input class="cool-auto-complete-window-input" data-key="hostQueryByhostId" onkeyup="autoLoad(this.getAttribute('data-key'))">--> |
| | | <!-- <select class="cool-auto-complete-window-select" data-key="hostQueryByhostIdSelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple">--> |
| | | <!-- </select>--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </div> |
| | | </script> |
| | | </html> |
| | | |