Compare commits

...

25 Commits

Author SHA1 Message Date
曹鹏飞 85fb4dddbc Merge branch 'prod/20260204' into develop 2026-02-04 10:05:28 +08:00
曹鹏飞 151a418fed 移动破工单详情增加问题部位id 2026-02-04 10:05:15 +08:00
曹鹏飞 7b03defe07 Merge branch 'prod/20260204' into develop 2026-02-04 09:58:36 +08:00
曹鹏飞 775691fe9e 移动破添加解决方案时增加问题部位设置 2026-02-04 09:58:09 +08:00
曹鹏飞 bcfe4c3ea4 Merge branch 'prod/20260204' into develop 2026-02-04 09:50:54 +08:00
曹鹏飞 802334cdf5 移动破添加解决方案时增加问题部位设置 2026-02-04 09:50:36 +08:00
曹鹏飞 c88fd86abe Merge branch 'prod/20260203' into develop 2026-02-03 16:19:49 +08:00
曹鹏飞 23e49b58f2 fix(admin): 修复客户查询中的公司名称匹配问题
- 将公司名称比较从大小写敏感改为大小写不敏感
2026-02-03 16:19:19 +08:00
曹鹏飞 98c4d21568 Merge branch 'prod/20260203' into develop 2026-02-03 14:38:55 +08:00
曹鹏飞 2e056a3324 feat(device): 设备列表添加导出搜索结果功能 2026-02-03 14:38:36 +08:00
曹鹏飞 25b5f1b99b Merge branch 'feature/bug-1286' into prod/20260203
# Conflicts:
#	nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java
2026-02-03 12:19:42 +08:00
曹鹏飞 27cd13eb3b Merge branch 'feature/gongfu-20260126' into prod/20260203 2026-02-03 12:14:37 +08:00
曹鹏飞 19e37daaaf Merge branch 'feature/bug-1286' into develop 2026-02-03 10:46:14 +08:00
曹鹏飞 d6a1074a79 feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:46:00 +08:00
曹鹏飞 c52f86f85a Merge branch 'feature/bug-1286' into develop 2026-02-03 10:41:31 +08:00
曹鹏飞 634a245b3d feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:41:14 +08:00
曹鹏飞 3fb86a4565 Merge branch 'feature/bug-1286' into develop 2026-02-03 10:30:09 +08:00
曹鹏飞 1d72e4bcc0 feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:29:56 +08:00
曹鹏飞 b2d1065233 Merge branch 'feature/bug-1286' into develop 2026-02-03 10:25:00 +08:00
曹鹏飞 6bac73d8b7 feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:24:48 +08:00
曹鹏飞 422489018c Merge branch 'feature/bug-1286' into develop 2026-02-03 10:21:59 +08:00
曹鹏飞 5c20d07732 feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:21:44 +08:00
曹鹏飞 2b74adc20c Merge branch 'feature/bug-1286' into develop
# Conflicts:
#	nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java
2026-02-03 10:19:16 +08:00
曹鹏飞 604895d758 feat: bug-1286 设备售后公司转移
导入和导出添加对服务代理商的支持
2026-02-03 10:16:19 +08:00
曹鹏飞 2c678c27cb feat(gongfu): 添加测试控制器并完善设备组件功能
- 新增TestController用于初始化设备组件产品线数据
- 实现批量更新设备组件的产品线信息功能
- 添加设备机型字段到GongfuDeviceComponent实体类
- 在SolutionMeasuresSaveRequest中增加componentId非空验证
- 实现设备组件详情的批量创建和更新逻辑
- 添加多产品线设备组件的复制处理机制
2026-01-29 16:09:01 +08:00
14 changed files with 647 additions and 94 deletions

View File

@ -8,10 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Sets;
import com.nflg.mobilebroken.admin.annotation.ApiMark;
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.dto.*;
import com.nflg.mobilebroken.admin.pojo.query.ChangeServiceAgentCodeQuery;
import com.nflg.mobilebroken.admin.pojo.query.DeviceQuery;
import com.nflg.mobilebroken.admin.pojo.vo.DeviceDetailResultVO;
@ -37,6 +34,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.ttzero.excel.entity.ListSheet;
import org.ttzero.excel.entity.TemplateSheet;
import org.ttzero.excel.entity.Workbook;
@ -49,6 +47,7 @@ import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
@ -135,6 +134,47 @@ public class DeviceController extends ControllerBase {
return ApiResult.success(resultData, query, result.getTotal());
}
/**
* 导出设备列表
* @param query
*/
@PostMapping("exportSearch")
public void exportSearch(HttpServletResponse response,@RequestBody DeviceQuery query) throws IOException {
Page<Device> result = deviceService.getList(new Page<>(1, Integer.MAX_VALUE), query);
List<DictionaryItem> states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE);
List<DeviceExportDTO> datas = result.getRecords().stream().map(d -> {
DeviceExportDTO dto = new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
dto.setDeviceStateDesc(states.stream().filter(s -> Objects.equals(s.getId(), d.getDeviceState())).findFirst().get().getName());
dto.setCustomerName(d.getCustomerName());
dto.setAgentName(d.getAgentName());
dto.setAreaName(d.getAreaName());
dto.setAddress(d.getAddress());
dto.setShipmentDate(d.getShipmentDate());
dto.setStartWarrantyDate(d.getStartWarrantyDate());
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
dto.setServiceAgentName(d.getServiceAgentName());
return dto;
}).collect(Collectors.toList());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备导出.xlsx", StandardCharsets.UTF_8));
// ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
// new Workbook()
// .addSheet(new TemplateSheet(resource.getInputStream())
// .setData(datas)
// .setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
// .stream().map(DictionaryItem::getName).collect(Collectors.toList())))
// .writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(datas)).writeTo(response.getOutputStream());
}
/**
* 获取设备详情
* @param id
@ -380,20 +420,44 @@ public class DeviceController extends ControllerBase {
} else {
device.setAgentName(customer.getAgencyCompanyName());
device.setAgentCode(customer.getAgencyCompanyCode());
}
}
if (StrUtil.isNotBlank(dto.getServiceAgentName())) {
TBaseCustomer customer = customerService.lambdaQuery()
.eq(TBaseCustomer::getDelIs, 0)
.eq(TBaseCustomer::getAgencyCompanyName, dto.getServiceAgentName())
.one();
if (Objects.isNull(customer)) {
sb.append("服务代理商不存在;");
} else if (customer.getEnableState() == 0) {
sb.append("服务代理商状态为禁用;");
} else {
device.setServiceAgentCode(customer.getAgencyCompanyCode());
device.setServiceAgentName(customer.getAgencyCompanyName());
}
}else {
device.setServiceAgentCode(device.getAgentCode());
device.setServiceAgentName(device.getAgentName());
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
TBaseArea area = areaService.lambdaQuery().eq(TBaseArea::getDelIs, 0).eq(TBaseArea::getAreaName, dto.getAreaName()).one();
if (Objects.isNull(area)) {
sb.append("区域不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域为禁用;");
} else {
device.setAreaName(area.getAreaName());
device.setAreaCode(area.getAreaCode());
}
List<String> areaNames = StrUtil.split(dto.getAreaName(), ",");
List<TBaseArea> areas = areaService.lambdaQuery()
.eq(TBaseArea::getDelIs, 0)
.in(TBaseArea::getAreaName, areaNames)
.list();
areaNames.forEach(name -> {
TBaseArea area = areas.stream().filter(a -> StrUtil.equals(a.getAreaName(), name)).findFirst().orElse(null);
if (Objects.isNull(area)) {
sb.append("区域").append(name).append("不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域").append(name).append("为禁用;");
} else {
device.setAreaName(area.getAreaName());
device.setAreaCode(area.getAreaCode());
}
});
device.setAreaName(dto.getAreaName());
device.setAreaCode(StrUtil.join(",",areas.stream().map(TBaseArea::getAreaCode).collect(Collectors.toList())));
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
@ -481,11 +545,11 @@ public class DeviceController extends ControllerBase {
public void exportSelect(HttpServletResponse response,@Valid @RequestBody @NotEmpty List<Integer> ids) throws Exception {
List<Device> devices=deviceService.listByIds(ids);
List<DictionaryItem> states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE);
List<DeviceUpdateImportDTO> datas=devices.stream().map(d->{
DeviceUpdateImportDTO dto= new DeviceUpdateImportDTO();
dto.setId(Long.valueOf(d.getId()));
List<DeviceExportDTO> datas=devices.stream().map(d->{
DeviceExportDTO dto= new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getDeviceName());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
@ -499,17 +563,19 @@ public class DeviceController extends ControllerBase {
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
dto.setServiceAgentName(d.getServiceAgentName());
return dto;
}).collect(Collectors.toList());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备更新.xlsx", "UTF-8"));
ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
new Workbook()
.addSheet(new TemplateSheet(resource.getInputStream())
.setData(datas)
.setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
.stream().map(DictionaryItem::getName).collect(Collectors.toList())))
.writeTo(response.getOutputStream());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备导出.xlsx", StandardCharsets.UTF_8));
// ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
// new Workbook()
// .addSheet(new TemplateSheet(resource.getInputStream())
// .setData(datas)
// .setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
// .stream().map(DictionaryItem::getName).collect(Collectors.toList())))
// .writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(datas)).writeTo(response.getOutputStream());
}
/**
@ -549,14 +615,16 @@ public class DeviceController extends ControllerBase {
List<Device> devices = new ArrayList<>();
List<TBaseDeviceType> deviceTypes = new ArrayList<>();
List<DeviceComponent> deviceComponents = new ArrayList<>();
List<Device> dbDevices = deviceService.listByIds(data.stream().map(DeviceUpdateImportDTO::getId).collect(Collectors.toList()));
List<DeviceAgentRecord> deviceAgentRecords = new ArrayList<>();
for (DeviceUpdateImportDTO dto : data) {
Device device = new Device();
StringBuilder sb = new StringBuilder();
if (Objects.isNull(dto.getId())) {
sb.append("id不能为空;");
}else {
device=deviceService.getById(dto.getId());
if (Objects.isNull(device)){
device = dbDevices.stream().filter(d -> d.getId().toString().equals(dto.getId())).findFirst().orElse(null);
if (Objects.isNull(device)) {
sb.append("设备不存在;");
device = new Device();
}
@ -565,7 +633,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isBlank(dto.getDeviceNo())) {
sb.append("设备编号不能为空;");
}
device.setDeviceName(dto.getDeviceName());
// device.setDeviceName(dto.getDeviceName());
device.setDeviceType(dto.getDeviceType());
if (StrUtil.isBlank(dto.getDeviceType())) {
sb.append("设备类型不能为空;");
@ -586,10 +654,6 @@ public class DeviceController extends ControllerBase {
sb.append("设备状态无效;");
} else {
device.setDeviceState(state.getId());
if (StrUtil.isNotBlank(dto.getDeviceNo()) && StrUtil.equals(state.getCode(), "Normal")
&& deviceService.lambdaQuery().ne(Device::getId, device.getId()).eq(Device::getDeviceNo, dto.getDeviceNo()).eq(Device::getDeviceState, state.getId()).exists()) {
sb.append("设备已存在;");
}
}
}
device.setCustomerId(0);
@ -611,16 +675,50 @@ public class DeviceController extends ControllerBase {
device.setAgentName("");
device.setAgentCode("");
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
TBaseArea area = areaService.lambdaQuery().eq(TBaseArea::getDelIs, 0).eq(TBaseArea::getAreaName, dto.getAreaName()).one();
if (Objects.isNull(area)) {
sb.append("区域不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域为禁用;");
String oldServiceAgentName = device.getServiceAgentName();
if (StrUtil.isNotBlank(dto.getServiceAgentName())) {
TBaseCustomer customer = customerService.lambdaQuery()
.eq(TBaseCustomer::getDelIs, 0)
.eq(TBaseCustomer::getAgencyCompanyName, dto.getServiceAgentName())
.one();
if (Objects.isNull(customer)) {
sb.append("服务代理商不存在;");
} else if (customer.getEnableState() == 0) {
sb.append("服务代理商状态为禁用;");
} else {
device.setAreaName(area.getAreaName());
device.setAreaCode(area.getAreaCode());
device.setServiceAgentCode(customer.getAgencyCompanyCode());
device.setServiceAgentName(customer.getAgencyCompanyName());
}
}else {
device.setServiceAgentCode("");
device.setServiceAgentName("");
}
if (Objects.nonNull(device.getId()) && !StrUtil.equals(device.getServiceAgentName(),oldServiceAgentName)){
deviceAgentRecords.add(new DeviceAgentRecord()
.setDeviceId(device.getId())
.setAgentCode(device.getServiceAgentCode())
.setAgentName(device.getServiceAgentName())
.setCreateById(AdminUserUtil.getUserId())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
List<String> areaNames = StrUtil.split(dto.getAreaName(), ",");
List<TBaseArea> areas = areaService.lambdaQuery()
.eq(TBaseArea::getDelIs, 0)
.in(TBaseArea::getAreaName, areaNames)
.list();
areaNames.forEach(name -> {
TBaseArea area = areas.stream().filter(a -> StrUtil.equals(a.getAreaName(), name)).findFirst().orElse(null);
if (Objects.isNull(area)) {
sb.append("区域").append(name).append("不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域").append(name).append("为禁用;");
}
});
device.setAreaName(dto.getAreaName());
device.setAreaCode(StrUtil.join(",",areas.stream().map(TBaseArea::getAreaCode).collect(Collectors.toList())));
}else {
device.setAreaName("");
device.setAreaCode("");
@ -700,6 +798,9 @@ public class DeviceController extends ControllerBase {
if (CollUtil.isNotEmpty(deviceComponents)){
deviceComponentService.saveBatch(deviceComponents);
}
if (CollUtil.isNotEmpty(deviceAgentRecords)){
deviceAgentRecordService.saveBatch(deviceAgentRecords);
}
return true;
}
return false;

View File

@ -642,7 +642,6 @@ public class TicketController extends ControllerBase {
**/
@GetMapping("getTicket")
public ApiResult<TicketInfoVO> getTicket(@Valid @RequestParam @NotNull Integer id) {
Ticket ticket = ticketService.getById(id);
AdminUser adminUser = StrUtil.equals(ticket.getUserPlatform(), Constant.FROM_ADMIN) ? adminUserService.getById(ticket.getUserId()) : null;
AppUser user = StrUtil.equals(ticket.getUserPlatform(), Constant.FROM_APP) ? appUserService.getById(ticket.getUserId()) : null;
@ -694,6 +693,7 @@ public class TicketController extends ControllerBase {
.setDeviceAddress(ticket.getDeviceAddress())
.setModelNo(device.getModelNo())
.setDeviceType(device.getDeviceType())
.setComponentId(Long.valueOf(ticket.getComponentId()))
.setComponent(Objects.nonNull(part) ? part.getPartName() : "")
.setUseTime(ticket.getUseTime())
.setDescription(ticket.getDescription())
@ -918,7 +918,6 @@ public class TicketController extends ControllerBase {
@GetMapping("getSolutionMeasures")
@ApiMark(moduleName = "工单管理", apiName = "获取工单解决方案措施")
public ApiResult<SolutionMeasuresVO> getSolutionMeasures(@Valid @RequestParam @NotNull Long ticketId) {
return ApiResult.success(ticketSolutionService.getSolutionMeasures(ticketId));
}
@ -930,7 +929,6 @@ public class TicketController extends ControllerBase {
@PostMapping("saveSolutionMeasures")
@ApiMark(moduleName = "工单管理", apiName = "保存工单解决方案措施")
public ApiResult<Void> saveSolutionMeasures(@Valid @RequestBody SolutionMeasuresSaveRequest request) {
Ticket ticket = ticketSolutionService.saveSolutionMeasures(request);
List<SolutionReviewDepartmentVO> audits = ticketSolutionAuditService.getByTicket(request.getTicketId());
audits.forEach(audit -> {

View File

@ -56,6 +56,12 @@ public class DeviceAddImportDTO {
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/

View File

@ -0,0 +1,102 @@
package com.nflg.mobilebroken.admin.pojo.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.ttzero.excel.annotation.ExcelColumn;
@EqualsAndHashCode(callSuper = false)
@Data
@Accessors(chain = true)
public class DeviceExportDTO {
/**
* id
*/
@ExcelColumn("id*")
private String id;
/**
* 设备编号
*/
@ExcelColumn("设备编号*")
private String deviceNo;
/**
* 设备名称
*/
@ExcelColumn("设备名称")
private String deviceName;
/**
* 设备类型
*/
@ExcelColumn("设备类型*")
private String deviceType;
/**
* 设备类型细分
*/
@ExcelColumn("设备类型细分*")
private String deviceTypeSub;
/**
* 设备机型
*/
@ExcelColumn("设备机型*")
private String modelNo;
/**
* 设备状态-来自字典
*/
@ExcelColumn("设备状态*")
private String deviceStateDesc;
/**
* 客户名称
*/
@ExcelColumn("客户名称")
private String customerName;
/**
* 代理商名称
*/
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/
@ExcelColumn("区域")
private String areaName;
/**
* 发货日期
*/
@ExcelColumn("发货日期")
private String shipmentDate;
/**
* 开始质保日期
*/
@ExcelColumn("开始质保日期")
private String startWarrantyDate;
/**
* 质保期
*/
@ExcelColumn("质保期(月)")
private String warrantyMonth;
/**
* 设备地址
*/
@ExcelColumn("设备地址")
private String address;
}

View File

@ -14,5 +14,5 @@ public class DeviceUpdateImportDTO extends DeviceAddImportDTO{
* id
*/
@ExcelColumn("id*")
private Long id;
private String id;
}

View File

@ -118,8 +118,8 @@ public class AdminCustomerService {
agentList.forEach(u -> {
// TBaseCustomer ent = crmCompanyMap.get(u.getId());
TBaseCustomer ent = customers.stream()
.filter(c -> Objects.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equals(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.filter(c -> StrUtil.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equalsIgnoreCase(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.findFirst()
.orElse(null);

View File

@ -41,6 +41,7 @@ public class SolutionMeasuresSaveRequest {
/**
* 问题部件id
*/
@NotNull
private Long componentId;
/**

View File

@ -17,10 +17,7 @@ import com.nflg.mobilebroken.common.pojo.vo.DeviceQRCodeVO;
import com.nflg.mobilebroken.common.util.*;
import com.nflg.mobilebroken.gongfu.annotation.ApiMark;
import com.nflg.mobilebroken.gongfu.constant.Constant1;
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.dto.*;
import com.nflg.mobilebroken.gongfu.pojo.query.ChangeServiceAgentCodeQuery;
import com.nflg.mobilebroken.gongfu.pojo.query.DeviceQuery;
import com.nflg.mobilebroken.gongfu.pojo.vo.DeviceDetailResultVO;
@ -31,7 +28,6 @@ import com.nflg.mobilebroken.repository.service.*;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import com.nflg.mobilebroken.starter.service.FileUploadService;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -39,16 +35,19 @@ import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.ttzero.excel.entity.ListSheet;
import org.ttzero.excel.entity.TemplateSheet;
import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
@ -138,6 +137,48 @@ public class DeviceController extends ControllerBase {
return ApiResult.success(resultData, query, result.getTotal());
}
/**
* 导出设备列表
* @param query
*/
@PostMapping("exportSearch")
public void exportSearch(HttpServletResponse response,@RequestBody DeviceQuery query) throws IOException {
Page<GongfuDevice> result = deviceService.getList(new Page<>(1, Integer.MAX_VALUE), query);
List<DictionaryItem> states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE);
List<DeviceExportDTO> datas = result.getRecords().stream().map(d -> {
DeviceExportDTO dto = new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
dto.setDeviceStateDesc(states.stream().filter(s -> Objects.equals(s.getId(), d.getDeviceState())).findFirst().get().getName());
dto.setCustomerName(d.getCustomerName());
dto.setAgentName(d.getAgentName());
dto.setAreaName(d.getAreaName());
dto.setAddress(d.getAddress());
dto.setShipmentDate(d.getShipmentDate());
dto.setStartWarrantyDate(d.getStartWarrantyDate());
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
dto.setProductLine(d.getProductLine());
dto.setServiceAgentName(d.getServiceAgentName());
return dto;
}).collect(Collectors.toList());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备导出.xlsx", StandardCharsets.UTF_8));
// ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
// new Workbook()
// .addSheet(new TemplateSheet(resource.getInputStream())
// .setData(datas)
// .setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
// .stream().map(DictionaryItem::getName).collect(Collectors.toList())))
// .writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(datas)).writeTo(response.getOutputStream());
}
/**
* 获取设备详情
* @param id
@ -386,6 +427,23 @@ public class DeviceController extends ControllerBase {
device.setServiceAgentName(customer.getAgencyCompanyName());
}
}
if (StrUtil.isNotBlank(dto.getServiceAgentName())) {
TBaseCustomer customer = customerService.lambdaQuery()
.eq(TBaseCustomer::getDelIs, 0)
.eq(TBaseCustomer::getAgencyCompanyName, dto.getServiceAgentName())
.one();
if (Objects.isNull(customer)) {
sb.append("服务代理商不存在;");
} else if (customer.getEnableState() == 0) {
sb.append("服务代理商状态为禁用;");
} else {
device.setServiceAgentCode(customer.getAgencyCompanyCode());
device.setServiceAgentName(customer.getAgencyCompanyName());
}
}else {
device.setServiceAgentCode(device.getAgentCode());
device.setServiceAgentName(device.getAgentName());
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
TBaseArea area = areaService.lambdaQuery().eq(TBaseArea::getDelIs, 0).eq(TBaseArea::getAreaName, dto.getAreaName()).one();
if (Objects.isNull(area)) {
@ -500,11 +558,11 @@ public class DeviceController extends ControllerBase {
public void exportSelect(HttpServletResponse response, @RequestBody @NotEmpty List<Long> ids) throws Exception {
List<GongfuDevice> devices = deviceService.listByIds(ids);
List<DictionaryItem> states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE);
List<DeviceUpdateImportDTO> datas = devices.stream().map(d -> {
DeviceUpdateImportDTO dto = new DeviceUpdateImportDTO();
dto.setId(d.getId());
List<DeviceExportDTO> datas = devices.stream().map(d -> {
DeviceExportDTO dto = new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getDeviceName());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
@ -512,22 +570,26 @@ public class DeviceController extends ControllerBase {
dto.setCustomerName(d.getCustomerName());
dto.setAgentName(d.getAgentName());
dto.setAreaName(d.getAreaName());
dto.setAddress(d.getAddress());
dto.setShipmentDate(d.getShipmentDate());
dto.setStartWarrantyDate(d.getStartWarrantyDate());
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
dto.setProductLine(d.getProductLine());
dto.setServiceAgentName(d.getServiceAgentName());
return dto;
}).collect(Collectors.toList());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备更新.xlsx", "UTF-8"));
ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
new Workbook()
.addSheet(new TemplateSheet(resource.getInputStream())
.setData(datas)
.setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
.stream().map(DictionaryItem::getName).collect(Collectors.toList())))
.writeTo(response.getOutputStream());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("设备导出.xlsx", StandardCharsets.UTF_8));
// ClassPathResource resource = new ClassPathResource("templates/deviceForUpdate.xlsx");
// new Workbook()
// .addSheet(new TemplateSheet(resource.getInputStream())
// .setData(datas)
// .setData("@list:deviceStateDesc", dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE)
// .stream().map(DictionaryItem::getName).collect(Collectors.toList())))
// .writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(datas)).writeTo(response.getOutputStream());
}
/**
@ -567,13 +629,16 @@ public class DeviceController extends ControllerBase {
List<GongfuDevice> devices = new ArrayList<>();
List<GongfuDeviceType> deviceTypes = new ArrayList<>();
List<GongfuDeviceComponent> deviceComponents = new ArrayList<>();
List<GongfuDevice> dbDevices = deviceService.listByIds(data.stream().map(DeviceUpdateImportDTO::getId).collect(Collectors.toList()));
List<GongfuDeviceAgentRecord> deviceAgentRecords = new ArrayList<>();
List<TBaseCustomer> customers = customerService.list();
for (DeviceUpdateImportDTO dto : data) {
GongfuDevice device = new GongfuDevice();
StringBuilder sb = new StringBuilder();
if (Objects.isNull(dto.getId())) {
sb.append("id不能为空;");
} else {
device = deviceService.getById(dto.getId());
device = dbDevices.stream().filter(d -> d.getId().toString().equals(dto.getId())).findFirst().orElse(null);
if (Objects.isNull(device)) {
sb.append("设备不存在;");
device = new GongfuDevice();
@ -587,7 +652,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isBlank(dto.getDeviceNo())) {
sb.append("设备编号不能为空;");
}
device.setDeviceName(dto.getDeviceName());
// device.setDeviceName(dto.getDeviceName());
device.setDeviceType(dto.getDeviceType());
if (StrUtil.isBlank(dto.getDeviceType())) {
sb.append("设备类型不能为空;");
@ -608,15 +673,6 @@ public class DeviceController extends ControllerBase {
sb.append("设备状态无效;");
} else {
device.setDeviceState(state.getId());
if (StrUtil.isNotBlank(dto.getDeviceNo()) && StrUtil.equals(state.getCode(), "Normal")
&& deviceService.lambdaQuery()
.ne(GongfuDevice::getId, device.getId())
.eq(GongfuDevice::getDeviceNo, dto.getDeviceNo())
.eq(GongfuDevice::getDeviceState, state.getId())
.exists()
) {
sb.append("设备已存在;");
}
}
}
device.setCustomerId(0);
@ -638,17 +694,51 @@ public class DeviceController extends ControllerBase {
device.setAgentName("");
device.setAgentCode("");
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
TBaseArea area = areaService.lambdaQuery().eq(TBaseArea::getDelIs, 0).eq(TBaseArea::getAreaName, dto.getAreaName()).one();
if (Objects.isNull(area)) {
sb.append("区域不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域为禁用;");
String oldServiceAgentName = device.getServiceAgentName();
if (StrUtil.isNotBlank(dto.getServiceAgentName())) {
TBaseCustomer customer = customerService.lambdaQuery()
.eq(TBaseCustomer::getDelIs, 0)
.eq(TBaseCustomer::getAgencyCompanyName, dto.getServiceAgentName())
.one();
if (Objects.isNull(customer)) {
sb.append("服务代理商不存在;");
} else if (customer.getEnableState() == 0) {
sb.append("服务代理商状态为禁用;");
} else {
device.setAreaName(area.getAreaName());
device.setAreaCode(area.getAreaCode());
device.setServiceAgentCode(customer.getAgencyCompanyCode());
device.setServiceAgentName(customer.getAgencyCompanyName());
}
} else {
}else {
device.setServiceAgentCode("");
device.setServiceAgentName("");
}
if (Objects.nonNull(device.getId()) && !StrUtil.equals(device.getServiceAgentName(),oldServiceAgentName)){
deviceAgentRecords.add(new GongfuDeviceAgentRecord()
.setDeviceId(device.getId())
.setAgentCode(device.getServiceAgentCode())
.setAgentName(device.getServiceAgentName())
.setCreateById(AdminUserUtil.getUserId())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
}
if (StrUtil.isNotBlank(dto.getAreaName())) {
List<String> areaNames = StrUtil.split(dto.getAreaName(), ",");
List<TBaseArea> areas = areaService.lambdaQuery()
.eq(TBaseArea::getDelIs, 0)
.in(TBaseArea::getAreaName, areaNames)
.list();
areaNames.forEach(name -> {
TBaseArea area = areas.stream().filter(a -> StrUtil.equals(a.getAreaName(), name)).findFirst().orElse(null);
if (Objects.isNull(area)) {
sb.append("区域").append(name).append("不存在;");
} else if (area.getAreaState().intValue() == 0) {
sb.append("区域").append(name).append("为禁用;");
}
});
device.setAreaName(dto.getAreaName());
device.setAreaCode(StrUtil.join(",",areas.stream().map(TBaseArea::getAreaCode).collect(Collectors.toList())));
}else {
device.setAreaName("");
device.setAreaCode("");
}
@ -739,6 +829,9 @@ public class DeviceController extends ControllerBase {
if (CollUtil.isNotEmpty(deviceComponents)) {
deviceComponentService.saveBatch(deviceComponents);
}
if (CollUtil.isNotEmpty(deviceAgentRecords)){
gongfuDeviceAgentRecordService.saveBatch(deviceAgentRecords);
}
return true;
}
return false;

View File

@ -0,0 +1,139 @@
package com.nflg.mobilebroken.gongfu.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponent;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponentDetail;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentDetailService;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentService;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 测试
*/
@RestController
@RequestMapping("/test")
public class TestController extends ControllerBase {
@Resource
private IGongfuDeviceService gongfuDeviceService;
@Resource
private IGongfuDeviceComponentService gongfuDeviceComponentService;
@Resource
private IGongfuDeviceComponentDetailService gongfuDeviceComponentDetailService;
/**
* 初始化设备组件中的产品线数据
*/
@Transactional
@GetMapping("initDeviceComponentProductLine")
public ApiResult<Void> initDeviceComponentProductLine() {
List<GongfuDeviceComponent> deviceComponents = gongfuDeviceComponentService
.lambdaQuery()
.isNull(GongfuDeviceComponent::getProductLine)
.list();
if (CollectionUtil.isEmpty(deviceComponents)) {
return ApiResult.success();
}
List<GongfuDevice> devices = gongfuDeviceService.lambdaQuery()
.select(GongfuDevice::getModelNo, GongfuDevice::getProductLine)
.eq(GongfuDevice::getDataValidState, 1)
.list();
List<GongfuDeviceComponent> forUpdate = new ArrayList<>();
List<GongfuDeviceComponent> forAdd = new ArrayList<>();
List<GongfuDeviceComponentDetail> detailsForAdd = new ArrayList<>();
deviceComponents.forEach(deviceComponent -> {
List<GongfuDevice> ds = devices.stream()
.filter(d -> d.getModelNo().equals(deviceComponent.getModelNo()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(ds)) {
forUpdate.add(new GongfuDeviceComponent()
.setId(deviceComponent.getId())
.setProductLine(ds.get(0).getProductLine())
);
if (ds.size() > 1) {
List<GongfuDeviceComponentDetail> details = gongfuDeviceComponentDetailService.lambdaQuery()
.eq(GongfuDeviceComponentDetail::getDeviceComponentId, deviceComponent.getId())
.list();
for (int i = 1; i < ds.size(); i++) {
String prodoctLine = ds.get(i).getProductLine();
GongfuDeviceComponent component = deviceComponents.stream()
.filter(dc -> StrUtil.equals(dc.getProductLine(), prodoctLine))
.findFirst()
.orElse(null);
if (Objects.isNull(component)) {
component = forAdd.stream()
.filter(dc -> StrUtil.equals(dc.getProductLine(), prodoctLine))
.findFirst()
.orElse(null);
if (Objects.isNull(component)) {
component = new GongfuDeviceComponent()
.setId(IdUtil.getSnowflakeNextId())
.setProductLine(ds.get(i).getProductLine())
.setComponent(deviceComponent.getComponent())
.setEnable(deviceComponent.getEnable())
.setCreateBy(deviceComponent.getCreateBy())
.setCreateTime(deviceComponent.getCreateTime())
.setUpdateBy(deviceComponent.getUpdateBy())
.setUpdateTime(deviceComponent.getUpdateTime());
forAdd.add(component);
}
}
for (GongfuDeviceComponentDetail detail : details) {
detailsForAdd.add(new GongfuDeviceComponentDetail()
.setDeviceComponentId(component.getId())
.setModelPartId(detail.getModelPartId())
.setModelPartName(detail.getModelPartName())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
}
}
}
}
});
if (CollectionUtil.isNotEmpty(forUpdate)) {
gongfuDeviceComponentService.updateBatchById(forUpdate);
}
if (CollectionUtil.isNotEmpty(forAdd)) {
gongfuDeviceComponentService.saveBatch(forAdd);
}
if (CollectionUtil.isNotEmpty(detailsForAdd)) {
gongfuDeviceComponentDetailService.saveBatch(detailsForAdd);
}
List<GongfuDeviceComponentDetail> allDetails = gongfuDeviceComponentDetailService
.lambdaQuery()
.select(GongfuDeviceComponentDetail::getDeviceComponentId, GongfuDeviceComponentDetail::getModelPartName)
.list();
List<GongfuDeviceComponent> allComponents = gongfuDeviceComponentService.lambdaQuery()
.select(GongfuDeviceComponent::getId)
.list();
allComponents.forEach(component -> {
component.setComponent(
allDetails.stream()
.filter(detail -> detail.getDeviceComponentId().equals(component.getId()))
.map(GongfuDeviceComponentDetail::getModelPartName)
.collect(Collectors.joining(","))
);
});
gongfuDeviceComponentService.updateBatchById(allComponents);
return ApiResult.success();
}
}

View File

@ -62,6 +62,12 @@ public class DeviceAddImportDTO {
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/

View File

@ -0,0 +1,108 @@
package com.nflg.mobilebroken.gongfu.pojo.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.ttzero.excel.annotation.ExcelColumn;
@EqualsAndHashCode(callSuper = false)
@Data
@Accessors(chain = true)
public class DeviceExportDTO {
/**
* id
*/
@ExcelColumn("id*")
private String id;
/**
* 产品线
*/
@ExcelColumn("产品线*")
private String productLine;
/**
* 设备编号
*/
@ExcelColumn("设备编号*")
private String deviceNo;
/**
* 设备名称
*/
@ExcelColumn("设备名称")
private String deviceName;
/**
* 设备类型
*/
@ExcelColumn("设备类型*")
private String deviceType;
/**
* 设备类型细分
*/
@ExcelColumn("设备类型细分*")
private String deviceTypeSub;
/**
* 设备机型
*/
@ExcelColumn("设备机型*")
private String modelNo;
/**
* 设备状态-来自字典
*/
@ExcelColumn("设备状态*")
private String deviceStateDesc;
/**
* 客户名称
*/
@ExcelColumn("客户名称")
private String customerName;
/**
* 代理商名称
*/
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/
@ExcelColumn("区域")
private String areaName;
/**
* 发货日期
*/
@ExcelColumn("发货日期")
private String shipmentDate;
/**
* 开始质保日期
*/
@ExcelColumn("开始质保日期")
private String startWarrantyDate;
/**
* 质保期
*/
@ExcelColumn("质保期(月)")
private String warrantyMonth;
/**
* 设备地址
*/
@ExcelColumn("设备地址")
private String address;
}

View File

@ -14,5 +14,5 @@ public class DeviceUpdateImportDTO extends DeviceAddImportDTO {
* id
*/
@ExcelColumn("id*")
private Long id;
private String id;
}

View File

@ -28,10 +28,10 @@ public class GongfuDeviceComponent implements Serializable {
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
// /**
// * 设备机型
// */
// private String modelNo;
/**
* 设备机型
*/
private String modelNo;
/**
* 产品线

View File

@ -133,11 +133,9 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
}
}
vo.setMeasures(items);
if (Objects.equals(ticket.getType(), 1)) {
DeviceInfoVO deviceInfoVO = deviceService.getByDeviceNo(ticket.getDeviceNo());
if (Objects.nonNull(deviceInfoVO)) {
vo.setComponents(deviceInfoVO.getComponents());
}
DeviceInfoVO deviceInfoVO = deviceService.getByDeviceNo(ticket.getDeviceNo());
if (Objects.nonNull(deviceInfoVO)) {
vo.setComponents(deviceInfoVO.getComponents());
}
return vo;
}
@ -198,6 +196,7 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
.set(Ticket::getReason, request.getReason())
.set(StrUtil.isNotBlank(request.getQuestion()), Ticket::getQuestion, request.getQuestion())
.set(Ticket::getAccidentLevel, request.getAccidentLevel())
.set(Ticket::getComponentId, request.getComponentId())
.eq(Ticket::getId, request.getTicketId())
.update();
if (CollectionUtil.isNotEmpty(idForReserve)) {
@ -279,7 +278,7 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
}
ticket1Service.lambdaUpdate()
.set(GongfuTicket::getReason, request.getReason())
.set(GongfuTicket::getQuestion, request.getQuestion())
.set(StrUtil.isNotBlank(request.getQuestion()), GongfuTicket::getQuestion, request.getQuestion())
.set(GongfuTicket::getAccidentLevel, request.getAccidentLevel())
.set(GongfuTicket::getComponentId, request.getComponentId())
.eq(GongfuTicket::getId, request.getTicketId())