feat: bug-1286 设备售后公司转移
This commit is contained in:
parent
e6be9a5b48
commit
34db62ba2f
|
|
@ -12,6 +12,7 @@ import com.nflg.mobilebroken.admin.pojo.dto.DeviceAddImportDTO;
|
|||
import com.nflg.mobilebroken.admin.pojo.dto.DeviceDTO;
|
||||
import com.nflg.mobilebroken.admin.pojo.dto.DeviceUpdateImportDTO;
|
||||
import com.nflg.mobilebroken.admin.pojo.dto.SyncFromCrmDTO;
|
||||
import com.nflg.mobilebroken.admin.pojo.query.ChangeServiceAgentCodeQuery;
|
||||
import com.nflg.mobilebroken.admin.pojo.query.DeviceQuery;
|
||||
import com.nflg.mobilebroken.admin.pojo.vo.DeviceDetailResultVO;
|
||||
import com.nflg.mobilebroken.admin.service.AdminDeviceService;
|
||||
|
|
@ -93,6 +94,9 @@ public class DeviceController extends ControllerBase {
|
|||
@Resource
|
||||
private DeviceQRCodeService deviceQRCodeService;
|
||||
|
||||
@Resource
|
||||
private IDeviceAgentRecordService deviceAgentRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备列表
|
||||
|
|
@ -771,4 +775,32 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务代理商公司
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("changeServiceAgentCode")
|
||||
public ApiResult<Void> changeServiceAgentCode(@RequestBody ChangeServiceAgentCodeQuery query) {
|
||||
TBaseCustomer customer = customerService.lambdaQuery()
|
||||
.eq(TBaseCustomer::getDelIs, 0)
|
||||
.eq(TBaseCustomer::getEnableState, 1)
|
||||
.eq(TBaseCustomer::getAgencyCompanyCode, query.getServiceAgentCode())
|
||||
.one();
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(customer)).throwMessage("代理商公司不存在");
|
||||
deviceService.lambdaUpdate()
|
||||
.set(Device::getServiceAgentCode, query.getServiceAgentCode())
|
||||
.set(Device::getServiceAgentName, customer.getAgencyCompanyName())
|
||||
.eq(Device::getId, query.getDeviceId())
|
||||
.update();
|
||||
deviceAgentRecordService.save(new DeviceAgentRecord()
|
||||
.setDeviceId(query.getDeviceId())
|
||||
.setAgentCode(query.getServiceAgentCode())
|
||||
.setAgentName(customer.getAgencyCompanyName())
|
||||
.setCreateById(AdminUserUtil.getUserId())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.nflg.mobilebroken.admin.pojo.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ChangeServiceAgentCodeQuery {
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@NotNull
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
@NotBlank
|
||||
private String serviceAgentCode;
|
||||
}
|
||||
|
|
@ -15,11 +15,17 @@ public class DeviceQuery extends PageBaseQuery {
|
|||
* 客户名称
|
||||
*/
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 代理商
|
||||
* 所属代理商
|
||||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 设备机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceAddImportDTO;
|
|||
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceDTO;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceUpdateImportDTO;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.dto.SyncFromCrmDTO;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.query.ChangeServiceAgentCodeQuery;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.query.DeviceQuery;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.vo.DeviceDetailResultVO;
|
||||
import com.nflg.mobilebroken.gongfu.service.AdminDeviceService;
|
||||
|
|
@ -94,6 +95,9 @@ public class DeviceController extends ControllerBase {
|
|||
@Resource
|
||||
private DeviceQRCodeService deviceQRCodeService;
|
||||
|
||||
@Resource
|
||||
private IGongfuDeviceAgentRecordService gongfuDeviceAgentRecordService;
|
||||
|
||||
/**
|
||||
* 获取产品线列表
|
||||
* @return 产品线列表
|
||||
|
|
@ -811,4 +815,32 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务代理商公司
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("changeServiceAgentCode")
|
||||
public ApiResult<Void> changeServiceAgentCode(@RequestBody ChangeServiceAgentCodeQuery query) {
|
||||
TBaseCustomer customer = customerService.lambdaQuery()
|
||||
.eq(TBaseCustomer::getDelIs, 0)
|
||||
.eq(TBaseCustomer::getEnableState, 1)
|
||||
.eq(TBaseCustomer::getAgencyCompanyCode, query.getServiceAgentCode())
|
||||
.one();
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(customer)).throwMessage("代理商公司不存在");
|
||||
deviceService.lambdaUpdate()
|
||||
.set(GongfuDevice::getServiceAgentCode, query.getServiceAgentCode())
|
||||
.set(GongfuDevice::getServiceAgentName, customer.getAgencyCompanyName())
|
||||
.eq(GongfuDevice::getId, query.getDeviceId())
|
||||
.update();
|
||||
gongfuDeviceAgentRecordService.save(new GongfuDeviceAgentRecord()
|
||||
.setDeviceId(query.getDeviceId())
|
||||
.setAgentCode(query.getServiceAgentCode())
|
||||
.setAgentName(customer.getAgencyCompanyName())
|
||||
.setCreateById(AdminUserUtil.getUserId())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.nflg.mobilebroken.gongfu.pojo.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ChangeServiceAgentCodeQuery {
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@NotNull
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
@NotBlank
|
||||
private String serviceAgentCode;
|
||||
}
|
||||
|
|
@ -15,11 +15,17 @@ public class DeviceQuery extends PageBaseQuery {
|
|||
* 客户名称
|
||||
*/
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 代理商
|
||||
* 所属代理商
|
||||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 设备机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,6 +78,16 @@ public class Device implements Serializable {
|
|||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
private String serviceAgentCode;
|
||||
|
||||
/**
|
||||
* 服务代理商名称
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("device_agent_record")
|
||||
public class DeviceAgentRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 公司编码
|
||||
*/
|
||||
private String agentCode;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Integer createById;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
|
@ -79,6 +79,16 @@ public class GongfuDevice implements Serializable {
|
|||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
private String serviceAgentCode;
|
||||
|
||||
/**
|
||||
* 服务代理商名称
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("gongfu_device_agent_record")
|
||||
public class GongfuDeviceAgentRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 公司编码
|
||||
*/
|
||||
private String agentCode;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Integer createById;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.mapper;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.DeviceAgentRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface DeviceAgentRecordMapper extends BaseMapper<DeviceAgentRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.mapper;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDeviceAgentRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface GongfuDeviceAgentRecordMapper extends BaseMapper<GongfuDeviceAgentRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.DeviceAgentRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface IDeviceAgentRecordService extends IService<DeviceAgentRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDeviceAgentRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface IGongfuDeviceAgentRecordService extends IService<GongfuDeviceAgentRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.DeviceAgentRecord;
|
||||
import com.nflg.mobilebroken.repository.mapper.DeviceAgentRecordMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IDeviceAgentRecordService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Service
|
||||
public class DeviceAgentRecordServiceImpl extends ServiceImpl<DeviceAgentRecordMapper, DeviceAgentRecord> implements IDeviceAgentRecordService {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDeviceAgentRecord;
|
||||
import com.nflg.mobilebroken.repository.mapper.GongfuDeviceAgentRecordMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IGongfuDeviceAgentRecordService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Service
|
||||
public class GongfuDeviceAgentRecordServiceImpl extends ServiceImpl<GongfuDeviceAgentRecordMapper, GongfuDeviceAgentRecord> implements IGongfuDeviceAgentRecordService {
|
||||
|
||||
}
|
||||
|
|
@ -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="com.nflg.mobilebroken.repository.mapper.DeviceAgentRecordMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -13,11 +13,12 @@
|
|||
, d.warranty_month AS 'warrantyMonth'
|
||||
, d.customer_name AS 'customerName'
|
||||
<!-- , dc.id AS 'componentId'-->
|
||||
, d.agent_name
|
||||
, d.service_agent_code as 'agent_code'
|
||||
, d.service_agent_name as 'agent_name'
|
||||
,c.area_name,d.type,d.address,d.product_line
|
||||
FROM v_all_device d
|
||||
<!-- LEFT JOIN device_component dc ON d.model_no = dc.model_no AND dc.`enable` = 1-->
|
||||
LEFT JOIN t_base_customer c ON c.agency_company_code=d.agent_code
|
||||
LEFT JOIN t_base_customer c ON c.agency_company_code=d.service_agent_code
|
||||
WHERE d.device_no = #{deviceNo}
|
||||
ORDER BY d.data_valid_state DESC,d.device_state DESC
|
||||
LIMIT 1;
|
||||
|
|
@ -32,6 +33,9 @@
|
|||
<if test="query.agentName!=null and query.agentName!=''">
|
||||
and a.agent_name=#{query.agentName}
|
||||
</if>
|
||||
<if test="query.serviceAgentName!=null and query.serviceAgentName!=''">
|
||||
and a.service_agent_name=#{query.serviceAgentName}
|
||||
</if>
|
||||
<if test="query.modelNo!=null and query.modelNo!=''">
|
||||
and a.model_no LIKE concat('%', #{query.modelNo}, '%')
|
||||
</if>
|
||||
|
|
@ -50,7 +54,7 @@
|
|||
<select id="getList" resultType="com.nflg.mobilebroken.repository.entity.Device">
|
||||
select a.* ,b.area_code ,b.area_name
|
||||
from device a
|
||||
left join t_base_customer b on a.agent_code=b.agency_company_code
|
||||
left join t_base_customer b on a.service_agent_code=b.agency_company_code
|
||||
where data_valid_state=1
|
||||
<include refid="whr"/>
|
||||
</select>
|
||||
|
|
@ -66,7 +70,7 @@
|
|||
SELECT d.device_no,d.device_name,d.model_no,d.device_type,d.shipment_date,d.customer_name
|
||||
,IFNULL(dit2.value,di2.value) AS 'warrantyState'
|
||||
FROM v_all_device d
|
||||
INNER JOIN t_base_customer c ON d.agent_code=c.agency_company_code
|
||||
INNER JOIN t_base_customer c ON d.service_agent_code=c.agency_company_code
|
||||
INNER JOIN dictionary_item di ON di.id=d.device_state
|
||||
LEFT JOIN dictionary_item di2 ON di2.id=d.warranty_state
|
||||
LEFT JOIN dictionary_item_translate dit2 ON dit2.dictionary_item_id=d.warranty_state AND dit2.language_code=#{language}
|
||||
|
|
@ -133,9 +137,9 @@
|
|||
</select>
|
||||
|
||||
<select id="getAgents" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceAgentVO">
|
||||
SELECT DISTINCT agent_code,agent_name
|
||||
SELECT DISTINCT service_agent_code as 'agent_code',service_agent_name as 'agent_name'
|
||||
FROM device
|
||||
WHERE LENGTH(agent_code)>0
|
||||
WHERE LENGTH(service_agent_code)>0
|
||||
</select>
|
||||
|
||||
<select id="getComponents1" resultType="com.nflg.mobilebroken.common.pojo.vo.ComponentInfo">
|
||||
|
|
|
|||
|
|
@ -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="com.nflg.mobilebroken.repository.mapper.GongfuDeviceAgentRecordMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.GongfuDeviceMapper">
|
||||
|
||||
<select id="getByDeviceNo" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO">
|
||||
SELECT d.*, dc.id AS 'componentId',c.area_name
|
||||
SELECT d.*, c.area_name
|
||||
FROM gongfu_device d
|
||||
LEFT JOIN gongfu_device_component dc ON d.model_no = dc.model_no AND dc.`enable` = 1
|
||||
LEFT JOIN t_base_customer c ON c.agency_company_code=d.agent_code
|
||||
LEFT JOIN t_base_customer c ON c.agency_company_code=d.service_agent_code
|
||||
WHERE d.device_no = #{deviceNo}
|
||||
ORDER BY d.data_valid_state DESC,d.device_state DESC
|
||||
LIMIT 1;
|
||||
|
|
@ -21,6 +21,9 @@
|
|||
<if test="query.agentName!=null and query.agentName!=''">
|
||||
and a.agent_name=#{query.agentName}
|
||||
</if>
|
||||
<if test="query.serviceAgentName!=null and query.serviceAgentName!=''">
|
||||
and a.service_agent_name=#{query.serviceAgentName}
|
||||
</if>
|
||||
<if test="query.modelNo!=null and query.modelNo!=''">
|
||||
and a.model_no LIKE concat('%', #{query.modelNo}, '%')
|
||||
</if>
|
||||
|
|
@ -39,7 +42,7 @@
|
|||
<select id="getList" resultType="com.nflg.mobilebroken.repository.entity.GongfuDevice">
|
||||
select a.* ,b.area_code ,b.area_name
|
||||
from gongfu_device a
|
||||
left join t_base_customer b on a.agent_code=b.agency_company_code
|
||||
left join t_base_customer b on a.service_agent_code=b.agency_company_code
|
||||
where data_valid_state=1
|
||||
<include refid="whr"/>
|
||||
order by a.id desc
|
||||
|
|
@ -56,7 +59,7 @@
|
|||
SELECT d.device_no AS 'deviceNo',d.device_name AS 'deviceName',d.model_no AS 'modelNo'
|
||||
,d.device_type AS 'deviceType',d.shipment_date AS 'shipmentDate',IFNULL(dit2.value,di2.value) AS 'warrantyState'
|
||||
FROM gongfu_device d
|
||||
INNER JOIN t_base_customer c ON d.agent_code=c.agency_company_code
|
||||
INNER JOIN t_base_customer c ON d.service_agent_code=c.agency_company_code
|
||||
INNER JOIN dictionary_item di ON di.id=d.device_state
|
||||
LEFT JOIN dictionary_item di2 ON di2.id=d.warranty_state
|
||||
LEFT JOIN dictionary_item_translate dit2 ON dit2.dictionary_item_id=d.warranty_state AND dit2.language_code=#{language}
|
||||
|
|
@ -114,9 +117,9 @@
|
|||
</select>
|
||||
|
||||
<select id="getAgents" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceAgentVO">
|
||||
SELECT DISTINCT agent_code,agent_name
|
||||
SELECT DISTINCT service_agent_code as 'agent_code',service_agent_name as 'agent_name'
|
||||
FROM gongfu_device
|
||||
WHERE LENGTH(agent_code)>0
|
||||
WHERE LENGTH(service_agent_code)>0
|
||||
</select>
|
||||
|
||||
<select id="getCustomerNames" resultType="java.lang.String">
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class CodeGeneratorTest {
|
|||
, Paths.get(System.getProperty("user.dir")) + "/src/main/resources/mapper"))
|
||||
)
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude("gongfu_external_user") //只生成指定表
|
||||
builder.addInclude("gongfu_device_agent_record") //只生成指定表
|
||||
.entityBuilder()
|
||||
.enableLombok()
|
||||
.enableChainModel()
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
package com.nflg.mobilebroken.starter.advice;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.SaTokenAdminUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseRequestLog;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseRequestLogDetail;
|
||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||
import com.nflg.mobilebroken.starter.service.IRequestLog;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class LoggingAspect {
|
||||
|
||||
// private static final ThreadLocal<Long> requestIdHolder = new ThreadLocal<>();
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
IRequestLog requestLog;
|
||||
|
||||
@Around("execution(* com.nflg.mobilebroken.admin.controller..*(..))")
|
||||
public Object logMethodCall(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// 获取ApiOperation注解
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
//有此注解 则-记录访问日志
|
||||
MethodInfoMark apiOperation = method.getAnnotation(MethodInfoMark.class);
|
||||
if (apiOperation != null) {
|
||||
TBaseRequestLogDetail logDetail = new TBaseRequestLogDetail();
|
||||
TBaseRequestLog logRecord = new TBaseRequestLog();
|
||||
try {
|
||||
// 获取HttpServletRequest对象
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
|
||||
// 构建日志对象
|
||||
Long requestId = IdWorker.getId();
|
||||
logRecord.setRowId(requestId);
|
||||
logRecord.setUrlPath(request.getRequestURL().toString());
|
||||
logRecord.setRequestIp(request.getRemoteAddr());
|
||||
logRecord.setRequestType(request.getMethod());
|
||||
logRecord.setRequestResult(true);
|
||||
if (SaTokenAdminUtil.isLogin()) {
|
||||
logRecord.setDataCreateUserName(AdminUserUtil.getUserName());
|
||||
}
|
||||
logRecord.setDataCreateTime(LocalDateTime.now());
|
||||
|
||||
logRecord.setMethodName(apiOperation.value());
|
||||
logRecord.setMenuName(apiOperation.menuName());
|
||||
|
||||
//日志明细
|
||||
logDetail.setRowId(requestId);
|
||||
logDetail.setRequestParam(JSONUtil.toJsonStr(joinPoint.getArgs()));
|
||||
Object result = joinPoint.proceed();
|
||||
logDetail.setRequestReturn(JSONUtil.toJsonStr(result));
|
||||
|
||||
return result;
|
||||
} catch (Throwable ex) {
|
||||
StackTraceElement[] stackTraceElements = ex.getStackTrace();
|
||||
logRecord.setRequestResult(false);
|
||||
logDetail.setRequestErrMsg(stackTraceElements.length > 0 ? ex.getMessage() + ":" + stackTraceElements[0].toString() : "");
|
||||
logger.error("未捕获的异常", ex);
|
||||
return ApiResult.error(STATE.Error,ex.getMessage());
|
||||
}
|
||||
finally {
|
||||
requestLog.addLog(logRecord,logDetail);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
// @AfterReturning(pointcut = "execution(* com.nflg.mobilebroken.admin.controller..*(..))", returning = "result")
|
||||
// public void logMethodResponse(Object result) {
|
||||
// try {
|
||||
// Long requestId = requestIdHolder.get();
|
||||
// TBaseRequestLogDetail logDetail=new TBaseRequestLogDetail();
|
||||
// logDetail.setRowId(requestId);
|
||||
// logDetail.setRequestReturn(JSON.toJSONString(result));
|
||||
// logger.info("Response for request {}: {}", requestId, JSON.toJSONString(result));
|
||||
// } finally {
|
||||
// requestIdHolder.remove();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @AfterThrowing(pointcut = "execution(* com.nflg.mobilebroken.admin.controller..*(..))", throwing = "ex")
|
||||
// public void logAfterThrowing(JoinPoint joinPoint, Throwable ex) {
|
||||
// try {
|
||||
// Long requestId = requestIdHolder.get();
|
||||
// StackTraceElement[] stackTraceElements = ex.getStackTrace();
|
||||
// TBaseRequestLogDetail logDetail=new TBaseRequestLogDetail();
|
||||
// logDetail.setRowId(requestId);
|
||||
// logDetail.setRequestErrMsg(stackTraceElements.length > 0 ?ex.getMessage()+":"+ stackTraceElements[0].toString() : "");
|
||||
//
|
||||
//
|
||||
// } finally {
|
||||
// requestIdHolder.remove();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue