Browse Source

设备和货道管理基础业务

LuoDLeo 7 months ago
parent
commit
a85aaefcd7

+ 128 - 0
src/main/java/org/springblade/modules/business/controller/FacilityController.java

@@ -0,0 +1,128 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.business.entity.Facility;
+import org.springblade.modules.business.service.IFacilityService;
+import org.springblade.modules.business.vo.FacilityVO;
+import org.springblade.modules.business.wrapper.FacilityWrapper;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * 售货设备表 控制器
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/facility")
+@Api(value = "售货设备表", tags = "售货设备表接口")
+public class FacilityController extends BladeController {
+
+	private final IFacilityService facilityService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入facility")
+	public R<FacilityVO> detail(Facility facility) {
+		Facility detail = facilityService.getOne(Condition.getQueryWrapper(facility));
+		return R.data(FacilityWrapper.build().entityVO(detail));
+	}
+
+	/**
+	 * 分页 售货设备表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入facility")
+	public R<IPage<FacilityVO>> list(Facility facility, Query query) {
+		IPage<Facility> pages = facilityService.page(Condition.getPage(query), Condition.getQueryWrapper(facility));
+		return R.data(FacilityWrapper.build().pageVO(pages));
+	}
+
+
+	/**
+	 * 自定义分页 售货设备表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入facility")
+	public R<IPage<FacilityVO>> page(FacilityVO facility, Query query) {
+		IPage<FacilityVO> pages = facilityService.selectFacilityPage(Condition.getPage(query), facility);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 售货设备表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入facility")
+	public R save(@Valid @RequestBody Facility facility) {
+		return R.status(facilityService.save(facility));
+	}
+
+	/**
+	 * 修改 售货设备表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入facility")
+	public R update(@Valid @RequestBody Facility facility) {
+		return R.status(facilityService.updateById(facility));
+	}
+
+	/**
+	 * 新增或修改 售货设备表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入facility")
+	public R submit(@Valid @RequestBody Facility facility) {
+		return R.status(facilityService.saveOrUpdate(facility));
+	}
+
+	
+	/**
+	 * 删除 售货设备表
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(facilityService.removeByIds(Func.toLongList(ids)));
+	}
+
+	
+}

+ 34 - 0
src/main/java/org/springblade/modules/business/dto/FacilityDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.dto;
+
+import org.springblade.modules.business.entity.Facility;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 售货设备表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FacilityDTO extends Facility {
+	private static final long serialVersionUID = 1L;
+
+}

+ 72 - 0
src/main/java/org/springblade/modules/business/entity/Facility.java

@@ -0,0 +1,72 @@
+package org.springblade.modules.business.entity;
+
+import org.springblade.common.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 售货设备表实体类
+ *
+ * @author zzyd
+ * @since 2024-07-16
+ */
+@Data
+@TableName("t_facility")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "Facility对象", description = "售货设备表")
+public class Facility extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 设备编号
+	*/
+	@ApiModelProperty(value = "设备编号")
+	private String facilityNo;
+	/**
+	* 门店id
+	*/
+	@ApiModelProperty(value = "门店id")
+	private Long shopId;
+	/**
+	* 设备名称
+	*/
+	@ApiModelProperty(value = "设备名称")
+	private String facilityName;
+	/**
+	* 设备型号
+	*/
+	@ApiModelProperty(value = "设备型号")
+	private String facilityType;
+	/**
+	* 设备经度
+	*/
+	@ApiModelProperty(value = "设备经度")
+	private String longitude;
+	/**
+	* 设备纬度
+	*/
+	@ApiModelProperty(value = "设备纬度")
+	private String latitude;
+	/**
+	* 设备状态
+	*/
+	@ApiModelProperty(value = "设备状态")
+	private Integer facilityStatus;
+	/**
+	* 最新上传数据时间
+	*/
+	@ApiModelProperty(value = "最新上传数据时间")
+	private LocalDateTime heartbeatTime;
+	/**
+	* 添加时间
+	*/
+	@ApiModelProperty(value = "添加时间")
+	private LocalDateTime addTime;
+
+
+}

+ 20 - 0
src/main/java/org/springblade/modules/business/entity/FacilityCargoWay.java

@@ -0,0 +1,20 @@
+package org.springblade.modules.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.common.base.BaseEntity;
+
+/**
+ * 货道表
+ */
+@Data
+@TableName("t_facility_cargo_way")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "货道", description = "货道表")
+public class FacilityCargoWay extends BaseEntity {
+
+
+
+}

+ 42 - 0
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.mapper;
+
+import org.springblade.modules.business.entity.Facility;
+import org.springblade.modules.business.vo.FacilityVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 售货设备表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public interface FacilityMapper extends BaseMapper<Facility> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param facility
+	 * @return
+	 */
+	List<FacilityVO> selectFacilityPage(IPage page, FacilityVO facility);
+
+}

+ 29 - 0
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.xml

@@ -0,0 +1,29 @@
+<?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.springblade.modules.business.mapper.FacilityMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="facilityResultMap" type="org.springblade.modules.business.entity.Facility">
+        <result column="id" property="id"/>
+        <result column="is_delete" property="isDelete"/>
+        <result column="create_user_id" property="createUserId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="facility_no" property="facilityNo"/>
+        <result column="shop_id" property="shopId"/>
+        <result column="facility_name" property="facilityName"/>
+        <result column="facility_type" property="facilityType"/>
+        <result column="longitude" property="longitude"/>
+        <result column="latitude" property="latitude"/>
+        <result column="facility_status" property="facilityStatus"/>
+        <result column="heartbeat_time" property="heartbeatTime"/>
+        <result column="add_time" property="addTime"/>
+    </resultMap>
+
+
+    <select id="selectFacilityPage" resultMap="facilityResultMap">
+        select * from t_facility where is_delete = 0
+    </select>
+
+</mapper>

+ 41 - 0
src/main/java/org/springblade/modules/business/service/IFacilityService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.service;
+
+import org.springblade.modules.business.entity.Facility;
+import org.springblade.modules.business.vo.FacilityVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 售货设备表 服务类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public interface IFacilityService extends IService<Facility> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param facility
+	 * @return
+	 */
+	IPage<FacilityVO> selectFacilityPage(IPage<FacilityVO> page, FacilityVO facility);
+
+}

+ 41 - 0
src/main/java/org/springblade/modules/business/service/impl/FacilityServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.service.impl;
+
+import org.springblade.modules.business.entity.Facility;
+import org.springblade.modules.business.vo.FacilityVO;
+import org.springblade.modules.business.mapper.FacilityMapper;
+import org.springblade.modules.business.service.IFacilityService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 售货设备表 服务实现类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Service
+public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> implements IFacilityService {
+
+	@Override
+	public IPage<FacilityVO> selectFacilityPage(IPage<FacilityVO> page, FacilityVO facility) {
+		return page.setRecords(baseMapper.selectFacilityPage(page, facility));
+	}
+
+}

+ 36 - 0
src/main/java/org/springblade/modules/business/vo/FacilityVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.vo;
+
+import org.springblade.modules.business.entity.Facility;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 售货设备表视图实体类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "FacilityVO对象", description = "售货设备表")
+public class FacilityVO extends Facility {
+	private static final long serialVersionUID = 1L;
+
+}

+ 49 - 0
src/main/java/org/springblade/modules/business/wrapper/FacilityWrapper.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.business.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.business.entity.Facility;
+import org.springblade.modules.business.vo.FacilityVO;
+import java.util.Objects;
+
+/**
+ * 售货设备表包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public class FacilityWrapper extends BaseEntityWrapper<Facility, FacilityVO>  {
+
+	public static FacilityWrapper build() {
+		return new FacilityWrapper();
+ 	}
+
+	@Override
+	public FacilityVO entityVO(Facility facility) {
+		FacilityVO facilityVO = Objects.requireNonNull(BeanUtil.copy(facility, FacilityVO.class));
+
+		//User createUser = UserCache.getUser(facility.getCreateUser());
+		//User updateUser = UserCache.getUser(facility.getUpdateUser());
+		//facilityVO.setCreateUserName(createUser.getName());
+		//facilityVO.setUpdateUserName(updateUser.getName());
+
+		return facilityVO;
+	}
+
+}