add:任务管理,任务配置,区域管理,点位管理

This commit is contained in:
2025-05-22 09:34:12 +08:00
parent d0c8cc6f03
commit de9098f68a
22 changed files with 2308 additions and 3 deletions

View File

@@ -0,0 +1,78 @@
package org.nl.wms.sch_manage.controller;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Set;
/**
* @author Liuxy
* @date 2025-05-20
**/
@Slf4j
@RestController
@RequestMapping("/api/schBasePoint")
public class SchBasePointController {
@Autowired
private ISchBasePointService schBasePointService;
@GetMapping
@Log("查询点位管理")
public ResponseEntity<Object> query(SchBasePointQuery whereJson, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(schBasePointService.queryAll(whereJson, page)), HttpStatus.OK);
}
@PostMapping
@Log("新增点位管理")
public ResponseEntity<Object> create(@Validated @RequestBody SchBasePoint entity) {
schBasePointService.create(entity);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改点位管理")
public ResponseEntity<Object> update(@Validated @RequestBody SchBasePoint entity) {
schBasePointService.update(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除点位管理")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
schBasePointService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("启动与禁用")
@PostMapping("/changeUsed")
public ResponseEntity<Object> changeUsedOn(@RequestBody JSONObject jsonObject) {
schBasePointService.changeUsed(jsonObject);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping("/getPointList")
@Log("获取区域下拉框")
public ResponseEntity<Object> getPointList(@RequestBody(required = false) SchBasePoint region) {
return new ResponseEntity<>(schBasePointService.getPointList(region), HttpStatus.OK);
}
@Log("锁定与解锁")
@PostMapping("/changeLock")
public ResponseEntity<Object> changeLock(@RequestBody JSONObject points) {
schBasePointService.changeLock(points);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

View File

@@ -0,0 +1,76 @@
package org.nl.wms.sch_manage.controller;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Set;
/**
* @author Liuxy
* @date 2025-05-20
**/
@Slf4j
@RestController
@RequestMapping("/api/schBaseRegion")
public class SchBaseRegionController {
@Autowired
private ISchBaseRegionService regionService;
@GetMapping
@Log("查询区域管理")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(regionService.queryAll(whereJson, page)), HttpStatus.OK);
}
@PostMapping
@Log("新增区域管理")
public ResponseEntity<Object> create(@Validated @RequestBody SchBaseRegion entity) {
regionService.create(entity);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改区域管理")
public ResponseEntity<Object> update(@Validated @RequestBody SchBaseRegion entity) {
regionService.update(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除区域管理")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
regionService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/getRegionList")
@Log("获取区域下拉框")
public ResponseEntity<Object> getRegionList(@RequestBody(required = false) SchBaseRegion region) {
return new ResponseEntity<>(regionService.getRegionList(region), HttpStatus.OK);
}
@PostMapping("/getPointStatusSelectById")
@Log("获取点位状态下拉框")
public ResponseEntity<Object> getPointStatusSelectById(@RequestBody String region_id) {
return new ResponseEntity<>(regionService.getPointStatusSelectById(region_id), HttpStatus.OK);
}
@PostMapping("/getPointTypeSelectById")
@Log("获取点位类型下拉框")
public ResponseEntity<Object> getPointTypeSelectById(@RequestBody String region_id) {
return new ResponseEntity<>(regionService.getPointTypeSelectById(region_id), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,29 @@
package org.nl.wms.sch_manage.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Author: Liuxy
* @Description:
* @Date: 2025/5/20
*/
@Getter
@AllArgsConstructor
public enum PointStatusEnum {
/**
* 空位/无货
*/
EMPTY_POINT("1", "空位/无货"),
/**
* 有料
*/
FULL_POINT("3", "有料"),
/**
* 空载具/有货
*/
EMPTY_VEHICLE("2", "空载具/有货");
private final String code;
private final String label;
}

View File

@@ -0,0 +1,86 @@
package org.nl.wms.sch_manage.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
import java.util.List;
import java.util.Set;
/**
* @author Liuxy
* @description 服务接口
* @date 2025-05-20
**/
public interface ISchBasePointService extends IService<SchBasePoint> {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param pageable 分页参数
* @return IPage<SchBasePoint>
*/
IPage<SchBasePoint> queryAll(SchBasePointQuery whereJson, PageQuery pageable);
/**
* 创建
*
* @param entity /
*/
void create(SchBasePoint entity);
/**
* 编辑
*
* @param entity /
*/
void update(SchBasePoint entity);
/**
* 多选删除
*
* @param ids /
*/
void deleteAll(Set<String> ids);
/**
* 改变启用状态
*
* @param jsonObject 参数
*/
void changeUsed(JSONObject jsonObject);
/**
* 获取点位
*
* @param region 参数
* @return List<SchBasePoint>
*/
List<SchBasePoint> getPointList(SchBasePoint region);
/**
* 解锁/上锁
*
* @param points 参数
*/
void changeLock(JSONObject points);
/**
* 获取所有未解锁的点位
*
* @return List<SchBasePoint>
*/
List<SchBasePoint> getAllUnlockAbnormalPoints();
/**
* 行锁获取对应点位
*
* @param id id
* @return SchBasePoint
*/
SchBasePoint selectByIdLock(String id);
}

View File

@@ -0,0 +1,73 @@
package org.nl.wms.sch_manage.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Liuxy
* @description 服务接口
* @date 2025-05-20
**/
public interface ISchBaseRegionService extends IService<SchBaseRegion> {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param pageable 分页参数
* @return IPage<SchBaseRegion>
*/
IPage<SchBaseRegion> queryAll(Map whereJson, PageQuery pageable);
/**
* 创建
*
* @param entity /
*/
void create(SchBaseRegion entity);
/**
* 编辑
*
* @param entity /
*/
void update(SchBaseRegion entity);
/**
* 多选删除
*
* @param ids /
*/
void deleteAll(Set<String> ids);
/**
* 区域下拉框
*
* @param region 区域
* @return /
*/
List<SchBaseRegion> getRegionList(SchBaseRegion region);
/**
* 获取点位状态下拉框
*
* @param regionId /
* @return /
*/
JSONArray getPointStatusSelectById(String regionId);
/**
* 获取点位类型下拉框
*
* @param regionId /
* @return /
*/
JSONArray getPointTypeSelectById(String regionId);
}

View File

@@ -0,0 +1,160 @@
package org.nl.wms.sch_manage.service.dao;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* @author Liuxy
* @description /
* @date 2025-05-20
**/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sch_base_point")
public class SchBasePoint implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "point_code")
private String point_code;
private String point_name;
private String region_code;
private String region_name;
private String point_type;
private String point_status;
private String can_material_type;
private String can_vehicle_type;
private Integer vehicle_max_qty;
private String vehicle_type;
private String vehicle_code;
private Integer vehicle_qty;
private Integer block_num;
private Integer row_num;
private Integer col_num;
private Integer layer_num;
private Integer in_order_seq;
private Integer out_order_seq;
private Integer in_empty_seq;
private Integer out_empty_seq;
private String parent_point_code;
private String ext_point_code;
private String ing_task_code;
private Boolean is_has_workder;
private String workshop_code;
private Boolean is_auto;
private String remark;
private Boolean is_used;
private String create_id;
private String create_name;
private String create_time;
private String update_id;
private String update_name;
private String update_time;
@TableField(exist = false)
private List<String> can_vehicle_types;
@TableField(exist = false)
private String point_type_name;
@TableField(exist = false)
private String point_status_name;
// 组盘标识
@TableField(exist = false)
private String group_id;
@TableField(exist = false)
private String record_id;
@TableField(exist = false)
private String device_code;
@TableField(exist = false)
private String material_qty;
@TableField(exist = false)
private String material_code;
@TableField(exist = false)
private String material_name;
@TableField(exist = false)
private String material_spec;
@TableField(exist = false)
private String material_model;
@TableField(exist = false)
private String raw_material_code;
@TableField(exist = false)
private String task_warn;
}

View File

@@ -0,0 +1,64 @@
package org.nl.wms.sch_manage.service.dao;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @author Liuxy
* @description /
* @date 2025-05-20
**/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sch_base_region")
public class SchBaseRegion implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "region_code")
private String region_code;
private String region_name;
private String point_type_explain;
private String point_status_explain;
private Boolean is_has_workder;
private String workshop_code;
private String remark;
private String create_id;
private String create_name;
private String create_time;
private String update_id;
private String update_name;
private String update_time;
private Integer order_seq;
}

View File

@@ -0,0 +1,47 @@
package org.nl.wms.sch_manage.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
import java.util.List;
/**
* @author Liuxy
* @date 2025-05-20
**/
public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
/**
* 批量禁用启用
*
* @param pointCodes 参数
* @param used 参数
*/
void batchChangeUsed(List<String> pointCodes, Boolean used);
/**
* 获得所有解锁异常点
*
* @return List<SchBasePoint>
*/
List<SchBasePoint> getAllUnlockAbnormalPoints();
/**
* 行锁获取id的点位
*
* @param id id
* @return SchBasePoint
*/
SchBasePoint selectByIdLock(String id);
/**
* 点位left join查询
*
* @param pages 参数
* @return IPage<SchBasePoint>
*/
IPage<SchBasePoint> selectPageLeftJoin(IPage<SchBasePoint> pages, SchBasePointQuery whereJson);
}

View File

@@ -0,0 +1,66 @@
<?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="org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper">
<update id="batchChangeUsed">
UPDATE sch_base_point
SET is_used = #{used}
<where>
point_code IN
<foreach collection="pointCodes" item="code" separator="," open="(" close=")">
#{code}
</foreach>
</where>
</update>
<select id="getAllUnlockAbnormalPoints" resultType="org.nl.wms.sch_manage.service.dao.SchBasePoint">
SELECT p.*
FROM `sch_base_point` p
LEFT JOIN sch_base_task t ON t.task_code = p.ing_task_code
WHERE p.ing_task_code IS NOT NULL
AND p.ing_task_code != '' AND (t.task_status = '5' OR t.task_status = '6')
</select>
<select id="selectByIdLock" resultType="org.nl.wms.sch_manage.service.dao.SchBasePoint">
SELECT p.*
FROM `sch_base_point` p
WHERE p.point_code = #{id}
FOR UPDATE
</select>
<select id="selectPageLeftJoin" resultType="org.nl.wms.sch_manage.service.dao.SchBasePoint"
parameterType="org.nl.wms.sch_manage.service.dto.SchBasePointQuery">
SELECT
p.*
FROM
`sch_base_point` p
<where>
<if test="whereJson.workshop_code != null and workshop_code != ''">
p.workshop_code = #{whereJson.workshop_code}
</if>
<if test="whereJson.blurry != null">
AND (p.point_code LIKE '%${whereJson.blurry}%' OR p.point_name LIKE '%${whereJson.blurry}%')
</if>
<if test="whereJson.region_code != null">
AND p.region_code = #{whereJson.region_code}
</if>
<if test="whereJson.point_type != null">
AND p.point_type = #{whereJson.point_type}
</if>
<if test="whereJson.point_status != null">
AND p.point_status = #{whereJson.point_status}
</if>
<if test="whereJson.is_used != null">
AND p.is_used = #{whereJson.is_used}
</if>
<choose>
<!-- Case: whereJson.lock_type is true -->
<when test="whereJson.lock_type">
AND (p.ing_task_code IS NOT NULL AND p.ing_task_code <![CDATA[<>]]> '')
</when>
<!-- Case: whereJson.lock_type is false -->
<otherwise>
AND (p.ing_task_code IS NULL OR p.ing_task_code = '')
</otherwise>
</choose>
</where>
ORDER BY p.region_code, p.point_code, p.point_type
</select>
</mapper>

View File

@@ -0,0 +1,12 @@
package org.nl.wms.sch_manage.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
/**
* @author Liuxy
* @date 2025-05-20
**/
public interface SchBaseRegionMapper extends BaseMapper<SchBaseRegion> {
}

View File

@@ -0,0 +1,5 @@
<?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="org.nl.wms.sch_manage.service.dao.mapper.SchBaseRegionMapper">
</mapper>

View File

@@ -0,0 +1,21 @@
package org.nl.wms.sch_manage.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author Liuxy
* @date 2025-05-20
**/
@Data
public class SchBasePointQuery implements Serializable {
private String blurry;
private String workshop_code;
private String region_code;
private String point_type;
private String point_status;
private Boolean is_used;
private Boolean lock_type;
private Boolean parent_point;
}

View File

@@ -0,0 +1,184 @@
package org.nl.wms.sch_manage.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.sch_manage.enums.PointStatusEnum;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper;
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseRegionMapper;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
import org.nl.wms.sch_manage.service.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Liuxy
* @description 服务实现
* @date 2025-05-20
**/
@Slf4j
@Service
public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, SchBasePoint> implements ISchBasePointService {
@Autowired
private SchBasePointMapper pointMapper;
@Autowired
private SchBaseRegionMapper regionMapper;
@Override
public IPage<SchBasePoint> queryAll(SchBasePointQuery whereJson, PageQuery page) {
IPage<SchBasePoint> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = pointMapper.selectPageLeftJoin(pages, whereJson);
// 可以存放的载具类型
pages.getRecords().forEach(point -> {
if (ObjectUtil.isNotEmpty(point.getCan_vehicle_type())) {
point.setCan_vehicle_types(Arrays.asList(point.getCan_vehicle_type().split(",")));
}
String pointStatus = point.getPoint_status(); // 点位状态
String pointType = point.getPoint_type(); // 点位类型
SchBaseRegion regionObj = regionMapper.selectById(point.getRegion_code());
if (ObjectUtil.isNotEmpty(regionObj)) {
if (ObjectUtil.isNotEmpty(pointStatus) && ObjectUtil.isNotEmpty(regionObj.getPoint_status_explain())) {
// 设置
point.setPoint_status_name(PointUtils.getStatusOrTypeName(
regionObj.getPoint_status_explain(), pointStatus));
}
if (ObjectUtil.isNotEmpty(pointType) && ObjectUtil.isNotEmpty(regionObj.getPoint_type_explain())) {
// 设置
point.setPoint_type_name(PointUtils.getStatusOrTypeName(
regionObj.getPoint_type_explain(), pointType));
}
}
});
return pages;
}
@Override
public void create(SchBasePoint entity) {
String point_code = entity.getPoint_code();
SchBasePoint pointObj = pointMapper.selectById(point_code);
if (ObjectUtil.isNotEmpty(pointObj) && !pointObj.getPoint_code().equals(entity.getPoint_code())) {
throw new BadRequestException("存在相同的点位编码");
}
// 默认父类点位为自身
if (ObjectUtil.isEmpty(entity.getParent_point_code())) {
entity.setParent_point_code(entity.getPoint_code());
}
if (ObjectUtil.isNotEmpty(entity.getCan_vehicle_types())) {
String can_vehicle_type = String.join(",", entity.getCan_vehicle_types());
entity.setCan_vehicle_type(can_vehicle_type);
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
// 获取region_name
SchBaseRegion baseRegion = regionMapper.selectById(entity.getRegion_code());
entity.setRegion_name(baseRegion.getRegion_name());
entity.setCreate_id(currentUserId);
entity.setCreate_name(nickName);
entity.setCreate_time(now);
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
pointMapper.insert(entity);
}
@Override
public void update(SchBasePoint entity) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
// 获取region_name
SchBaseRegion baseRegion = regionMapper.selectById(entity.getRegion_code());
entity.setRegion_name(baseRegion.getRegion_name());
if (ObjectUtil.isNotEmpty(entity.getCan_vehicle_types())) {
String can_vehicle_type = String.join(",", entity.getCan_vehicle_types());
entity.setCan_vehicle_type(can_vehicle_type);
}
String pointStatus = entity.getPoint_status();
// 根据点位状态来判断更新内容
if (ObjectUtil.isNotEmpty(pointStatus) && pointStatus.equals(PointStatusEnum.EMPTY_POINT.getCode())) {
entity.setVehicle_type("");
entity.setVehicle_code("");
}
pointMapper.updateById(entity);
}
@Override
public void deleteAll(Set<String> ids) {
// 真删除
pointMapper.deleteBatchIds(ids);
}
@Override
public void changeUsed(JSONObject jsonObject) {
// 不可能为空
JSONArray data = jsonObject.getJSONArray("data");
Boolean used = jsonObject.getBoolean("used");
Assert.notNull(data, "数据为空!");
Assert.notNull(used, "数据为空!");
List<SchBasePoint> schBasePoints = JSONArray.parseArray(JSONArray.toJSONString(data), SchBasePoint.class);
// 获取所有pointCode
List<String> pointCodes = schBasePoints.stream()
.map(SchBasePoint::getPoint_code)
.collect(Collectors.toList());
pointMapper.batchChangeUsed(pointCodes, used);
}
@Override
public List<SchBasePoint> getPointList(SchBasePoint region) {
if (ObjectUtil.isEmpty(region)) {
return this.list();
}
return pointMapper.selectList(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getRegion_code, region.getRegion_code())
.eq(SchBasePoint::getIs_has_workder, true));
}
@Override
public void changeLock(JSONObject points) {
JSONArray data = points.getJSONArray("data");
Boolean lockType = points.getBoolean("lock_type");
List<SchBasePoint> pointList = data.toJavaList(SchBasePoint.class);
pointList.forEach(point -> point.setIng_task_code(lockType ? "" : "-"));
this.updateBatchById(pointList);
}
@Override
public List<SchBasePoint> getAllUnlockAbnormalPoints() {
return pointMapper.getAllUnlockAbnormalPoints();
}
@Override
public SchBasePoint selectByIdLock(String id) {
return pointMapper.selectByIdLock(id);
}
}

View File

@@ -0,0 +1,136 @@
package org.nl.wms.sch_manage.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseRegionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Liuxy
* @description 服务实现
* @date 2025-05-20
**/
@Slf4j
@Service
public class SchBaseRegionServiceImpl extends ServiceImpl<SchBaseRegionMapper, SchBaseRegion> implements ISchBaseRegionService {
@Autowired
private SchBaseRegionMapper schBaseRegionMapper;
@Override
public IPage<SchBaseRegion> queryAll(Map whereJson, PageQuery page) {
String workshop_code = ObjectUtil.isNotEmpty(whereJson.get("workshop_code")) ? whereJson.get("workshop_code").toString() : null;
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry")) ? whereJson.get("blurry").toString() : null;
Boolean is_has_workder = ObjectUtil.isNotEmpty(whereJson.get("is_has_workder")) ? Boolean.valueOf(whereJson.get("is_has_workder").toString()) : null;
LambdaQueryWrapper<SchBaseRegion> lam = new LambdaQueryWrapper<>();
lam.eq(ObjectUtil.isNotEmpty(workshop_code), SchBaseRegion::getWorkshop_code, workshop_code)
.eq(ObjectUtil.isNotEmpty(is_has_workder), SchBaseRegion::getIs_has_workder, is_has_workder)
.like(ObjectUtil.isNotEmpty(blurry), SchBaseRegion::getRegion_code, blurry)
.or(ObjectUtil.isNotEmpty(blurry), la -> la.like(SchBaseRegion::getRegion_name, blurry))
.orderByAsc(SchBaseRegion::getOrder_seq);
IPage<SchBaseRegion> pages = new Page<>(page.getPage() + 1, page.getSize());
schBaseRegionMapper.selectPage(pages, lam);
return pages;
}
@Override
public void create(SchBaseRegion entity) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setCreate_id(currentUserId);
entity.setCreate_name(nickName);
entity.setCreate_time(now);
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
schBaseRegionMapper.insert(entity);
}
@Override
public void update(SchBaseRegion entity) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
schBaseRegionMapper.updateById(entity);
}
@Override
public void deleteAll(Set<String> ids) {
// 真删除
schBaseRegionMapper.deleteBatchIds(ids);
}
@Override
public List<SchBaseRegion> getRegionList(SchBaseRegion region) {
return schBaseRegionMapper.selectList(new LambdaQueryWrapper<SchBaseRegion>()
.eq(ObjectUtil.isNotEmpty(region), SchBaseRegion::getIs_has_workder, true)
.orderByAsc(SchBaseRegion::getOrder_seq));
}
@Override
public JSONArray getPointStatusSelectById(String regionId) {
/**
* label,value
*/
SchBaseRegion schBaseRegion = schBaseRegionMapper.selectById(regionId);
JSONArray res = new JSONArray();
String pointStatusExplain = schBaseRegion.getPoint_status_explain();
if (ObjectUtil.isEmpty(pointStatusExplain)) {
return res;
}
String[] explain = pointStatusExplain.split("");
for (int i = 0; i < explain.length; i++) {
String[] status = explain[i].split("-");
JSONObject point_status = new JSONObject();
point_status.put("label", status[1]);
point_status.put("value", status[0]);
res.add(point_status);
}
return res;
}
@Override
public JSONArray getPointTypeSelectById(String regionId) {
/**
* label,value
*/
SchBaseRegion schBaseRegion = schBaseRegionMapper.selectById(regionId);
JSONArray res = new JSONArray();
String pointTypeExplain = schBaseRegion.getPoint_type_explain();
if (ObjectUtil.isEmpty(pointTypeExplain)) {
return res;
}
String[] explain = pointTypeExplain.split("");
for (int i = 0; i < explain.length; i++) {
String[] types = explain[i].split("-");
JSONObject point_type = new JSONObject();
point_type.put("label", types[1]);
point_type.put("value", types[0]);
res.add(point_type);
}
return res;
}
}

View File

@@ -0,0 +1,29 @@
package org.nl.wms.sch_manage.service.util;
import com.alibaba.fastjson.JSONObject;
/**
* @Author: Liuxy
* @Description: 点位工具类
* @Date: 2025/5/20
*/
public class PointUtils {
/**
* 获取状态名或者类型名
*
* @param explain 参数
* @param label 参数
* @return String
*/
public static String getStatusOrTypeName(String explain, String label) {
JSONObject statusArr = new JSONObject();
String[] split = explain.split("");
for (int j = 0; j < split.length; j++) {
String[] status = split[j].split("-");
statusArr.put(status[0], status[1]);
}
// 设置
return statusArr.getString(label);
}
}