| | |
| | | import com.example.client.dto.JComboBoxItem; |
| | | import com.example.client.utils.CommonTable; |
| | | import com.example.client.utils.GBC; |
| | | import com.example.client.utils.MultiSelectComboBox2; |
| | | import com.example.client.utils.RequiredLabel; |
| | | import com.example.server.ExportExcel.dto.ExcelColumnDto; |
| | | import com.example.server.progressTrack.model.DjJdgzTrackRecord; |
| | | import com.example.server.progressTrack.service.DjJdgzNetworkLevel1Service; |
| | | import com.example.server.progressTrack.service.DjJdgzNetworkLevel3ListService; |
| | |
| | | import com.example.server.progressTrack.service.DjJdgzTrackRecordService; |
| | | import com.example.server.teamGroup.service.SysTeamGroupClassService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.jdesktop.swingx.JXDatePicker; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.File; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class ExportTrackRecordService { |
| | |
| | | |
| | | GridBagLayout layout = new GridBagLayout(); |
| | | frame1.setLayout(layout); |
| | | |
| | | List<ExcelColumnDto> columnDto = new ArrayList<>(); |
| | | |
| | | columnDto.add(new ExcelColumnDto("一级节点", "Level1NodeName", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("二级节点", "Level2NodeName", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("项目名称", "Level3NetworkName", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("当前节点", "Level3NodeName", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("专业", "teamgroupName", 20, HorizontalAlignment.CENTER)); |
| | | columnDto.add(new ExcelColumnDto("总承修单位及负责人", "GeneralRepair", 25, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("分承修单位及负责人", "Repair", 25, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("跟踪方式", "trackMethodStr", 10, HorizontalAlignment.CENTER)); |
| | | columnDto.add(new ExcelColumnDto("助修人", "TrackPerson", 25, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("厂方", "TrackedPerson", 25, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("跟踪地点", "TrackLocation", 10, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("节点进展", "status", 10, HorizontalAlignment.CENTER)); |
| | | columnDto.add(new ExcelColumnDto("脱期风险", "hasDelayRiskStr", 10, HorizontalAlignment.CENTER)); |
| | | columnDto.add(new ExcelColumnDto("预计完成时间", "EstimatedCompletionTime", 15, HorizontalAlignment.CENTER)); |
| | | columnDto.add(new ExcelColumnDto("存在问题", "Problem", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("后续计划", "FollowupPlan", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("备注", "Remark", 20, HorizontalAlignment.LEFT)); |
| | | columnDto.add(new ExcelColumnDto("填写时间", "UpdateDate", 15, HorizontalAlignment.CENTER)); |
| | | |
| | | |
| | | JComboBoxItem[] statusList = { |
| | | new JComboBoxItem(0L, "进行中"), |
| | |
| | | JLabel JLabel7 = new JLabel("结束日期"); |
| | | JXDatePicker endDate = new JXDatePicker(); |
| | | endDate.setPreferredSize(new Dimension(300, 28)); |
| | | |
| | | List<String> itemList = new ArrayList<>(); |
| | | for (ExcelColumnDto dto : columnDto) { |
| | | itemList.add(dto.getColumnDesc()); // 将 dto.getColumnDesc() 添加到 List 中 |
| | | } |
| | | |
| | | String[] items = itemList.toArray(new String[0]); |
| | | MultiSelectComboBox2 mulcomboBox = new MultiSelectComboBox2(items, null, null); |
| | | |
| | | comboBox.addItemListener(new ItemListener() { |
| | | @Override |
| | |
| | | |
| | | frame1.add(JLabel7, new GBC(0, 7, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | frame1.add(endDate, new GBC(1, 7, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | frame1.add(mulcomboBox, new GBC(1, 8, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | |
| | | frame1.add(exportButton, new GBC(0, 8, 2, 1).setWeight(0, 0)); |
| | | frame1.add(exportButton, new GBC(0, 11, 2, 1).setWeight(0, 0)); |
| | | |
| | | exportButton.addActionListener(new ActionListener() { |
| | | @Override |
| | |
| | | istq = Math.toIntExact(tq.getId()); |
| | | } |
| | | |
| | | String filePath = "跟踪记录报表.xlsx"; |
| | | djJdgzTrackRecordService.exportExcel(filePath, teamGroupId, level1NetworkId, level3NetworkId, level3NodeId, status, beginDate2, endDate2, istq); |
| | | List<ExcelColumnDto> columnDto2 = new ArrayList<>(); |
| | | Set<Integer> selectedIndices = mulcomboBox.getSelectedIndices(); |
| | | |
| | | for (Integer index : selectedIndices) { |
| | | columnDto2.add(columnDto.get(index)); |
| | | } |
| | | |
| | | String fileName = "跟踪记录报表.xlsx"; |
| | | JFileChooser fileChooser = new JFileChooser(); |
| | | fileChooser.setSelectedFile(new File(filePath)); |
| | | fileChooser.setSelectedFile(new File(fileName)); |
| | | int result = fileChooser.showSaveDialog(frame1); |
| | | |
| | | if (result == JFileChooser.APPROVE_OPTION) { |
| | | File selectedFile = fileChooser.getSelectedFile(); |
| | | // 将文件移动到用户选择的位置 |
| | | File originalFile = new File(filePath); |
| | | originalFile.renameTo(selectedFile); |
| | | djJdgzTrackRecordService.exportExcel(selectedFile.getPath(), teamGroupId, level1NetworkId, level3NetworkId, level3NodeId, status, beginDate2, endDate2, istq, columnDto2); |
| | | JOptionPane.showMessageDialog(frame1, "文件导出成功"); |
| | | } else { |
| | | JOptionPane.showMessageDialog(frame1, "文件导出取消"); |