11/5 增加货架功能,优化货位1.0
							parent
							
								
									605287e869
								
							
						
					
					
						commit
						efdc7cb70f
					
				| @ -0,0 +1,94 @@ | |||||||
|  | package com.glxp.api.controller.auth; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||||
|  | import com.github.pagehelper.PageInfo; | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.common.util.ResultVOUtils; | ||||||
|  | import com.glxp.api.controller.BaseController; | ||||||
|  | import com.glxp.api.entity.basic.SysWorkplaceFreight; | ||||||
|  | import com.glxp.api.entity.basic.SysWorkplaceQueue; | ||||||
|  | import com.glxp.api.req.basic.SysWorkplaceFreightRequest; | ||||||
|  | import com.glxp.api.req.basic.SysWorkplaceQueueRequest; | ||||||
|  | import com.glxp.api.res.PageSimpleResponse; | ||||||
|  | import com.glxp.api.res.basic.SysWorkplaceFreightResponse; | ||||||
|  | import com.glxp.api.res.basic.SysWorkplaceQueueResponse; | ||||||
|  | import com.glxp.api.service.basic.SysWorkplaceFreightService; | ||||||
|  | import com.glxp.api.service.basic.SysWorkplaceQueueService; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
|  | import org.springframework.web.bind.annotation.GetMapping; | ||||||
|  | import org.springframework.web.bind.annotation.PostMapping; | ||||||
|  | import org.springframework.web.bind.annotation.RequestBody; | ||||||
|  | import org.springframework.web.bind.annotation.RestController; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * @author : zhuzhu | ||||||
|  |  * @date : 2024/11/5 9:51 | ||||||
|  |  * @modyified By : | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @Slf4j | ||||||
|  | @RestController | ||||||
|  | public class SysWorkplaceFreightController extends BaseController { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     SysWorkplaceFreightService sysWorkplaceFreightService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/udiwms/WorkplaceFreight/createFreightCode") | ||||||
|  |     public BaseResponse createFreightCode() { | ||||||
|  |         String code = sysWorkplaceFreightService.createQueueCode(); | ||||||
|  |         return ResultVOUtils.success(code); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/udiwms/WorkplaceFreight/addWorkplaceFreight") | ||||||
|  |     public BaseResponse addWorkplaceFreight(@RequestBody SysWorkplaceFreight workplaceFreight) { | ||||||
|  |         // 创建时间 更新时间
 | ||||||
|  |         workplaceFreight.setCreateTime(new Date()); | ||||||
|  |         workplaceFreight.setCreateUser(getUserId() + ""); | ||||||
|  |         workplaceFreight.setUpdateUser(getUserId() + ""); | ||||||
|  |         workplaceFreight.setUpdateTime(new Date()); | ||||||
|  |         boolean save = sysWorkplaceFreightService.WorkplaceFreight(workplaceFreight); | ||||||
|  |         if (!save) { | ||||||
|  |             return ResultVOUtils.error("新增错误"); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success("新增成功"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/udiwms/WorkplaceFreight/getPage") | ||||||
|  |     public BaseResponse getWorkplaceFreights(SysWorkplaceFreightRequest request) { | ||||||
|  |         List<SysWorkplaceFreightResponse> page = sysWorkplaceFreightService.filterList(request); | ||||||
|  |         PageInfo<SysWorkplaceFreightResponse> pageInfo = new PageInfo<>(page); | ||||||
|  |         PageSimpleResponse<SysWorkplaceFreightResponse> pageSimpleResponse = new PageSimpleResponse<>(); | ||||||
|  |         pageSimpleResponse.setTotal(pageInfo.getTotal()); | ||||||
|  |         pageSimpleResponse.setList(page); | ||||||
|  |         return ResultVOUtils.success(pageSimpleResponse); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/udiwms/WorkplaceFreight/deleteById") | ||||||
|  |     public BaseResponse deleteByIdWorkplaceFreight(@RequestBody SysWorkplaceFreight workplaceFreight) { | ||||||
|  |         boolean save = sysWorkplaceFreightService.removeFreight(workplaceFreight); | ||||||
|  |         if (!save) { | ||||||
|  |             return ResultVOUtils.error("删除错误"); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success("删除成功"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/udiwms/WorkplaceFreight/updateWorkplaceFreight") | ||||||
|  |     public BaseResponse page(@RequestBody SysWorkplaceFreight workplaceFreight) { | ||||||
|  |         workplaceFreight.setUpdateTime(new Date()); | ||||||
|  |         workplaceFreight.setUpdateUser(getUserId() + ""); | ||||||
|  |         boolean b = sysWorkplaceFreightService.updateById(workplaceFreight); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(500, "更新失败"); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success("更新成功"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,17 @@ | |||||||
|  | package com.glxp.api.dao.basic; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
|  | import com.glxp.api.entity.basic.SysWorkplaceFreight; | ||||||
|  | import com.glxp.api.req.basic.SysWorkplaceFreightRequest; | ||||||
|  | import com.glxp.api.res.basic.SysWorkplaceFreightResponse; | ||||||
|  | import org.apache.ibatis.annotations.Mapper; | ||||||
|  | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @Mapper | ||||||
|  | public interface SysWorkplaceFreightMapper extends BaseMapper<SysWorkplaceFreight> { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     List<SysWorkplaceFreightResponse> filterList(SysWorkplaceFreightRequest request); | ||||||
|  | } | ||||||
| @ -0,0 +1,67 @@ | |||||||
|  | package com.glxp.api.entity.basic; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.annotation.IdType; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableField; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | import java.io.Serializable; | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | @ApiModel(description = "sys_workplace_freight") | ||||||
|  | @Data | ||||||
|  | @TableName(value = "sys_workplace_freight") | ||||||
|  | public class SysWorkplaceFreight implements Serializable { | ||||||
|  |     @TableId(value = "id", type = IdType.INPUT) | ||||||
|  |     @ApiModelProperty(value = "") | ||||||
|  |     private Integer id; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 货架编码 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "code") | ||||||
|  |     @ApiModelProperty(value = "货架编码") | ||||||
|  |     private String code; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 货架名称 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "`name`") | ||||||
|  |     @ApiModelProperty(value = "货架名称") | ||||||
|  |     private String name; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 工位ID | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "workPlaceIdFk") | ||||||
|  |     @ApiModelProperty(value = "工位ID") | ||||||
|  |     private Long workPlaceIdFk; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 备注 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "remark") | ||||||
|  |     @ApiModelProperty(value = "备注") | ||||||
|  |     private String remark; | ||||||
|  | 
 | ||||||
|  |     @TableField(value = "createTime") | ||||||
|  |     @ApiModelProperty(value = "") | ||||||
|  |     private Date createTime; | ||||||
|  | 
 | ||||||
|  |     @TableField(value = "updateTime") | ||||||
|  |     @ApiModelProperty(value = "") | ||||||
|  |     private Date updateTime; | ||||||
|  | 
 | ||||||
|  |     @TableField(value = "`createUser`") | ||||||
|  |     @ApiModelProperty(value = "") | ||||||
|  |     private String createUser; | ||||||
|  | 
 | ||||||
|  |     @TableField(value = "updateUser") | ||||||
|  |     @ApiModelProperty(value = "") | ||||||
|  |     private String updateUser; | ||||||
|  | 
 | ||||||
|  |     private static final long serialVersionUID = 1L; | ||||||
|  | } | ||||||
| @ -0,0 +1,22 @@ | |||||||
|  | package com.glxp.api.req.basic; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.util.page.ListPageRequest; | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * @author : zhangsan | ||||||
|  |  * @date : 2024/10/30 10:42 | ||||||
|  |  * @modyified By : | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | public class SysWorkplaceFreightRequest extends ListPageRequest { | ||||||
|  |     private String key; | ||||||
|  | //    private String code;
 | ||||||
|  | //    private String name;
 | ||||||
|  |     private Long workPlaceIdFk; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,59 @@ | |||||||
|  | package com.glxp.api.res.basic; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableField; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * @author : zhuzhu | ||||||
|  |  * @date : 2024/11/4 11:08 | ||||||
|  |  * @modyified By : | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | public class SysWorkplaceFreightResponse { | ||||||
|  |     private Integer id; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 货位编码 | ||||||
|  |      */ | ||||||
|  |     private String code; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 货位名称 | ||||||
|  |      */ | ||||||
|  |     private String name; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 工位ID | ||||||
|  |      */ | ||||||
|  |     private Long workPlaceIdFk; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 备注 | ||||||
|  |      */ | ||||||
|  |     private String remark; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     private Date createTime; | ||||||
|  | 
 | ||||||
|  |     private Date updateTime; | ||||||
|  | 
 | ||||||
|  |     private String createUser; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     private String updateUser; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 所属工位 | ||||||
|  |      */ | ||||||
|  |     private String workPlaceName; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,80 @@ | |||||||
|  | package com.glxp.api.service.basic; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||||
|  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||||
|  | import com.github.pagehelper.PageHelper; | ||||||
|  | import com.glxp.api.dao.basic.SysWorkplaceFreightMapper; | ||||||
|  | import com.glxp.api.entity.basic.SysWorkplaceFreight; | ||||||
|  | import com.glxp.api.entity.basic.SysWorkplaceQueue; | ||||||
|  | import com.glxp.api.exception.JsonException; | ||||||
|  | import com.glxp.api.req.basic.SysWorkplaceFreightRequest; | ||||||
|  | import com.glxp.api.res.basic.SysWorkplaceFreightResponse; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.Collections; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * @author : zhuzhu | ||||||
|  |  * @date : 2024/11/5 9:52 | ||||||
|  |  * @modyified By : | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class SysWorkplaceFreightService extends ServiceImpl<SysWorkplaceFreightMapper, SysWorkplaceFreight> { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     private SysWorkplaceFreightMapper sysWorkplaceFreightMapper; | ||||||
|  |     @Resource | ||||||
|  |     private SysWorkplaceQueueService sysWorkplaceQueueService; | ||||||
|  | 
 | ||||||
|  |     public boolean WorkplaceFreight(SysWorkplaceFreight workplaceFreight) { | ||||||
|  |         SysWorkplaceFreight sysWorkplaceFreight = sysWorkplaceFreightMapper.selectOne(new LambdaQueryWrapper<SysWorkplaceFreight>().eq(SysWorkplaceFreight::getName, workplaceFreight.getName())); | ||||||
|  |         if (sysWorkplaceFreight != null) { | ||||||
|  |             throw new JsonException(500, "货架名称重复"); | ||||||
|  |         } | ||||||
|  |         int insert = sysWorkplaceFreightMapper.insert(workplaceFreight); | ||||||
|  |         if (insert == 0) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public List<SysWorkplaceFreightResponse> filterList(SysWorkplaceFreightRequest request) { | ||||||
|  |         if (null == request) { | ||||||
|  |             return Collections.emptyList(); | ||||||
|  |         } | ||||||
|  |         if (null != request.getPage() && null != request.getLimit()) { | ||||||
|  |             PageHelper.offsetPage((request.getPage() - 1) * request.getLimit(), request.getLimit()); | ||||||
|  |         } | ||||||
|  |         return sysWorkplaceFreightMapper.filterList(request); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public boolean removeFreight(SysWorkplaceFreight workplaceFreight) { | ||||||
|  |         //如果有货位 是直接删除下面货位 还是不让删除
 | ||||||
|  |         List<SysWorkplaceQueue> list = sysWorkplaceQueueService.list(new LambdaQueryWrapper<SysWorkplaceQueue>().eq(SysWorkplaceQueue::getFreightCode, workplaceFreight.getCode())); | ||||||
|  |         if (list.size() > 0 ){ | ||||||
|  |             throw new JsonException(500,"当前货架已有货位,请先移除货位!"); | ||||||
|  |         } | ||||||
|  |         int i = sysWorkplaceFreightMapper.deleteById(workplaceFreight); | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String createQueueCode() { | ||||||
|  |         String code; | ||||||
|  |         SysWorkplaceFreight sysWorkplaceQueue = sysWorkplaceFreightMapper.selectOne(new LambdaQueryWrapper<SysWorkplaceFreight>().orderByDesc(SysWorkplaceFreight::getCode).last("LIMIT 1")); | ||||||
|  |         if (sysWorkplaceQueue == null){ | ||||||
|  |             //没有数据 新增
 | ||||||
|  |             code = "DMQ00" + 1; | ||||||
|  |         }else { | ||||||
|  |             String code1 = sysWorkplaceQueue.getCode(); | ||||||
|  |             String withoutDMQ = code1.replace("DMQ", ""); | ||||||
|  |             Integer result = Integer.parseInt(withoutDMQ.trim()); | ||||||
|  |             result += 1; | ||||||
|  |             String sixDigitResult = String.format("%03d", result); | ||||||
|  |             code = "DMQ" + sixDigitResult; | ||||||
|  |         } | ||||||
|  |         return code; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,23 @@ | |||||||
|  | <?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.glxp.api.dao.basic.SysWorkplaceFreightMapper"> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     <select id="filterList" resultType="com.glxp.api.res.basic.SysWorkplaceFreightResponse"> | ||||||
|  |         select swf.*, | ||||||
|  |         sw.workplaceName  workPlaceName | ||||||
|  |         from sys_workplace_freight swf | ||||||
|  |         left join sys_workplace sw on sw.workplaceId = swf.workPlaceIdFk | ||||||
|  |         <where> | ||||||
|  |             <if test="key != null and key != ''"> | ||||||
|  |                 AND ( | ||||||
|  |                 swf.code like concat('%', #{key}, '%') | ||||||
|  |                 or swf.name like concat('%', #{key}, '%') | ||||||
|  |                 ) | ||||||
|  |             </if> | ||||||
|  |             <if test=" workPlaceIdFk != null and workPlaceIdFk != ''"> | ||||||
|  |                 AND swf.workPlaceIdFk = #{workPlaceIdFk} | ||||||
|  |             </if> | ||||||
|  |         </where> | ||||||
|  |     </select> | ||||||
|  | </mapper> | ||||||
					Loading…
					
					
				
		Reference in New Issue