Compare commits
7 Commits
34df03ebd9
...
d8c99e3cf9
| Author | SHA1 | Date |
|---|---|---|
|
|
d8c99e3cf9 | |
|
|
34db62ba2f | |
|
|
ef3357f150 | |
|
|
8f9fcc2dda | |
|
|
1edb6ce1c5 | |
|
|
7e9dfb607a | |
|
|
e6be9a5b48 |
|
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备列表
|
||||
|
|
@ -390,8 +394,8 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(dto.getShipmentDate());
|
||||
} catch (DateTimeParseException e) {
|
||||
sb.append("发货日期无效;");
|
||||
}
|
||||
|
|
@ -399,7 +403,7 @@ public class DeviceController extends ControllerBase {
|
|||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||
sb.append("质保期不能为空;");
|
||||
} else {
|
||||
|
|
@ -487,8 +491,8 @@ public class DeviceController extends ControllerBase {
|
|||
dto.setAgentName(d.getAgentName());
|
||||
dto.setAreaName(d.getAreaName());
|
||||
dto.setAddress(d.getAddress());
|
||||
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
||||
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
||||
dto.setShipmentDate(d.getShipmentDate());
|
||||
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
||||
if (Objects.nonNull(d.getWarrantyMonth())) {
|
||||
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
||||
}
|
||||
|
|
@ -620,8 +624,8 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(dto.getShipmentDate());
|
||||
} catch (DateTimeParseException e) {
|
||||
sb.append("发货日期无效;");
|
||||
}
|
||||
|
|
@ -631,7 +635,7 @@ public class DeviceController extends ControllerBase {
|
|||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||
sb.append("质保期不能为空;");
|
||||
} else {
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 设备机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.nflg.mobilebroken.admin.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* CRM-设备信息
|
||||
|
|
@ -37,12 +39,14 @@ public class CmrDeviceResultVO {
|
|||
/**
|
||||
* 发货日期
|
||||
*/
|
||||
private LocalDate LastCarDevliverDate__c;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
private OffsetDateTime LastCarDevliverDate__c;
|
||||
|
||||
/**
|
||||
* 质保开始日期
|
||||
*/
|
||||
private LocalDate WarrantyStartDate__c;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
private OffsetDateTime WarrantyStartDate__c;
|
||||
|
||||
/**
|
||||
* 质保期(月)
|
||||
|
|
|
|||
|
|
@ -14,11 +14,14 @@ import com.nflg.mobilebroken.admin.pojo.vo.DeviceExcelVO;
|
|||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.DateTimeUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.Device;
|
||||
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
|
||||
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -27,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -52,6 +56,9 @@ public class AdminDeviceService {
|
|||
@Resource
|
||||
private ITBaseCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
IDictionaryItemService dictionaryItemService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(DeviceDTO deviceDTO) {
|
||||
Device device = Convert.convert(Device.class, deviceDTO);
|
||||
|
|
@ -142,6 +149,7 @@ public class AdminDeviceService {
|
|||
|
||||
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
||||
Set<String> deviceNos = new HashSet<>();
|
||||
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
|
||||
crmDeviceList.forEach(u -> {
|
||||
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
||||
log.info("跳过没有产品线或设备类型的设备");
|
||||
|
|
@ -187,9 +195,30 @@ public class AdminDeviceService {
|
|||
}
|
||||
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
||||
ent.setProductLine(u.getProductLine__c());
|
||||
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
||||
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
||||
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
||||
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
} else {
|
||||
ent.setShipmentDate(null);
|
||||
}
|
||||
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
||||
if (Objects.nonNull(u.getWarrantyStartDate__c())) {
|
||||
if (Objects.isNull(ent.getWarrantyMonth())){
|
||||
ent.setWarrantyMonth(0);
|
||||
}
|
||||
LocalDateTime warrantyStartDate=DateTimeUtil.asSystemDateTime(u.getWarrantyStartDate__c());
|
||||
ent.setStartWarrantyDate(warrantyStartDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
if (now.isBefore(warrantyStartDate)){
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "NotStarted")).findFirst().get().getId());
|
||||
}else if (now.isAfter(warrantyStartDate.plusMonths(ent.getWarrantyMonth()))){
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "OutsideWarranty")).findFirst().get().getId());
|
||||
}else {
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "WithinWarranty")).findFirst().get().getId());
|
||||
}
|
||||
}else {
|
||||
ent.setStartWarrantyDate(null);
|
||||
ent.setWarrantyState(null);
|
||||
}
|
||||
if (Objects.nonNull(u.getAgent__r())) {
|
||||
TBaseCustomer customer = agents.stream()
|
||||
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package com.nflg.mobilebroken.common.util;
|
|||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Objects;
|
||||
|
|
@ -53,6 +50,14 @@ public class DateTimeUtil {
|
|||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
public static LocalDateTime asSystemDateTime(OffsetDateTime datetime) {
|
||||
if (Objects.isNull(datetime)) {
|
||||
return null;
|
||||
}
|
||||
return datetime.atZoneSameInstant(ZoneId.systemDefault())
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
public static LocalDate parse(String dateStr) {
|
||||
return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 产品线列表
|
||||
|
|
@ -393,8 +397,8 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(dto.getShipmentDate());
|
||||
} catch (DateTimeParseException e) {
|
||||
sb.append("发货日期无效;");
|
||||
}
|
||||
|
|
@ -402,7 +406,7 @@ public class DeviceController extends ControllerBase {
|
|||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||
sb.append("质保期不能为空;");
|
||||
} else {
|
||||
|
|
@ -506,8 +510,8 @@ public class DeviceController extends ControllerBase {
|
|||
dto.setCustomerName(d.getCustomerName());
|
||||
dto.setAgentName(d.getAgentName());
|
||||
dto.setAreaName(d.getAreaName());
|
||||
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
||||
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
||||
dto.setShipmentDate(d.getShipmentDate());
|
||||
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
||||
if (Objects.nonNull(d.getWarrantyMonth())) {
|
||||
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
||||
}
|
||||
|
|
@ -648,8 +652,8 @@ public class DeviceController extends ControllerBase {
|
|||
}
|
||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setShipmentDate(dto.getShipmentDate());
|
||||
} catch (DateTimeParseException e) {
|
||||
sb.append("发货日期无效;");
|
||||
}
|
||||
|
|
@ -659,7 +663,7 @@ public class DeviceController extends ControllerBase {
|
|||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||
sb.append("质保期不能为空;");
|
||||
} else {
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 设备机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.nflg.mobilebroken.gongfu.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* CRM-设备信息
|
||||
|
|
@ -37,12 +39,14 @@ public class CmrDeviceResultVO {
|
|||
/**
|
||||
* 发货日期
|
||||
*/
|
||||
private LocalDate LastCarDevliverDate__c;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
private OffsetDateTime LastCarDevliverDate__c;
|
||||
|
||||
/**
|
||||
* 质保开始日期
|
||||
*/
|
||||
private LocalDate WarrantyStartDate__c;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
private OffsetDateTime WarrantyStartDate__c;
|
||||
|
||||
/**
|
||||
* 质保期(月)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,21 @@ import cn.hutool.json.JSONObject;
|
|||
import cn.hutool.json.JSONUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.DateTimeUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.gongfu.constant.Constant1;
|
||||
import com.nflg.mobilebroken.gongfu.constant.DeviceSourceFromEnum;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceDTO;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.dto.SyncFromCrmDTO;
|
||||
import com.nflg.mobilebroken.gongfu.pojo.vo.CmrDeviceResultVO;
|
||||
import com.nflg.mobilebroken.repository.entity.Device;
|
||||
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
|
||||
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -25,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -50,6 +56,9 @@ public class AdminDeviceService {
|
|||
@Resource
|
||||
private ITBaseCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
IDictionaryItemService dictionaryItemService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(DeviceDTO deviceDTO) {
|
||||
GongfuDevice device = Convert.convert(GongfuDevice.class, deviceDTO);
|
||||
|
|
@ -148,6 +157,7 @@ public class AdminDeviceService {
|
|||
|
||||
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
||||
Set<String> deviceNos = new HashSet<>();
|
||||
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
|
||||
crmDeviceList.forEach(u -> {
|
||||
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
||||
log.info("跳过没有产品线或设备类型的设备");
|
||||
|
|
@ -156,6 +166,7 @@ public class AdminDeviceService {
|
|||
} else if (StrUtil.isBlank(u.getProductLine5__c())) {
|
||||
log.error("设备机型为空,{}", JSONUtil.toJsonStr(u));
|
||||
} else {
|
||||
log.debug("处理设备:"+u.getMachine_Number__c());
|
||||
if (StrUtil.isNotBlank(u.getMachine_Number__c())) {
|
||||
GongfuDevice ent = deviceMap.get(u.getId());
|
||||
if (Objects.nonNull(ent)) {
|
||||
|
|
@ -194,9 +205,31 @@ public class AdminDeviceService {
|
|||
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
||||
ent.setProductLine(u.getProductLine__c());
|
||||
Constant1.PRODUCT_LINE.add(u.getProductLine__c());
|
||||
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
||||
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
||||
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
||||
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
} else {
|
||||
ent.setShipmentDate(null);
|
||||
}
|
||||
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
||||
if (Objects.nonNull(u.getWarrantyStartDate__c())) {
|
||||
if (Objects.isNull(ent.getWarrantyMonth())){
|
||||
ent.setWarrantyMonth(0);
|
||||
}
|
||||
LocalDateTime warrantyStartDate=DateTimeUtil.asSystemDateTime(u.getWarrantyStartDate__c());
|
||||
ent.setStartWarrantyDate(warrantyStartDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
if (now.isBefore(warrantyStartDate)){
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "NotStarted")).findFirst().get().getId());
|
||||
}else if (now.isAfter(warrantyStartDate.plusMonths(ent.getWarrantyMonth()))){
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "OutsideWarranty")).findFirst().get().getId());
|
||||
}else {
|
||||
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "WithinWarranty")).findFirst().get().getId());
|
||||
}
|
||||
} else {
|
||||
ent.setStartWarrantyDate(null);
|
||||
ent.setWarrantyState(null);
|
||||
}
|
||||
// VUtils.trueThrow(true).throwMessage(STATE.SystemErr,"测试");
|
||||
if (Objects.nonNull(u.getAgent__r())) {
|
||||
TBaseCustomer customer = agents.stream()
|
||||
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
||||
|
|
|
|||
|
|
@ -124,11 +124,14 @@ public class CrmService {
|
|||
HttpUtils httpUtils = new HttpUtils();
|
||||
// reBody.put("CrLsDate", startDate);
|
||||
String token = StrUtil.join(" ", "Bearer", getToken());
|
||||
String orderResult = httpUtils.doPost(getDeviceUrl, JSONUtil.toJsonStr(dateParam), token);
|
||||
String data = JSONUtil.toJsonStr(dateParam);
|
||||
log.debug("请求地址:" + getDeviceUrl);
|
||||
log.debug("请求参数:" + data);
|
||||
String orderResult = httpUtils.doPost(getDeviceUrl, data, token);
|
||||
log.debug("响应数据:" + orderResult);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(orderResult);
|
||||
String code = jsonObject.getStr("code");
|
||||
if (Objects.equals(code, "0")) {
|
||||
log.debug("响应数据:" + orderResult);
|
||||
String dataResult = jsonObject.getStr("jsonData");
|
||||
return JSONUtil.toList(dataResult, CmrDeviceResultVO.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -78,6 +80,16 @@ public class Device implements Serializable {
|
|||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
private String serviceAgentCode;
|
||||
|
||||
/**
|
||||
* 服务代理商名称
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
|
|
@ -91,17 +103,20 @@ public class Device implements Serializable {
|
|||
/**
|
||||
* 发货日期
|
||||
*/
|
||||
private LocalDate shipmentDate;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String shipmentDate;
|
||||
|
||||
/**
|
||||
* 质保状态-来自字典
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Integer warrantyState;
|
||||
|
||||
/**
|
||||
* 开始质保日期
|
||||
*/
|
||||
private LocalDate startWarrantyDate;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String startWarrantyDate;
|
||||
|
||||
/**
|
||||
* 质保期(月)
|
||||
|
|
@ -156,5 +171,6 @@ public class Device implements Serializable {
|
|||
/**
|
||||
* 设备地址
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String address;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -79,6 +77,16 @@ public class GongfuDevice implements Serializable {
|
|||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
*/
|
||||
private String serviceAgentCode;
|
||||
|
||||
/**
|
||||
* 服务代理商名称
|
||||
*/
|
||||
private String serviceAgentName;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
|
|
@ -92,17 +100,20 @@ public class GongfuDevice implements Serializable {
|
|||
/**
|
||||
* 发货日期
|
||||
*/
|
||||
private LocalDate shipmentDate;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String shipmentDate;
|
||||
|
||||
/**
|
||||
* 质保状态-来自字典
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Integer warrantyState;
|
||||
|
||||
/**
|
||||
* 开始质保日期
|
||||
*/
|
||||
private LocalDate startWarrantyDate;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String startWarrantyDate;
|
||||
|
||||
/**
|
||||
* 质保期(月)
|
||||
|
|
@ -157,5 +168,6 @@ public class GongfuDevice implements Serializable {
|
|||
/**
|
||||
* 设备地址
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String address;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
||||
}
|
||||
|
|
@ -219,7 +219,8 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setCreateBy(appUser.getName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setExpireTime(appUser.getExpireTime())
|
||||
.setSalesUserName(appUser.getSalesUserName());
|
||||
.setSalesUserName(appUser.getSalesUserName())
|
||||
.setIsPrimary(false);
|
||||
appUserService.save(user);
|
||||
} else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
|
||||
//账号启用
|
||||
|
|
|
|||
|
|
@ -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