
- •Р е ф е р а т
- •Содержание
- •Введение
- •Постановка задания
- •Описание комплекса средств для разработки проекта
- •Поиск, сравнительный анализ технологий для реализации проекта
- •Язык программированияPhp
- •Язык программированияC#
- •Язык программированияJava
- •Интерпретируемый языкVba
- •ФреймворкSpring
- •Выбор технологии для реализации проекта
- •Разработка проекта
- •Разработка плана решения поставленной задачи
- •Программный интерфейс
- •Подготовка системы к работе
- •Ввод данных и вывод на печать
- •Заключение
- •Список использованных источников
- •Приложение а
Приложение а
Класс контроллера – MainController
public class MainController extends HttpServlet{
@Autowired
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
@Autowired
public void setM() {
ModelMap map = new ModelMap ();
map.put("contract", new Contract());
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showMain (ModelMap model) {
Contract contract = new Contract();
model.put("contract", contract);
return new ModelAndView("index");
}
@RequestMapping(method = RequestMethod.GET, params="link")
public String navigation (ModelMap model, @RequestParam("link") String link) {
Contract contract = new Contract();
model.addAttribute("contract", contract);
return (link);
}
@RequestMapping(method = RequestMethod.POST, params="zapVneb")
public void fillextraBudgetary (@ModelAttribute("contract") Contract contract, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String inputFile = getServletConfig().getServletContext().getRealPath("/contract" + Constants.EXTRABUD_ORDER + ".rtf");
String outputFile = getServletConfig().getServletContext().getRealPath("/OutputContract" + Constants.EXTRABUD_OUTPUT_FILE);
String fileWithSpace = getServletConfig().getServletContext().getRealPath("/contract" + Constants.EXTRABUD_ORDER + ".doc.txt");
SearchReplace search = new SearchReplace();
search.searchAndReplace(inputFile, outputFile, contract, fileWithSpace);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/OutputContract" + Constants.EXTRABUD_OUTPUT_FILE);
response.setHeader("Content-Disposition", "attachment; filename="+Constants.EXTRABUD_OUTPUT_FILE);
rd.forward(request, response);
}
@RequestMapping(method
= RequestMethod.POST, params="zapBud")
public void fillBudget (@ModelAttribute("contract") Contract contract, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String inputFile = getServletConfig().getServletContext().getRealPath("/contract"+Constants.BUD_ORDER + ".rtf");
String outputFile = getServletConfig().getServletContext().getRealPath("/OutputContract"+Constants.BUD_OUTPUT_FILE);
String fileWithSpace = getServletConfig().getServletContext().getRealPath("/contract"+Constants.BUD_ORDER + ".doc.txt");
SearchReplace search = new SearchReplace();
search.searchAndReplace(inputFile, outputFile, contract, fileWithSpace);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/OutputContract"+Constants.BUD_OUTPUT_FILE);
response.setHeader("Content-Disposition", "attachment; filename="+Constants.BUD_OUTPUT_FILE);
rd.forward(request, response);
}
@RequestMapping(method = RequestMethod.POST, params="zapIpk")
public void fillIPK (@ModelAttribute("contract") Contract contract, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String inputFile = getServletConfig().getServletContext().getRealPath("/contract"+Constants.IPK_ORDER + ".rtf");
String outputFile = getServletConfig().getServletContext().getRealPath("/OutputContract"+Constants.IPK_OUTPUT_FILE);
String fileWithSpace = getServletConfig().getServletContext().getRealPath("/contract"+Constants.IPK_ORDER + ".doc.txt");
SearchReplace search = new SearchReplace();
search.searchAndReplace(inputFile, outputFile, contract, fileWithSpace);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/OutputContract"+Constants.IPK_OUTPUT_FILE);
response.setHeader("Content-Disposition", "attachment; filename="+Constants.IPK_OUTPUT_FILE);
rd.forward(request, response);
}
@RequestMapping(method = RequestMethod.POST, params="zapAkt")
public void fillAct (@ModelAttribute("contract") Contract contract, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String inputFile = getServletConfig().getServletContext().getRealPath("/contract"+Constants.AKT_ORDER + ".rtf");
String outputFile = getServletConfig().getServletContext().getRealPath("/OutputContract"+Constants.AKT_OUTPUT_FILE);
String fileWithSpace = getServletConfig().getServletContext().getRealPath("/contract"+Constants.AKT_ORDER + ".doc.txt");
SearchReplace search = new SearchReplace();
contract.setFIO(contract.getFIO() +" " + contract.getDegree() + " " + contract.getAcademicTitle());
search.searchAndReplace(inputFile, outputFile, contract, fileWithSpace);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/OutputContract"+Constants.AKT_OUTPUT_FILE);
response.setHeader("Content-Disposition", "attachment; filename="+Constants.AKT_OUTPUT_FILE);
rd.forward(request, response);
}
@RequestMapping(method = RequestMethod.POST, params="zapAktPriv")
public void fillActPriv (@ModelAttribute("contract") Contract contract, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String inputFile = getServletConfig().getServletContext().getRealPath("/contract"+Constants.AKT_PRIV_ORDER + ".rtf");
String outputFile = getServletConfig().getServletContext().getRealPath("/OutputContract"+Constants.AKT_PRIV_OUTPUT_FILE);
String fileWithSpace = getServletConfig().getServletContext().getRealPath("/contract"+Constants.AKT_PRIV_ORDER + ".doc.txt");
SearchReplace search = new SearchReplace();
contract.setFIO(contract.getFIO() +" " + contract.getDegree() + " " + contract.getAcademicTitle());
search.searchAndReplace(inputFile, outputFile, contract, fileWithSpace);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/OutputContract"+Constants.AKT_PRIV_OUTPUT_FILE);
response.setHeader("Content-Disposition", "attachment; filename="+Constants.AKT_PRIV_OUTPUT_FILE);
rd.forward(request, response);
}
}
Метод searchAndReplace()
public void searchAndReplace(String inputFile, String outputFile, Contract contract, String fileWithSPace) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
Spaces space = new Spaces ();
space = readFileWithSpaces(fileWithSPace);
contract = alignContract(contract, space);
String line = reader.readLine();
while(line != null) {
line = line.replace(Constants.PERFORMER, contract.getFIO());
line = line.replace(Constants.DEPARTMNET_AND_FACULTY, contract.getDepartmentAndFacul());
line = line.replace(Constants.NUMBER_OF_HOURS, contract.getNumberOfHours());
line = line.replace(Constants.START_DATE, contract.getDateStart());
line = line.replace(Constants.END_DATE, contract.getDateEnd());
line = line.replace(Constants.PASSPORT_SER, contract.getPassportSer());
line = line.replace(Constants.PASSPORT_NUMBER, contract.getPassportNumber());
line = line.replace(Constants.PASSPORT_DATE, contract.getPassportDate());
line = line.replace(Constants.ORGAN_PASS, contract.getOrganPass());
line = line.replace(Constants.PASSPORT_PRIVATE_NUMBER, contract.getPassportPrivateNum());
line = line.replace(Constants.INSURANCE_NUM, contract.getInsuranceNum());
line = line.replace(Constants.HOME_ADDRESS, contract.getHomeAdds());
line = line.replace(Constants.PHONE_HOME_NUM, contract.getPhoneHomeNum());
line = line.replace(Constants.PHONE_WORK_NUM, contract.getPhoneWorkNum());
line = line.replace(Constants.PHONE_MOBILE, contract.getPhoneMobNum());
line = line.replace(Constants.WORK, contract.getWork());
line = line.replace(Constants.POST, contract.getPost());
line = line.replace(Constants.ACADEMIC_TITLE, contract.getAcademicTitle());
line = line.replace(Constants.DEGREE, contract.getDegree());
line = line.replace(Constants.PENSIONER, contract.getPensioner());
line = line.replace(Constants.CITIZEN, contract.getCitizen());
Integer i = line.indexOf("scan");
writer.write(line);
line = reader.readLine();
}
reader.close();
writer.close();
}