新增入库
							parent
							
								
									c50f674f66
								
							
						
					
					
						commit
						4e619f5a3a
					
				| 
						 | 
				
			
			@ -56,6 +56,7 @@ public class AddressService {
 | 
			
		|||
     * @param addForm 添加参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> add(AddressAddForm addForm) {
 | 
			
		||||
        AddressEntity addressEntity = SmartBeanUtil.copy(addForm, AddressEntity.class);
 | 
			
		||||
        addressDao.insert(addressEntity);
 | 
			
		||||
| 
						 | 
				
			
			@ -71,6 +72,7 @@ public class AddressService {
 | 
			
		|||
     * @param updateForm 更新参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> update(AddressUpdateForm updateForm) {
 | 
			
		||||
        AddressEntity addressEntity = SmartBeanUtil.copy(updateForm, AddressEntity.class);
 | 
			
		||||
        addressDao.updateById(addressEntity);
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +88,7 @@ public class AddressService {
 | 
			
		|||
     * @param idList 集合
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> batchDelete(List<Long> idList) {
 | 
			
		||||
        if (CollectionUtils.isEmpty(idList)) {
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
| 
						 | 
				
			
			@ -104,6 +107,7 @@ public class AddressService {
 | 
			
		|||
     * @param addressId id
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> delete(Long addressId) {
 | 
			
		||||
        if (null == addressId) {
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ package net.lab1024.sa.admin.module.business.base.customer.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.area.domain.entity.AreaEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.area.domain.form.AreaSelect;
 | 
			
		||||
| 
						 | 
				
			
			@ -10,12 +11,16 @@ import net.lab1024.sa.admin.module.business.base.customer.domain.entity.Customer
 | 
			
		|||
import net.lab1024.sa.admin.module.business.base.customer.domain.form.CustomerQueryForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.form.CustomerSelect;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.vo.CustomerVO;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.manager.CustomerManager;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.PageResult;
 | 
			
		||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
 | 
			
		||||
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 CustomerQueryService {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,6 +28,9 @@ public class CustomerQueryService {
 | 
			
		|||
    @Resource
 | 
			
		||||
    private CustomerDao customerDao;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CustomerManager customerManager;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 分页查询
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -48,4 +56,36 @@ public class CustomerQueryService {
 | 
			
		|||
        }
 | 
			
		||||
        return customerDao.selectList(queryWrapper);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据客户id集合查询客户信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param customerIdList 客户id集合
 | 
			
		||||
     * @return Map<Long, AreaEntity>
 | 
			
		||||
     */
 | 
			
		||||
    public Map<Long, CustomerEntity> queryCustomerList(List<Long> customerIdList) {
 | 
			
		||||
        if (CollectionUtils.isEmpty(customerIdList)) {
 | 
			
		||||
            return Collections.emptyMap();
 | 
			
		||||
        }
 | 
			
		||||
        customerIdList = customerIdList.stream().distinct().collect(Collectors.toList());
 | 
			
		||||
        Map<Long, CustomerEntity> customerMap = Maps.newHashMap();
 | 
			
		||||
        for (Long customerId : customerIdList) {
 | 
			
		||||
            CustomerEntity customer = customerManager.queryCustomer(customerId);
 | 
			
		||||
            if (customer != null) {
 | 
			
		||||
                customerMap.put(customerId, customer);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return customerMap;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据客户名称查询客户信息
 | 
			
		||||
     * @param customerName 客户名称
 | 
			
		||||
     * @return CustomerEntity
 | 
			
		||||
     */
 | 
			
		||||
    public CustomerEntity queryByCustomerName(String customerName) {
 | 
			
		||||
        LambdaQueryWrapper<CustomerEntity> queryWrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        queryWrapper.eq(CustomerEntity::getCustomerName, customerName);
 | 
			
		||||
        return customerDao.selectOne(queryWrapper);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,17 +2,20 @@ package net.lab1024.sa.admin.module.business.base.customer.service;
 | 
			
		|||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.dao.CustomerDao;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.entity.CustomerEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.form.CustomerAddForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.form.CustomerUpdateForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.manager.CustomerManager;
 | 
			
		||||
import net.lab1024.sa.base.common.code.UserErrorCode;
 | 
			
		||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
 | 
			
		||||
import org.apache.commons.collections4.CollectionUtils;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 客户管理 Service
 | 
			
		||||
| 
						 | 
				
			
			@ -31,15 +34,25 @@ public class CustomerService {
 | 
			
		|||
    @Resource
 | 
			
		||||
    private CustomerManager customerManager;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CustomerQueryService customerQueryService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加
 | 
			
		||||
     *
 | 
			
		||||
     * @param addForm 添加参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> add(CustomerAddForm addForm) {
 | 
			
		||||
        CustomerEntity existingCustomer = customerQueryService.queryByCustomerName(addForm.getCustomerName());
 | 
			
		||||
        if (existingCustomer != null) {
 | 
			
		||||
            return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, UserErrorCode.ALREADY_EXIST.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
        CustomerEntity customerEntity = SmartBeanUtil.copy(addForm, CustomerEntity.class);
 | 
			
		||||
        customerDao.insert(customerEntity);
 | 
			
		||||
        //更新缓存
 | 
			
		||||
        customerManager.removeCache();
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -49,9 +62,16 @@ public class CustomerService {
 | 
			
		|||
     * @param updateForm 更新参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> update(CustomerUpdateForm updateForm) {
 | 
			
		||||
        CustomerEntity existingCustomer = customerQueryService.queryByCustomerName(updateForm.getCustomerName());
 | 
			
		||||
        if (existingCustomer != null && !existingCustomer.getCustomerId().equals(updateForm.getCustomerId())) {
 | 
			
		||||
            return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, UserErrorCode.ALREADY_EXIST.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
        CustomerEntity customerEntity = SmartBeanUtil.copy(updateForm, CustomerEntity.class);
 | 
			
		||||
        customerDao.updateById(customerEntity);
 | 
			
		||||
        //更新缓存
 | 
			
		||||
        customerManager.removeCache();
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -61,12 +81,15 @@ public class CustomerService {
 | 
			
		|||
     * @param idList id集合
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> batchDelete(List<Long> idList) {
 | 
			
		||||
        if (CollectionUtils.isEmpty(idList)) {
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
            return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        customerManager.removeBatchByIds(idList);
 | 
			
		||||
        //更新缓存
 | 
			
		||||
        customerManager.removeCache();
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -76,12 +99,15 @@ public class CustomerService {
 | 
			
		|||
     * @param customerId id
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> delete(Long customerId) {
 | 
			
		||||
        if (null == customerId) {
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
            return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        customerDao.deleteById(customerId);
 | 
			
		||||
        //更新缓存
 | 
			
		||||
        customerManager.removeCache();
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -151,6 +151,7 @@ public class StockService {
 | 
			
		|||
     * @param stockId 容器Id
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<String> delete(Long stockId) {
 | 
			
		||||
        if (null == stockId) {
 | 
			
		||||
            return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,46 @@
 | 
			
		|||
package net.lab1024.sa.admin.module.business.receive.asn.constant;
 | 
			
		||||
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import net.lab1024.sa.base.common.enumeration.BaseEnum;
 | 
			
		||||
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@Getter
 | 
			
		||||
public enum AsnOrderStatusEnum implements BaseEnum {
 | 
			
		||||
    /**
 | 
			
		||||
     * 1 已创建
 | 
			
		||||
     */
 | 
			
		||||
    CREATED("CREATED", "已创建"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 2 已提交
 | 
			
		||||
     */
 | 
			
		||||
    APPROVING("APPROVING", "已提交"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 3 已审核
 | 
			
		||||
     */
 | 
			
		||||
    APPROVED("APPROVED", "已审核"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 4 入库中
 | 
			
		||||
     */
 | 
			
		||||
    IN_PROGRESS("IN_PROGRESS", "入库中"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 5 已完成
 | 
			
		||||
     */
 | 
			
		||||
    COMPLETED("COMPLETED", "已完成"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 6 已取消
 | 
			
		||||
     */
 | 
			
		||||
    CANCELLED("CANCELLED", "已取消"),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
    private final String value;
 | 
			
		||||
 | 
			
		||||
    private final String desc;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
package net.lab1024.sa.admin.module.business.receive.asn.constant;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import net.lab1024.sa.base.common.enumeration.BaseEnum;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品状态
 | 
			
		||||
 *
 | 
			
		||||
 * @Author 1024创新实验室: 胡克
 | 
			
		||||
 * @Date 2021-10-25 20:26:54
 | 
			
		||||
 * @Wechat zhuoda1024
 | 
			
		||||
 * @Email lab1024@163.com
 | 
			
		||||
 * @Copyright  <a href="https://1024lab.net">1024创新实验室</a>
 | 
			
		||||
 */
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@Getter
 | 
			
		||||
public enum AsnOrderTypeEnum implements BaseEnum {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 1 采购入库
 | 
			
		||||
     */
 | 
			
		||||
    PURCHASE("PURCHASE", "采购入库"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 2 退货入库
 | 
			
		||||
     */
 | 
			
		||||
    RETURN("RETURN", "退货入库"),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 3 其他入库
 | 
			
		||||
     */
 | 
			
		||||
    OTHER("OTHER", "其他入库"),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
    private final String value;
 | 
			
		||||
 | 
			
		||||
    private final String desc;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +1,17 @@
 | 
			
		|||
package net.lab1024.sa.admin.module.business.receive.asn.controller;
 | 
			
		||||
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnAddForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnQueryForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnUpdateForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.vo.AsnVO;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.service.AsnQueryService;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.service.AsnService;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.RequestUser;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.ValidateList;
 | 
			
		||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
 | 
			
		||||
import net.lab1024.sa.base.module.support.serialnumber.constant.SerialNumberIdEnum;
 | 
			
		||||
import net.lab1024.sa.base.module.support.serialnumber.service.SerialNumberService;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.PageResult;
 | 
			
		||||
| 
						 | 
				
			
			@ -34,6 +39,8 @@ public class AsnController {
 | 
			
		|||
    @Resource
 | 
			
		||||
    private AsnQueryService asnQueryService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "分页查询 @author 霍锦")
 | 
			
		||||
    @PostMapping("/asn/queryPage")
 | 
			
		||||
    @SaCheckPermission("asn:query")
 | 
			
		||||
| 
						 | 
				
			
			@ -44,14 +51,17 @@ public class AsnController {
 | 
			
		|||
    @Operation(summary = "添加 @author 霍锦")
 | 
			
		||||
    @PostMapping("/asn/add")
 | 
			
		||||
    @SaCheckPermission("asn:add")
 | 
			
		||||
    public ResponseDTO<String> add(@RequestBody @Valid AsnAddForm addForm) {
 | 
			
		||||
    public ResponseDTO<AsnEntity> add(@RequestBody @Valid AsnAddForm addForm) {
 | 
			
		||||
        RequestUser requestUser = SmartRequestUtil.getRequestUser();
 | 
			
		||||
        addForm.setCreateUserId(requestUser.getUserId());
 | 
			
		||||
        addForm.setCreateUserName(requestUser.getUserName());
 | 
			
		||||
        return asnService.add(addForm);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "更新 @author 霍锦")
 | 
			
		||||
    @PostMapping("/asn/update")
 | 
			
		||||
    @SaCheckPermission("asn:update")
 | 
			
		||||
    public ResponseDTO<String> update(@RequestBody @Valid AsnUpdateForm updateForm) {
 | 
			
		||||
    public ResponseDTO<AsnEntity> update(@RequestBody @Valid AsnUpdateForm updateForm) {
 | 
			
		||||
        return asnService.update(updateForm);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,11 @@ import com.baomidou.mybatisplus.annotation.TableName;
 | 
			
		|||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
import lombok.Builder;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单 实体类
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +23,9 @@ import lombok.Data;
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@Builder
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@TableName("t_asn")
 | 
			
		||||
public class AsnEntity {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -49,10 +56,30 @@ public class AsnEntity {
 | 
			
		|||
    private String status;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 收货地址
 | 
			
		||||
     * 收货单位
 | 
			
		||||
     */
 | 
			
		||||
    private Long addressId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 联系人
 | 
			
		||||
     */
 | 
			
		||||
    private String person;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 电话
 | 
			
		||||
     */
 | 
			
		||||
    private String telephone;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 地址
 | 
			
		||||
     */
 | 
			
		||||
    private String address;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 客户
 | 
			
		||||
     */
 | 
			
		||||
    private Long customerId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 订单数量
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,8 +4,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		|||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.NotNull;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.constant.AsnOrderTypeEnum;
 | 
			
		||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
 | 
			
		||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单 新建表单
 | 
			
		||||
| 
						 | 
				
			
			@ -18,42 +20,46 @@ import lombok.Data;
 | 
			
		|||
@Data
 | 
			
		||||
public class AsnAddForm {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "入库单号", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotBlank(message = "入库单号 不能为空")
 | 
			
		||||
    @Schema(description = "入库单号")
 | 
			
		||||
    private String asnNumber;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态")
 | 
			
		||||
    private String status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "客户 不能为空")
 | 
			
		||||
    private Long customerId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户订单号", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotBlank(message = "客户订单号 不能为空")
 | 
			
		||||
    private String customerNumber;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "单据类型")
 | 
			
		||||
    @SchemaEnum(AsnOrderTypeEnum.class)
 | 
			
		||||
    @CheckEnum(message = "单据类型", value = AsnOrderTypeEnum.class, required = true)
 | 
			
		||||
    private String orderType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态")
 | 
			
		||||
    private String status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "收货地址", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "收货地址 不能为空")
 | 
			
		||||
    @Schema(description = "收货单位", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "收货单位 不能为空")
 | 
			
		||||
    private Long addressId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "联系人")
 | 
			
		||||
    private String person;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "电话")
 | 
			
		||||
    private String telephone;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "地址")
 | 
			
		||||
    private String address;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "订单日期", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "订单日期 不能为空")
 | 
			
		||||
    private LocalDate orderDate;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "创建时间 不能为空")
 | 
			
		||||
    private LocalDateTime createTime;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "创建人ID 不能为空")
 | 
			
		||||
    @Schema(hidden = true)
 | 
			
		||||
    private Long createUserId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotBlank(message = "创建人 不能为空")
 | 
			
		||||
    @Schema(hidden = true)
 | 
			
		||||
    private String createUserName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "更新时间 不能为空")
 | 
			
		||||
    private LocalDateTime updateTime;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ import lombok.Data;
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
public class AsnUpdateForm {
 | 
			
		||||
public class AsnUpdateForm extends AsnAddForm {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "入库单id", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "入库单id 不能为空")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,12 @@ public class AsnVO {
 | 
			
		|||
    @Schema(description = "入库单号")
 | 
			
		||||
    private String asnNumber;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户id")
 | 
			
		||||
    private Long customerId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户")
 | 
			
		||||
    private String customerName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户订单号")
 | 
			
		||||
    private String customerNumber;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,9 +39,22 @@ public class AsnVO {
 | 
			
		|||
    @Schema(description = "状态")
 | 
			
		||||
    private String status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "收货地址")
 | 
			
		||||
    @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 BigDecimal orderQuantity;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,16 @@
 | 
			
		|||
package net.lab1024.sa.admin.module.business.receive.asn.service;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.address.domain.entity.AddressEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.address.service.AddressQueryService;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.domain.entity.CustomerEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.customer.service.CustomerQueryService;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.dao.AsnDao;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnQueryForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.vo.AsnVO;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.PageResult;
 | 
			
		||||
| 
						 | 
				
			
			@ -10,6 +18,8 @@ import net.lab1024.sa.base.common.util.SmartPageUtil;
 | 
			
		|||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class AsnQueryService {
 | 
			
		||||
| 
						 | 
				
			
			@ -17,6 +27,12 @@ public class AsnQueryService {
 | 
			
		|||
    @Resource
 | 
			
		||||
    private AsnDao asnDao;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CustomerQueryService customerQueryService;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private AddressQueryService addressQueryService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 分页查询
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -26,8 +42,38 @@ public class AsnQueryService {
 | 
			
		|||
    public PageResult<AsnVO> queryPage(AsnQueryForm queryForm) {
 | 
			
		||||
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
 | 
			
		||||
        List<AsnVO> list = asnDao.queryPage(page, queryForm);
 | 
			
		||||
 | 
			
		||||
        // 查询客户名称
 | 
			
		||||
        List<Long> customerIdList = list.stream().map(AsnVO::getCustomerId).distinct().collect(Collectors.toList());
 | 
			
		||||
        Map<Long, CustomerEntity> customerMap = customerQueryService.queryCustomerList(customerIdList);
 | 
			
		||||
 | 
			
		||||
        // 查询收货单位
 | 
			
		||||
        List<Long> addressIdList = list.stream().map(AsnVO::getAddressId).distinct().collect(Collectors.toList());
 | 
			
		||||
        Map<Long, AddressEntity> addressMap = addressQueryService.queryAddressList(addressIdList);
 | 
			
		||||
 | 
			
		||||
        list.forEach(asnVO -> {
 | 
			
		||||
            CustomerEntity customer = customerMap.get(asnVO.getCustomerId());
 | 
			
		||||
            if (customer != null) {
 | 
			
		||||
                asnVO.setCustomerName(customer.getCustomerName());
 | 
			
		||||
            }
 | 
			
		||||
            AddressEntity address=addressMap.get(asnVO.getAddressId());
 | 
			
		||||
            if (address != null) {
 | 
			
		||||
                asnVO.setName(address.getName());
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return SmartPageUtil.convert2PageResult(page, list);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据客户订单号查询入库单
 | 
			
		||||
     * @param customerNumber 客户订单号
 | 
			
		||||
     * @return AsnEntity
 | 
			
		||||
     */
 | 
			
		||||
    public AsnEntity queryByCustomerNumber(String customerNumber) {
 | 
			
		||||
        LambdaQueryWrapper<AsnEntity> queryWrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        queryWrapper.eq(AsnEntity::getCustomerNumber, customerNumber);
 | 
			
		||||
        return asnDao.selectOne(queryWrapper);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
package net.lab1024.sa.admin.module.business.receive.asn.service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.constant.AsnOrderStatusEnum;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.dao.AsnDao;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnAddForm;
 | 
			
		||||
| 
						 | 
				
			
			@ -8,21 +10,26 @@ import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnQueryForm
 | 
			
		|||
import net.lab1024.sa.admin.module.business.receive.asn.domain.form.AsnUpdateForm;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.domain.vo.AsnVO;
 | 
			
		||||
import net.lab1024.sa.admin.module.business.receive.asn.manager.AsnManager;
 | 
			
		||||
import net.lab1024.sa.base.common.code.UserErrorCode;
 | 
			
		||||
import net.lab1024.sa.base.common.exception.BusinessException;
 | 
			
		||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
 | 
			
		||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.PageResult;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import net.lab1024.sa.base.module.support.serialnumber.constant.SerialNumberIdEnum;
 | 
			
		||||
import net.lab1024.sa.base.module.support.serialnumber.service.SerialNumberService;
 | 
			
		||||
import org.apache.commons.collections4.CollectionUtils;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单 Service
 | 
			
		||||
 *
 | 
			
		||||
 * @author 霍锦
 | 
			
		||||
 * @since  2025-03-26 15:10:02
 | 
			
		||||
 * @since 2025-03-26 15:10:02
 | 
			
		||||
 * copyright 友仓
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -35,16 +42,31 @@ public class AsnService {
 | 
			
		|||
    @Resource
 | 
			
		||||
    private AsnManager asnManager;
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
    @Resource
 | 
			
		||||
    private AsnQueryService asnQueryService;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private SerialNumberService serialNumberService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加
 | 
			
		||||
     *
 | 
			
		||||
     * @param addForm 添加参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    public ResponseDTO<String> add(AsnAddForm addForm) {
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<AsnEntity> add(AsnAddForm addForm) {
 | 
			
		||||
        AsnEntity exitAsn = asnQueryService.queryByCustomerNumber(addForm.getCustomerNumber());
 | 
			
		||||
        if (exitAsn != null) {
 | 
			
		||||
            throw new BusinessException(addForm.getCustomerNumber()+"客户订单号已存在");
 | 
			
		||||
        }
 | 
			
		||||
        //自动生成入库编号
 | 
			
		||||
        addForm.setAsnNumber(serialNumberService.generate(SerialNumberIdEnum.ASN));
 | 
			
		||||
        //默认已创建
 | 
			
		||||
        addForm.setStatus(AsnOrderStatusEnum.CREATED.getValue());
 | 
			
		||||
        AsnEntity asnEntity = SmartBeanUtil.copy(addForm, AsnEntity.class);
 | 
			
		||||
        asnDao.insert(asnEntity);
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
        return ResponseDTO.ok(asnEntity);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -53,10 +75,15 @@ public class AsnService {
 | 
			
		|||
     * @param updateForm 更新参数
 | 
			
		||||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    public ResponseDTO<String> update(AsnUpdateForm updateForm) {
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public ResponseDTO<AsnEntity> update(AsnUpdateForm updateForm) {
 | 
			
		||||
        AsnEntity exitAsn = asnQueryService.queryByCustomerNumber(updateForm.getCustomerNumber());
 | 
			
		||||
        if (exitAsn != null && !exitAsn.getAsnId().equals(updateForm.getAsnId())) {
 | 
			
		||||
            throw new BusinessException(updateForm.getCustomerNumber()+"客户订单号已存在");
 | 
			
		||||
        }
 | 
			
		||||
        AsnEntity asnEntity = SmartBeanUtil.copy(updateForm, AsnEntity.class);
 | 
			
		||||
        asnDao.updateById(asnEntity);
 | 
			
		||||
        return ResponseDTO.ok();
 | 
			
		||||
        return ResponseDTO.ok(asnEntity);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -66,8 +93,8 @@ public class AsnService {
 | 
			
		|||
     * @return ResponseDTO<String>
 | 
			
		||||
     */
 | 
			
		||||
    public ResponseDTO<String> batchDelete(List<Long> idList) {
 | 
			
		||||
        if (CollectionUtils.isEmpty(idList)){
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
        if (CollectionUtils.isEmpty(idList)) {
 | 
			
		||||
            return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        asnManager.removeBatchByIds(idList);
 | 
			
		||||
| 
						 | 
				
			
			@ -78,8 +105,8 @@ public class AsnService {
 | 
			
		|||
     * 单个删除
 | 
			
		||||
     */
 | 
			
		||||
    public ResponseDTO<String> delete(Long asnId) {
 | 
			
		||||
        if (null == asnId){
 | 
			
		||||
            return ResponseDTO.ok();
 | 
			
		||||
        if (null == asnId) {
 | 
			
		||||
            return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        asnDao.deleteById(asnId);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,11 @@
 | 
			
		|||
        t_asn.customer_number,
 | 
			
		||||
        t_asn.order_type,
 | 
			
		||||
        t_asn.status,
 | 
			
		||||
        t_asn.customer_id,
 | 
			
		||||
        t_asn.address_id,
 | 
			
		||||
        t_asn.person,
 | 
			
		||||
        t_asn.telephone,
 | 
			
		||||
        t_asn.address,
 | 
			
		||||
        t_asn.order_quantity,
 | 
			
		||||
        t_asn.received_quantity,
 | 
			
		||||
        t_asn.order_date,
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +31,7 @@
 | 
			
		|||
        <where>
 | 
			
		||||
            <!--客户订单号-->
 | 
			
		||||
            <if test="queryForm.customerNumber != null and queryForm.customerNumber != ''">
 | 
			
		||||
                        AND INSTR(t_asn.customer_number,#{queryForm.customerNumber})
 | 
			
		||||
                AND INSTR(t_asn.customer_number,#{queryForm.customerNumber})
 | 
			
		||||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </select>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,9 +17,13 @@ import net.lab1024.sa.base.common.enumeration.BaseEnum;
 | 
			
		|||
@Getter
 | 
			
		||||
public enum SerialNumberIdEnum implements BaseEnum {
 | 
			
		||||
 | 
			
		||||
    ORDER(1, "订单id"),
 | 
			
		||||
    ORDER(1, "订单编号"),
 | 
			
		||||
 | 
			
		||||
    CONTRACT(2, "合同id"),
 | 
			
		||||
    CONTRACT(2, "合同编号"),
 | 
			
		||||
 | 
			
		||||
    AGV(3, "AGV编号"),
 | 
			
		||||
 | 
			
		||||
    ASN(4, "入库单编号"),
 | 
			
		||||
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue