| | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | |
| | | <artifactId>guns-admin</artifactId> |
| | | <artifactId>management</artifactId> |
| | | <name>guns-admin</name> |
| | | <description>guns 的spring boot版本</description> |
| | | <parent> |
| | |
| | | <version>1.0.0</version> |
| | | <relativePath>../pom.xml</relativePath> |
| | | </parent> |
| | | <packaging>war</packaging> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | <!-- itext7html转pdf --> |
| | | <dependency> |
| | | <groupId>com.itextpdf</groupId> |
| | | <artifactId>html2pdf</artifactId> |
| | | <version>3.0.2</version> |
| | | </dependency> |
| | | <!-- 中文字体支持 --> |
| | | <dependency> |
| | | <groupId>com.itextpdf</groupId> |
| | | <artifactId>font-asian</artifactId> |
| | | <version>7.1.13</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | |
| | | |
| | | |
| | | <build> |
| | | <!--<plugins>--> |
| | | <!--<plugin>--> |
| | | <!--<groupId>org.springframework.boot</groupId>--> |
| | | <!--<artifactId>spring-boot-maven-plugin</artifactId>--> |
| | | <!--<configuration>--> |
| | | <!--<fork>true</fork><!– 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart –>--> |
| | | <!--</configuration>--> |
| | | <!--</plugin>--> |
| | | <!--<plugin>--> |
| | | <!--<groupId>org.apache.maven.plugins</groupId>--> |
| | | <!--<artifactId>maven-surefire-plugin</artifactId>--> |
| | | <!--<configuration>--> |
| | | <!--<skip>true</skip>--> |
| | | <!--</configuration>--> |
| | | <!--</plugin>--> |
| | | <!--</plugins>--> |
| | | |
| | | <!--打包war包引入本地jar的打包方式--> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-war-plugin</artifactId> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <!-- 设置成false,否则检查web.xml是否存在。因为springboot是没有web.xml的 --> |
| | | <failOnMissingWebXml>false</failOnMissingWebXml> |
| | | <!--打包后的项目名--> |
| | | <!--<warName>example</warName>--> |
| | | <!--<webResources>--> |
| | | <!--<resource>--> |
| | | <!--<!–把本地lib里面的jar复制到lib–>--> |
| | | <!--<directory>${project.basedir}/lib</directory>--> |
| | | <!--<targetPath>WEB-INF/lib/</targetPath>--> |
| | | <!--<includes>--> |
| | | <!--<include>**/*.jar</include>--> |
| | | <!--</includes>--> |
| | | <!--</resource>--> |
| | | <!--</webResources>--> |
| | | <fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart --> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <configuration> |
| | | <skip>true</skip> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | |
| | | <!--打包war包引入本地jar的打包方式--> |
| | | <!--<plugins>--> |
| | | <!--<plugin>--> |
| | | <!--<groupId>org.apache.maven.plugins</groupId>--> |
| | | <!--<artifactId>maven-war-plugin</artifactId>--> |
| | | <!--<configuration>--> |
| | | <!--<!– 设置成false,否则检查web.xml是否存在。因为springboot是没有web.xml的 –>--> |
| | | <!--<failOnMissingWebXml>false</failOnMissingWebXml>--> |
| | | <!--<!–打包后的项目名–>--> |
| | | <!--<!–<warName>example</warName>–>--> |
| | | <!--<!–<webResources>–>--> |
| | | <!--<!–<resource>–>--> |
| | | <!--<!–<!–把本地lib里面的jar复制到lib–>–>--> |
| | | <!--<!–<directory>${project.basedir}/lib</directory>–>--> |
| | | <!--<!–<targetPath>WEB-INF/lib/</targetPath>–>--> |
| | | <!--<!–<includes>–>--> |
| | | <!--<!–<include>**/*.jar</include>–>--> |
| | | <!--<!–</includes>–>--> |
| | | <!--<!–</resource>–>--> |
| | | <!--<!–</webResources>–>--> |
| | | <!--</configuration>--> |
| | | <!--</plugin>--> |
| | | <!--</plugins>--> |
| | | |
| | | <resources> |
| | | <resource> |
| | | <directory>lib</directory> |
| | |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.model.TUser; |
| | | import com.stylefeng.guns.modular.system.service.ITUserService; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | |
| | | import com.stylefeng.guns.modular.system.service.ITReportLossService; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Notification of the result of the loss report"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_content = document.getElementById("english_content"); |
| | | english_content.text(info); |
| | | EmailUtil.send(userInfo.getEmail(), "Notification of the result of the loss report", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/usr/local/nginx/html/files/html/reportLossResult_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/reportLossResult_" + randomString + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf(fileInputStream, "IGO", fileOutputStream); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/reportLossResult_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("Notification of the result of the loss report"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm("AM"); |
| | | }else { |
| | | tEmail.setAmOrPm("PM"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | model.addAttribute("startTime", sdf.format(driverActivity.getStartTime())); |
| | | model.addAttribute("endTime", sdf.format(driverActivity.getEndTime())); |
| | | DriverActivityRegistered driverActivityRegistered = driverActivityRegisteredService.selectOne(new EntityWrapper<DriverActivityRegistered>().eq("driverActivityId",activityId).eq("type",1)); |
| | | model.addAttribute("id1",driverActivityRegistered.getId()); |
| | | model.addAttribute("id1", null == driverActivityRegistered ? 0 : driverActivityRegistered.getId()); |
| | | driverActivityRegistered = driverActivityRegisteredService.selectOne(new EntityWrapper<DriverActivityRegistered>().eq("driverActivityId",activityId).eq("type",2)); |
| | | model.addAttribute("id2",driverActivityRegistered.getId()); |
| | | model.addAttribute("id2", null == driverActivityRegistered ? 0 : driverActivityRegistered.getId()); |
| | | DriverActivityOnline driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",1)); |
| | | model.addAttribute("id3",driverActivityOnline.getId()); |
| | | model.addAttribute("id3", null == driverActivityOnline ? 0 : driverActivityOnline.getId()); |
| | | //统计专车在线 |
| | | driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",2)); |
| | | model.addAttribute("id4",driverActivityOnline.getId()); |
| | | model.addAttribute("id4", null == driverActivityOnline ? 0 : driverActivityOnline.getId()); |
| | | driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",3)); |
| | | model.addAttribute("id5",driverActivityOnline.getId()); |
| | | model.addAttribute("id5", null == driverActivityOnline ? 0 : driverActivityOnline.getId()); |
| | | DriverActivityOrder driverActivityOrder = driverActivityOrderService.selectOne(new EntityWrapper<DriverActivityOrder>().eq("driverActivityId",activityId)); |
| | | model.addAttribute("id6",driverActivityOrder.getId()); |
| | | return PREFIX + "receiveRecord.html"; |
| | |
| | | } |
| | | map.put("money3",money); |
| | | map.put("number3",number); |
| | | driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",2)); |
| | | // driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",2)); |
| | | //统计出租车在线 |
| | | historyList = driverActivityHistoryService.selectList(new EntityWrapper<DriverActivityHistory>().between("insertTime",startTimes,endTimes).eq("type",3).eq("activityId",driverActivityOnline.getId()).eq("carryOut",2)); |
| | | // historyList = driverActivityHistoryService.selectList(new EntityWrapper<DriverActivityHistory>().between("insertTime",startTimes,endTimes).eq("type",3).eq("activityId",driverActivityOnline.getId()).eq("carryOut",2)); |
| | | money=0d; |
| | | number=0; |
| | | for(DriverActivityHistory history:historyList){ |
| | | totalMOney+=history.getMoney(); |
| | | money+=history.getMoney(); |
| | | number+=1; |
| | | } |
| | | // for(DriverActivityHistory history:historyList){ |
| | | // totalMOney+=history.getMoney(); |
| | | // money+=history.getMoney(); |
| | | // number+=1; |
| | | // } |
| | | map.put("money4",money); |
| | | map.put("number4",number); |
| | | driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",3)); |
| | | // driverActivityOnline = driverActivityOnlineService.selectOne(new EntityWrapper<DriverActivityOnline>().eq("driverActivityId",activityId).eq("type",3)); |
| | | //统计城际在线 |
| | | historyList = driverActivityHistoryService.selectList(new EntityWrapper<DriverActivityHistory>().between("insertTime",startTimes,endTimes).eq("type",3).eq("activityId",driverActivityOnline.getId()).eq("carryOut",2)); |
| | | // historyList = driverActivityHistoryService.selectList(new EntityWrapper<DriverActivityHistory>().between("insertTime",startTimes,endTimes).eq("type",3).eq("activityId",driverActivityOnline.getId()).eq("carryOut",2)); |
| | | money=0d; |
| | | number=0; |
| | | for(DriverActivityHistory history:historyList){ |
| | | totalMOney+=history.getMoney(); |
| | | money+=history.getMoney(); |
| | | number+=1; |
| | | } |
| | | // for(DriverActivityHistory history:historyList){ |
| | | // totalMOney+=history.getMoney(); |
| | | // money+=history.getMoney(); |
| | | // number+=1; |
| | | // } |
| | | map.put("money5",money); |
| | | map.put("number5",number); |
| | | DriverActivityOrder driverActivityOrder = driverActivityOrderService.selectOne(new EntityWrapper<DriverActivityOrder>().eq("driverActivityId",activityId)); |
| | |
| | | TAdvertisementUser tAdvertisementUser = itAdvertisementUserService.selectById(id); |
| | | TAdvertisement tAdvertisement = tAdvertisementService.selectById(tAdvertisementUser.getAdvertisementId()); |
| | | // 司机所有 TODO |
| | | if("[]".equals(tAdvertisementUser.getDriverId())){ |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getDriverId())){ |
| | | List<TDriver> list = driverService.selectList(null); |
| | | for (TDriver tDriver : list) { |
| | | String email = tDriver.getEmail(); |
| | |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | } |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getDriverId())){ |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getDriverId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TDriver tDriver = driverService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | |
| | | } |
| | | } |
| | | // 用户所有 |
| | | if("[]".equals(tAdvertisementUser.getUserId())){ |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | List<TUser> users = userService.selectList(null); |
| | | for (TUser user : users) { |
| | | String email = user.getEmail(); |
| | |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | } |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getUserId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TUser tUser = userService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | |
| | | document.getElementById("reward1").remove(); |
| | | document.getElementById("rewardToday1").remove(); |
| | | document.getElementById("driverAudit1").remove(); |
| | | |
| | | document.getElementsByTag("title").get(0).text("Vehicle audit notice"); |
| | | Element car_audit1_user = document.getElementById("car_audit1_user"); |
| | | car_audit1_user.text("Hello " + tDriver.getFirstName() + " " + tDriver.getLastName() + ","); |
| | | Element car_audit1_content = document.getElementById("car_audit1_content"); |
| | |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.model.TSystemNotice; |
| | | import com.stylefeng.guns.modular.system.model.TUser; |
| | | import com.stylefeng.guns.modular.system.service.ITSystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.ITUserService; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | |
| | | import com.stylefeng.guns.modular.system.service.ITComplaintService; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | import static org.bouncycastle.asn1.x500.style.RFC4519Style.uid; |
| | | |
| | | /** |
| | | * 投诉列表控制器 |
| | |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | |
| | | |
| | |
| | | tComplaintService.updateById(tComplaint); |
| | | |
| | | try { |
| | | TUser userInfo = userService.selectById(tComplaint.getUserId()); |
| | | String path = templatePath + "user/complaint.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | document.getElementById("chinese").remove(); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_content = document.getElementById("english_content"); |
| | | english_content.text(handleResult); |
| | | EmailUtil.send(userInfo.getEmail(), "Complaint driver handling result notification", document.html()); |
| | | TUser tUser = userService.selectById(tComplaint.getUserId()); |
| | | if(ToolUtil.isNotEmpty(tUser.getEmail())){ |
| | | String path = templatePath + "user/complaintResult.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Complain against driver"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + tUser.getNickName() + ","); |
| | | Element english_content = document.getElementById("english_content"); |
| | | english_content.text(handleResult); |
| | | EmailUtil.send(tUser.getEmail(), "Complain against driver feedback", document.html()); |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/usr/local/nginx/html/files/html/complaintResult_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/complaintResult_" + randomString + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf(fileInputStream, "IGO", fileOutputStream); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/complaintResult_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(tUser.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("Complain against driver feedback"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm("AM"); |
| | | }else { |
| | | tEmail.setAmOrPm("PM"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | TSystemNotice notice = new TSystemNotice(); |
| | | notice.setType(2); |
| | | notice.setUserType(1); |
| | | notice.setContent("投诉处理结果:【"+handleResult+"】。"); |
| | | notice.setContent(handleResult); |
| | | notice.setUserId(tComplaint.getUserId()); |
| | | notice.setInsertTime(new Date()); |
| | | notice.setRead(1); |
| | |
| | | document.getElementById("rewardToday1").remove(); |
| | | document.getElementById("carAudit1").remove(); |
| | | |
| | | document.getElementsByTag("title").get(0).text("Notice of driver registration application"); |
| | | Element driver_audit1_user = document.getElementById("driver_audit1_user"); |
| | | driver_audit1_user.text("Hello " + tDriver.getFirstName() + " " + tDriver.getLastName() + ","); |
| | | Element driver_audit1_content = document.getElementById("driver_audit1_content"); |
| | |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.model.TSystemNotice; |
| | | import com.stylefeng.guns.modular.system.model.TUser; |
| | | import com.stylefeng.guns.modular.system.service.ITSystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.ITUserService; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | |
| | | import com.stylefeng.guns.modular.system.service.ITFeedbackService; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | /** |
| | | * 跳转到司机反馈管理首页 |
| | |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Feedback Processing Results"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_content = document.getElementById("english_content"); |
| | | english_content.text(remark); |
| | | EmailUtil.send(userInfo.getEmail(), "Feedback Processing Results", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/usr/local/nginx/html/files/html/feedbackResult_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/feedbackResult_" + randomString + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf(fileInputStream, "IGO", fileOutputStream); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/feedbackResult_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("Feedback Processing Results"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm("AM"); |
| | | }else { |
| | | tEmail.setAmOrPm("PM"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | TSystemNotice notice = new TSystemNotice(); |
| | | notice.setType(2); |
| | | notice.setUserType(tFeedback.getType()); |
| | | notice.setContent("反馈处理结果:【"+remark+"】。"); |
| | | notice.setContent(remark); |
| | | notice.setUserId(tFeedback.getUserId()); |
| | | notice.setInsertTime(new Date()); |
| | | notice.setRead(1); |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.dao; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author administrator |
| | | * @since 2023-09-01 |
| | | */ |
| | | public interface TEmailMapper extends BaseMapper<TEmail> { |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.stylefeng.guns.modular.system.dao.TEmailMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TEmail"> |
| | | <id column="id" property="id" /> |
| | | <result column="userId" property="userId" /> |
| | | <result column="type" property="type" /> |
| | | <result column="link" property="link" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author administrator |
| | | * @since 2023-09-01 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @TableName("t_email") |
| | | public class TEmail extends Model<TEmail> { |
| | | |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | |
| | | /** |
| | | * 1用户2司机 |
| | | */ |
| | | private Integer type; |
| | | |
| | | /** |
| | | * html 链接 |
| | | */ |
| | | private String link; |
| | | @TableField("orderId") |
| | | private Integer orderId; |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | private String week; |
| | | @TableField("amOrPm") |
| | | private String amOrPm; |
| | | |
| | | private String name; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | HSSFWorkbook downloadDiscountInfo(String name, String time, Integer companyId) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 发送活动提醒邮件 |
| | | */ |
| | | void sendActivityEmail(); |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author administrator |
| | | * @since 2023-09-01 |
| | | */ |
| | | public interface TEmailService extends IService<TEmail> { |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.dao.TAdvertisementUserMapper; |
| | | import com.stylefeng.guns.modular.system.model.TAdvertisement; |
| | | import com.stylefeng.guns.modular.system.dao.TAdvertisementMapper; |
| | |
| | | for (Map<String, Object> stringObjectMap : advertisementList1) { |
| | | Integer id = (Integer)stringObjectMap.get("id"); |
| | | TAdvertisementUser tAdvertisementUser = tAdvertisementUserMapper.selectTAdvertisementUser(id); |
| | | if("[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | // all |
| | | stringObjectMap.put("sendUser",1); |
| | | }else if("[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | // driver |
| | | stringObjectMap.put("sendUser",2); |
| | | }else if(!"[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && !"[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",3); |
| | | }else if(!"[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && !"[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",4); |
| | | }else if(ToolUtil.isEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",5); |
| | | }else if(ToolUtil.isEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",6); |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getDriverId())){ |
| | | stringObjectMap.put("sendUser",7); |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isEmpty(tAdvertisementUser.getUserId()) && !"[]".equals(tAdvertisementUser.getDriverId())){ |
| | | stringObjectMap.put("sendUser",8); |
| | | } |
| | | } |
| | | return advertisementList1; |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.TEmailMapper; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author administrator |
| | | * @since 2023-09-01 |
| | | */ |
| | | @Service |
| | | public class TEmailServiceImpl extends ServiceImpl<TEmailMapper, TEmail> implements TEmailService { |
| | | |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.model.TUser; |
| | | import com.stylefeng.guns.modular.system.model.User; |
| | | import com.stylefeng.guns.modular.system.model.UserActivityDiscount1; |
| | | import com.stylefeng.guns.modular.system.dao.UserActivityDiscount1Mapper; |
| | | import com.stylefeng.guns.modular.system.service.ITCompanyService; |
| | | import com.stylefeng.guns.modular.system.service.ITUserService; |
| | | import com.stylefeng.guns.modular.system.service.IUserActivityDiscount1Service; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.CellType; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired |
| | | private ITCompanyService companyService; |
| | | |
| | | @Autowired |
| | | private ITUserService userService; |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | return hssfWorkbook; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送活动提醒邮件 |
| | | */ |
| | | @Override |
| | | public void sendActivityEmail() { |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<UserActivityDiscount1> lis = this.selectList(new EntityWrapper<UserActivityDiscount1>().eq("enable", 2).last(" and DATE_FORMAT(startTime, '%Y-%m-%d') = '" + sdf.format(new Date()) + "'")); |
| | | if(lis.size() > 0){ |
| | | List<TUser> tUsers = userService.selectList(new EntityWrapper<TUser>().ne("flag", 3).eq("state", 1)); |
| | | for (UserActivityDiscount1 uad : lis) { |
| | | Map<String, Double> map = new HashMap<>(); |
| | | Double special = uad.getSpecial(); |
| | | if(null != special){ |
| | | map.put("ride", special * 10); |
| | | } |
| | | Double logistics = uad.getLogistics(); |
| | | if(null != special){ |
| | | map.put("package", logistics * 10); |
| | | } |
| | | Set<String> strings = map.keySet(); |
| | | |
| | | for (TUser user : tUsers) { |
| | | if(ToolUtil.isNotEmpty(user.getEmail())){ |
| | | for (String key : strings) { |
| | | Double aDouble = map.get(key); |
| | | String path1 = templatePath + "user/discount.html"; |
| | | Document document1 = Jsoup.parse(new File(path1), "UTF-8"); |
| | | document1.getElementById("chinese").remove(); |
| | | document1.getElementById("french").remove(); |
| | | document1.getElementsByTag("title").get(0).text("I-GO Discount activity"); |
| | | Element english_user = document1.getElementById("english_user"); |
| | | english_user.text("Hello " + user.getNickName() + ","); |
| | | Element english_ride = document1.getElementById("english_ride"); |
| | | english_ride.text("Discount for I-GO " + key); |
| | | Element english_discount = document1.getElementById("english_discount"); |
| | | english_discount.text(" Enjoy " + aDouble + "% off your trip fare."); |
| | | EmailUtil.send(user.getEmail(), "I-GO Discount activity", document1.html()); |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/usr/local/nginx/html/files/html/discount_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document1.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/discount_" + randomString + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf(fileInputStream, "IGO", fileOutputStream); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/discount_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(user.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("I-GO Discount activity"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm("AM"); |
| | | }else { |
| | | tEmail.setAmOrPm("PM"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | transport.close(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public static String getWeek(int language,int i){ |
| | | String week=""; |
| | | if(language==1){ |
| | | switch (i){ |
| | | case 1: |
| | | week="星期一"; |
| | | break; |
| | | case 2: |
| | | week="星期二"; |
| | | break; |
| | | case 3: |
| | | week="星期三"; |
| | | break; |
| | | case 4: |
| | | week="星期四"; |
| | | break; |
| | | case 5: |
| | | week="星期五"; |
| | | break; |
| | | case 6: |
| | | week="星期六"; |
| | | break; |
| | | case 7: |
| | | week="星期天"; |
| | | break; |
| | | } |
| | | }else if(language==2){ |
| | | switch (i){ |
| | | case 1: |
| | | week="Monday"; |
| | | break; |
| | | case 2: |
| | | week="Tuesday"; |
| | | break; |
| | | case 3: |
| | | week="Wednesday"; |
| | | break; |
| | | case 4: |
| | | week="Thursday"; |
| | | break; |
| | | case 5: |
| | | week="Friday"; |
| | | break; |
| | | case 6: |
| | | week="Saturday"; |
| | | break; |
| | | case 7: |
| | | week="Sunday"; |
| | | break; |
| | | } |
| | | }else { |
| | | switch (i) { |
| | | case 1: |
| | | week = "lundi"; |
| | | break; |
| | | case 2: |
| | | week = "Mardi mardi "; |
| | | break; |
| | | case 3: |
| | | week = "mercredi"; |
| | | break; |
| | | case 4: |
| | | week = "jeudi"; |
| | | break; |
| | | case 5: |
| | | week = "vendredi"; |
| | | break; |
| | | case 6: |
| | | week = "Samedi samedi"; |
| | | break; |
| | | case 7: |
| | | week = "dimanche"; |
| | | break; |
| | | } |
| | | } |
| | | return week; |
| | | } |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import com.stylefeng.guns.modular.system.service.ITLocationService; |
| | | import com.stylefeng.guns.modular.system.service.IUserActivityDiscount1Service; |
| | | import com.stylefeng.guns.modular.system.service.IUserCouponRecordService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | |
| | | @Autowired |
| | | private IUserActivityDiscount1Service userActivityDiscount1Service; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | try { |
| | | // locationService.updateFence();//更新线上电子围栏 |
| | | userActivityDiscount1Service.sendActivityEmail(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.itextpdf; |
| | | |
| | | import com.itextpdf.html2pdf.ConverterProperties; |
| | | import com.itextpdf.html2pdf.HtmlConverter; |
| | | import com.itextpdf.kernel.events.PdfDocumentEvent; |
| | | import com.itextpdf.kernel.font.PdfFont; |
| | | import com.itextpdf.kernel.font.PdfFontFactory; |
| | | import com.itextpdf.kernel.geom.PageSize; |
| | | import com.itextpdf.kernel.pdf.PdfDocument; |
| | | import com.itextpdf.kernel.pdf.PdfWriter; |
| | | import com.itextpdf.layout.font.FontProvider; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2023/8/14 11:13 |
| | | */ |
| | | public class HtmlToPdfUtils { |
| | | |
| | | public static void convertToPdf(InputStream inputStream, String waterMark, OutputStream outputStream) throws IOException { |
| | | |
| | | PdfWriter pdfWriter = new PdfWriter(outputStream); |
| | | PdfDocument pdfDocument = new PdfDocument(pdfWriter); |
| | | //设置为A4大小 |
| | | pdfDocument.setDefaultPageSize(PageSize.A4); |
| | | //添加水印 |
| | | pdfDocument.addEventHandler(PdfDocumentEvent.END_PAGE, new WaterMarkEventHandler(waterMark)); |
| | | |
| | | //添加页码 |
| | | //pdfDocument.addEventHandler(PdfDocumentEvent.END_PAGE,new PageEventHandler()); |
| | | //添加中文字体支持 |
| | | ConverterProperties properties = new ConverterProperties(); |
| | | FontProvider fontProvider = new FontProvider(); |
| | | |
| | | PdfFont sysFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false); |
| | | fontProvider.addFont(sysFont.getFontProgram(), "UniGB-UCS2-H"); |
| | | |
| | | //添加自定义字体,例如微软雅黑 |
| | | /*if (StringUtils.isNotBlank(fontPath)){ |
| | | PdfFont microsoft = PdfFontFactory.createFont(fontPath, PdfEncodings.IDENTITY_H, false); |
| | | fontProvider.addFont(microsoft.getFontProgram(), PdfEncodings.IDENTITY_H); |
| | | }*/ |
| | | |
| | | properties.setFontProvider(fontProvider); |
| | | HtmlConverter.convertToPdf(inputStream, pdfDocument, properties); |
| | | |
| | | pdfWriter.close(); |
| | | pdfDocument.close(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.itextpdf; |
| | | |
| | | import com.itextpdf.kernel.colors.WebColors; |
| | | import com.itextpdf.kernel.events.Event; |
| | | import com.itextpdf.kernel.events.IEventHandler; |
| | | import com.itextpdf.kernel.events.PdfDocumentEvent; |
| | | import com.itextpdf.kernel.font.PdfFont; |
| | | import com.itextpdf.kernel.font.PdfFontFactory; |
| | | import com.itextpdf.kernel.geom.Rectangle; |
| | | import com.itextpdf.kernel.pdf.PdfDocument; |
| | | import com.itextpdf.kernel.pdf.PdfPage; |
| | | import com.itextpdf.kernel.pdf.canvas.PdfCanvas; |
| | | import com.itextpdf.layout.Canvas; |
| | | import com.itextpdf.layout.element.Paragraph; |
| | | import com.itextpdf.layout.property.TextAlignment; |
| | | import com.itextpdf.layout.property.VerticalAlignment; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2023/8/14 11:15 |
| | | */ |
| | | public class WaterMarkEventHandler implements IEventHandler { |
| | | /** |
| | | * 水印内容 |
| | | */ |
| | | private String waterMarkContent; |
| | | |
| | | /** |
| | | * 一页中有几列水印 |
| | | */ |
| | | private int waterMarkX; |
| | | |
| | | /** |
| | | * 一页中每列有多少水印 |
| | | */ |
| | | private int waterMarkY; |
| | | |
| | | public WaterMarkEventHandler(String waterMarkContent) { |
| | | this(waterMarkContent, 5, 5); |
| | | } |
| | | |
| | | public WaterMarkEventHandler(String waterMarkContent, int waterMarkX, int waterMarkY) { |
| | | this.waterMarkContent = waterMarkContent; |
| | | this.waterMarkX = waterMarkX; |
| | | this.waterMarkY = waterMarkY; |
| | | } |
| | | |
| | | @Override |
| | | public void handleEvent(Event event) { |
| | | |
| | | PdfDocumentEvent documentEvent = (PdfDocumentEvent) event; |
| | | PdfDocument document = documentEvent.getDocument(); |
| | | PdfPage page = documentEvent.getPage(); |
| | | Rectangle pageSize = page.getPageSize(); |
| | | |
| | | PdfFont pdfFont = null; |
| | | try { |
| | | pdfFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | PdfCanvas pdfCanvas = new PdfCanvas(page.newContentStreamAfter(), page.getResources(), document); |
| | | |
| | | Paragraph waterMark = new Paragraph(waterMarkContent).setOpacity(0.5f); |
| | | Canvas canvas = new Canvas(pdfCanvas, pageSize) |
| | | .setFontColor(WebColors.getRGBColor("lightgray")) |
| | | .setFontSize(16) |
| | | .setFont(pdfFont); |
| | | |
| | | for (int i = 0; i < waterMarkX; i++) { |
| | | for (int j = 0; j < waterMarkY; j++) { |
| | | canvas.showTextAligned(waterMark, (150 + i * 300), (160 + j * 150), document.getNumberOfPages(), TextAlignment.CENTER, VerticalAlignment.BOTTOM, 120); |
| | | } |
| | | } |
| | | canvas.close(); |
| | | } |
| | | } |
| | |
| | | <label class="col-sm-3 control-label">发送对象:</label> |
| | | <div class="col-sm-9" style="display: flex;align-items: center;"> |
| | | <div class="radio radio-info radio-inline"> |
| | | <input type="radio" id="sendType1" value="1" name="sendType" checked="" > |
| | | <input type="radio" id="sendType1" value="1" name="sendType" > |
| | | <label for="sendType1"> 全部用户 </label> |
| | | </div> |
| | | <div class="radio radio-success radio-inline"> |
| | |
| | | </div> |
| | | <div class="col-sm-9 left:50px" style="display: flex;align-items: center;left: 341px;"> |
| | | <div class="radio radio-info radio-inline"> |
| | | <input type="radio" id="sendType3" value="1" name="sendType1" checked="" > |
| | | <input type="radio" id="sendType3" value="1" name="sendType1"> |
| | | <label for="sendType3"> 全部司机 </label> |
| | | </div> |
| | | <div class="radio radio-success radio-inline"> |
| | |
| | | }else if(type==1 && selected[0].status!=1){ |
| | | Feng.info("当前状态不能审核!"); |
| | | return false; |
| | | }else if(type==2 && selected[0].status!=2){ |
| | | }else if(type==2 && selected[0].status!=2 && new Date()>=new Date(selected[0].startTime.replace(/-/g,"/"))){ |
| | | Feng.info("当前状态不能编辑!"); |
| | | return false; |
| | | } |
| | |
| | | |
| | | this.clearData(); |
| | | this.collectData(); |
| | | var staTime =$("#staTime").val(); |
| | | |
| | | if ($.trim($("#num1").val())=="") { |
| | | Feng.error("名称不能为空!"); |
| | | return; |
| | |
| | | Feng.error("请选择活动时间!"); |
| | | return; |
| | | } |
| | | if($.trim($("#staTime").val())==""){ |
| | | if($.trim(staTime)==""){ |
| | | Feng.error("请选择时间!"); |
| | | return; |
| | | } |
| | |
| | | },function(data){ |
| | | Feng.error("修改失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("id",$("#id").val()); |
| | | ajax.set("startTime",$("#startTime").val()); |
| | | ajax.set("staTime",$("#staTime").val()); |
| | | ajax.set("num1",$("#num1").val()); |
| | |
| | | ajax.set("num9",0); |
| | | ajax.set("num10",$("#num10").val()); |
| | | ajax.set("num11",$("#num11").val()); |
| | | ajax.set("id",$("#id").val()); |
| | | ajax.start(); |
| | | } |
| | | |
| | |
| | | if(data==4){ |
| | | return '部分用户/部分司机' |
| | | } |
| | | if(data==5){ |
| | | return '所有用户' |
| | | } |
| | | if(data==6){ |
| | | return '部分用户' |
| | | } |
| | | if(data==7){ |
| | | return '所有司机' |
| | | } |
| | | if(data==8){ |
| | | return '部分司机' |
| | | } |
| | | } |
| | | }, |
| | | {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', |
| | |
| | | Feng.info("请输入广告标题"); |
| | | return; |
| | | } |
| | | if ("" == editor){ |
| | | Feng.info("请输入发送内容"); |
| | | return; |
| | | } |
| | | var subArr=[]; |
| | | $(".timeClass").each(function () { |
| | | subArr.push({ |
| | |
| | | }) |
| | | }); |
| | | var sendType = $("input[name='sendType']:checked").val(); |
| | | var sendType1 = $("input[name='sendType1']:checked").val(); |
| | | console.log(sendType) |
| | | if(sendType==2 && subArr.length <= 0){ |
| | | console.log(sendType1) |
| | | if(null == sendType && null == sendType1){ |
| | | Feng.error("请选择发送对象"); |
| | | return; |
| | | } |
| | | if(null != sendType && sendType==2 && subArr.length <= 0){ |
| | | Feng.error("请选择用户"); |
| | | return; |
| | | } |
| | | if(null != sendType1 && sendType1==2 && subArr1.length <= 0){ |
| | | Feng.error("请选择司机"); |
| | | return; |
| | | } |
| | | if(null == sendType){ |
| | | subArr = null; |
| | | } |
| | | if(null == sendType1){ |
| | | subArr1 = null; |
| | | } |
| | | console.log(subArr) |
| | | console.log(subArr1) |
| | |
| | | },function(data){ |
| | | Feng.error("添加失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("userId",JSON.stringify(subArr)) |
| | | ajax.set("driverId",JSON.stringify(subArr1)) |
| | | ajax.set("userId", null == subArr ? '' : JSON.stringify(subArr)) |
| | | ajax.set("driverId", null == subArr1 ? '' : JSON.stringify(subArr1)) |
| | | ajax.set("name",name) |
| | | ajax.set("content",editor) |
| | | ajax.start(); |
| | |
| | | }else if(type==1 && selected[0].status!=1){ |
| | | Feng.info("当前状态不能审核!"); |
| | | return false; |
| | | }else if(type==2 && selected[0].status!=2){ |
| | | }else if(type==2 && selected[0].status!=2 && new Date()>=new Date(selected[0].startTime.replace(/-/g,"/"))){ |
| | | Feng.info("当前状态不能编辑!"); |
| | | return false; |
| | | } |
| | |
| | | ajax.set("balanceEnable",elem3.checked==true?2:1); |
| | | ajax.set("balanceInfo",JSON.stringify(subArr)); |
| | | ajax.set("discountEnable",elem4.checked==true?2:1); |
| | | ajax.set("discountSpecial",parseFloat(content5Num1)); |
| | | ajax.set("discountTaxi",parseFloat(content5Num2)); |
| | | ajax.set("discountLogistics",parseFloat(content5Num3)); |
| | | ajax.set("discountSpecial",content5Num1); |
| | | ajax.set("discountTaxi",content5Num2); |
| | | ajax.set("discountLogistics",content5Num3); |
| | | ajax.set("discountDistance",content5Num4); |
| | | ajax.set("discountOrderNum",content5Num5); |
| | | ajax.set("redenvelopeId",$("#content6RedId").val()); |