package com.example.client.service; import com.example.client.dto.ColumnDto; import com.example.client.dto.JComboBoxItem; import com.example.client.utils.CommonTable; import com.example.client.utils.GBC; import com.example.client.utils.UploadFile; import com.example.server.progressTrack.model.DjJdgzDismantTrack; import com.example.server.progressTrack.model.DjJdgzNetworkLevel3; import com.example.server.progressTrack.model.DjJdgzTrackRecord; import com.example.server.progressTrack.service.*; import com.example.server.sysOss.model.SysOss; import com.example.server.user.model.SysUser; import com.example.server.utils.UserAndSiteUtils; import org.apache.commons.lang3.StringUtils; import org.jdesktop.swingx.JXDatePicker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; @Service public class TrackRecordAddOrUpdate { @Autowired private DjJdgzTrackRecordService djJdgzTrackRecordService; @Autowired private DjJdgzNetworkLevel3Service djJdgzNetworkLevel3Service; @Autowired private TrackRecordManageService trackRecordManageService; @Autowired private UploadFile uploadFile; @Autowired private DjJdgzDismantTrackService djJdgzDismantTrackService; public void openDialog(DjJdgzTrackRecord data, JFrame jFrame, Long level1Id, List columnDto, JTable table) { JFrame frame1 = new JFrame(data.getLevel3NetworkName() + "跟踪记录"); frame1.setSize(1200, 800); frame1.setResizable(false); frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame1.setLocationRelativeTo(null); frame1.setVisible(true); frame1.addWindowListener(new WindowAdapter() { //添加第二个界面的关闭事件: public void windowClosing(WindowEvent e) { //添加事件: jFrame.setEnabled(true);//将主界面再设置为可操作的 } }); GridBagLayout layout = new GridBagLayout(); frame1.setLayout(layout); Map trackMethodMap = new HashMap<>(); trackMethodMap.put(0, "线下"); trackMethodMap.put(1, "电话"); Map statusMap = new HashMap<>(); statusMap.put(0, "进行中"); statusMap.put(1, "已完成"); Map hasDelayRiskMap = new HashMap<>(); hasDelayRiskMap.put(1, "有"); hasDelayRiskMap.put(0, "无"); JComboBoxItem[] trackList = { new JComboBoxItem(0L, "线下"), new JComboBoxItem(1L, "电话"), }; JComboBoxItem[] statusList = { new JComboBoxItem(0L, "进行中"), new JComboBoxItem(1L, "已完成"), }; JComboBoxItem[] hasDelayRiskList = { new JComboBoxItem(0L, "无"), new JComboBoxItem(1L, "有"), }; JLabel JLabel0 = new JLabel("当前节点"); JTextField nodeDesc = new JTextField(16); nodeDesc.setEditable(false); nodeDesc.setText(data.getProcessName()); JLabel JLabel1 = new JLabel("跟踪方式"); JComboBox comboBox0 = new JComboBox<>(trackList); comboBox0.setPreferredSize(new Dimension(185, 28)); if (data.getTrackMethod() != null) { comboBox0.setSelectedItem(trackList[data.getTrackMethod()]); } JLabel JLabel2 = new JLabel("跟踪地点"); JTextField trackLocatDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackLocation())) { trackLocatDesc.setText(data.getTrackLocation()); } JLabel JLabel3 = new JLabel("跟踪人(T方)"); JTextField trackPersonDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackPerson())) { trackPersonDesc.setText(data.getTrackPerson()); } JLabel JLabel34 = new JLabel("T方单位"); JTextField trackPersonUnitDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackPersonUnit())) { trackPersonUnitDesc.setText(data.getTrackPersonUnit()); } JLabel JLabel4 = new JLabel("联系方式"); JTextField trackPersonContactDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackPersonContact())) { trackPersonContactDesc.setText(data.getTrackPersonContact()); } JLabel JLabel5 = new JLabel("被跟踪人(厂方)"); JTextField trackedPersonDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackedPerson())) { trackedPersonDesc.setText(data.getTrackedPerson()); } JLabel JLabel56 = new JLabel("厂方单位"); JTextField trackedPersonUnitDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackedPersonUnit())) { trackedPersonUnitDesc.setText(data.getTrackedPersonUnit()); } JLabel JLabel6 = new JLabel("联系方式"); JTextField trackedPersonContactDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getTrackedPersonContact())) { trackedPersonContactDesc.setText(data.getTrackedPersonContact()); } JLabel JLabel7 = new JLabel("总承修单位"); JTextField generalRepairUnitDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getGeneralRepairUnit())) { generalRepairUnitDesc.setText(data.getGeneralRepairUnit()); } JLabel JLabel8 = new JLabel("负责人"); JTextField generalRepairUnitDirectorDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getGeneralRepairUnitDirector())) { generalRepairUnitDirectorDesc.setText(data.getGeneralRepairUnitDirector()); } JLabel JLabel9 = new JLabel("联系方式"); JTextField generalRepairUnitContactDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getGeneralRepairUnitContact())) { generalRepairUnitContactDesc.setText(data.getGeneralRepairUnitContact()); } JLabel JLabel10 = new JLabel("分承修单位"); JTextField repairUnitDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getRepairUnitContact())) { repairUnitDesc.setText(data.getRepairUnitContact()); } JLabel JLabel11 = new JLabel("负责人"); JTextField repairUnitDirectorDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getRepairUnitDirector())) { repairUnitDirectorDesc.setText(data.getRepairUnitDirector()); } JLabel JLabel12 = new JLabel("联系方式"); JTextField repairUnitContactDesc = new JTextField(16); if (StringUtils.isNotBlank(data.getRepairUnitContact())) { repairUnitContactDesc.setText(data.getRepairUnitContact()); } JLabel JLabel13 = new JLabel("节点进展"); JComboBox comboBox1 = new JComboBox<>(statusList); comboBox1.setPreferredSize(new Dimension(185, 28)); if (data.getCurrentStatus() != null) { comboBox1.setSelectedItem(statusList[data.getCurrentStatus()]); } JLabel JLabel14 = new JLabel("有无脱期风险"); JComboBox comboBox2 = new JComboBox<>(hasDelayRiskList); comboBox2.setPreferredSize(new Dimension(185, 28)); if (data.getHasDelayRisk() != null) { comboBox2.setSelectedItem(hasDelayRiskList[data.getHasDelayRisk()]); } JLabel JLabel15 = new JLabel("预计完成时间"); JXDatePicker estimatedCompletionDate = new JXDatePicker(); estimatedCompletionDate.setPreferredSize(new Dimension(185, 28)); SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd"); estimatedCompletionDate.setFormats(sdFormat); Date parse = new Date(); try { if (StringUtils.isNotBlank(data.getEstimatedCompletionTime())) { parse = sdFormat.parse(data.getEstimatedCompletionTime()); } else { parse = sdFormat.parse(data.getRequiredCompletionTime()); } } catch (ParseException e) { e.printStackTrace(); } estimatedCompletionDate.setDate(parse); JLabel JLabel16 = new JLabel("存在问题"); JTextArea problem = new JTextArea(5, 30); problem.setLineWrap(true); //设置文本域中的文本为自动换行 if (StringUtils.isNotBlank(data.getProblem())) { problem.setText(data.getProblem()); } JLabel JLabel17 = new JLabel("后续计划"); JTextArea plan = new JTextArea(5, 29); plan.setLineWrap(true); if (StringUtils.isNotBlank(data.getFollowupPlan())) { plan.setText(data.getFollowupPlan()); } JLabel JLabel18 = new JLabel("备注"); JTextArea remark = new JTextArea(3, 77); remark.setLineWrap(true); if (StringUtils.isNotBlank(data.getRemark())) { remark.setText(data.getRemark()); } JLabel JLabel19 = new JLabel("附件"); SysOss oss = new SysOss(); if (data.getId() != null) { oss.setBusiId(data.getId()); } oss.setBusiType("ProjectProgressFileUpload"); oss.setBusiField("ProjectProgressFileUpload"); oss.setBusiTypeName("项目进度文件"); oss.setBusiFieldName("项目进度文件"); oss.setStatus(1); oss.setChannel("local"); JPanel jPanel = uploadFile.uploadFile(jFrame, 500, 220, oss); JButton saveButton = new JButton("保存"); frame1.add(JLabel0, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(nodeDesc, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel1, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(comboBox0, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel2, new GBC(4, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackLocatDesc, new GBC(5, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel3, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackPersonDesc, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel34, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackPersonUnitDesc, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel4, new GBC(4, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackPersonContactDesc, new GBC(5, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel5, new GBC(0, 2, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackedPersonDesc, new GBC(1, 2, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel56, new GBC(2, 2, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackedPersonUnitDesc, new GBC(3, 2, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel6, new GBC(4, 2, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(trackedPersonContactDesc, new GBC(5, 2, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel7, new GBC(0, 3, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(generalRepairUnitDesc, new GBC(1, 3, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel8, new GBC(2, 3, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(generalRepairUnitDirectorDesc, new GBC(3, 3, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel9, new GBC(4, 3, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(generalRepairUnitContactDesc, new GBC(5, 3, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel10, new GBC(0, 4, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(repairUnitDesc, new GBC(1, 4, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel11, new GBC(2, 4, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(repairUnitDirectorDesc, new GBC(3, 4, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel12, new GBC(4, 4, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(repairUnitContactDesc, new GBC(5, 4, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel13, new GBC(0, 5, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(comboBox1, new GBC(1, 5, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel14, new GBC(2, 5, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(comboBox2, new GBC(3, 5, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel15, new GBC(4, 5, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(estimatedCompletionDate, new GBC(5, 5, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); frame1.add(JLabel16, new GBC(0, 6, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(problem, new GBC(1, 6, 2, 5).setAnchor(GBC.NORTHWEST).setInsets(5)); frame1.add(JLabel17, new GBC(3, 6, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(plan, new GBC(4, 6, 2, 5).setAnchor(GBC.NORTHWEST).setInsets(5)); frame1.add(JLabel18, new GBC(0, 11, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(remark, new GBC(1, 11, 6, 3).setAnchor(GBC.NORTHWEST).setInsets(5)); frame1.add(JLabel19, new GBC(0, 15, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); frame1.add(jPanel, new GBC(1, 15, 6, 3).setAnchor(GBC.NORTHWEST).setInsets(5)); frame1.add(saveButton, new GBC(0, 21, 6, 1).setWeight(0, 0)); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SysUser user = (SysUser) UserAndSiteUtils.get("user", "user"); if (user == null) { JOptionPane.showMessageDialog(null, "当前用户已失效请重新登录", "提示", JOptionPane.WARNING_MESSAGE); return; } DjJdgzNetworkLevel3 level3 = djJdgzNetworkLevel3Service.get(data.getLevel3NetworkId()); if (user.getTeamgroup() != null && !user.getTeamgroup().equals(level3.getTeamgroupId().toString())) { JOptionPane.showMessageDialog(null, "当前用户不可操作其他专业数据", "提示", JOptionPane.WARNING_MESSAGE); return; } JComboBoxItem trackMethod = (JComboBoxItem) comboBox0.getSelectedItem(); JComboBoxItem currentStatus = (JComboBoxItem) comboBox1.getSelectedItem(); JComboBoxItem hasDelayRisk = (JComboBoxItem) comboBox2.getSelectedItem(); List list1 = djJdgzDismantTrackService.getList(data.getLevel3NetworkId(), null); if (data.getProcessName().equals("设备拆卸出舱") && currentStatus.getId() == 1 && list1 != null && list1.size() > 0) { Boolean status = djJdgzDismantTrackService.getStatus(data.getLevel3NetworkId()); if (!status) { JOptionPane.showMessageDialog(null, "有未完成的子部件", "提示", JOptionPane.WARNING_MESSAGE); return; } } data.setTrackMethod(Math.toIntExact(trackMethod.getId())); data.setProcessName(data.getLevel3NodeName()); data.setTrackLocation(trackLocatDesc.getText()); data.setTrackPerson(trackPersonDesc.getText()); data.setTrackPersonContact(trackPersonContactDesc.getText()); data.setTrackPersonUnit(trackPersonUnitDesc.getText()); data.setTrackedPersonUnit(trackedPersonUnitDesc.getText()); data.setTrackedPerson(trackedPersonDesc.getText()); data.setTrackedPersonContact(trackedPersonContactDesc.getText()); data.setGeneralRepairUnit(generalRepairUnitDesc.getText()); data.setGeneralRepairUnitContact(generalRepairUnitContactDesc.getText()); data.setGeneralRepairUnitDirector(generalRepairUnitDirectorDesc.getText()); data.setRepairUnit(repairUnitDesc.getText()); data.setRepairUnitContact(repairUnitContactDesc.getText()); data.setRepairUnitDirector(repairUnitDirectorDesc.getText()); data.setCurrentStatus(Math.toIntExact(currentStatus.getId())); data.setHasDelayRisk(Math.toIntExact(hasDelayRisk.getId())); data.setEstimatedCompletionTime(sdFormat.format(estimatedCompletionDate.getDate())); data.setProblem(problem.getText()); data.setFollowupPlan(plan.getText()); data.setRemark(remark.getText()); Long id = djJdgzTrackRecordService.save(data,"save"); uploadFile.save(id); List list = djJdgzTrackRecordService.getList(level1Id, level3.getDeptId(), null, null, level3.getType(), 0,0, null); CommonTable.refreshTable(list, columnDto, table); trackRecordManageService.tableModelListener(table, jFrame, list); frame1.dispose(); jFrame.setEnabled(true);//将主界面再设置为可操作的 JOptionPane.showMessageDialog(null, "保存成功", "提示", JOptionPane.WARNING_MESSAGE); } }); } }