zds
1 month ago
23 changed files with 545 additions and 686 deletions
@ -0,0 +1,46 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.Customerbase; |
||||
|
import org.nl.wms.basedata.master.customer.service.dto.CustomerbaseQuery; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @author ldjun |
||||
|
* @description 服务接口 |
||||
|
* @date 2021-12-06 |
||||
|
**/ |
||||
|
public interface CustomerbaseService extends IService<Customerbase> { |
||||
|
|
||||
|
/** |
||||
|
* 查询数据分页 |
||||
|
* |
||||
|
* @param whereJson 条件 |
||||
|
* @param page 分页参数 |
||||
|
* @return Map<String, Object> |
||||
|
*/ |
||||
|
IPage<Customerbase> queryAll(CustomerbaseQuery whereJson, PageQuery page); |
||||
|
|
||||
|
/** |
||||
|
* 创建 |
||||
|
* |
||||
|
* @param dto / |
||||
|
*/ |
||||
|
void create(Customerbase dto); |
||||
|
|
||||
|
/** |
||||
|
* 编辑 |
||||
|
* |
||||
|
* @param dto / |
||||
|
*/ |
||||
|
void update(Customerbase dto); |
||||
|
|
||||
|
/** |
||||
|
* 多选删除 |
||||
|
* |
||||
|
* @param ids / |
||||
|
*/ |
||||
|
void deleteAll(Long[] ids); |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.dao; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author: zds |
||||
|
* @date: 2024-09-27 |
||||
|
* @description: |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
@TableName("md_cs_customerbase") |
||||
|
public class Customerbase implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@TableId(value = "cust_id", type = IdType.NONE) |
||||
|
private String cust_id; |
||||
|
//客户编码
|
||||
|
private String cust_code; |
||||
|
//客户名称
|
||||
|
private String cust_name; |
||||
|
//客户简称
|
||||
|
private String cust_simple_name; |
||||
|
//公司电话
|
||||
|
private String corp_tele_no; |
||||
|
//公司地址
|
||||
|
private String corp_address; |
||||
|
//业务员
|
||||
|
private String sales_owner; |
||||
|
//创建人
|
||||
|
private String create_id; |
||||
|
//创建人姓名
|
||||
|
private String create_name; |
||||
|
//创建时间
|
||||
|
private String create_time; |
||||
|
//修改人
|
||||
|
private String update_id; |
||||
|
//修改人姓名
|
||||
|
private String update_name; |
||||
|
//修改时间
|
||||
|
private String update_time; |
||||
|
//是否启用
|
||||
|
private String is_used; |
||||
|
//是否删除
|
||||
|
private String is_delete; |
||||
|
//备注
|
||||
|
private String remark; |
||||
|
//子卷打印模板号
|
||||
|
private String zj_print_no; |
||||
|
//包装打印模板号
|
||||
|
private String bz_print_no; |
||||
|
//送货单打印模板号
|
||||
|
private String shd_print_no; |
||||
|
//送货单明细数
|
||||
|
private Integer shd_dtl_num; |
||||
|
//是否自动贴标
|
||||
|
private String is_auto_table; |
||||
|
//内标打印模版
|
||||
|
private String bz_print_within; |
||||
|
|
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.dao; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.bean.copier.CopyOptions; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author: zds |
||||
|
* @date: 2024-09-27 |
||||
|
* @description: |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
@TableName("md_cs_customerbaseproc") |
||||
|
public class CustomerbaseProc implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@TableId(value = "id", type = IdType.NONE) |
||||
|
private String id; |
||||
|
//客户code
|
||||
|
private String customer_name; |
||||
|
//客户名称
|
||||
|
private String description; |
||||
|
//客户简称
|
||||
|
private String company; |
||||
|
//国家
|
||||
|
private String country; |
||||
|
//省份/州
|
||||
|
private String state; |
||||
|
//城市
|
||||
|
private String city; |
||||
|
//客户地址/街道
|
||||
|
private String address_line1; |
||||
|
//邮编
|
||||
|
private String zip_code; |
||||
|
//手机号
|
||||
|
private String phone_number; |
||||
|
//传真
|
||||
|
private String fax_number; |
||||
|
//邮箱
|
||||
|
private String web_site; |
||||
|
//备注
|
||||
|
private String notes; |
||||
|
//业务员
|
||||
|
private String sales_owner; |
||||
|
//新增时间
|
||||
|
private String create_time; |
||||
|
|
||||
|
public void copyFrom(JSONObject source){ |
||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.dao.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.Customerbase; |
||||
|
|
||||
|
/** |
||||
|
* @author: zds |
||||
|
* @date: 2024-09-27 |
||||
|
* @description: |
||||
|
*/ |
||||
|
public interface CustomerbaseMapper extends BaseMapper<Customerbase> { |
||||
|
|
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="org.nl.wms.basedata.master.customer.service.dao.mapper.CustomerbaseMapper"> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,14 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.dao.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.Customerbase; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.CustomerbaseProc; |
||||
|
|
||||
|
/** |
||||
|
* @author: zds |
||||
|
* @date: 2024-09-27 |
||||
|
* @description: |
||||
|
*/ |
||||
|
public interface CustomerbaseProcMapper extends BaseMapper<CustomerbaseProc> { |
||||
|
|
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="org.nl.wms.basedata.master.customer.service.dao.mapper.CustomerbaseProcMapper"> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,18 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author: zds |
||||
|
* @date: 2024-09-27 |
||||
|
* @description: |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CustomerbaseQuery implements Serializable { |
||||
|
//编码或名称
|
||||
|
private String search; |
||||
|
//是否启用
|
||||
|
private String is_used; |
||||
|
} |
@ -0,0 +1,111 @@ |
|||||
|
package org.nl.wms.basedata.master.customer.service.impl; |
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.common.utils.SecurityUtils; |
||||
|
import org.nl.modules.common.exception.BadRequestException; |
||||
|
import org.nl.wms.basedata.master.customer.service.CustomerbaseService; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.Customerbase; |
||||
|
import org.nl.wms.basedata.master.customer.service.dao.mapper.CustomerbaseMapper; |
||||
|
import org.nl.wms.basedata.master.customer.service.dto.CustomerbaseQuery; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @author ldjun |
||||
|
* @description 服务实现 |
||||
|
* @date 2021-12-06 |
||||
|
**/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class CustomerbaseServiceImpl extends ServiceImpl<CustomerbaseMapper, Customerbase> implements CustomerbaseService { |
||||
|
|
||||
|
@Autowired |
||||
|
private CustomerbaseMapper customerbaseMapper; |
||||
|
|
||||
|
@Override |
||||
|
public IPage<Customerbase> queryAll(CustomerbaseQuery whereJson, PageQuery page) { |
||||
|
IPage<Customerbase> pages = new Page<>(page.getPage() + 1, page.getSize()); |
||||
|
LambdaQueryWrapper<Customerbase> lam = new LambdaQueryWrapper<Customerbase>(); |
||||
|
|
||||
|
lam.eq(ObjectUtil.isNotEmpty(whereJson.getIs_used()), Customerbase::getIs_used, whereJson.getIs_used()) |
||||
|
.and(ObjectUtil.isNotEmpty(whereJson.getSearch()),blam -> blam.like(Customerbase::getCust_name, whereJson.getSearch()).or() |
||||
|
.like(Customerbase::getCust_code, whereJson.getSearch())) |
||||
|
.orderByDesc(Customerbase::getCust_code); |
||||
|
customerbaseMapper.selectPage(pages, lam); |
||||
|
return pages; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void create(Customerbase dto) { |
||||
|
LambdaQueryWrapper<Customerbase> lam = new LambdaQueryWrapper<Customerbase>(); |
||||
|
lam.eq(Customerbase::getCust_code,dto.getCust_code()); |
||||
|
lam.eq(Customerbase::getIs_delete,"0"); |
||||
|
Customerbase customer = customerbaseMapper.selectOne(lam); |
||||
|
if (ObjectUtil.isNotEmpty(customer)) { |
||||
|
throw new BadRequestException("已存在相同的客户编号!"); |
||||
|
} |
||||
|
|
||||
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
||||
|
String nickName = SecurityUtils.getCurrentNickName(); |
||||
|
String now = DateUtil.now(); |
||||
|
|
||||
|
dto.setCust_id(IdUtil.getSnowflake(1, 1).nextId()+""); |
||||
|
dto.setCreate_id(currentUserId); |
||||
|
dto.setCreate_name(nickName); |
||||
|
dto.setCreate_time(now); |
||||
|
customerbaseMapper.insert(dto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(Customerbase dto) { |
||||
|
LambdaQueryWrapper<Customerbase> lam = new LambdaQueryWrapper<Customerbase>(); |
||||
|
lam.eq(Customerbase::getCust_code,dto.getCust_code()); |
||||
|
lam.eq(Customerbase::getIs_delete,"0"); |
||||
|
lam.ne(Customerbase::getCust_id,dto.getCust_id()); |
||||
|
Customerbase customer = customerbaseMapper.selectOne(lam); |
||||
|
if (ObjectUtil.isNotEmpty(customer)) { |
||||
|
throw new BadRequestException("已存在相同的客户编号!"); |
||||
|
} |
||||
|
|
||||
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
||||
|
String nickName = SecurityUtils.getCurrentNickName(); |
||||
|
String now = DateUtil.now(); |
||||
|
|
||||
|
dto.setUpdate_time(now); |
||||
|
dto.setUpdate_id(currentUserId); |
||||
|
dto.setUpdate_name(nickName); |
||||
|
customerbaseMapper.updateById(dto); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void deleteAll(Long[] ids) { |
||||
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
||||
|
String nickName = SecurityUtils.getCurrentNickName(); |
||||
|
String now = DateUtil.now(); |
||||
|
//设置更新条件
|
||||
|
LambdaUpdateWrapper<Customerbase> lam = new LambdaUpdateWrapper<Customerbase>(); |
||||
|
lam.in(Customerbase::getCust_id,ids); |
||||
|
|
||||
|
lam.set(Customerbase::getIs_delete, "1"); |
||||
|
lam.set(Customerbase::getUpdate_id, currentUserId); |
||||
|
lam.set(Customerbase::getUpdate_name, nickName); |
||||
|
lam.set(Customerbase::getUpdate_time, now); |
||||
|
customerbaseMapper.update(null,lam); |
||||
|
} |
||||
|
} |
@ -1,70 +0,0 @@ |
|||||
package org.nl.wms.basedata.master.service; |
|
||||
|
|
||||
import org.nl.wms.basedata.master.service.dto.CustomerbaseDto; |
|
||||
import org.springframework.data.domain.Pageable; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
/** |
|
||||
* @author ldjun |
|
||||
* @description 服务接口 |
|
||||
* @date 2021-12-06 |
|
||||
**/ |
|
||||
public interface CustomerbaseService { |
|
||||
|
|
||||
/** |
|
||||
* 查询数据分页 |
|
||||
* |
|
||||
* @param whereJson 条件 |
|
||||
* @param page 分页参数 |
|
||||
* @return Map<String, Object> |
|
||||
*/ |
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page); |
|
||||
|
|
||||
/** |
|
||||
* 查询所有数据不分页 |
|
||||
* |
|
||||
* @param whereJson 条件参数 |
|
||||
* @return List<CustomerbaseDto> |
|
||||
*/ |
|
||||
List<CustomerbaseDto> queryAll(Map whereJson); |
|
||||
|
|
||||
/** |
|
||||
* 根据ID查询 |
|
||||
* |
|
||||
* @param cust_id ID |
|
||||
* @return Customerbase |
|
||||
*/ |
|
||||
CustomerbaseDto findById(Long cust_id); |
|
||||
|
|
||||
/** |
|
||||
* 根据编码查询 |
|
||||
* |
|
||||
* @param code code |
|
||||
* @return Customerbase |
|
||||
*/ |
|
||||
CustomerbaseDto findByCode(String code); |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 创建 |
|
||||
* |
|
||||
* @param dto / |
|
||||
*/ |
|
||||
void create(CustomerbaseDto dto); |
|
||||
|
|
||||
/** |
|
||||
* 编辑 |
|
||||
* |
|
||||
* @param dto / |
|
||||
*/ |
|
||||
void update(CustomerbaseDto dto); |
|
||||
|
|
||||
/** |
|
||||
* 多选删除 |
|
||||
* |
|
||||
* @param ids / |
|
||||
*/ |
|
||||
void deleteAll(Long[] ids); |
|
||||
} |
|
@ -1,212 +0,0 @@ |
|||||
package org.nl.wms.basedata.master.service.dto; |
|
||||
|
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|
||||
import lombok.Data; |
|
||||
|
|
||||
import java.io.Serializable; |
|
||||
|
|
||||
/** |
|
||||
* @author ldjun |
|
||||
* @description / |
|
||||
* @date 2021-12-06 |
|
||||
**/ |
|
||||
@Data |
|
||||
public class CustomerbaseDto implements Serializable { |
|
||||
/** 客户标识 */ |
|
||||
/** |
|
||||
* 防止精度丢失 |
|
||||
*/ |
|
||||
@JsonSerialize(using = ToStringSerializer.class) |
|
||||
private Long cust_id; |
|
||||
|
|
||||
/** |
|
||||
* 客户编码 |
|
||||
*/ |
|
||||
private String cust_code; |
|
||||
|
|
||||
/** |
|
||||
* 客户名称 |
|
||||
*/ |
|
||||
private String cust_name; |
|
||||
|
|
||||
/** |
|
||||
* 业务员 |
|
||||
*/ |
|
||||
private String sales_owner; |
|
||||
|
|
||||
/** |
|
||||
* 客户简称 |
|
||||
*/ |
|
||||
private String cust_simple_name; |
|
||||
|
|
||||
/** |
|
||||
* 国家 |
|
||||
*/ |
|
||||
private String country; |
|
||||
|
|
||||
/** |
|
||||
* 省份 |
|
||||
*/ |
|
||||
private String state; |
|
||||
|
|
||||
/** |
|
||||
* 城市 |
|
||||
*/ |
|
||||
private String city; |
|
||||
|
|
||||
/** |
|
||||
* 传真 |
|
||||
*/ |
|
||||
private String faxnumber; |
|
||||
|
|
||||
/** |
|
||||
* 邮箱 |
|
||||
*/ |
|
||||
private String webSite; |
|
||||
|
|
||||
/** |
|
||||
* 法人代表 |
|
||||
*/ |
|
||||
private String jurid_name; |
|
||||
|
|
||||
/** |
|
||||
* 税务登记号 |
|
||||
*/ |
|
||||
private String tax_no; |
|
||||
|
|
||||
/** |
|
||||
* 工商注册号 |
|
||||
*/ |
|
||||
private String register_no; |
|
||||
|
|
||||
/** |
|
||||
* 经营许可证号 |
|
||||
*/ |
|
||||
private String manage_lice_no; |
|
||||
|
|
||||
/** |
|
||||
* 营业执照 |
|
||||
*/ |
|
||||
private String busi_char_name; |
|
||||
|
|
||||
/** |
|
||||
* 行政区划 |
|
||||
*/ |
|
||||
private Long area_id; |
|
||||
|
|
||||
/** |
|
||||
* 邮政编码 |
|
||||
*/ |
|
||||
private String zip_code; |
|
||||
|
|
||||
/** |
|
||||
* 公司电话 |
|
||||
*/ |
|
||||
private String corp_tele_no; |
|
||||
|
|
||||
/** |
|
||||
* 公司地址 |
|
||||
*/ |
|
||||
private String corp_address; |
|
||||
|
|
||||
/** |
|
||||
* 创建人 |
|
||||
*/ |
|
||||
private String create_id; |
|
||||
|
|
||||
/** |
|
||||
* 创建人姓名 |
|
||||
*/ |
|
||||
private String create_name; |
|
||||
|
|
||||
/** |
|
||||
* 创建时间 |
|
||||
*/ |
|
||||
private String create_time; |
|
||||
|
|
||||
/** |
|
||||
* 修改人 |
|
||||
*/ |
|
||||
private String update_optid; |
|
||||
|
|
||||
/** |
|
||||
* 修改人姓名 |
|
||||
*/ |
|
||||
private String update_optname; |
|
||||
|
|
||||
/** |
|
||||
* 修改时间 |
|
||||
*/ |
|
||||
private String update_time; |
|
||||
|
|
||||
/** |
|
||||
* 启用时间 |
|
||||
*/ |
|
||||
private String is_used_time; |
|
||||
|
|
||||
/** |
|
||||
* 是否启用 |
|
||||
*/ |
|
||||
private String is_used; |
|
||||
|
|
||||
/** |
|
||||
* 是否删除 |
|
||||
*/ |
|
||||
private String is_delete; |
|
||||
|
|
||||
/** |
|
||||
* 外部标识 |
|
||||
*/ |
|
||||
private String ext_id; |
|
||||
|
|
||||
/** |
|
||||
* 备注 |
|
||||
*/ |
|
||||
private String remark; |
|
||||
|
|
||||
/** |
|
||||
* 分类标识 |
|
||||
*/ |
|
||||
private Long class_id; |
|
||||
|
|
||||
/** |
|
||||
* 分类编码 |
|
||||
*/ |
|
||||
private String class_code; |
|
||||
|
|
||||
/** |
|
||||
* 分类名称 |
|
||||
*/ |
|
||||
private String class_name; |
|
||||
|
|
||||
/** |
|
||||
* 子卷打印模板号 |
|
||||
*/ |
|
||||
private String zj_print_no; |
|
||||
|
|
||||
/** |
|
||||
* 包装打印模板号 |
|
||||
*/ |
|
||||
private String bz_print_no; |
|
||||
|
|
||||
/** |
|
||||
* 送货单打印模板号 |
|
||||
*/ |
|
||||
private String shd_print_no; |
|
||||
|
|
||||
/** |
|
||||
* 送货单明细数 |
|
||||
*/ |
|
||||
private String shd_dtl_num; |
|
||||
|
|
||||
/** |
|
||||
* 是否自动贴标 |
|
||||
*/ |
|
||||
private String is_auto_table; |
|
||||
|
|
||||
/** |
|
||||
* 内标打印模版 |
|
||||
*/ |
|
||||
private String bz_print_within; |
|
||||
} |
|
@ -1,155 +0,0 @@ |
|||||
package org.nl.wms.basedata.master.service.impl; |
|
||||
|
|
||||
|
|
||||
import cn.hutool.core.date.DateUtil; |
|
||||
import cn.hutool.core.util.IdUtil; |
|
||||
import cn.hutool.core.util.ObjectUtil; |
|
||||
import cn.hutool.core.util.StrUtil; |
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.alibaba.fastjson.JSONArray; |
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import lombok.RequiredArgsConstructor; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.nl.common.utils.SecurityUtils; |
|
||||
import org.nl.modules.common.exception.BadRequestException; |
|
||||
import org.nl.modules.wql.core.bean.ResultBean; |
|
||||
import org.nl.modules.wql.core.bean.WQLObject; |
|
||||
import org.nl.modules.wql.util.WqlUtil; |
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService; |
|
||||
import org.nl.wms.basedata.master.service.CustomerbaseService; |
|
||||
import org.nl.wms.basedata.master.service.dto.CustomerbaseDto; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.data.domain.Pageable; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
import org.springframework.transaction.annotation.Transactional; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
/** |
|
||||
* @author ldjun |
|
||||
* @description 服务实现 |
|
||||
* @date 2021-12-06 |
|
||||
**/ |
|
||||
@Service |
|
||||
@RequiredArgsConstructor |
|
||||
@Slf4j |
|
||||
public class CustomerbaseServiceImpl implements CustomerbaseService { |
|
||||
@Autowired |
|
||||
private ClassstandardService classstandardService; |
|
||||
|
|
||||
@Override |
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|
||||
String where = ""; |
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
String search = (String) whereJson.get("search"); |
|
||||
if (!StrUtil.isEmpty(search)) { |
|
||||
where = "AND (cust_code like '%" + search + "%' OR cust_name like '%" + search + "%')"; |
|
||||
} |
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete = '0'" + where, "update_time desc"); |
|
||||
final JSONObject json = rb.pageResult(); |
|
||||
return json; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<CustomerbaseDto> queryAll(Map whereJson) { |
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
JSONArray arr = wo.query().getResultJSONArray(0); |
|
||||
List<CustomerbaseDto> list = arr.toJavaList(CustomerbaseDto.class); |
|
||||
return list; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public CustomerbaseDto findById(Long cust_id) { |
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
JSONObject json = wo.query("cust_id =" + cust_id + "").uniqueResult(0); |
|
||||
if (ObjectUtil.isEmpty(json)) { |
|
||||
return null; |
|
||||
} |
|
||||
final CustomerbaseDto obj = json.toJavaObject(CustomerbaseDto.class); |
|
||||
return obj; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public CustomerbaseDto findByCode(String code) { |
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
JSONObject json = wo.query("cust_code ='" + code + "'").uniqueResult(0); |
|
||||
if (ObjectUtil.isEmpty(json)) { |
|
||||
return null; |
|
||||
} |
|
||||
final CustomerbaseDto obj = json.toJavaObject(CustomerbaseDto.class); |
|
||||
return obj; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
@Transactional(rollbackFor = Exception.class) |
|
||||
public void create(CustomerbaseDto dto) { |
|
||||
String cust_code = dto.getCust_code(); |
|
||||
CustomerbaseDto customerbaseDto = this.findByCode(cust_code); |
|
||||
if (customerbaseDto != null && "0".equals(customerbaseDto.getIs_delete())) { |
|
||||
throw new BadRequestException("存在相同的客户编号"); |
|
||||
} |
|
||||
|
|
||||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
||||
String nickName = SecurityUtils.getCurrentNickName(); |
|
||||
String now = DateUtil.now(); |
|
||||
|
|
||||
dto.setCust_id(IdUtil.getSnowflake(1, 1).nextId()); |
|
||||
dto.setCreate_id(currentUserId); |
|
||||
dto.setCreate_name(nickName); |
|
||||
dto.setUpdate_optid(currentUserId); |
|
||||
dto.setUpdate_optname(nickName); |
|
||||
dto.setUpdate_time(now); |
|
||||
dto.setCreate_time(now); |
|
||||
|
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|
||||
wo.insert(json); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
@Transactional(rollbackFor = Exception.class) |
|
||||
public void update(CustomerbaseDto dto) { |
|
||||
CustomerbaseDto entity = this.findById(dto.getCust_id()); |
|
||||
if (entity == null) { |
|
||||
throw new BadRequestException("被删除或无权限,操作失败!"); |
|
||||
} |
|
||||
|
|
||||
String cust_code = dto.getCust_code(); |
|
||||
CustomerbaseDto customerbaseDto = this.findByCode(cust_code); |
|
||||
if (customerbaseDto != null && !customerbaseDto.getCust_id().equals(dto.getCust_id()) && "0".equals(customerbaseDto.getIs_delete())) { |
|
||||
throw new BadRequestException("存在相同的客户编号"); |
|
||||
} |
|
||||
|
|
||||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
||||
String nickName = SecurityUtils.getCurrentNickName(); |
|
||||
|
|
||||
String now = DateUtil.now(); |
|
||||
dto.setUpdate_time(now); |
|
||||
dto.setUpdate_optid(currentUserId); |
|
||||
dto.setUpdate_optname(nickName); |
|
||||
|
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|
||||
wo.update(json); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
@Transactional(rollbackFor = Exception.class) |
|
||||
public void deleteAll(Long[] ids) { |
|
||||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
||||
String nickName = SecurityUtils.getCurrentNickName(); |
|
||||
String now = DateUtil.now(); |
|
||||
|
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase"); |
|
||||
for (Long cust_id : ids) { |
|
||||
JSONObject param = new JSONObject(); |
|
||||
param.put("cust_id", String.valueOf(cust_id)); |
|
||||
param.put("is_delete", "1"); |
|
||||
param.put("update_optid", currentUserId); |
|
||||
param.put("update_optname", nickName); |
|
||||
param.put("update_time", now); |
|
||||
wo.update(param); |
|
||||
} |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue