基础资料已完善
parent
1f38a4a636
commit
95bb20b1d1
|
|
@ -62,6 +62,7 @@ public class AdminCacheConst extends CacheKeyConst {
|
||||||
public static final String LOCATION_ENTITY = "location_cache";
|
public static final String LOCATION_ENTITY = "location_cache";
|
||||||
public static final String ITEM_ENTITY = "item_cache";
|
public static final String ITEM_ENTITY = "item_cache";
|
||||||
public static final String STOCK_ENTITY = "stock_cache";
|
public static final String STOCK_ENTITY = "stock_cache";
|
||||||
|
public static final String ADDRESS_ENTITY = "address_cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressAddForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressQueryForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressSelect;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressUpdateForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressExcelVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.service.AddressQueryService;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.service.AddressService;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemSelect;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.vo.ItemsExcelVO;
|
||||||
|
import net.lab1024.sa.base.common.domain.RequestUser;
|
||||||
|
import net.lab1024.sa.base.common.domain.ValidateList;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartExcelUtil;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 Controller
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "收货地址")
|
||||||
|
public class AddressController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressService addressService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressQueryService addressQueryService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询 @author hj")
|
||||||
|
@PostMapping("/address/queryPage")
|
||||||
|
@SaCheckPermission("address:query")
|
||||||
|
public ResponseDTO<PageResult<AddressVO>> queryPage(@RequestBody @Valid AddressQueryForm queryForm) {
|
||||||
|
return ResponseDTO.ok(addressQueryService.queryPage(queryForm));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加 @author hj")
|
||||||
|
@PostMapping("/address/add")
|
||||||
|
@SaCheckPermission("address:add")
|
||||||
|
public ResponseDTO<String> add(@RequestBody @Valid AddressAddForm addForm) {
|
||||||
|
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||||
|
addForm.setCreateUserId(requestUser.getUserId());
|
||||||
|
addForm.setCreateUserName(requestUser.getUserName());
|
||||||
|
return addressService.add(addForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新 @author hj")
|
||||||
|
@PostMapping("/address/update")
|
||||||
|
@SaCheckPermission("address:update")
|
||||||
|
public ResponseDTO<String> update(@RequestBody @Valid AddressUpdateForm updateForm) {
|
||||||
|
return addressService.update(updateForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "批量删除 @author hj")
|
||||||
|
@PostMapping("/address/batchDelete")
|
||||||
|
@SaCheckPermission("address:batchDelete")
|
||||||
|
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
||||||
|
return addressService.batchDelete(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "单个删除 @author hj")
|
||||||
|
@GetMapping("/address/delete")
|
||||||
|
@SaCheckPermission("address:delete")
|
||||||
|
public ResponseDTO<String> delete(@RequestParam Long addressId) {
|
||||||
|
return addressService.delete(addressId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "地址下拉查询")
|
||||||
|
@PostMapping("/address/queryAddress")
|
||||||
|
public ResponseDTO<List<AddressEntity>> queryAddress(@RequestBody AddressSelect addressSelect) {
|
||||||
|
return ResponseDTO.ok(addressQueryService.queryAddress(addressSelect));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "导入 霍锦")
|
||||||
|
@PostMapping("/address/importAddress")
|
||||||
|
@SaCheckPermission("address:importAddress")
|
||||||
|
public ResponseDTO<String> importAddress(@RequestParam MultipartFile file) {
|
||||||
|
return addressService.importAddress(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "导出 霍锦")
|
||||||
|
@GetMapping("/address/exportAddress")
|
||||||
|
@SaCheckPermission("address:exportAddress")
|
||||||
|
public void exportAddress(HttpServletResponse response) throws IOException {
|
||||||
|
List<AddressExcelVO> addressList = addressQueryService.getAddressExcelVOList();
|
||||||
|
SmartExcelUtil.exportExcel(response, "收货地址信息.xlsx", "收货地址", AddressExcelVO.class, addressList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressQueryForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressVO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 Dao
|
||||||
|
*
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2024-12-26 15:35:23
|
||||||
|
* @Copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface AddressDao extends BaseMapper<AddressEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页 查询
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param queryForm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AddressVO> queryPage(Page page, @Param("queryForm") AddressQueryForm queryForm);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
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 java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 实体类
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("t_address")
|
||||||
|
public class AddressEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称/单位
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人
|
||||||
|
*/
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电话
|
||||||
|
*/
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人ID
|
||||||
|
*/
|
||||||
|
private Long createUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.form;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 新建表单
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddressAddForm {
|
||||||
|
|
||||||
|
@Schema(description = "名称/单位")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "联系人")
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
@Schema(description = "电话")
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@Schema(description = "地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Long createUserId;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String createUserName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.form;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddressImportForm {
|
||||||
|
@ExcelProperty("收货单位")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty("联系人")
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
@ExcelProperty("电话")
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@ExcelProperty("地址")
|
||||||
|
private String address;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.form;
|
||||||
|
|
||||||
|
import net.lab1024.sa.base.common.domain.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 分页查询表单
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class AddressQueryForm extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "收货单位")
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.form;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class AddressSelect {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.form;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 更新表单
|
||||||
|
*
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2024-12-26 15:35:23
|
||||||
|
* @Copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddressUpdateForm extends AddressAddForm{
|
||||||
|
|
||||||
|
@Schema(description = "收货地址id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "收货地址id 不能为空")
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.vo;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class AddressExcelVO {
|
||||||
|
@ExcelProperty("收货单位")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty("联系人")
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
@ExcelProperty("电话")
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@ExcelProperty("地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 列表VO
|
||||||
|
*
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2024-12-26 15:35:23
|
||||||
|
* @Copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddressVO {
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "收货地址id")
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
@Schema(description = "名称/单位")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "联系人")
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
@Schema(description = "电话")
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@Schema(description = "地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.manager;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.sa.admin.constant.AdminCacheConst;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.dao.AddressDao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 Manager
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class AddressManager extends ServiceImpl<AddressDao, AddressEntity> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressDao addressDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类目id 移除缓存
|
||||||
|
*/
|
||||||
|
@CacheEvict(value = {AdminCacheConst.Base.ADDRESS_ENTITY}, allEntries = true)
|
||||||
|
public void removeCache() {
|
||||||
|
log.info("clear ADDRESS_ENTITY");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查詢类目
|
||||||
|
*/
|
||||||
|
@Cacheable(AdminCacheConst.Base.ADDRESS_ENTITY)
|
||||||
|
public AddressEntity queryAddress(Long addressId) {
|
||||||
|
return addressDao.selectById(addressId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.dao.AddressDao;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressQueryForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressSelect;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressExcelVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressVO;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.manager.AddressManager;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.vo.ItemsExcelVO;
|
||||||
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
|
import net.lab1024.sa.base.module.support.dict.constant.DictConst;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AddressQueryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressDao addressDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressManager addressManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param queryForm 查询参数
|
||||||
|
* @return PageResult<AddressVO>
|
||||||
|
*/
|
||||||
|
public PageResult<AddressVO> queryPage(AddressQueryForm queryForm) {
|
||||||
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||||
|
List<AddressVO> list = addressDao.queryPage(page, queryForm);
|
||||||
|
return SmartPageUtil.convert2PageResult(page, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址下拉查询
|
||||||
|
*
|
||||||
|
* @param addressSelect 入参
|
||||||
|
* @return List<AddressEntity>
|
||||||
|
*/
|
||||||
|
public List<AddressEntity> queryAddress(AddressSelect addressSelect) {
|
||||||
|
return addressDao.selectList(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地址id集合查询地址信息
|
||||||
|
*
|
||||||
|
* @param addressIdList 地址id集合
|
||||||
|
* @return Map<Long, AreaEntity>
|
||||||
|
*/
|
||||||
|
public Map<Long, AddressEntity> queryAddressList(List<Long> addressIdList) {
|
||||||
|
if (CollectionUtils.isEmpty(addressIdList)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
addressIdList = addressIdList.stream().distinct().collect(Collectors.toList());
|
||||||
|
Map<Long, AddressEntity> addressMap = Maps.newHashMap();
|
||||||
|
for (Long addressId : addressIdList) {
|
||||||
|
AddressEntity address = addressManager.queryAddress(addressId);
|
||||||
|
if (address != null) {
|
||||||
|
addressMap.put(addressId, address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addressMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地址name集合查询地址信息
|
||||||
|
*
|
||||||
|
* @param addressNameList 地址name集合
|
||||||
|
* @return Map<Long, AddressEntity>
|
||||||
|
*/
|
||||||
|
public Map<String, AddressEntity> queryAddressByNameList(List<String> addressNameList) {
|
||||||
|
if (CollectionUtils.isEmpty(addressNameList)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<AddressEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.in(AddressEntity::getName, addressNameList);
|
||||||
|
|
||||||
|
List<AddressEntity> addressList = addressDao.selectList(queryWrapper);
|
||||||
|
if (CollectionUtils.isEmpty(addressList)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return addressList.stream()
|
||||||
|
.collect(Collectors.toMap(AddressEntity::getName, address -> address, (existing, replacement) -> existing));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地址名称查询地址信息
|
||||||
|
*
|
||||||
|
* @param addressName 地址名称
|
||||||
|
* @return AddressEntity
|
||||||
|
*/
|
||||||
|
public AddressEntity queryByAddressName(String addressName) {
|
||||||
|
LambdaQueryWrapper<AddressEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AddressEntity::getName, addressName);
|
||||||
|
return addressDao.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址导出
|
||||||
|
*
|
||||||
|
* @return List<AddressExcelVO>
|
||||||
|
*/
|
||||||
|
public List<AddressExcelVO> getAddressExcelVOList() {
|
||||||
|
List<AddressEntity> addressList = addressDao.selectList(null);
|
||||||
|
return addressList.stream()
|
||||||
|
.map(address ->
|
||||||
|
AddressExcelVO.builder()
|
||||||
|
.name(address.getName())
|
||||||
|
.person(address.getPerson())
|
||||||
|
.telephone(address.getTelephone())
|
||||||
|
.address(address.getAddress())
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
package net.lab1024.sa.admin.module.business.base.address.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.idev.excel.FastExcel;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.dao.AddressDao;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressAddForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressImportForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.domain.form.AddressUpdateForm;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.address.manager.AddressManager;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||||
|
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemsImportForm;
|
||||||
|
import net.lab1024.sa.admin.util.JoinerResult;
|
||||||
|
import net.lab1024.sa.admin.util.ResponseDTOUtils;
|
||||||
|
import net.lab1024.sa.base.common.exception.BusinessException;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||||
|
import net.lab1024.sa.base.module.support.dict.constant.DictConst;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 Service
|
||||||
|
*
|
||||||
|
* @author hj
|
||||||
|
* @since 2024-12-26 15:35:23
|
||||||
|
* copyright 友仓
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AddressService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressDao addressDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressManager addressManager;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressQueryService addressQueryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param addForm 添加参数
|
||||||
|
* @return ResponseDTO<String>
|
||||||
|
*/
|
||||||
|
public ResponseDTO<String> add(AddressAddForm addForm) {
|
||||||
|
AddressEntity addressEntity = SmartBeanUtil.copy(addForm, AddressEntity.class);
|
||||||
|
addressDao.insert(addressEntity);
|
||||||
|
|
||||||
|
//更新缓存
|
||||||
|
addressManager.removeCache();
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @param updateForm 更新参数
|
||||||
|
* @return ResponseDTO<String>
|
||||||
|
*/
|
||||||
|
public ResponseDTO<String> update(AddressUpdateForm updateForm) {
|
||||||
|
AddressEntity addressEntity = SmartBeanUtil.copy(updateForm, AddressEntity.class);
|
||||||
|
addressDao.updateById(addressEntity);
|
||||||
|
|
||||||
|
//更新缓存
|
||||||
|
addressManager.removeCache();
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param idList 集合
|
||||||
|
* @return ResponseDTO<String>
|
||||||
|
*/
|
||||||
|
public ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||||
|
if (CollectionUtils.isEmpty(idList)) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
addressManager.removeBatchByIds(idList);
|
||||||
|
|
||||||
|
//更新缓存
|
||||||
|
addressManager.removeCache();
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个删除
|
||||||
|
*
|
||||||
|
* @param addressId id
|
||||||
|
* @return ResponseDTO<String>
|
||||||
|
*/
|
||||||
|
public ResponseDTO<String> delete(Long addressId) {
|
||||||
|
if (null == addressId) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
addressDao.deleteById(addressId);
|
||||||
|
//更新缓存
|
||||||
|
addressManager.removeCache();
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址导入
|
||||||
|
*
|
||||||
|
* @param file 上传文件
|
||||||
|
* @return ResponseDTO<String>
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ResponseDTO<String> importAddress(MultipartFile file) {
|
||||||
|
List<AddressImportForm> dataList;
|
||||||
|
try {
|
||||||
|
dataList = FastExcel.read(file.getInputStream()).head(AddressImportForm.class)
|
||||||
|
.sheet()
|
||||||
|
.doReadSync();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException("数据格式存在问题,无法读取");
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(dataList)) {
|
||||||
|
return ResponseDTO.userErrorParam("数据为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取所有去重后的收货单位
|
||||||
|
List<String> addressName = dataList.stream().map(AddressImportForm::getName).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
//查询数据库存在的物料
|
||||||
|
Map<String, AddressEntity> exitAddressMap = addressQueryService.queryAddressByNameList(addressName);
|
||||||
|
|
||||||
|
List<AddressEntity> insertToAddress = new ArrayList<>();
|
||||||
|
List<AddressEntity> updateToAddress = new ArrayList<>();
|
||||||
|
for (AddressImportForm addressImportForm : dataList) {
|
||||||
|
|
||||||
|
|
||||||
|
//物料
|
||||||
|
AddressEntity address = exitAddressMap.get(addressImportForm.getName());
|
||||||
|
|
||||||
|
//物料为空则新增,否则更新
|
||||||
|
if (address == null) {
|
||||||
|
insertToAddress.add(createAddress(addressImportForm.getName(), addressImportForm.getPerson(), addressImportForm.getTelephone(), addressImportForm.getAddress()));
|
||||||
|
} else {
|
||||||
|
updateToAddress.add(createAddress(addressImportForm.getName(), addressImportForm.getPerson(), addressImportForm.getTelephone(), addressImportForm.getAddress()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JoinerResult resultMsg = JoinerResult.createJoiner();
|
||||||
|
return ResponseDTOUtils.buildResponseSussDTO(insertToAddress, updateToAddress, addressManager::saveBatch, addressManager::updateBatchById, resultMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建收货地址
|
||||||
|
*
|
||||||
|
* @param name 收货单位
|
||||||
|
* @param person 联系人
|
||||||
|
* @param telephone 电话
|
||||||
|
* @param address 地址
|
||||||
|
* @return AddressEntity
|
||||||
|
*/
|
||||||
|
public AddressEntity createAddress(String name, String person, String telephone, String address) {
|
||||||
|
return AddressEntity.builder()
|
||||||
|
.name(name)
|
||||||
|
.person(person)
|
||||||
|
.telephone(telephone)
|
||||||
|
.address(address)
|
||||||
|
.createUserId(SmartRequestUtil.getRequestUser().getUserId())
|
||||||
|
.createUserName(SmartRequestUtil.getRequestUser().getUserName())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下,
|
||||||
|
# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。
|
||||||
|
# 如果你一切都是按照默认,那么下面的 SQL 基本不用改
|
||||||
|
|
||||||
|
INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id )
|
||||||
|
VALUES ( '收货地址', 2, 0, '/address/list', '/business/address/address-list.vue', false, false, true, false, 1, 1 );
|
||||||
|
|
||||||
|
# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID
|
||||||
|
SET @parent_id = NULL;
|
||||||
|
SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = '收货地址';
|
||||||
|
|
||||||
|
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||||
|
VALUES ( '查询', 3, @parent_id, false, false, true, false, 'address:query', 1, @parent_id, 1 );
|
||||||
|
|
||||||
|
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||||
|
VALUES ( '添加', 3, @parent_id, false, false, true, false, 'address:add', 1, @parent_id, 1 );
|
||||||
|
|
||||||
|
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||||
|
VALUES ( '更新', 3, @parent_id, false, false, true, false, 'address:update', 1, @parent_id, 1 );
|
||||||
|
|
||||||
|
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||||
|
VALUES ( '删除', 3, @parent_id, false, false, true, false, 'address:delete', 1, @parent_id, 1 );
|
||||||
|
|
@ -7,8 +7,6 @@ import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
|
||||||
import net.lab1024.sa.admin.module.business.base.area.dao.AreaDao;
|
import net.lab1024.sa.admin.module.business.base.area.dao.AreaDao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import net.lab1024.sa.admin.module.business.base.area.service.AreaQueryService;
|
|
||||||
import net.lab1024.sa.admin.module.business.category.domain.entity.CategoryEntity;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ public class LocationQueryService {
|
||||||
public List<LocationsExcelVO> getLocationsExcelVOList() {
|
public List<LocationsExcelVO> getLocationsExcelVOList() {
|
||||||
List<LocationEntity> locationsList = locationDao.selectList(null);
|
List<LocationEntity> locationsList = locationDao.selectList(null);
|
||||||
//库区
|
//库区
|
||||||
List areaIds = locationsList.stream().map(LocationEntity::getAreaId).distinct().collect(Collectors.toList());
|
List<Long> areaIds = locationsList.stream().map(LocationEntity::getAreaId).distinct().collect(Collectors.toList());
|
||||||
Map<Long, AreaEntity> areaMap = areaQueryService.queryAreaList(areaIds);
|
Map<Long, AreaEntity> areaMap = areaQueryService.queryAreaList(areaIds);
|
||||||
return locationsList.stream()
|
return locationsList.stream()
|
||||||
.map(location ->
|
.map(location ->
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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="net.lab1024.sa.admin.module.business.base.address.dao.AddressDao">
|
||||||
|
|
||||||
|
<!-- 查询结果列 -->
|
||||||
|
<sql id="base_columns">
|
||||||
|
t_address.address_id,
|
||||||
|
t_address.name,
|
||||||
|
t_address.person,
|
||||||
|
t_address.telephone,
|
||||||
|
t_address.address,
|
||||||
|
t_address.create_time,
|
||||||
|
t_address.create_user_id,
|
||||||
|
t_address.create_user_name,
|
||||||
|
t_address.update_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 分页查询 -->
|
||||||
|
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.base.address.domain.vo.AddressVO">
|
||||||
|
SELECT
|
||||||
|
<include refid="base_columns"/>
|
||||||
|
FROM t_address
|
||||||
|
<where>
|
||||||
|
<!--收货单位-->
|
||||||
|
<if test="queryForm.addressId != null ">
|
||||||
|
AND t_address.address_id=#{queryForm.addressId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by t_address.address_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue