Compare commits

..

No commits in common. "85fb4dddbc04c153233b914bdce27ccfa21b7e64" and "57d850e17fc53c97604d892d00621e344e480ecd" have entirely different histories.

14 changed files with 96 additions and 649 deletions

View File

@ -8,7 +8,10 @@ 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.*;
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;
@ -34,7 +37,6 @@ 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;
@ -47,7 +49,6 @@ 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;
@ -134,47 +135,6 @@ 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
@ -420,44 +380,20 @@ 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())) {
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())));
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());
}
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
@ -545,11 +481,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<DeviceExportDTO> datas=devices.stream().map(d->{
DeviceExportDTO dto= new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
List<DeviceUpdateImportDTO> datas=devices.stream().map(d->{
DeviceUpdateImportDTO dto= new DeviceUpdateImportDTO();
dto.setId(Long.valueOf(d.getId()));
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceName(d.getDeviceName());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
@ -563,19 +499,17 @@ 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", 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());
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());
}
/**
@ -615,16 +549,14 @@ 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 = dbDevices.stream().filter(d -> d.getId().toString().equals(dto.getId())).findFirst().orElse(null);
if (Objects.isNull(device)) {
device=deviceService.getById(dto.getId());
if (Objects.isNull(device)){
sb.append("设备不存在;");
device = new Device();
}
@ -633,7 +565,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("设备类型不能为空;");
@ -654,6 +586,10 @@ 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);
@ -675,50 +611,16 @@ public class DeviceController extends ControllerBase {
device.setAgentName("");
device.setAgentCode("");
}
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.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())));
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());
}
}else {
device.setAreaName("");
device.setAreaCode("");
@ -798,9 +700,6 @@ 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,6 +642,7 @@ 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;
@ -693,7 +694,6 @@ 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,6 +918,7 @@ 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));
}
@ -929,6 +930,7 @@ 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,12 +56,6 @@ public class DeviceAddImportDTO {
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/

View File

@ -1,102 +0,0 @@
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 String id;
private Long 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 -> StrUtil.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equalsIgnoreCase(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.filter(c -> Objects.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equals(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.findFirst()
.orElse(null);

View File

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

View File

@ -17,7 +17,10 @@ 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.*;
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;
@ -28,6 +31,7 @@ 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;
@ -35,19 +39,16 @@ 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;
@ -137,48 +138,6 @@ 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
@ -427,23 +386,6 @@ 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)) {
@ -558,11 +500,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<DeviceExportDTO> datas = devices.stream().map(d -> {
DeviceExportDTO dto = new DeviceExportDTO();
dto.setId(String.valueOf(d.getId()));
List<DeviceUpdateImportDTO> datas = devices.stream().map(d -> {
DeviceUpdateImportDTO dto = new DeviceUpdateImportDTO();
dto.setId(d.getId());
dto.setDeviceNo(d.getDeviceNo());
dto.setDeviceName(d.getCustomerName()+d.getDeviceNo());
dto.setDeviceName(d.getDeviceName());
dto.setDeviceType(d.getDeviceType());
dto.setDeviceTypeSub(d.getDeviceTypeSub());
dto.setModelNo(d.getModelNo());
@ -570,26 +512,22 @@ 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", 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());
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());
}
/**
@ -629,16 +567,13 @@ 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 = dbDevices.stream().filter(d -> d.getId().toString().equals(dto.getId())).findFirst().orElse(null);
device = deviceService.getById(dto.getId());
if (Objects.isNull(device)) {
sb.append("设备不存在;");
device = new GongfuDevice();
@ -652,7 +587,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("设备类型不能为空;");
@ -673,6 +608,15 @@ 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);
@ -694,51 +638,17 @@ public class DeviceController extends ControllerBase {
device.setAgentName("");
device.setAgentCode("");
}
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.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 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 {
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());
}
} else {
device.setAreaName("");
device.setAreaCode("");
}
@ -829,9 +739,6 @@ 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

@ -1,139 +0,0 @@
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,12 +62,6 @@ public class DeviceAddImportDTO {
@ExcelColumn("代理商")
private String agentName;
/**
* 服务代理商名称
*/
@ExcelColumn("服务代理商")
private String serviceAgentName;
/**
* 区域名称
*/

View File

@ -1,108 +0,0 @@
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 String id;
private Long 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,9 +133,11 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
}
}
vo.setMeasures(items);
DeviceInfoVO deviceInfoVO = deviceService.getByDeviceNo(ticket.getDeviceNo());
if (Objects.nonNull(deviceInfoVO)) {
vo.setComponents(deviceInfoVO.getComponents());
if (Objects.equals(ticket.getType(), 1)) {
DeviceInfoVO deviceInfoVO = deviceService.getByDeviceNo(ticket.getDeviceNo());
if (Objects.nonNull(deviceInfoVO)) {
vo.setComponents(deviceInfoVO.getComponents());
}
}
return vo;
}
@ -196,7 +198,6 @@ 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)) {
@ -278,7 +279,7 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
}
ticket1Service.lambdaUpdate()
.set(GongfuTicket::getReason, request.getReason())
.set(StrUtil.isNotBlank(request.getQuestion()), GongfuTicket::getQuestion, request.getQuestion())
.set(GongfuTicket::getQuestion, request.getQuestion())
.set(GongfuTicket::getAccidentLevel, request.getAccidentLevel())
.set(GongfuTicket::getComponentId, request.getComponentId())
.eq(GongfuTicket::getId, request.getTicketId())