Commit b3d374a8970f50b451a3897a804e622461dba444
1 parent
dbb8dd28
update
Showing
4 changed files
with
35 additions
and
3 deletions
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| @@ -20,7 +20,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -20,7 +20,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 20 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by jName,clZbh,lpName") | 20 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by jName,clZbh,lpName") |
| 21 | List<ScheduleRealInfo> queryUserInfo(String line,String date); | 21 | List<ScheduleRealInfo> queryUserInfo(String line,String date); |
| 22 | 22 | ||
| 23 | - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3") | 23 | + @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by fcsj") |
| 24 | List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); | 24 | List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); |
| 25 | 25 | ||
| 26 | @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl,sum(addMileage) as ksgl,count(jName) as bcs) from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh") | 26 | @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl,sum(addMileage) as ksgl,count(jName) as bcs) from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh") |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -411,12 +411,39 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -411,12 +411,39 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 411 | ReportUtils ee = new ReportUtils(); | 411 | ReportUtils ee = new ReportUtils(); |
| 412 | List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | 412 | List<Iterator<?>> list = new ArrayList<Iterator<?>>(); |
| 413 | List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.exportWaybill(jName, clZbh, lpName); | 413 | List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.exportWaybill(jName, clZbh, lpName); |
| 414 | - ScheduleRealInfo scheduleRealInfo = scheduleRealInfoRepository.findOne(scheduleRealInfos.get(0).getId()); | 414 | + ScheduleRealInfo scheduleReal = scheduleRealInfoRepository.findOne(scheduleRealInfos.get(0).getId()); |
| 415 | + | ||
| 416 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 417 | + int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 418 | + int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 419 | + int jhbc = 0; | ||
| 420 | + double jhlc = 0; | ||
| 421 | + float realMileage = 0l,addMileage = 0l,remMileage = 0l; | ||
| 422 | + Map<String,Object> map = new HashMap<String, Object>(); | ||
| 423 | + for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){ | ||
| 424 | + if(scheduleRealInfo != null){ | ||
| 425 | + jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); | ||
| 426 | + realMileage += scheduleRealInfo.getRealMileage()==null?0:scheduleRealInfo.getRealMileage(); | ||
| 427 | + addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage(); | ||
| 428 | + remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage(); | ||
| 429 | + jhbc++; | ||
| 430 | + } | ||
| 431 | + } | ||
| 432 | + map.put("jhlc", format.format(jhlc)); | ||
| 433 | + map.put("remMileage", format.format(remMileage)); | ||
| 434 | + map.put("addMileage", format.format(addMileage)); | ||
| 435 | + map.put("yygl", format.format(realMileage-addMileage)); | ||
| 436 | + map.put("ksgl", format.format(realMileage-addMileage)); | ||
| 437 | + map.put("realMileage", format.format(realMileage)); | ||
| 438 | + map.put("jhbc", jhbc); | ||
| 439 | + map.put("cjbc", cjbc); | ||
| 440 | + map.put("ljbc", ljbc); | ||
| 441 | + map.put("sjbc", jhbc-cjbc+ljbc); | ||
| 415 | 442 | ||
| 416 | String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | 443 | String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; |
| 417 | 444 | ||
| 418 | list.add(scheduleRealInfos.iterator()); | 445 | list.add(scheduleRealInfos.iterator()); |
| 419 | - ee.excelReplace(list, new Object[] { scheduleRealInfo }, path+"mould\\waybill.xls", | 446 | + ee.excelReplace(list, new Object[] { scheduleReal,map }, path+"mould\\waybill.xls", |
| 420 | path+"export\\" + jName + ".xls"); | 447 | path+"export\\" + jName + ".xls"); |
| 421 | return scheduleRealInfos; | 448 | return scheduleRealInfos; |
| 422 | } | 449 | } |
src/main/java/com/bsth/util/ReportUtils.java
| @@ -4,8 +4,10 @@ import java.io.File; | @@ -4,8 +4,10 @@ import java.io.File; | ||
| 4 | import java.io.FileInputStream; | 4 | import java.io.FileInputStream; |
| 5 | import java.io.FileOutputStream; | 5 | import java.io.FileOutputStream; |
| 6 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
| 7 | +import java.util.HashMap; | ||
| 7 | import java.util.Iterator; | 8 | import java.util.Iterator; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| 10 | +import java.util.Map; | ||
| 9 | 11 | ||
| 10 | import org.apache.poi.hssf.usermodel.HSSFCell; | 12 | import org.apache.poi.hssf.usermodel.HSSFCell; |
| 11 | import org.apache.poi.hssf.usermodel.HSSFCellStyle; | 13 | import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
| @@ -212,6 +214,9 @@ public class ReportUtils { | @@ -212,6 +214,9 @@ public class ReportUtils { | ||
| 212 | cellValue = cellValue.replace("$" + tmpKey | 214 | cellValue = cellValue.replace("$" + tmpKey |
| 213 | + "$", getKeyValue(objs[k], fieldName) | 215 | + "$", getKeyValue(objs[k], fieldName) |
| 214 | + ""); | 216 | + ""); |
| 217 | + } else if(objs[k].getClass().getName().equals("java.util.HashMap")){ | ||
| 218 | + Map<String,Object> map = (HashMap<String,Object>)objs[k]; | ||
| 219 | + cellValue = cellValue.replace("$" + tmpKey + "$",map.get(fieldName)+""); | ||
| 215 | } | 220 | } |
| 216 | } | 221 | } |
| 217 | } else if (obj.getClass().getName().equals(classWholeName)) { | 222 | } else if (obj.getClass().getName().equals(classWholeName)) { |
src/main/resources/static/pages/forms/mould/waybill.xls
No preview for this file type