feat: 客户管理

master
李小林 9 months ago
parent 9f578f48c8
commit 8f35f4d9f2
  1. 5
      src/main/java/com/bellmann/common/result/ResultCode.java
  2. 27
      src/main/java/com/bellmann/controller/CustomerController.java
  3. 3
      src/main/java/com/bellmann/converter/CustomerConverter.java
  4. 8
      src/main/java/com/bellmann/converter/DeviceStaticConverter.java
  5. 2
      src/main/java/com/bellmann/mapper/CustomerMapper.java
  6. 4
      src/main/java/com/bellmann/mapper/DeviceStaticMapper.java
  7. 2
      src/main/java/com/bellmann/model/entity/DeviceStatic.java
  8. 44
      src/main/java/com/bellmann/model/form/CustomForm.java
  9. 2
      src/main/java/com/bellmann/model/query/SelectQuery.java
  10. 10
      src/main/java/com/bellmann/service/CustomerService.java
  11. 67
      src/main/java/com/bellmann/service/impl/CustomerServiceImpl.java
  12. 14
      src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java
  13. 17
      src/main/resources/mapper/DeviceStaticMapper.xml

@ -99,7 +99,10 @@ public enum ResultCode implements IResultCode, Serializable {
TR069_BINDING_SERVICE("F0009","TR069数据模型已经和业务绑定"),
CUSTOM_NOT_FIND("F0010", "客户不存在"),
DEV_DOMAIN_MAP_NOT_FOUNT("F0011", "传入的设备软件版本和系统管理域映射不存在");
DEV_DOMAIN_MAP_NOT_FOUNT("F0011", "传入的设备软件版本和系统管理域映射不存在"),
EXIST_USER_DEV("F0012","存在该用户的设备"),
DEV_ALREADY_CUSTOM("F0013","设备已经绑定客户"),
;
@Override
public String getCode() {
return code;

@ -2,16 +2,17 @@ package com.bellmann.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bellmann.common.result.PageResult;
import com.bellmann.common.result.Result;
import com.bellmann.model.form.CustomForm;
import com.bellmann.model.query.SelectQuery;
import com.bellmann.model.vo.CustomerVO;
import com.bellmann.service.CustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "17.客户管理")
@ -22,9 +23,25 @@ public class CustomerController {
private final CustomerService customerService;
@PostMapping("customer-page")
@Operation(summary = "资源管理-设备管理表格接口")
@Operation(summary = "客户管理-page")
public PageResult<CustomerVO> resourcePage(@RequestBody SelectQuery query){
Page<CustomerVO> page = customerService.resourcePage(query);
return PageResult.success(page);
}
@PutMapping("update-status/{customId}/{status}")
@Operation(summary = "修改客户状态")
public Result<String> updateStatus(@PathVariable Long customId, @PathVariable String status){
return customerService.updateStatus(customId,status);
}
@PostMapping("delete-custom")
@Operation(summary = "修改客户状态")
public Result<String> deleteCustom(@RequestBody List<Long> ids){
return customerService.deleteCustom(ids);
}
@PostMapping("add-custom")
@Operation(summary = "新增客户")
public Result<Long> addCustom(@RequestBody CustomForm form){
return customerService.addCustom(form);
}
}

@ -1,6 +1,7 @@
package com.bellmann.converter;
import com.bellmann.model.entity.Customer;
import com.bellmann.model.form.CustomForm;
import com.bellmann.model.vo.EquipmentCustomerVO;
import org.mapstruct.Mapper;
@ -9,4 +10,6 @@ import org.mapstruct.Mapper;
public interface CustomerConverter {
EquipmentCustomerVO entityE2EquipmentVO(Customer customer);
Customer form2Entity(CustomForm form);
}

@ -1,5 +1,6 @@
package com.bellmann.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bellmann.model.bo.EquipmentBO;
import com.bellmann.model.entity.DeviceStatic;
import com.bellmann.model.form.EquipmentAddForm;
@ -8,8 +9,6 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import java.util.List;
@Mapper(componentModel = "spring")
public interface DeviceStaticConverter {
@ -20,9 +19,8 @@ public interface DeviceStaticConverter {
@Mapping(target = "devOnline", expression = "java(com.bellmann.common.base.IBaseEnum.getLabelByValue(bo.getDevOnline(), com.bellmann.common.enums.DevOnlineEnum.class))")
})
EquipmentVO resourceBOList2VOList(EquipmentBO bo);
List<EquipmentVO> resourceBOList2VOList(List<EquipmentBO> list);
EquipmentVO resourceBOPage2VOPage(EquipmentBO bo);
DeviceStatic resourceForm2VOEntity(EquipmentAddForm form);
Page<EquipmentVO> resourceBOPage2VOPage(Page<EquipmentBO> boPage);
}

@ -11,5 +11,5 @@ import java.util.List;
@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {
List<CustomerVO> resourcePage(Page<CustomerVO> page, @Param("column") String column, @Param("value") String value);
List<CustomerVO> resourcePage(Page<CustomerVO> page, @Param("column") String column, @Param("value") Object value);
}

@ -8,11 +8,9 @@ import com.bellmann.model.vo.EquipmentDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DeviceStaticMapper extends BaseMapper<DeviceStatic> {
List<EquipmentBO> resourcePage(Page<EquipmentBO> page, @Param("column") String column, @Param("value") String value);
Page<EquipmentBO> resourcePage(Page<EquipmentBO> page, @Param("column") String column, @Param("value") Object value);
EquipmentDetailVO detailInfo(@Param("devId") Long devId);

@ -20,7 +20,7 @@ public class DeviceStatic implements Serializable {
private Long typeAndVerId;
@TableField("cust_id")
private String customId;
private Long customId;
private Long regionAreaId;

@ -0,0 +1,44 @@
package com.bellmann.model.form;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "客户表单")
public class CustomForm {
@Schema(description = "客户ID")
private Long custId;
@Schema(description = "系统管理域")
private Long regionAreaId;
@Schema(description = "客户账号")
private String customAccount;
@Schema(description = "客户名称" )
private String customName;
@Schema(description = "客户地址")
private String customAddr;
@Schema(description = "联系人方式")
private String contactType;
@Schema(description = "客户类型")
private String customType;
@Schema(description = "客户状态")
private String customStatus;
@Schema(description = "客户端口号")
private String customRemark1;
@Schema(description = "接入电话号码")
private String customRemark2;
@TableField(value = "客户身份证号码")
private String customRemark3;
}

@ -10,5 +10,5 @@ public class SelectQuery extends BasePageQuery {
private String selectName;
private String selectValue;
private Object selectValue;
}

@ -1,9 +1,19 @@
package com.bellmann.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bellmann.common.result.Result;
import com.bellmann.model.form.CustomForm;
import com.bellmann.model.query.SelectQuery;
import com.bellmann.model.vo.CustomerVO;
import java.util.List;
public interface CustomerService {
Page<CustomerVO> resourcePage(SelectQuery query);
Result<String> updateStatus(Long customId, String status);
Result<String> deleteCustom(List<Long> ids);
Result<Long> addCustom(CustomForm form);
}

@ -1,25 +1,42 @@
package com.bellmann.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bellmann.common.base.IBaseEnum;
import com.bellmann.common.constant.SecurityConstants;
import com.bellmann.common.enums.CustomStatusEnum;
import com.bellmann.common.enums.CustomTypeEnum;
import com.bellmann.common.exception.BusinessException;
import com.bellmann.common.result.Result;
import com.bellmann.common.result.ResultCode;
import com.bellmann.converter.CustomerConverter;
import com.bellmann.mapper.CustomerMapper;
import com.bellmann.mapper.DeviceStaticMapper;
import com.bellmann.model.entity.Customer;
import com.bellmann.model.entity.DeviceStatic;
import com.bellmann.model.form.CustomForm;
import com.bellmann.model.query.SelectQuery;
import com.bellmann.model.vo.CustomerVO;
import com.bellmann.service.CustomerService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
@Service
@RequiredArgsConstructor
public class CustomerServiceImpl implements CustomerService {
private final CustomerMapper customerMapper;
private final RedisTemplate<String, Object> redisTemplate;
private final DeviceStaticMapper deviceStaticMapper;
private final CustomerConverter customerConverter;
@Override
public Page<CustomerVO> resourcePage(SelectQuery query) {
int pageNum = query.getPageNum();
@ -35,4 +52,54 @@ public class CustomerServiceImpl implements CustomerService {
});
return page.setRecords(list);
}
@Override
public Result<String> updateStatus(Long customId, String status) {
if(customId==null||status==null){
return Result.failed(ResultCode.PARAM_ERROR);
}
if (CustomStatusEnum.SIGN_OUT.getValue().equals(status)) {
Long count = deviceStaticMapper.selectCount(new LambdaQueryWrapper<DeviceStatic>()
.eq(DeviceStatic::getCustomId, customId)
);
if (count > 0L) {
return Result.failed(ResultCode.EXIST_USER_DEV);
}
}
customerMapper.update(null,new LambdaUpdateWrapper<Customer>()
.eq(Customer::getCustId,customId)
.set(Customer::getCustomStatus,status)
);
return Result.success();
}
@Override
@Transactional
public Result<String> deleteCustom(List<Long> ids) {
if (ids.isEmpty()){
return Result.failed(ResultCode.IDS_IS_NULL);
}
for (Long customId:ids){
Long count = deviceStaticMapper.selectCount(new LambdaQueryWrapper<DeviceStatic>()
.eq(DeviceStatic::getCustomId, customId)
);
if (count > 0L) {
throw new BusinessException(ResultCode.EXIST_USER_DEV);
}
customerMapper.update(null,new LambdaUpdateWrapper<Customer>()
.eq(Customer::getCustId,customId)
.set(Customer::getCustomStatus,CustomStatusEnum.SIGN_OUT.getValue())
);
}
return Result.success();
}
@Override
public Result<Long> addCustom(CustomForm form) {
Customer customer = customerConverter.form2Entity(form);
customer.setCustomCreateTime(LocalDateTime.now());
customer.setCustomModifyTime(LocalDateTime.now());
customerMapper.insert(customer);
return Result.success(customer.getCustId());
}
}

@ -71,12 +71,8 @@ public class DeviceStaticServiceImpl implements DeviceStaticService {
int pageNum = query.getPageNum();
int pageSize = query.getPageSize();
Page<EquipmentBO> page = new Page<>(pageNum,pageSize);
List<EquipmentBO> list = deviceStaticMapper.resourcePage(page,query.getSelectName(),query.getSelectValue());
List<EquipmentVO> voList = deviceStaticConverter.resourceBOList2VOList(list);
Page<EquipmentVO> vp = new Page<>(pageNum,pageSize);
vp.setTotal(page.getTotal());
vp.setRecords(voList);
return vp;
Page<EquipmentBO> boPage = deviceStaticMapper.resourcePage(page,query.getSelectName(),query.getSelectValue());
return deviceStaticConverter.resourceBOPage2VOPage(boPage);
}
@Override
@ -190,6 +186,12 @@ public class DeviceStaticServiceImpl implements DeviceStaticService {
@Override
public Result<String> bindingCustom(Long customId, Long devId) {
DeviceStatic deviceStatic = deviceStaticMapper.selectOne(new LambdaQueryWrapper<DeviceStatic>()
.eq(DeviceStatic::getDevId, devId)
);
if(deviceStatic.getCustomId()!=null){
return Result.failed(ResultCode.DEV_ALREADY_CUSTOM);
}
Customer customer = customerManager.findByCustomId(customId);
if (customer==null){
return Result.failed(ResultCode.CUSTOM_NOT_FIND);

@ -22,14 +22,23 @@
dy.dev_online_time
FROM
itms_device_static s
LEFT JOIN ITMS_DEVICE_DYNAMIC dy ON s.DEV_ID = dy.DEV_ID
LEFT JOIN itms_device_type_ver v ON s.type_and_ver_id = v.type_and_ver_id
LEFT JOIN itms_device_type T ON v.dev_type_id = T.dev_type_id
LEFT JOIN itms_device_type_ver_detail d ON v.type_and_ver_id = d.type_and_ver_id
<if test="column=='customName' or column=='customId' and column!=null and column!=''">
INNER JOIN itms_customer ON itms_customer.cust_id = s.cust_id
</if>
INNER JOIN ITMS_DEVICE_DYNAMIC dy ON s.DEV_ID = dy.DEV_ID
INNER JOIN itms_device_type_ver v ON s.type_and_ver_id = v.type_and_ver_id
INNER JOIN itms_device_type T ON v.dev_type_id = T.dev_type_id
INNER JOIN itms_device_type_ver_detail d ON v.type_and_ver_id = d.type_and_ver_id
<where>
<if test="column=='devAdNo' and column!=null and column!=''">
and s.dev_ad_no = #{value}
</if>
<if test="column=='customName' and column!=null and column!=''">
and itms_customer.cust_name = #{value}
</if>
<if test="column=='customId' and column!=null and column!=''">
and s.cust_id = #{value}
</if>
</where>
</select>

Loading…
Cancel
Save