|
@@ -1,474 +1,474 @@
|
|
|
-package com.ygj.yuemum.controller.admin;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ygj.yuemum.component.Constant;
|
|
|
-import com.ygj.yuemum.domain.admin.Photo;
|
|
|
-import com.ygj.yuemum.domain.admin.Resume;
|
|
|
-import com.ygj.yuemum.domain.maternitymatron.JlServiceUser;
|
|
|
-import com.ygj.yuemum.domain.pay.CustomerPayVoucher;
|
|
|
-import com.ygj.yuemum.service.admin.PhotoService;
|
|
|
-import com.ygj.yuemum.service.admin.ResumeService;
|
|
|
-import com.ygj.yuemum.service.maternitymatron.JlServiceUserService;
|
|
|
-import com.ygj.yuemum.service.pay.CustomerPayVoucherService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.core.io.ResourceLoader;
|
|
|
-import org.springframework.util.ResourceUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import java.io.*;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-
|
|
|
-@RestController
|
|
|
-public class ImageUploadController {
|
|
|
- @Autowired
|
|
|
- private PhotoService photoService;
|
|
|
- @Autowired
|
|
|
- private JlServiceUserService jlServiceUserService;
|
|
|
- @Autowired
|
|
|
- private ResumeService resumeService;
|
|
|
- @Autowired
|
|
|
- private CustomerPayVoucherService customerPayVoucherService;
|
|
|
- private ResourceLoader resourceLoader;
|
|
|
-
|
|
|
- public static final String ROOT = Constant.ROOT;
|
|
|
- public static final String ResumeFile = Constant.RESUMEFILE;
|
|
|
- public static final String httpRoot = Constant.HTTPROOT;
|
|
|
- public static final String httphtmlRoot = Constant.HTTPHTMLROOT;
|
|
|
- public static final String modulePath = Constant.MODULEPATH;
|
|
|
- public static final String payvoucher = Constant.PAYVOUCHER;
|
|
|
- public static final String httppayvoucher = Constant.HTTPPAYVOUCHER;
|
|
|
- public static final String promotionvoucher = Constant.PROMOTIONVOUCHER;
|
|
|
- public static final String httppromotionvoucher = Constant.HTTPPROMOTIONVOUCHER;
|
|
|
-
|
|
|
- @RequestMapping(value = "/upload", method = RequestMethod.GET)
|
|
|
- public String upload() {
|
|
|
- return "/fileupload";
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/uploadImg", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public int uploadImg(@RequestParam("file") MultipartFile file,
|
|
|
- @RequestParam(value = "id") Integer id,
|
|
|
- @RequestParam(value = "type") Integer type) {
|
|
|
-// 照片类型 1:display 2:certificate 3:comment 4:service 5:meal
|
|
|
- String folder = "";
|
|
|
- int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
- String newName = file.getOriginalFilename().substring(dot);
|
|
|
- String path = ROOT + getpathtype(type) + "Img";
|
|
|
- Photo photo = new Photo();
|
|
|
- if (file.isEmpty()) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
- DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- File dest = new File(path + "/" + getpathtype(type) + id + type + sdf.format(date) + newName);
|
|
|
-
|
|
|
- try {
|
|
|
- file.transferTo(dest); //保存文件
|
|
|
- photo.setServant_code(id);
|
|
|
- photo.setPhoto_type(type);
|
|
|
- photo.setPhoto_name(getpathtype(type) + id + type + sdf.format(date) + newName);
|
|
|
- photo.setPhoto_path(httpRoot+ getpathtype(type) + "Img/"+dest.getName());
|
|
|
- photoService.addPhoto(photo);
|
|
|
- return 1;
|
|
|
- } catch (IllegalStateException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return 0;
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/deletePhoto")
|
|
|
- public int deletePhoto(@ModelAttribute Photo photo) throws ParseException {
|
|
|
- try {
|
|
|
- String path = ROOT+ getpathtype(photo.getPhoto_type()) +"Img/"+ photo.getPhoto_name();
|
|
|
- File dest = new File(path);
|
|
|
- dest.delete();
|
|
|
- return photoService.deletePhoto(photo);
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- @PostMapping("/queryPhoto")
|
|
|
- public String queryPhoto(@ModelAttribute Photo photo) throws ParseException {
|
|
|
- List<Photo> photos= photoService.queryPhoto(photo);
|
|
|
- String jso = JSONObject.toJSONString(photos);
|
|
|
- jso = jso.replaceAll("photo_path","url");
|
|
|
- jso = jso.replaceAll("servant_code","name");
|
|
|
- return jso;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping("/createResume")
|
|
|
- public String createResume(@ModelAttribute Photo photo) {
|
|
|
- String urlName = "";
|
|
|
- try {
|
|
|
- JlServiceUser jlServiceUser = jlServiceUserService.getResume(photo.getServant_code());
|
|
|
- urlName = String.valueOf(jlServiceUser.getId());
|
|
|
- File file = ResourceUtils.getFile(modulePath);
|
|
|
- BufferedReader br = new BufferedReader(new FileReader(file));
|
|
|
- Resume resume =new Resume();
|
|
|
- Resume resumeold = new Resume();
|
|
|
- StringBuilder stringHtml = new StringBuilder();
|
|
|
- String str = "";
|
|
|
- String photoDisplay ="";
|
|
|
- String certificate ="";
|
|
|
- String certificatehref ="";
|
|
|
- String service ="";
|
|
|
- String servicehref ="";
|
|
|
- String meal = "";
|
|
|
- String mealhref = "";
|
|
|
- String comment ="";
|
|
|
- String littcomm = "";
|
|
|
- if(photo.getComment() == null){
|
|
|
- photo.setComment(" ");
|
|
|
- }
|
|
|
- List<Photo> photos = photoService.queryPhoto(photo);
|
|
|
- if(photos.size() > 0 ) {
|
|
|
- int stepcertificate = 0;
|
|
|
- int stepservice = 0;
|
|
|
- int stepmeal = 0;
|
|
|
- String certificatestart = "<div class=\"resume-certificate-image\">"+ "\r\n"
|
|
|
- +"<span class=\"resume-item-title\">相关证件</span>"+ "\r\n"
|
|
|
- +"<div class=\"lb_gl_certificate\">"+ "\r\n"
|
|
|
- +"<div class=\"container\">"+ "\r\n"
|
|
|
- +"<div class=\"pictureSlider-certificate poster-main \">"+ "\r\n"
|
|
|
- +"<div class=\"left-modal modal-certificate\"></div>"+ "\r\n"
|
|
|
- +"<ul id=\"zturn-certificate\" class=\"poster-list\">"+ "\r\n"
|
|
|
- +"<div class=\"poster-btn poster-certificate-prev-btn certificate\"></div>"+ "\r\n";
|
|
|
- String certificateend = "<div class=\"poster-btn poster-certificate-next-btn\"></div>"+ "\r\n"
|
|
|
- +"</ul>"+ "\r\n"
|
|
|
- +"<div class=\"right-modal modal-certificate\"></div>"+ "\r\n"
|
|
|
- +"<div class=\"indicator-list indicator-list-cer\">"+ "\r\n"
|
|
|
- +"$cfstyle"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n";
|
|
|
- String mealstart = "<div class=\"resume-service-image\">"+ "\r\n"
|
|
|
- +"<span class=\"resume-item-title\">月子餐照片</span>"+ "\r\n"
|
|
|
- +"<div class=\"lb_gl\">"+ "\r\n"
|
|
|
- +"<div class=\"container\">"+ "\r\n"
|
|
|
- +"<div class=\"pictureSlider poster-main poster-main-yzfood\">"+ "\r\n"
|
|
|
- +"<div class=\"left-modal\"></div>"+ "\r\n"
|
|
|
- +"<ul id=\"yzfood\" class=\"poster-list\">"+ "\r\n"
|
|
|
- +"<div class=\"poster-btn poster-prev-btn poster-prev-btn-yzfood\"></div>"+ "\r\n";
|
|
|
- String mealend = "<div class=\"poster-btn poster-next-btn poster-next-btn-yzfood\"></div>"+ "\r\n"
|
|
|
- +"</ul>"+ "\r\n"
|
|
|
- +"<div class=\"right-modal\"></div>"+ "\r\n"
|
|
|
- +"<div class=\"indicator-list indicator-list-service\">"+ "\r\n"
|
|
|
- +"$smstyle"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n";
|
|
|
- String commentstart = "<div class=\"resume-comments\">" + "\r\n"
|
|
|
- + "<span class=\"resume-item-title\">最新评论</span>" + "\r\n"
|
|
|
- + "<div class=\"resume-comments-div\" id=\"resume-comments\">" + "\r\n"
|
|
|
- + "<div class=\"box_4\" id=\"box-comments\">" + "\r\n"
|
|
|
- + "<div class=\"roll\" id=\"roll\">" + "\r\n"
|
|
|
- + "<div class=\"roll_list\">" + "\r\n"
|
|
|
- + "<div class=\"ul_box\" id=\"ul_box\">" + "\r\n";
|
|
|
- String commentend = "</div>"
|
|
|
- + "<div class=\"ul_box\" id=\"ul_box2\"></div>"
|
|
|
- + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>";
|
|
|
- String servicestart = "<div class=\"resume-service-image\">"+ "\r\n"
|
|
|
- +"<span class=\"resume-item-title\">服务照片</span>"+ "\r\n"
|
|
|
- +"<div class=\"left-modal\" id=\"left-modal-service\"></div>"+ "\r\n"
|
|
|
- +"<div class=\"lb_gl\">"+ "\r\n"
|
|
|
- +"<div class=\"container\">"+ "\r\n"
|
|
|
- +"<div class=\"pictureSlider poster-main poster-main-services\">"+ "\r\n"
|
|
|
- +"<ul id=\"zturn\" class=\"poster-list\">"+ "\r\n"
|
|
|
- +"<div class=\"poster-btn poster-prev-btn poster-prev-btn-service\"></div>"+ "\r\n";
|
|
|
- String serviceend = "<div class=\"poster-btn poster-next-btn poster-next-btn-service\"></div>"+ "\r\n"
|
|
|
- +"</ul>"+ "\r\n"
|
|
|
- +"<div class=\"right-modal\"></div>"+ "\r\n"
|
|
|
- +"<div class=\"indicator-list indicator-list-service\">"+ "\r\n"
|
|
|
- +"$scstyle"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n"
|
|
|
- +"</div>"+ "\r\n";
|
|
|
-
|
|
|
- for (Photo onePhoto : photos) {
|
|
|
- if (onePhoto.getPhoto_type() == 1) {
|
|
|
- if (onePhoto.getPhoto_path() != null) {
|
|
|
- photoDisplay = "<image class=\"resume-header-left-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n";
|
|
|
- }
|
|
|
- }
|
|
|
- if (onePhoto.getPhoto_type() == 2) {
|
|
|
- if (onePhoto.getPhoto_path() != null) {
|
|
|
- certificate = certificate + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
- + "<image class=\"zturn-item-image-cer\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
- + "</li>" + "\r\n";
|
|
|
- if (stepcertificate == 0) {
|
|
|
- certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='" + stepcertificate + "' class=\"indicator-list-item selected\"></a>" + "\r\n";
|
|
|
- } else {
|
|
|
- certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='" + stepcertificate + "' class=\"indicator-list-item \"></a>" + "\r\n";
|
|
|
- }
|
|
|
- stepcertificate++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (onePhoto.getPhoto_type() == 4) {
|
|
|
- if (onePhoto.getPhoto_path() != null) {
|
|
|
- service = service + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
- + "<image class=\"zturn-item-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
- + "</li>" + "\r\n";
|
|
|
- if (stepservice == 0) {
|
|
|
- servicehref = servicehref + " <a href=\"javascript:void(0);\" value='" + stepservice + "' class=\"indicator-list-item-service selected\"></a>" + "\r\n";
|
|
|
- } else {
|
|
|
- servicehref = servicehref + " <a href=\"javascript:void(0);\" value='" + stepservice + "' class=\"indicator-list-item-service\"></a>" + "\r\n";
|
|
|
- }
|
|
|
- stepservice++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (onePhoto.getPhoto_type() == 5) {
|
|
|
- if (onePhoto.getPhoto_path() != null) {
|
|
|
- meal = meal + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
- + "<image class=\"zturn-item-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
- + "</li>" + "\r\n";
|
|
|
- if (stepmeal == 0) {
|
|
|
- mealhref = mealhref + " <a href=\"javascript:void(0);\" value='" + stepmeal + "' class=\"indicator-list-item-yzfood selected\"></a>" + "\r\n";
|
|
|
- } else {
|
|
|
- mealhref = mealhref + " <a href=\"javascript:void(0);\" value='" + stepmeal + "' class=\"indicator-list-item-yzfood\"></a>" + "\r\n";
|
|
|
- }
|
|
|
- stepmeal++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (onePhoto.getPhoto_type() == 3) {
|
|
|
- comment = comment + "<a href=\"\"><img src='" + onePhoto.getPhoto_path() + "'/></a>" + "\r\n";
|
|
|
- littcomm = littcomm + "<image class=\"resume-comments-list\" src=\"" + onePhoto.getPhoto_path() + "\"/>";
|
|
|
- }
|
|
|
- }
|
|
|
- if (comment != "") {
|
|
|
- comment = commentstart + comment + commentend;
|
|
|
- }
|
|
|
- if (meal != "") {
|
|
|
- meal = mealstart + meal + mealend;
|
|
|
- }
|
|
|
- if (service != "") {
|
|
|
- service = servicestart + service + serviceend;
|
|
|
- }
|
|
|
- if (certificate != "") {
|
|
|
- certificate = certificatestart + certificate + certificateend;
|
|
|
- }
|
|
|
- }
|
|
|
- while((str = br.readLine())!=null){
|
|
|
- str = str.replace("$name",jlServiceUser.getTruename());
|
|
|
- str = str.replace("$np",jlServiceUser.getNp());
|
|
|
- str = str.replace("$age",jlServiceUser.getAge()+"岁");
|
|
|
- str = str.replace("$ethnicgroup",jlServiceUser.getEthnicgroup());
|
|
|
- str = str.replace("$constellation",jlServiceUser.getConstellation());
|
|
|
- str = str.replace("$seniority",jlServiceUser.getSeniority());
|
|
|
- str = str.replace("$babynumber",jlServiceUser.getBabynumber());
|
|
|
- str = str.replace("$education",jlServiceUser.getEducation());
|
|
|
- str = str.replace("$weight",jlServiceUser.getWeight());
|
|
|
- str = str.replace("$marriage",jlServiceUser.getMarriage());
|
|
|
- str = str.replace("$highlight",jlServiceUser.getHighlight());
|
|
|
- str = str.replace("$resumecomment",photo.getComment());
|
|
|
- str = str.replace("$zodiac","属"+jlServiceUser.getZodiac());
|
|
|
- str = str.replace("$height",jlServiceUser.getHeight());
|
|
|
- str = str.replace("$starts",jlServiceUser.getGender());
|
|
|
- str = str.replace("$display",photoDisplay);
|
|
|
- str = str.replace("$credentials",certificate);
|
|
|
- str = str.replace("$cfstyle",certificatehref);
|
|
|
- str = str.replace("$service",service);
|
|
|
- str = str.replace("$scstyle",servicehref);
|
|
|
- str = str.replace("$meal",meal);
|
|
|
- str = str.replace("$smstyle",mealhref);
|
|
|
- str = str.replace("$comment",comment);
|
|
|
- str = str.replace("$littcomm",littcomm);
|
|
|
- str = str.replace("$ystitle","悦所-月嫂简历:"+jlServiceUser.getTruename());
|
|
|
- str = str.replace("$yuesaohref",httphtmlRoot+ urlName + ".html");
|
|
|
- stringHtml.append(str+"\r\n");
|
|
|
- }
|
|
|
- resumeold = resumeService.getResume(photo.getServant_code());
|
|
|
- if(resumeold != null) {
|
|
|
- resumeService.deleteResume(resumeold.getId());
|
|
|
- File fileDel = new File(resumeold.getRqcode_path());
|
|
|
- if (file.exists()) {
|
|
|
- fileDel.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- resume.setServant_code(photo.getServant_code());
|
|
|
- resume.setResume_comment(photo.getComment());
|
|
|
- resume.setResume_path(httphtmlRoot+ urlName + ".html");
|
|
|
- resume.setRqcode_path(ResumeFile+urlName + ".html");
|
|
|
- resumeService.addResume(resume);
|
|
|
- File newResume = new File(ResumeFile + urlName + ".html");
|
|
|
- FileWriter fileWriter = new FileWriter(newResume);
|
|
|
- fileWriter.write(stringHtml.toString());
|
|
|
- fileWriter.close();
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return "error";
|
|
|
- }
|
|
|
- return httphtmlRoot+urlName+".html";
|
|
|
- }
|
|
|
- public String getpathtype(int type){
|
|
|
- switch (type) {
|
|
|
- case 1:
|
|
|
- return "display";
|
|
|
- case 2:
|
|
|
- return "certificate";
|
|
|
- case 3:
|
|
|
- return "comment";
|
|
|
- case 4:
|
|
|
- return "service";
|
|
|
- case 5:
|
|
|
- return "meal";
|
|
|
- }
|
|
|
- return "error";
|
|
|
- }
|
|
|
- @GetMapping("/reBulidResume")
|
|
|
- public int reBulidResume(@RequestParam("servant_code") String servant_code) {
|
|
|
- return photoService.reBuildResume(servant_code);
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/uploadPayImg", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public int uploadPayImg(@RequestParam("file") MultipartFile file,
|
|
|
- @RequestParam(value = "eh_code") String eh_code,
|
|
|
- @RequestParam(value = "cv_orderstaus") Integer cv_orderstaus) {
|
|
|
- int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
- String newName = file.getOriginalFilename().substring(dot);
|
|
|
- CustomerPayVoucher customerPayVoucher = new CustomerPayVoucher();
|
|
|
- if (file.isEmpty()) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
- DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- File dest = new File(payvoucher + "/" + eh_code + sdf.format(date) +newName);
|
|
|
- // 删除
|
|
|
- try {
|
|
|
- file.transferTo(dest); //保存文件
|
|
|
- customerPayVoucher.setEh_code(eh_code);
|
|
|
- customerPayVoucher.setCv_filename(eh_code + sdf.format(date) +newName);
|
|
|
- customerPayVoucher.setCv_orderstaus(cv_orderstaus);
|
|
|
- customerPayVoucher.setCv_filepath(httppayvoucher + "/"+ eh_code + sdf.format(date) +newName);
|
|
|
- customerPayVoucherService.insertCustomerPayVoucher(customerPayVoucher);
|
|
|
- return 1;
|
|
|
- } catch (IllegalStateException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return 0;
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- @GetMapping("/deletePayPhoto")
|
|
|
- public int deletePayPhoto(@RequestParam("cv_filename") String cv_filename) throws ParseException {
|
|
|
- try {
|
|
|
- String path = payvoucher + "/"+ cv_filename;
|
|
|
- File dest = new File(path);
|
|
|
- dest.delete();
|
|
|
- return customerPayVoucherService.deleteCustomerPayVoucher(cv_filename);
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/deleteCustomerPayVoucherAll")
|
|
|
- public int deleteCustomerPayVoucherAll(@RequestParam("eh_code") String eh_code) throws ParseException {
|
|
|
- try {
|
|
|
- List<CustomerPayVoucher> customerPays= customerPayVoucherService.selectCustomerPayVoucher(eh_code);
|
|
|
- for(CustomerPayVoucher cpv:customerPays){
|
|
|
- String path = payvoucher + "/"+ cpv.getCv_filename();
|
|
|
- File dest = new File(path);
|
|
|
- dest.delete();
|
|
|
- }
|
|
|
- return customerPayVoucherService.deleteCustomerPayVoucherAll(eh_code);
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping ("/queryPayPhoto")
|
|
|
- public String queryPayPhoto(@RequestParam("eh_code") String eh_code) throws ParseException {
|
|
|
- List<CustomerPayVoucher> customerPays= customerPayVoucherService.selectCustomerPayVoucher(eh_code);
|
|
|
- String jso = JSONObject.toJSONString(customerPays);
|
|
|
- jso = jso.replaceAll("cv_filepath","url");
|
|
|
- jso = jso.replaceAll("cv_filename","name");
|
|
|
- return jso;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping ("/queryOrderPayPhoto")
|
|
|
- public String queryOrderPayPhoto(@ModelAttribute CustomerPayVoucher customerPayVoucher) throws ParseException {
|
|
|
- List<CustomerPayVoucher> customerPays= customerPayVoucherService.queryOrderPayPhoto(customerPayVoucher);
|
|
|
- String jso = JSONObject.toJSONString(customerPays);
|
|
|
- jso = jso.replaceAll("cv_filepath","url");
|
|
|
- jso = jso.replaceAll("cv_filename","name");
|
|
|
- return jso;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/deleteOrderPayPhoto")
|
|
|
- public int deleteOrderPayPhoto(@ModelAttribute CustomerPayVoucher customerPayVoucher) throws ParseException {
|
|
|
- try {
|
|
|
- List<CustomerPayVoucher> customerPays= customerPayVoucherService.queryOrderPayPhoto(customerPayVoucher);
|
|
|
- for(CustomerPayVoucher cpv:customerPays){
|
|
|
- String path = payvoucher + "/"+ cpv.getCv_filename();
|
|
|
- File dest = new File(path);
|
|
|
- dest.delete();
|
|
|
- }
|
|
|
- return customerPayVoucherService.deleteOrderPayPhoto(customerPayVoucher);
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/uploadPromotionImg", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public String uploadPromotionImg(@RequestParam(value = "file", required = false) MultipartFile file) {
|
|
|
- int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
- String newName = file.getOriginalFilename().substring(dot);
|
|
|
- if (file.isEmpty()) {
|
|
|
- return "";
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
- DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- String fileUrl = promotionvoucher + "/" + sdf.format(date) +newName;
|
|
|
- String httpfileUrl = httppromotionvoucher + "/" + sdf.format(date) +newName;
|
|
|
- File dest = new File(fileUrl);
|
|
|
- // 删除
|
|
|
- try {
|
|
|
- file.transferTo(dest); //保存文件
|
|
|
- return httpfileUrl;
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- return "";
|
|
|
- }
|
|
|
- }
|
|
|
- @GetMapping("/deletePromotionImg")
|
|
|
- public int deletePromotionImg(@RequestParam("cv_filename") String cv_filename) throws ParseException {
|
|
|
- try {
|
|
|
- String path = promotionvoucher + "/"+ cv_filename;
|
|
|
- File dest = new File(path);
|
|
|
- dest.delete();
|
|
|
- return 1 ;
|
|
|
- } catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+package com.ygj.yuemum.controller.admin;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ygj.yuemum.component.Constant;
|
|
|
+import com.ygj.yuemum.domain.admin.Photo;
|
|
|
+import com.ygj.yuemum.domain.admin.Resume;
|
|
|
+import com.ygj.yuemum.domain.maternitymatron.JlServiceUser;
|
|
|
+import com.ygj.yuemum.domain.pay.CustomerPayVoucher;
|
|
|
+import com.ygj.yuemum.service.admin.PhotoService;
|
|
|
+import com.ygj.yuemum.service.admin.ResumeService;
|
|
|
+import com.ygj.yuemum.service.maternitymatron.JlServiceUserService;
|
|
|
+import com.ygj.yuemum.service.pay.CustomerPayVoucherService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.ResourceLoader;
|
|
|
+import org.springframework.util.ResourceUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+@RestController
|
|
|
+public class ImageUploadController {
|
|
|
+ @Autowired
|
|
|
+ private PhotoService photoService;
|
|
|
+ @Autowired
|
|
|
+ private JlServiceUserService jlServiceUserService;
|
|
|
+ @Autowired
|
|
|
+ private ResumeService resumeService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerPayVoucherService customerPayVoucherService;
|
|
|
+ private ResourceLoader resourceLoader;
|
|
|
+
|
|
|
+ public static final String ROOT = Constant.ROOT;
|
|
|
+ public static final String ResumeFile = Constant.RESUMEFILE;
|
|
|
+ public static final String httpRoot = Constant.HTTPROOT;
|
|
|
+ public static final String httphtmlRoot = Constant.HTTPHTMLROOT;
|
|
|
+ public static final String modulePath = Constant.MODULEPATH;
|
|
|
+ public static final String payvoucher = Constant.PAYVOUCHER;
|
|
|
+ public static final String httppayvoucher = Constant.HTTPPAYVOUCHER;
|
|
|
+ public static final String promotionvoucher = Constant.PROMOTIONVOUCHER;
|
|
|
+ public static final String httppromotionvoucher = Constant.HTTPPROMOTIONVOUCHER;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/upload", method = RequestMethod.GET)
|
|
|
+ public String upload() {
|
|
|
+ return "/fileupload";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadImg", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public int uploadImg(@RequestParam("file") MultipartFile file,
|
|
|
+ @RequestParam(value = "id") Integer id,
|
|
|
+ @RequestParam(value = "type") Integer type) {
|
|
|
+// 照片类型 1:display 2:certificate 3:comment 4:service 5:meal
|
|
|
+ String folder = "";
|
|
|
+ int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
+ String newName = file.getOriginalFilename().substring(dot);
|
|
|
+ String path = ROOT + getpathtype(type) + "Img";
|
|
|
+ Photo photo = new Photo();
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ File dest = new File(path + "/" + getpathtype(type) + id + type + sdf.format(date) + newName);
|
|
|
+
|
|
|
+ try {
|
|
|
+ file.transferTo(dest); //保存文件
|
|
|
+ photo.setServant_code(id);
|
|
|
+ photo.setPhoto_type(type);
|
|
|
+ photo.setPhoto_name(getpathtype(type) + id + type + sdf.format(date) + newName);
|
|
|
+ photo.setPhoto_path(httpRoot+ getpathtype(type) + "Img/"+dest.getName());
|
|
|
+ photoService.addPhoto(photo);
|
|
|
+ return 1;
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/deletePhoto")
|
|
|
+ public int deletePhoto(@ModelAttribute Photo photo) throws ParseException {
|
|
|
+ try {
|
|
|
+ String path = ROOT+ getpathtype(photo.getPhoto_type()) +"Img/"+ photo.getPhoto_name();
|
|
|
+ File dest = new File(path);
|
|
|
+ dest.delete();
|
|
|
+ return photoService.deletePhoto(photo);
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @PostMapping("/queryPhoto")
|
|
|
+ public String queryPhoto(@ModelAttribute Photo photo) throws ParseException {
|
|
|
+ List<Photo> photos= photoService.queryPhoto(photo);
|
|
|
+ String jso = JSONObject.toJSONString(photos);
|
|
|
+ jso = jso.replaceAll("photo_path","url");
|
|
|
+ jso = jso.replaceAll("servant_code","name");
|
|
|
+ return jso;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/createResume")
|
|
|
+ public String createResume(@ModelAttribute Photo photo) {
|
|
|
+ String urlName = "";
|
|
|
+ try {
|
|
|
+ JlServiceUser jlServiceUser = jlServiceUserService.getResume(photo.getServant_code());
|
|
|
+ urlName = String.valueOf(jlServiceUser.getId());
|
|
|
+ File file = ResourceUtils.getFile(modulePath);
|
|
|
+ BufferedReader br = new BufferedReader(new FileReader(file));
|
|
|
+ Resume resume =new Resume();
|
|
|
+ Resume resumeold = new Resume();
|
|
|
+ StringBuilder stringHtml = new StringBuilder();
|
|
|
+ String str = "";
|
|
|
+ String photoDisplay ="";
|
|
|
+ String certificate ="";
|
|
|
+ String certificatehref ="";
|
|
|
+ String service ="";
|
|
|
+ String servicehref ="";
|
|
|
+ String meal = "";
|
|
|
+ String mealhref = "";
|
|
|
+ String comment ="";
|
|
|
+ String littcomm = "";
|
|
|
+ if(photo.getComment() == null){
|
|
|
+ photo.setComment(" ");
|
|
|
+ }
|
|
|
+ List<Photo> photos = photoService.queryPhoto(photo);
|
|
|
+ if(photos.size() > 0 ) {
|
|
|
+ int stepcertificate = 0;
|
|
|
+ int stepservice = 0;
|
|
|
+ int stepmeal = 0;
|
|
|
+ String certificatestart = "<div class=\"resume-certificate-image\">"+ "\r\n"
|
|
|
+ +"<span class=\"resume-item-title\">相关证件</span>"+ "\r\n"
|
|
|
+ +"<div class=\"lb_gl_certificate\">"+ "\r\n"
|
|
|
+ +"<div class=\"container\">"+ "\r\n"
|
|
|
+ +"<div class=\"pictureSlider-certificate poster-main \">"+ "\r\n"
|
|
|
+ +"<div class=\"left-modal modal-certificate\"></div>"+ "\r\n"
|
|
|
+ +"<ul id=\"zturn-certificate\" class=\"poster-list\">"+ "\r\n"
|
|
|
+ +"<div class=\"poster-btn poster-certificate-prev-btn certificate\"></div>"+ "\r\n";
|
|
|
+ String certificateend = "<div class=\"poster-btn poster-certificate-next-btn\"></div>"+ "\r\n"
|
|
|
+ +"</ul>"+ "\r\n"
|
|
|
+ +"<div class=\"right-modal modal-certificate\"></div>"+ "\r\n"
|
|
|
+ +"<div class=\"indicator-list indicator-list-cer\">"+ "\r\n"
|
|
|
+ +"$cfstyle"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n";
|
|
|
+ String mealstart = "<div class=\"resume-service-image\">"+ "\r\n"
|
|
|
+ +"<span class=\"resume-item-title\">月子餐照片</span>"+ "\r\n"
|
|
|
+ +"<div class=\"lb_gl\">"+ "\r\n"
|
|
|
+ +"<div class=\"container\">"+ "\r\n"
|
|
|
+ +"<div class=\"pictureSlider poster-main poster-main-yzfood\">"+ "\r\n"
|
|
|
+ +"<div class=\"left-modal\"></div>"+ "\r\n"
|
|
|
+ +"<ul id=\"yzfood\" class=\"poster-list\">"+ "\r\n"
|
|
|
+ +"<div class=\"poster-btn poster-prev-btn poster-prev-btn-yzfood\"></div>"+ "\r\n";
|
|
|
+ String mealend = "<div class=\"poster-btn poster-next-btn poster-next-btn-yzfood\"></div>"+ "\r\n"
|
|
|
+ +"</ul>"+ "\r\n"
|
|
|
+ +"<div class=\"right-modal\"></div>"+ "\r\n"
|
|
|
+ +"<div class=\"indicator-list indicator-list-service\">"+ "\r\n"
|
|
|
+ +"$smstyle"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n";
|
|
|
+ String commentstart = "<div class=\"resume-comments\">" + "\r\n"
|
|
|
+ + "<span class=\"resume-item-title\">最新评论</span>" + "\r\n"
|
|
|
+ + "<div class=\"resume-comments-div\" id=\"resume-comments\">" + "\r\n"
|
|
|
+ + "<div class=\"box_4\" id=\"box-comments\">" + "\r\n"
|
|
|
+ + "<div class=\"roll\" id=\"roll\">" + "\r\n"
|
|
|
+ + "<div class=\"roll_list\">" + "\r\n"
|
|
|
+ + "<div class=\"ul_box\" id=\"ul_box\">" + "\r\n";
|
|
|
+ String commentend = "</div>"
|
|
|
+ + "<div class=\"ul_box\" id=\"ul_box2\"></div>"
|
|
|
+ + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>" + "\r\n" + "</div>";
|
|
|
+ String servicestart = "<div class=\"resume-service-image\">"+ "\r\n"
|
|
|
+ +"<span class=\"resume-item-title\">服务照片</span>"+ "\r\n"
|
|
|
+ +"<div class=\"left-modal\" id=\"left-modal-service\"></div>"+ "\r\n"
|
|
|
+ +"<div class=\"lb_gl\">"+ "\r\n"
|
|
|
+ +"<div class=\"container\">"+ "\r\n"
|
|
|
+ +"<div class=\"pictureSlider poster-main poster-main-services\">"+ "\r\n"
|
|
|
+ +"<ul id=\"zturn\" class=\"poster-list\">"+ "\r\n"
|
|
|
+ +"<div class=\"poster-btn poster-prev-btn poster-prev-btn-service\"></div>"+ "\r\n";
|
|
|
+ String serviceend = "<div class=\"poster-btn poster-next-btn poster-next-btn-service\"></div>"+ "\r\n"
|
|
|
+ +"</ul>"+ "\r\n"
|
|
|
+ +"<div class=\"right-modal\"></div>"+ "\r\n"
|
|
|
+ +"<div class=\"indicator-list indicator-list-service\">"+ "\r\n"
|
|
|
+ +"$scstyle"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n"
|
|
|
+ +"</div>"+ "\r\n";
|
|
|
+
|
|
|
+ for (Photo onePhoto : photos) {
|
|
|
+ if (onePhoto.getPhoto_type() == 1) {
|
|
|
+ if (onePhoto.getPhoto_path() != null) {
|
|
|
+ photoDisplay = "<image class=\"resume-header-left-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (onePhoto.getPhoto_type() == 2) {
|
|
|
+ if (onePhoto.getPhoto_path() != null) {
|
|
|
+ certificate = certificate + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
+ + "<image class=\"zturn-item-image-cer\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
+ + "</li>" + "\r\n";
|
|
|
+ if (stepcertificate == 0) {
|
|
|
+ certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='" + stepcertificate + "' class=\"indicator-list-item selected\"></a>" + "\r\n";
|
|
|
+ } else {
|
|
|
+ certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='" + stepcertificate + "' class=\"indicator-list-item \"></a>" + "\r\n";
|
|
|
+ }
|
|
|
+ stepcertificate++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (onePhoto.getPhoto_type() == 4) {
|
|
|
+ if (onePhoto.getPhoto_path() != null) {
|
|
|
+ service = service + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
+ + "<image class=\"zturn-item-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
+ + "</li>" + "\r\n";
|
|
|
+ if (stepservice == 0) {
|
|
|
+ servicehref = servicehref + " <a href=\"javascript:void(0);\" value='" + stepservice + "' class=\"indicator-list-item-service selected\"></a>" + "\r\n";
|
|
|
+ } else {
|
|
|
+ servicehref = servicehref + " <a href=\"javascript:void(0);\" value='" + stepservice + "' class=\"indicator-list-item-service\"></a>" + "\r\n";
|
|
|
+ }
|
|
|
+ stepservice++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (onePhoto.getPhoto_type() == 5) {
|
|
|
+ if (onePhoto.getPhoto_path() != null) {
|
|
|
+ meal = meal + "<li class=\"poster-item zturn-item\">" + "\r\n"
|
|
|
+ + "<image class=\"zturn-item-image\" src='" + onePhoto.getPhoto_path() + "'></image>" + "\r\n"
|
|
|
+ + "</li>" + "\r\n";
|
|
|
+ if (stepmeal == 0) {
|
|
|
+ mealhref = mealhref + " <a href=\"javascript:void(0);\" value='" + stepmeal + "' class=\"indicator-list-item-yzfood selected\"></a>" + "\r\n";
|
|
|
+ } else {
|
|
|
+ mealhref = mealhref + " <a href=\"javascript:void(0);\" value='" + stepmeal + "' class=\"indicator-list-item-yzfood\"></a>" + "\r\n";
|
|
|
+ }
|
|
|
+ stepmeal++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (onePhoto.getPhoto_type() == 3) {
|
|
|
+ comment = comment + "<a href=\"\"><img src='" + onePhoto.getPhoto_path() + "'/></a>" + "\r\n";
|
|
|
+ littcomm = littcomm + "<image class=\"resume-comments-list\" src=\"" + onePhoto.getPhoto_path() + "\"/>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (comment != "") {
|
|
|
+ comment = commentstart + comment + commentend;
|
|
|
+ }
|
|
|
+ if (meal != "") {
|
|
|
+ meal = mealstart + meal + mealend;
|
|
|
+ }
|
|
|
+ if (service != "") {
|
|
|
+ service = servicestart + service + serviceend;
|
|
|
+ }
|
|
|
+ if (certificate != "") {
|
|
|
+ certificate = certificatestart + certificate + certificateend;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ while((str = br.readLine())!=null){
|
|
|
+ str = str.replace("$name",jlServiceUser.getTruename());
|
|
|
+ str = str.replace("$np",jlServiceUser.getNp());
|
|
|
+ str = str.replace("$age",jlServiceUser.getAge()+"岁");
|
|
|
+ str = str.replace("$ethnicgroup",jlServiceUser.getEthnicgroup());
|
|
|
+ str = str.replace("$constellation",jlServiceUser.getConstellation());
|
|
|
+ str = str.replace("$seniority",jlServiceUser.getSeniority());
|
|
|
+ str = str.replace("$babynumber",jlServiceUser.getBabynumber());
|
|
|
+ str = str.replace("$education",jlServiceUser.getEducation());
|
|
|
+ str = str.replace("$weight",jlServiceUser.getWeight());
|
|
|
+ str = str.replace("$marriage",jlServiceUser.getMarriage());
|
|
|
+ str = str.replace("$highlight",jlServiceUser.getHighlight());
|
|
|
+ str = str.replace("$resumecomment",photo.getComment());
|
|
|
+ str = str.replace("$zodiac","属"+jlServiceUser.getZodiac());
|
|
|
+ str = str.replace("$height",jlServiceUser.getHeight());
|
|
|
+ str = str.replace("$starts",String.valueOf(jlServiceUser.getGender()));
|
|
|
+ str = str.replace("$display",photoDisplay);
|
|
|
+ str = str.replace("$credentials",certificate);
|
|
|
+ str = str.replace("$cfstyle",certificatehref);
|
|
|
+ str = str.replace("$service",service);
|
|
|
+ str = str.replace("$scstyle",servicehref);
|
|
|
+ str = str.replace("$meal",meal);
|
|
|
+ str = str.replace("$smstyle",mealhref);
|
|
|
+ str = str.replace("$comment",comment);
|
|
|
+ str = str.replace("$littcomm",littcomm);
|
|
|
+ str = str.replace("$ystitle","悦所-月嫂简历:"+jlServiceUser.getTruename());
|
|
|
+ str = str.replace("$yuesaohref",httphtmlRoot+ urlName + ".html");
|
|
|
+ stringHtml.append(str+"\r\n");
|
|
|
+ }
|
|
|
+ resumeold = resumeService.getResume(photo.getServant_code());
|
|
|
+ if(resumeold != null) {
|
|
|
+ resumeService.deleteResume(resumeold.getId());
|
|
|
+ File fileDel = new File(resumeold.getRqcode_path());
|
|
|
+ if (file.exists()) {
|
|
|
+ fileDel.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resume.setServant_code(photo.getServant_code());
|
|
|
+ resume.setResume_comment(photo.getComment());
|
|
|
+ resume.setResume_path(httphtmlRoot+ urlName + ".html");
|
|
|
+ resume.setRqcode_path(ResumeFile+urlName + ".html");
|
|
|
+ resumeService.addResume(resume);
|
|
|
+ File newResume = new File(ResumeFile + urlName + ".html");
|
|
|
+ FileWriter fileWriter = new FileWriter(newResume);
|
|
|
+ fileWriter.write(stringHtml.toString());
|
|
|
+ fileWriter.close();
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+ return httphtmlRoot+urlName+".html";
|
|
|
+ }
|
|
|
+ public String getpathtype(int type){
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ return "display";
|
|
|
+ case 2:
|
|
|
+ return "certificate";
|
|
|
+ case 3:
|
|
|
+ return "comment";
|
|
|
+ case 4:
|
|
|
+ return "service";
|
|
|
+ case 5:
|
|
|
+ return "meal";
|
|
|
+ }
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+ @GetMapping("/reBulidResume")
|
|
|
+ public int reBulidResume(@RequestParam("servant_code") String servant_code) {
|
|
|
+ return photoService.reBuildResume(servant_code);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadPayImg", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public int uploadPayImg(@RequestParam("file") MultipartFile file,
|
|
|
+ @RequestParam(value = "eh_code") String eh_code,
|
|
|
+ @RequestParam(value = "cv_orderstaus") Integer cv_orderstaus) {
|
|
|
+ int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
+ String newName = file.getOriginalFilename().substring(dot);
|
|
|
+ CustomerPayVoucher customerPayVoucher = new CustomerPayVoucher();
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ File dest = new File(payvoucher + "/" + eh_code + sdf.format(date) +newName);
|
|
|
+ // 删除
|
|
|
+ try {
|
|
|
+ file.transferTo(dest); //保存文件
|
|
|
+ customerPayVoucher.setEh_code(eh_code);
|
|
|
+ customerPayVoucher.setCv_filename(eh_code + sdf.format(date) +newName);
|
|
|
+ customerPayVoucher.setCv_orderstaus(cv_orderstaus);
|
|
|
+ customerPayVoucher.setCv_filepath(httppayvoucher + "/"+ eh_code + sdf.format(date) +newName);
|
|
|
+ customerPayVoucherService.insertCustomerPayVoucher(customerPayVoucher);
|
|
|
+ return 1;
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @GetMapping("/deletePayPhoto")
|
|
|
+ public int deletePayPhoto(@RequestParam("cv_filename") String cv_filename) throws ParseException {
|
|
|
+ try {
|
|
|
+ String path = payvoucher + "/"+ cv_filename;
|
|
|
+ File dest = new File(path);
|
|
|
+ dest.delete();
|
|
|
+ return customerPayVoucherService.deleteCustomerPayVoucher(cv_filename);
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/deleteCustomerPayVoucherAll")
|
|
|
+ public int deleteCustomerPayVoucherAll(@RequestParam("eh_code") String eh_code) throws ParseException {
|
|
|
+ try {
|
|
|
+ List<CustomerPayVoucher> customerPays= customerPayVoucherService.selectCustomerPayVoucher(eh_code);
|
|
|
+ for(CustomerPayVoucher cpv:customerPays){
|
|
|
+ String path = payvoucher + "/"+ cpv.getCv_filename();
|
|
|
+ File dest = new File(path);
|
|
|
+ dest.delete();
|
|
|
+ }
|
|
|
+ return customerPayVoucherService.deleteCustomerPayVoucherAll(eh_code);
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping ("/queryPayPhoto")
|
|
|
+ public String queryPayPhoto(@RequestParam("eh_code") String eh_code) throws ParseException {
|
|
|
+ List<CustomerPayVoucher> customerPays= customerPayVoucherService.selectCustomerPayVoucher(eh_code);
|
|
|
+ String jso = JSONObject.toJSONString(customerPays);
|
|
|
+ jso = jso.replaceAll("cv_filepath","url");
|
|
|
+ jso = jso.replaceAll("cv_filename","name");
|
|
|
+ return jso;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping ("/queryOrderPayPhoto")
|
|
|
+ public String queryOrderPayPhoto(@ModelAttribute CustomerPayVoucher customerPayVoucher) throws ParseException {
|
|
|
+ List<CustomerPayVoucher> customerPays= customerPayVoucherService.queryOrderPayPhoto(customerPayVoucher);
|
|
|
+ String jso = JSONObject.toJSONString(customerPays);
|
|
|
+ jso = jso.replaceAll("cv_filepath","url");
|
|
|
+ jso = jso.replaceAll("cv_filename","name");
|
|
|
+ return jso;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/deleteOrderPayPhoto")
|
|
|
+ public int deleteOrderPayPhoto(@ModelAttribute CustomerPayVoucher customerPayVoucher) throws ParseException {
|
|
|
+ try {
|
|
|
+ List<CustomerPayVoucher> customerPays= customerPayVoucherService.queryOrderPayPhoto(customerPayVoucher);
|
|
|
+ for(CustomerPayVoucher cpv:customerPays){
|
|
|
+ String path = payvoucher + "/"+ cpv.getCv_filename();
|
|
|
+ File dest = new File(path);
|
|
|
+ dest.delete();
|
|
|
+ }
|
|
|
+ return customerPayVoucherService.deleteOrderPayPhoto(customerPayVoucher);
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadPromotionImg", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public String uploadPromotionImg(@RequestParam(value = "file", required = false) MultipartFile file) {
|
|
|
+ int dot = file.getOriginalFilename().lastIndexOf('.');
|
|
|
+ String newName = file.getOriginalFilename().substring(dot);
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ String fileUrl = promotionvoucher + "/" + sdf.format(date) +newName;
|
|
|
+ String httpfileUrl = httppromotionvoucher + "/" + sdf.format(date) +newName;
|
|
|
+ File dest = new File(fileUrl);
|
|
|
+ // 删除
|
|
|
+ try {
|
|
|
+ file.transferTo(dest); //保存文件
|
|
|
+ return httpfileUrl;
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @GetMapping("/deletePromotionImg")
|
|
|
+ public int deletePromotionImg(@RequestParam("cv_filename") String cv_filename) throws ParseException {
|
|
|
+ try {
|
|
|
+ String path = promotionvoucher + "/"+ cv_filename;
|
|
|
+ File dest = new File(path);
|
|
|
+ dest.delete();
|
|
|
+ return 1 ;
|
|
|
+ } catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|