客户模块

product
17602169347 2 years ago
parent f85fac116f
commit 5a0186fd91

@ -0,0 +1,347 @@
package jnpf.customer.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.base.UserInfo;
import jnpf.base.vo.DownloadVO;
import jnpf.config.ConfigValueUtil;
import jnpf.exception.DataException;
import org.springframework.transaction.annotation.Transactional;
import jnpf.base.entity.ProvinceEntity;
import jnpf.customer.model.customer.*;
import jnpf.customer.model.customer.CustomerPagination;
import jnpf.customer.entity.*;
import jnpf.util.*;
import jnpf.base.util.*;
import jnpf.base.vo.ListVO;
import jnpf.util.context.SpringContext;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import lombok.Cleanup;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jnpf.customer.entity.CustomerJGEntity;
import jnpf.customer.service.CustomerJGService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import jnpf.util.GeneraterSwapUtil;
import java.util.*;
import jnpf.util.file.UploadUtil;
import jnpf.util.enums.FileTypeEnum;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Slf4j
@RestController
@Api(tags = "客户档案" , value = "customer")
@RequestMapping("/api/customer/Customer")
public class CustomerJGController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private ConfigValueUtil configValueUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CustomerJGService customerService;
/**
*
*
* @param customerPagination
* @return
*/
@PostMapping("/getList")
public ActionResult list(@RequestBody CustomerPagination customerPagination)throws IOException{
List<CustomerJGEntity> list= customerService.getList(customerPagination);
//处理id字段转名称若无需转或者为空可删除
for(CustomerJGEntity entity:list){
entity.setStatus(generaterSwapUtil.switchSelectValue(entity.getStatus() ,"1" ,"2"));
}
List<CustomerListVO> listVO=JsonUtil.getJsonToList(list,CustomerListVO.class);
for(CustomerListVO customerVO:listVO){
}
PageListVO vo=new PageListVO();
vo.setList(listVO);
PaginationVO page=JsonUtil.getJsonToBean(customerPagination,PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
* @param customerCrForm
* @return
*/
@PostMapping
@Transactional
public ActionResult create(@RequestBody @Valid CustomerCrForm customerCrForm) throws DataException {
String mainId =RandomUtil.uuId();
UserInfo userInfo=userProvider.get();
CustomerJGEntity entity = JsonUtil.getJsonToBean(customerCrForm, CustomerJGEntity.class);
entity.setId(mainId);
customerService.save(entity);
return ActionResult.success("创建成功");
}
/**
*
*
* @return
*/
@ApiOperation("模板下载")
@GetMapping("/templateDownload")
public ActionResult<DownloadVO> TemplateDownload(){
UserInfo userInfo=userProvider.get();
DownloadVO vo=DownloadVO.builder().build();
try{
vo.setName("职员信息.xlsx");
vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=" ,userInfo.getId()+"#"+"职员信息.xlsx"+"#"+"Temporary"));
}catch(Exception e){
log.error("信息导出Excel错误:{}" ,e.getMessage());
}
return ActionResult.success(vo);
}
/**
* Excel
*
* @return
*/
@ApiOperation("导出Excel")
@GetMapping("/Actions/Export")
public ActionResult Export(CustomerPaginationExportModel customerPaginationExportModel) throws IOException {
if (StringUtil.isEmpty(customerPaginationExportModel.getSelectKey())){
return ActionResult.fail("请选择导出字段");
}
CustomerPagination customerPagination=JsonUtil.getJsonToBean(customerPaginationExportModel, CustomerPagination.class);
List<CustomerJGEntity> list= customerService.getTypeList(customerPagination,customerPaginationExportModel.getDataType());
//处理id字段转名称若无需转或者为空可删除
for(CustomerJGEntity entity:list){
entity.setStatus(generaterSwapUtil.switchSelectValue(entity.getStatus() ,"1" ,"2"));
}
List<CustomerListVO> listVO=JsonUtil.getJsonToList(list,CustomerListVO.class);
for(CustomerListVO customerVO:listVO){
}
//转换为map输出
List<Map<String, Object>>mapList=JsonUtil.getJsonToListMap(JsonUtil.getObjectToStringDateFormat(listVO,"yyyy-MM-dd HH:mm:ss"));
String[]keys=!StringUtil.isEmpty(customerPaginationExportModel.getSelectKey())?customerPaginationExportModel.getSelectKey().split(","):new String[0];
UserInfo userInfo=userProvider.get();
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),mapList,keys,userInfo);
return ActionResult.success(vo);
}
//导出表格
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
for(String key:keys){
switch(key){
case "supplierCd" :
entitys.add(new ExcelExportEntity("客户编码" ,"supplierCd"));
break;
case "supplierNm" :
entitys.add(new ExcelExportEntity("客户名称" ,"supplierNm"));
break;
case "orgId" :
entitys.add(new ExcelExportEntity("所属公司ID" ,"orgId"));
break;
case "orgName" :
entitys.add(new ExcelExportEntity("公司代码" ,"orgName"));
break;
case "customerLevel" :
entitys.add(new ExcelExportEntity("客户等级" ,"customerLevel"));
break;
case "contactName" :
entitys.add(new ExcelExportEntity("联系人" ,"contactName"));
break;
case "address" :
entitys.add(new ExcelExportEntity("地址" ,"address"));
break;
case "contactPhone" :
entitys.add(new ExcelExportEntity("电话" ,"contactPhone"));
break;
case "status" :
entitys.add(new ExcelExportEntity("是否启用" ,"status"));
break;
default:
break;
}
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
}
String name = "表单信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
String fileName = configValueUtil.getTemporaryFilePath() + name;
@Cleanup FileOutputStream output = new FileOutputStream(XSSEscape.escapePath(fileName));
workbook.write(output);
//上传文件
UploadUtil.uploadFile(configValueUtil.getFileType(), fileName, FileTypeEnum.TEMPORARY, name);
vo.setName(name);
vo.setUrl(UploaderUtil.uploaderFile(userInfo.getId() + "#" + name + "#" + "Temporary"));
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
/**
*
*
* @param ids
* @return
*/
@DeleteMapping("/batchRemove/{ids}")
@Transactional
public ActionResult batchRemove(@PathVariable("ids") String ids){
String[] idList = ids.split(",");
int i =0;
for (String allId : idList){
this.delete(allId);
i++;
}
if (i == 0 ){
return ActionResult.fail("删除失败");
}
return ActionResult.success("删除成功");
}
/**
*
*
* @param id
* @return
*/
@GetMapping("/{id}")
public ActionResult<CustomerInfoVO> info(@PathVariable("id") String id){
CustomerJGEntity entity= customerService.getInfo(id);
CustomerInfoVO vo=JsonUtil.getJsonToBean(entity, CustomerInfoVO.class);
//子表
//副表
return ActionResult.success(vo);
}
/**
* ()
*
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public ActionResult<CustomerInfoVO> detailInfo(@PathVariable("id") String id){
CustomerJGEntity entity= customerService.getInfo(id);
CustomerInfoVO vo=JsonUtil.getJsonToBean(entity, CustomerInfoVO.class);
//子表数据转换
//附表数据转换
//添加到详情表单对象中
vo.setStatus(generaterSwapUtil.switchSelectValue(vo.getStatus() ,"1" ,"2"));
return ActionResult.success(vo);
}
/**
*
*
* @param id
* @return
*/
@PutMapping("/{id}")
@Transactional
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid CustomerUpForm customerUpForm) throws DataException {
UserInfo userInfo=userProvider.get();
CustomerJGEntity entity= customerService.getInfo(id);
if(entity!=null){
CustomerJGEntity subentity=JsonUtil.getJsonToBean(customerUpForm, CustomerJGEntity.class);
customerService.update(id, subentity);
return ActionResult.success("更新成功");
}else{
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
*
*
* @param id
* @return
*/
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id){
CustomerJGEntity entity= customerService.getInfo(id);
if(entity!=null){
customerService.delete(entity);
}
return ActionResult.success("删除成功");
}
}

@ -0,0 +1,100 @@
package jnpf.customer.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
@TableName("jg_customer")
public class CustomerJGEntity {
@TableId("ID")
private String id;
@TableField("F_CREATORUSERID")
private String creatoruserid;
@TableField("F_CREATORUSERNAME")
private String creatorusername;
@TableField("F_CREATORTIME")
private Date creatortime;
@TableField("F_LASTMODIFYUSERID")
private String lastmodifyuserid;
@TableField("F_LASTMODIFYUSERNAME")
private String lastmodifyusername;
@TableField("F_LASTMODIFYTIME")
private Date lastmodifytime;
@TableField("F_DELETEUSERID")
private String deleteuserid;
@TableField("F_DELETEUSERNAME")
private String deleteusername;
@TableField("F_DELETETIME")
private Date deletetime;
@TableField("F_DELETEMARK")
private String deletemark;
@TableField("orgnize_id")
private String originId;
@TableField("department_id")
private String deptId;
@TableField("SUPPLIER_CD")
private String supplierCd;
@TableField("SUPPLIER_NM")
private String supplierNm;
@TableField("SUPPLIER_SITE_ID")
private String supplierSiteId;
@TableField("SUPPLIER_SITE_CODE")
private String supplierSiteCode;
@TableField("ORG_ID")
private String orgId;
@TableField("ORG_NAME")
private String orgName;
@TableField("VAT_REGISTRATION_NUM")
private String vatRegistrationNum;
@TableField("CUSTOMER_LEVEL")
private String customerLevel;
@TableField("CONTACT_NAME")
private String contactName;
@TableField("CONTACT_PHONE")
private String contactPhone;
@TableField("STATUS")
private String status;
@TableField("ADDRESS")
private String address;
}

@ -0,0 +1,17 @@
package jnpf.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.customer.entity.CustomerJGEntity;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-01-04
*/
public interface CustomerJGMapper extends BaseMapper<CustomerJGEntity> {
}

@ -0,0 +1,60 @@
package jnpf.customer.model.customer;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerCrForm {
/** 客户编码 **/
@JsonProperty("supplierCd")
private String supplierCd;
/** 客户名称 **/
@JsonProperty("supplierNm")
private String supplierNm;
/** 所属公司ID **/
@JsonProperty("orgId")
private String orgId;
/** 公司代码 **/
@JsonProperty("orgName")
private String orgName;
/** 客户等级 **/
@JsonProperty("customerLevel")
private String customerLevel;
/** 联系人 **/
@JsonProperty("contactName")
private String contactName;
/** 地址 **/
@JsonProperty("address")
private String address;
/** 电话 **/
@JsonProperty("contactPhone")
private String contactPhone;
/** 是否启用 **/
@JsonProperty("status")
private String status;
}

@ -0,0 +1,62 @@
package jnpf.customer.model.customer;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerInfoVO{
/** 主键 **/
@JsonProperty("id")
private String id;
/** 客户编码 **/
@JsonProperty("supplierCd")
private String supplierCd;
/** 客户名称 **/
@JsonProperty("supplierNm")
private String supplierNm;
/** 所属公司ID **/
@JsonProperty("orgId")
private String orgId;
/** 公司代码 **/
@JsonProperty("orgName")
private String orgName;
/** 客户等级 **/
@JsonProperty("customerLevel")
private String customerLevel;
/** 联系人 **/
@JsonProperty("contactName")
private String contactName;
/** 地址 **/
@JsonProperty("address")
private String address;
/** 电话 **/
@JsonProperty("contactPhone")
private String contactPhone;
/** 是否启用 **/
@JsonProperty("status")
private String status;
}

@ -0,0 +1,27 @@
package jnpf.customer.model.customer;
import lombok.Data;
import java.util.Date;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerListQuery extends Pagination {
/** 客户编码 */
private String supplierCd;
/** 客户名称 */
private String supplierNm;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,72 @@
package jnpf.customer.model.customer;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerListVO{
/** 主键 */
private String id;
/** 客户编码 **/
@JsonProperty("supplierCd")
private String supplierCd;
/** 客户名称 **/
@JsonProperty("supplierNm")
private String supplierNm;
/** 所属公司ID **/
@JsonProperty("orgId")
private String orgId;
/** 公司代码 **/
@JsonProperty("orgName")
private String orgName;
/** 客户等级 **/
@JsonProperty("customerLevel")
private String customerLevel;
/** 联系人 **/
@JsonProperty("contactName")
private String contactName;
/** 地址 **/
@JsonProperty("address")
private String address;
/** 电话 **/
@JsonProperty("contactPhone")
private String contactPhone;
/** 是否启用 **/
@JsonProperty("status")
private String status;
}

@ -0,0 +1,28 @@
package jnpf.customer.model.customer;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerPagination extends Pagination {
/** 客户编码 */
private String supplierCd;
/** 客户名称 */
private String supplierNm;
/**
* id
*/
private String menuId;
}

@ -0,0 +1,29 @@
package jnpf.customer.model.customer;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.*;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerPaginationExportModel extends Pagination {
private String selectKey;
private String json;
private String dataType;
/** 客户编码 */
private String supplierCd;
/** 客户名称 */
private String supplierNm;
}

@ -0,0 +1,71 @@
package jnpf.customer.model.customer;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-01-04
*/
@Data
public class CustomerUpForm{
/** 主键 */
private String id;
/** 客户编码 **/
@JsonProperty("supplierCd")
private String supplierCd;
/** 客户名称 **/
@JsonProperty("supplierNm")
private String supplierNm;
/** 所属公司ID **/
@JsonProperty("orgId")
private String orgId;
/** 公司代码 **/
@JsonProperty("orgName")
private String orgName;
/** 客户等级 **/
@JsonProperty("customerLevel")
private String customerLevel;
/** 联系人 **/
@JsonProperty("contactName")
private String contactName;
/** 地址 **/
@JsonProperty("address")
private String address;
/** 电话 **/
@JsonProperty("contactPhone")
private String contactPhone;
/** 是否启用 **/
@JsonProperty("status")
private String status;
}

@ -0,0 +1,35 @@
package jnpf.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.customer.entity.CustomerJGEntity;
import jnpf.customer.model.customer.CustomerPagination;
import java.util.*;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-01-04
*/
public interface CustomerJGService extends IService<CustomerJGEntity> {
List<CustomerJGEntity> getList(CustomerPagination customerPagination);
List<CustomerJGEntity> getTypeList(CustomerPagination customerPagination, String dataType);
CustomerJGEntity getInfo(String id);
void delete(CustomerJGEntity entity);
void create(CustomerJGEntity entity);
boolean update(String id, CustomerJGEntity entity);
// 子表方法
//列表子表数据方法
}

@ -0,0 +1,232 @@
package jnpf.customer.service.impl;
import jnpf.customer.entity.*;
import jnpf.customer.mapper.CustomerJGMapper;
import jnpf.customer.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.util.RandomUtil;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.customer.model.customer.CustomerPagination;
import jnpf.permission.service.AuthorizeService;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;
/**
*
*
* V3.2.0
* LINKAGE-BOOT
* LINKAGE-BOOT
* 2023-01-04
*/
@Service
public class CustomerJGServiceImpl extends ServiceImpl<CustomerJGMapper, CustomerJGEntity> implements CustomerJGService{
@Autowired
private UserProvider userProvider;
@Autowired
private AuthorizeService authorizeService;
@Override
public List<CustomerJGEntity> getList(CustomerPagination customerPagination){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int customerNum =0;
QueryWrapper<CustomerJGEntity> customerQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerJGEntity>)customerObj;
customerNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerJGEntity>)customerObj;
customerNum++;
}
}
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierCd())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerJGEntity::getSupplierCd,customerPagination.getSupplierCd());
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierNm())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerJGEntity::getSupplierNm,customerPagination.getSupplierNm());
}
if(AllIdList.size()>0){
customerQueryWrapper.lambda().in(CustomerJGEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(customerPagination.getSidx())){
customerQueryWrapper.lambda().orderByDesc(CustomerJGEntity::getSupplierCd);
}else{
try {
String sidx = customerPagination.getSidx();
CustomerJGEntity customerEntity = new CustomerJGEntity();
Field declaredField = customerEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
customerQueryWrapper="asc".equals(customerPagination.getSort().toLowerCase())?customerQueryWrapper.orderByAsc(value):customerQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if((total>0 && AllIdList.size()>0) || total==0){
Page<CustomerJGEntity> page=new Page<>(customerPagination.getCurrentPage(), customerPagination.getPageSize());
IPage<CustomerJGEntity> userIPage=this.page(page, customerQueryWrapper);
return customerPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<CustomerJGEntity> list = new ArrayList();
return customerPagination.setData(list, list.size());
}
}
@Override
public List<CustomerJGEntity> getTypeList(CustomerPagination customerPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int customerNum =0;
QueryWrapper<CustomerJGEntity> customerQueryWrapper=new QueryWrapper<>();
boolean pcPermission = false;
boolean appPermission = false;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerJGEntity>)customerObj;
customerNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerJGEntity>)customerObj;
customerNum++;
}
}
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierCd())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerJGEntity::getSupplierCd,customerPagination.getSupplierCd());
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierNm())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerJGEntity::getSupplierNm,customerPagination.getSupplierNm());
}
if(AllIdList.size()>0){
customerQueryWrapper.lambda().in(CustomerJGEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(customerPagination.getSidx())){
customerQueryWrapper.lambda().orderByDesc(CustomerJGEntity::getSupplierCd);
}else{
try {
String sidx = customerPagination.getSidx();
CustomerJGEntity customerEntity = new CustomerJGEntity();
Field declaredField = customerEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
customerQueryWrapper="asc".equals(customerPagination.getSort().toLowerCase())?customerQueryWrapper.orderByAsc(value):customerQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if("0".equals(dataType)){
if((total>0 && AllIdList.size()>0) || total==0){
Page<CustomerJGEntity> page=new Page<>(customerPagination.getCurrentPage(), customerPagination.getPageSize());
IPage<CustomerJGEntity> userIPage=this.page(page, customerQueryWrapper);
return customerPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<CustomerJGEntity> list = new ArrayList();
return customerPagination.setData(list, list.size());
}
}else{
return this.list(customerQueryWrapper);
}
}
@Override
public CustomerJGEntity getInfo(String id){
QueryWrapper<CustomerJGEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(CustomerJGEntity::getId,id);
return this.getOne(queryWrapper);
}
@Override
public void create(CustomerJGEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, CustomerJGEntity entity){
entity.setId(id);
return this.updateById(entity);
}
@Override
public void delete(CustomerJGEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
//子表方法
//列表子表数据方法
}

@ -0,0 +1,7 @@
<?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="jnpf.customer.mapper.CustomerJGMapper">
</mapper>

@ -0,0 +1,132 @@
<template>
<el-dialog title="详情"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="12" >
<el-form-item label="客户编码"
prop="supplierCd" >
<p>{{dataForm.supplierCd}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="客户名称"
prop="supplierNm" >
<p>{{dataForm.supplierNm}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="所属公司ID"
prop="orgId" >
<p>{{dataForm.orgId}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="公司代码"
prop="orgName" >
<p>{{dataForm.orgName}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="客户等级"
prop="customerLevel" >
<p>{{ dataForm.customerLevel | dynamicText(customerLevelOptions) }} </p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="联系人"
prop="contactName" >
<p>{{dataForm.contactName}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="地址"
prop="address" >
<p>{{dataForm.address}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="电话"
prop="contactPhone" >
<p>{{dataForm.contactPhone}}</p>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="是否启用"
prop="status" >
<p>{{dataForm.status}}</p>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import PrintBrowse from '@/components/PrintBrowse'
import jnpf from '@/utils/jnpf'
export default {
components: {PrintBrowse},
props: [],
data() {
return {
visible: false,
loading: false,
printBrowseVisible: false,
printId: '',
dataForm: {
id :'',
supplierCd : '',
supplierNm : '',
orgId : '',
orgName : '',
customerLevel : "1",
contactName : '',
address : '',
contactPhone : '',
status : 1,
},
customerLevelOptions:[{"fullName":"一级","id":"1"},{"fullName":"二级","id":"2"},{"fullName":"三级","id":"3"}],
}
},
computed: {},
watch: {},
created() {
},
mounted() {},
methods: {
dataInfo(dataAll){
let _dataAll =dataAll
this.dataForm = _dataAll
},
init(id) {
this.dataForm.id = id || 0;
this.visible = true;
this.$nextTick(() => {
if(this.dataForm.id){
this.loading = true
request({
url: '/api/customer/Customer/detail/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
})
}
})
},
},
}
</script>

@ -0,0 +1,68 @@
<template>
<el-dialog title="导出数据" :close-on-click-modal="false" :visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center" lock-scroll width="600px">
<el-form label-position="top" label-width="80px">
<el-form-item label="数据选择">
<el-radio-group v-model="type">
<el-radio :label="0">当前页面数据</el-radio>
<el-radio :label="1">全部页面数据</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="导出字段">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
@change="handleCheckAllChange">全选</el-checkbox>
<el-checkbox-group v-model="columns" @change="handleCheckedChange">
<el-checkbox v-for="item in columnList" :label="item.prop" :key="item.prop">
{{item.label}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible=false"> </el-button>
<el-button type="primary" @click="downLoad"> </el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
visible: false,
btnLoading: false,
type: 0,
columns: [],
checkAll: true,
isIndeterminate: false,
columnList: []
}
},
methods: {
init(columnList) {
this.visible = true
this.checkAll = true
this.isIndeterminate = false
this.columnList = columnList
this.columns = columnList.map(o => o.prop)
},
handleCheckAllChange(val) {
this.columns = val ? this.columnList.map(o => o.prop) : [];
this.isIndeterminate = false;
},
handleCheckedChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.columnList.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columnList.length;
},
downLoad() {
this.$emit('download', { dataType: this.type, selectKey: this.columns.join(',') })
}
}
}
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
padding: 20px !important;
}
</style>

@ -0,0 +1,241 @@
<template>
<el-dialog :title="!dataForm.id ? '新建' : isDetail ? '详情':'编辑'"
:close-on-click-modal="false" append-to-body
:visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" :rules="rules" size="small" label-width="100px" label-position="right" >
<template v-if="!loading">
<el-col :span="12" >
<el-form-item label="客户编码"
prop="supplierCd" >
<el-input v-model="dataForm.supplierCd"
placeholder="请输入客户编码" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="客户名称"
prop="supplierNm" >
<el-input v-model="dataForm.supplierNm"
placeholder="请输入客户名称" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="所属公司ID"
prop="orgId" >
<el-input v-model="dataForm.orgId"
placeholder="请输入所属公司ID" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="公司代码"
prop="orgName" >
<el-input v-model="dataForm.orgName"
placeholder="请输入公司代码" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="客户等级"
prop="customerLevel" >
<el-select v-model="dataForm.customerLevel"
placeholder="请选择客户等级" :style='{"width":"100%"}'>
<el-option v-for="(item, index) in customerLevelOptions" :key="index" :label="item.fullName" :value="item.id" :disabled="item.disabled" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="联系人"
prop="contactName" >
<el-input v-model="dataForm.contactName"
placeholder="请输入联系人" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="地址"
prop="address" >
<el-input v-model="dataForm.address"
placeholder="请输入地址" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="电话"
prop="contactPhone" >
<el-input v-model="dataForm.contactPhone"
placeholder="请输入电话" clearable :style='{"width":"100%"}'>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="是否启用"
prop="status" >
<el-switch v-model="dataForm.status"
:active-value="1" :inactive-value="0" >
</el-switch>
</el-form-item>
</el-col>
</template>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail"> </el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import { getDataInterfaceRes } from '@/api/systemData/dataInterface'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
export default {
components: {},
props: [],
data() {
return {
visible: false,
loading: false,
isDetail: false,
dataForm: {
supplierCd : '',
supplierNm : '',
orgId : '',
orgName : '',
customerLevel : "1",
contactName : '',
address : '',
contactPhone : '',
status : 1,
},
rules:
{
supplierCd: [
{
required: true,
message: '请输入客户编码',
trigger: 'blur'
},
],
supplierNm: [
{
required: true,
message: '请输入客户名称',
trigger: 'blur'
},
],
contactPhone: [
],
},
customerLevelOptions:[{"fullName":"一级","id":"1"},{"fullName":"二级","id":"2"},{"fullName":"三级","id":"3"}],
}
},
computed: {},
watch: {},
created() {
},
mounted() {},
methods: {
clearData(data){
for (let key in data) {
if (data[key] instanceof Array) {
data[key] = [];
} else if (data[key] instanceof Object) {
this.clearData(data[key]);
} else {
data[key] = "";
}
}
},
init(id, isDetail) {
this.dataForm.id = id || 0;
this.visible = true;
this.isDetail = isDetail || false;
this.$nextTick(() => {
this.$refs['elForm'].resetFields();
if(this.dataForm.id){
this.loading = true
request({
url: '/api/customer/Customer/'+this.dataForm.id,
method: 'get'
}).then(res => {
this.dataInfo(res.data)
this.loading = false
});
}else{
this.clearData(this.dataForm)
}
});
this.$store.commit('generator/UPDATE_RELATION_DATA', {})
},
//
dataFormSubmit() {
this.$refs['elForm'].validate((valid) => {
if (valid) {
this.request()
}
})
},
request() {
var _data =this.dataList()
if (!this.dataForm.id) {
request({
url: '/api/customer/Customer',
method: 'post',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}else{
request({
url: '/api/customer/Customer/'+this.dataForm.id,
method: 'PUT',
data: _data
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false
this.$emit('refresh', true)
}
})
})
}
},
dataList(){
var _data = JSON.parse(JSON.stringify(this.dataForm));
_data.status = parseInt(_data.status)
return _data;
},
dataInfo(dataAll){
let _dataAll =dataAll
_dataAll.status = parseInt( _dataAll.status)
this.dataForm = _dataAll
},
},
}
</script>

@ -0,0 +1,277 @@
<template>
<div class="JNPF-common-layout">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="客户编码">
<el-input v-model="query.supplierCd" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="客户名称">
<el-input v-model="query.supplierNm" placeholder="请输入" clearable> </el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()"></el-button>
<el-button icon="el-icon-refresh-right" @click="reset()"></el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
</el-button>
<el-button type="text" icon="el-icon-download" @click="exportData()" >导出
</el-button>
<el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()" >批量删除
</el-button>
</div>
<div class="JNPF-common-head-right">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"
@click="reset()"/>
</el-tooltip>
<screenfull isContainer/>
</div>
</div>
<JNPF-table v-loading="listLoading" :data="list" @sort-change='sortChange' has-c @selection-change="handleSelectionChange">
<el-table-column prop="supplierCd" label="客户编码" width="0" align="left"
sortable="custom" />
<el-table-column prop="supplierNm" label="客户名称" width="0" align="left"
sortable="custom" />
<el-table-column prop="orgId" label="所属公司ID" width="0" align="left"
sortable="custom" />
<el-table-column prop="orgName" label="公司代码" width="0" align="left"
sortable="custom" />
<el-table-column label="客户等级" width="0" prop="customerLevel" algin="left"
sortable="custom" >
<template slot-scope="scope">
{{ scope.row.customerLevel | dynamicText(customerLevelOptions) }}
</template>
</el-table-column>
<el-table-column prop="contactName" label="联系人" width="0" align="left"
sortable="custom" />
<el-table-column prop="address" label="地址" width="0" align="left"
sortable="custom" />
<el-table-column prop="contactPhone" label="电话" width="0" align="left"
sortable="custom" />
<el-table-column prop="status" label="是否启用" width="0" align="left"
/>
<el-table-column label="操作" fixed="right"
width="150" >
<template slot-scope="scope">
<el-button type="text"
@click="addOrUpdateHandle(scope.row.id)" >编辑
</el-button>
<el-button type="text" class="JNPF-table-delBtn" @click="handleDel(scope.row.id)">
</el-button>
<el-button type="text"
@click="goDetail(scope.row.id)">详情
</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/>
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/>
<Detail v-if="detailVisible" ref="Detail" @refresh="detailVisible=false"/>
</div>
</template>
<script>
import request from '@/utils/request'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
import JNPFForm from './Form'
import ExportBox from './ExportBox'
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import Detail from './Detail'
export default {
components: {JNPFForm, ExportBox,Detail},
data() {
return {
detailVisible: false,
query: {
supplierCd:undefined,
supplierNm:undefined,
},
treeProps: {
children: 'children',
label: 'fullName',
value: 'id'
},
list: [],
listLoading: true,
multipleSelection: [], total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "supplierCd",
},
formVisible: false,
exportBoxVisible: false,
columnList: [
{prop: 'supplierCd', label: '客户编码'},
{prop: 'supplierNm', label: '客户名称'},
{prop: 'orgId', label: '所属公司ID'},
{prop: 'orgName', label: '公司代码'},
{prop: 'customerLevel', label: '客户等级'},
{prop: 'contactName', label: '联系人'},
{prop: 'address', label: '地址'},
{prop: 'contactPhone', label: '电话'},
{prop: 'status', label: '是否启用'},
],
customerLevelOptions:[{"fullName":"一级","id":"1"},{"fullName":"二级","id":"2"},{"fullName":"三级","id":"3"}],
customerLevelProps:{"label":"fullName","value":"id"},
}
},
computed: {
menuId() {
return this.$route.meta.modelId || ''
}
},
created() {
this.initData()
},
methods: {
goDetail(id){
this.detailVisible = true
this.$nextTick(() => {
this.$refs.Detail.init(id)
})
},
sortChange({column, prop, order}) {
this.listQuery.sort = order == 'ascending' ? 'asc' : 'desc'
this.listQuery.sidx = !order ? '' : prop
this.initData()
},
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
menuId:this.menuId
};
request({
url: `/api/customer/Customer/getList`,
method: 'post',
data: _query
}).then(res => {
var _list =[];
for(let i=0;i<res.data.list.length;i++){
let _data = res.data.list[i];
_list.push(_data)
}
this.list = _list
this.total = res.data.pagination.total
this.listLoading = false
})
},
handleDel(id) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
request({
url: `/api/customer/Customer/${id}`,
method: 'DELETE'
}).then(res => {
this.$message({
type: 'success',
message: res.msg,
onClose: () => {
this.initData()
}
});
})
}).catch(() => {
});
},
handleSelectionChange(val) {
const res = val.map(item => item.id)
this.multipleSelection = res
},
handleBatchRemoveDel() {
if (!this.multipleSelection.length) {
this.$message({
type: 'error',
message: '请选择一条数据',
duration: 1500,
})
return
}
const ids = this.multipleSelection.join()
this.$confirm('您确定要删除这些数据吗, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
request({
url: `/api/customer/Customer/batchRemove/${ids}`,
method: 'DELETE'
}).then(res => {
this.$message({
type: 'success',
message: res.msg,
onClose: () => {
this.initData()
}
});
})
}).catch(() => {
})
},
addOrUpdateHandle(id, isDetail) {
this.formVisible = true
this.$nextTick(() => {
this.$refs.JNPFForm.init(id, isDetail)
})
},
exportData() {
this.exportBoxVisible = true
this.$nextTick(() => {
this.$refs.ExportBox.init(this.columnList)
})
},
download(data) {
let query = {...data, ...this.listQuery, ...this.query,menuId:this.menuId}
request({
url: `/api/customer/Customer/Actions/Export`,
method: 'GET',
data: query
}).then(res => {
if (!res.data.url) return
this.jnpf.downloadFile(res.data.url)
this.$refs.ExportBox.visible = false
this.exportBoxVisible = false
})
},
search() {
this.listQuery = {
currentPage: 1,
pageSize: 20,
sort: "desc",
sidx: "supplierCd",
}
this.initData()
},
refresh(isrRefresh) {
this.formVisible = false
if (isrRefresh) this.reset()
},
reset() {
for (let key in this.query) {
this.query[key] = undefined
}
this.search()
}
}
}
</script>

@ -65,8 +65,18 @@
</el-table-column>
<el-table-column prop="address" label="地址" width="0" align="left"
sortable="custom" />
<el-table-column prop="status" label="启用" width="0" align="left"
sortable="custom" />
<!-- <el-table-column prop="status" label="启用" width="0" align="left"
sortable="custom" /> -->
<el-table-column prop="status" label="状态" width="0" align="left">
<template slot-scope="scope">
<el-tag type="success" disable-transitions v-if="scope.row.status == 1">
</el-tag>
<el-tag type="danger" disable-transitions v-else></el-tag>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right"
width="150" >
<template slot-scope="scope">

Loading…
Cancel
Save