Commit 18ae82457136eb807751993fe2f75d41125b9aee

Authored by 娄高锋
1 parent 322a21d6

手动导入加油日报

src/main/java/com/bsth/controller/RefuelController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.entity.Refuel;
  4 +import com.bsth.service.RefuelService;
  5 +import com.google.common.io.Files;
  6 +
  7 +import java.io.File;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.RequestParam;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +import org.springframework.web.multipart.MultipartFile;
  17 +
  18 +/**
  19 + * Created in 19/9/3.
  20 + */
  21 +@RestController
  22 +@RequestMapping("refuel")
  23 +public class RefuelController extends BaseController<Refuel, Long> {
  24 +
  25 + @Autowired
  26 + private RefuelService refuelService;
  27 +
  28 + @RequestMapping(value = "/query", method = RequestMethod.GET)
  29 + public List<Refuel> query(@RequestParam Map<String, Object> map){
  30 + return refuelService.query(map);
  31 + }
  32 +
  33 + @RequestMapping(value = "/queryDaily", method = RequestMethod.GET)
  34 + public List<Map<String, Object>> queryDaily(@RequestParam Map<String, Object> map){
  35 + return refuelService.queryDaily(map);
  36 + }
  37 +
  38 + @RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
  39 + public String uploadFile(MultipartFile file) throws Exception{
  40 + File newFile = new File(
  41 + getDataImportClasspath() + File.separator +
  42 + file.getOriginalFilename());
  43 + Files.write(file.getBytes(), newFile);
  44 + String result = refuelService.importExcel(newFile);
  45 + return "{\"result\":" + "\""+result+"\"}";
  46 + }
  47 +
  48 + private String getDataImportClasspath(){
  49 + return this.getClass().getResource("/").getPath() + "/static/pages/forms";
  50 + }
  51 +
  52 +}
... ...
src/main/java/com/bsth/entity/Refuel.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +import javax.persistence.Entity;
  6 +import javax.persistence.GeneratedValue;
  7 +import javax.persistence.Id;
  8 +import javax.persistence.Table;
  9 +
  10 +/**
  11 + * Created in 19/9/3.
  12 + */
  13 +@Entity
  14 +@Table(name = "bsth_c_refuel")
  15 +public class Refuel {
  16 + @Id
  17 + @GeneratedValue
  18 + private Long id;
  19 +
  20 + private Date date;
  21 +
  22 + private String dateStr;
  23 +
  24 + private String lineName;
  25 +
  26 + private String car;
  27 +
  28 + private String driver;
  29 +
  30 + private String outOil;
  31 +
  32 + private String inOil;
  33 +
  34 + private String inStation0;
  35 +
  36 + private String inStation5;
  37 +
  38 + private String oilCard0;
  39 +
  40 + private String oilCard10;
  41 +
  42 + private String eastStation0;
  43 +
  44 + private String eastStation10;
  45 +
  46 + private String outStation0;
  47 +
  48 + private String outStation10;
  49 +
  50 + private String createBy;
  51 +
  52 + private Date createDate;
  53 +
  54 + private String updateBy;
  55 +
  56 + private Date updateDate;
  57 +
  58 + public Long getId() {
  59 + return id;
  60 + }
  61 +
  62 + public void setId(Long id) {
  63 + this.id = id;
  64 + }
  65 +
  66 + public Date getDate() {
  67 + return date;
  68 + }
  69 +
  70 + public void setDate(Date date) {
  71 + this.date = date;
  72 + }
  73 +
  74 + public String getDateStr() {
  75 + return dateStr;
  76 + }
  77 +
  78 + public void setDateStr(String dateStr) {
  79 + this.dateStr = dateStr;
  80 + }
  81 +
  82 + public String getLineName() {
  83 + return lineName;
  84 + }
  85 +
  86 + public void setLineName(String lineName) {
  87 + this.lineName = lineName;
  88 + }
  89 +
  90 + public String getCar() {
  91 + return car;
  92 + }
  93 +
  94 + public void setCar(String car) {
  95 + this.car = car;
  96 + }
  97 +
  98 + public String getDriver() {
  99 + return driver;
  100 + }
  101 +
  102 + public void setDriver(String driver) {
  103 + this.driver = driver;
  104 + }
  105 +
  106 + public String getOutOil() {
  107 + return outOil;
  108 + }
  109 +
  110 + public void setOutOil(String outOil) {
  111 + this.outOil = outOil;
  112 + }
  113 +
  114 + public String getInOil() {
  115 + return inOil;
  116 + }
  117 +
  118 + public void setInOil(String inOil) {
  119 + this.inOil = inOil;
  120 + }
  121 +
  122 + public String getInStation0() {
  123 + return inStation0;
  124 + }
  125 +
  126 + public void setInStation0(String inStation0) {
  127 + this.inStation0 = inStation0;
  128 + }
  129 +
  130 + public String getInStation5() {
  131 + return inStation5;
  132 + }
  133 +
  134 + public void setInStation5(String inStation5) {
  135 + this.inStation5 = inStation5;
  136 + }
  137 +
  138 + public String getOilCard0() {
  139 + return oilCard0;
  140 + }
  141 +
  142 + public void setOilCard0(String oilCard0) {
  143 + this.oilCard0 = oilCard0;
  144 + }
  145 +
  146 + public String getOilCard10() {
  147 + return oilCard10;
  148 + }
  149 +
  150 + public void setOilCard10(String oilCard10) {
  151 + this.oilCard10 = oilCard10;
  152 + }
  153 +
  154 + public String getEastStation0() {
  155 + return eastStation0;
  156 + }
  157 +
  158 + public void setEastStation0(String eastStation0) {
  159 + this.eastStation0 = eastStation0;
  160 + }
  161 +
  162 + public String getEastStation10() {
  163 + return eastStation10;
  164 + }
  165 +
  166 + public void setEastStation10(String eastStation10) {
  167 + this.eastStation10 = eastStation10;
  168 + }
  169 +
  170 + public String getOutStation0() {
  171 + return outStation0;
  172 + }
  173 +
  174 + public void setOutStation0(String outStation0) {
  175 + this.outStation0 = outStation0;
  176 + }
  177 +
  178 + public String getOutStation10() {
  179 + return outStation10;
  180 + }
  181 +
  182 + public void setOutStation10(String outStation10) {
  183 + this.outStation10 = outStation10;
  184 + }
  185 +
  186 + public String getCreateBy() {
  187 + return createBy;
  188 + }
  189 +
  190 + public void setCreateBy(String createBy) {
  191 + this.createBy = createBy;
  192 + }
  193 +
  194 + public Date getCreateDate() {
  195 + return createDate;
  196 + }
  197 +
  198 + public void setCreateDate(Date createDate) {
  199 + this.createDate = createDate;
  200 + }
  201 +
  202 + public String getUpdateBy() {
  203 + return updateBy;
  204 + }
  205 +
  206 + public void setUpdateBy(String updateBy) {
  207 + this.updateBy = updateBy;
  208 + }
  209 +
  210 + public Date getUpdateDate() {
  211 + return updateDate;
  212 + }
  213 +
  214 + public void setUpdateDate(Date updateDate) {
  215 + this.updateDate = updateDate;
  216 + }
  217 +
  218 +}
... ...
src/main/java/com/bsth/repository/RefuelRepository.java 0 → 100644
  1 +package com.bsth.repository;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.data.jpa.repository.EntityGraph;
  6 +import org.springframework.data.jpa.repository.Modifying;
  7 +import org.springframework.data.jpa.repository.Query;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
  10 +import com.bsth.entity.Refuel;
  11 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  12 +import com.bsth.repository.BaseRepository;
  13 +
  14 +/**
  15 + * Created in 19/9/3.
  16 + */
  17 +public interface RefuelRepository extends BaseRepository<Refuel, Long> {
  18 +
  19 + @Query(value="select r.date_str, r.line_name, r.car, r.driver, r.in_oil, r.out_oil, r.in_station0, r.in_station5, "
  20 + +"r.oil_card0, r.oil_card10, r.east_station0, r.east_station10, r.out_station0, r.out_station10, r.id, "
  21 + +"r.date, r.create_by, r.create_date, r.update_by, r.update_date "
  22 + +"from bsth_c_refuel r where binary r.date_str = ?1 and r.car like ?2 and r.driver like ?3", nativeQuery=true)
  23 + List<Refuel> findByDate(String date, String car, String driver);
  24 +
  25 + @Query(value="select r from Refuel r where r.dateStr = ?1 and r.lineName = ?2 and r.car = ?3 and r.driver = ?4")
  26 + List<Refuel> selectByDateAndCar(String date, String line, String car, String driver);
  27 +
  28 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  29 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.clZbh = ?2 and s.jGh = ?3")
  30 + List<ScheduleRealInfo> scheduleByDate(String date, String clZbh, String jGh);
  31 +
  32 + @Transactional
  33 + @Modifying
  34 + @Query(value="INSERT INTO bsth_c_refuel(" +
  35 + "date, date_str, line_name, car, driver, out_oil, in_oil, in_station0, in_station5, oil_card0, oil_card10, east_station0, east_station10, out_station0, out_station10, create_by, create_date)" +
  36 + " VALUES(" +
  37 + "str_to_date(?1,'%Y-%m-%d'),?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,str_to_date(?17,'%Y-%m-%d %H:%i:%s'))", nativeQuery=true)
  38 + void insertData(String date, String dateStr, String lineName, String car, String driver, String outOil, String inOil, String inStation0, String inStation5, String oilCard0, String oilCard10,
  39 + String eastStation0, String eastStation10, String outStation0, String outStation10, String createBy, String createDate);
  40 +
  41 + @Transactional
  42 + @Modifying
  43 + @Query(value="update bsth_c_refuel set date=str_to_date(?2,'%Y-%m-%d'), date_str=?3, line_name=?4, car=?5, driver=?6, out_oil=?7, in_oil=?8,"
  44 + + " in_station0=?9, in_station5=?10, oil_card0=?11, oil_card10=?12, east_station0=?13, east_station10=?14, out_station0=?15, out_station10=?16,"
  45 + + " update_by=?17, update_date=str_to_date(?18,'%Y-%m-%d %H:%i:%s') where id=?1", nativeQuery=true)
  46 + public void update(long id, String date, String dateStr, String lineName, String car, String driver, String outOil, String inOil, String inStation0, String inStation5,
  47 + String oilCard0, String oilCard10, String eastStation0, String eastStation10, String outStation0, String outStation10, String updateBy, String updateDate);
  48 +
  49 +}
... ...
src/main/java/com/bsth/service/RefuelService.java 0 → 100644
  1 +package com.bsth.service;
  2 +
  3 +import java.io.File;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import com.bsth.entity.Refuel;
  8 +
  9 +/**
  10 + * Created in 19/9/3.
  11 + */
  12 +public interface RefuelService extends BaseService<Refuel, Long> {
  13 +
  14 + List<Refuel> query(Map<String, Object> map);
  15 +
  16 + List<Map<String, Object>> queryDaily(Map<String, Object> map);
  17 +
  18 + public String importExcel(File file);
  19 +}
... ...
src/main/java/com/bsth/service/impl/RefuelServiceImpl.java 0 → 100644
  1 +package com.bsth.service.impl;
  2 +
  3 +import com.bsth.entity.Refuel;
  4 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.sys.SysUser;
  7 +import com.bsth.repository.RefuelRepository;
  8 +import com.bsth.security.util.SecurityUtils;
  9 +import com.bsth.service.RefuelService;
  10 +import com.bsth.service.report.CulateMileageService;
  11 +
  12 +import java.io.File;
  13 +import java.io.FileInputStream;
  14 +import java.math.BigDecimal;
  15 +import java.text.DecimalFormat;
  16 +import java.text.SimpleDateFormat;
  17 +import java.util.ArrayList;
  18 +import java.util.Date;
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +import java.util.Set;
  23 +
  24 +import org.apache.poi.hssf.usermodel.HSSFCell;
  25 +import org.apache.poi.hssf.usermodel.HSSFRow;
  26 +import org.apache.poi.hssf.usermodel.HSSFSheet;
  27 +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  28 +import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  29 +import org.springframework.beans.factory.annotation.Autowired;
  30 +import org.springframework.stereotype.Service;
  31 +
  32 +/**
  33 + * Created in 19/9/3.
  34 + */
  35 +@Service
  36 +public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements RefuelService {
  37 +
  38 + @Autowired
  39 + private RefuelRepository repository;
  40 +
  41 + @Autowired
  42 + private CulateMileageService culateMileageService;
  43 +
  44 + @Override
  45 + public List<Refuel> query(Map<String, Object> map) {
  46 + // TODO Auto-generated method stub
  47 + String date = "", car = "%%", driver = "%%";
  48 + if(map.get("date") != null){
  49 + date = map.get("date").toString();
  50 + }
  51 + if(map.get("car") != null){
  52 + car = "%" + map.get("car").toString() + "%";
  53 + }
  54 + if(map.get("driver") != null){
  55 + driver = "%" + map.get("driver").toString() + "%";
  56 + }
  57 + List<Refuel> list = repository.findByDate(date, car, driver);
  58 + return list;
  59 + }
  60 +
  61 + @Override
  62 + public List<Map<String, Object>> queryDaily(Map<String, Object> map) {
  63 + // TODO Auto-generated method stub
  64 + DecimalFormat df = new DecimalFormat("0.##");
  65 +
  66 + String date = "", car = "%%", driver = "%%";
  67 + if(map.get("date") != null){
  68 + date = map.get("date").toString();
  69 + }
  70 + if(map.get("car") != null){
  71 + car = "%" + map.get("car").toString() + "%";
  72 + }
  73 + if(map.get("driver") != null){
  74 + driver = "%" + map.get("driver").toString() + "%";
  75 + }
  76 +
  77 + List<Refuel> list = repository.findByDate(date, car, driver);
  78 +
  79 + List<String> keyList = new ArrayList<String>();
  80 + Map<String, Refuel> rMap = new HashMap<String, Refuel>();
  81 + for(Refuel rf : list){
  82 + String key = rf.getCar() + "/" + rf.getDriver();
  83 + if("/".equals(key)){
  84 + continue;
  85 + }
  86 + if(rMap.containsKey(key)){
  87 + Refuel r = rMap.get(key);
  88 + if(rf.getOutOil().length() > 0){
  89 + if(r.getOutOil().length() == 0){
  90 + r.setOutOil(rf.getOutOil());
  91 + } else if(Double.valueOf(rf.getOutOil()) > Double.valueOf(r.getOutOil())){
  92 + r.setOutOil(rf.getOutOil());
  93 + }
  94 + }
  95 + if(rf.getInOil().length() > 0){
  96 + if(r.getInOil().length() == 0){
  97 + r.setInOil(rf.getInOil());
  98 + } else if(Double.valueOf(rf.getInOil()) < Double.valueOf(r.getInOil())){
  99 + r.setInOil(rf.getInOil());
  100 + }
  101 + }
  102 + if(rf.getInStation0().length() > 0){
  103 + if(r.getInStation0().length() == 0){
  104 + r.setInStation0(rf.getInStation0());
  105 + } else {
  106 + r.setInStation0(add(r.getInStation0(), rf.getInStation0()));
  107 + }
  108 + }
  109 + if(rf.getInStation5().length() > 0){
  110 + if(r.getInStation5().length() == 0){
  111 + r.setInStation5(rf.getInStation5());
  112 + } else {
  113 + r.setInStation5(add(r.getInStation5(), rf.getInStation5()));
  114 + }
  115 + }
  116 + if(rf.getOilCard0().length() > 0){
  117 + if(r.getOilCard0().length() == 0){
  118 + r.setOilCard0(rf.getOilCard0());
  119 + } else {
  120 + r.setOilCard0(add(r.getOilCard0(), rf.getOilCard0()));
  121 + }
  122 + }
  123 + if(rf.getOilCard10().length() > 0){
  124 + if(r.getOilCard10().length() == 0){
  125 + r.setOilCard10(rf.getOilCard10());
  126 + } else {
  127 + r.setOilCard10(add(r.getOilCard10(), rf.getOilCard10()));
  128 + }
  129 + }
  130 + if(rf.getEastStation0().length() > 0){
  131 + if(r.getEastStation0().length() == 0){
  132 + r.setEastStation0(rf.getEastStation0());
  133 + } else {
  134 + r.setEastStation0(add(r.getEastStation0(), rf.getEastStation0()));
  135 + }
  136 + }
  137 + if(rf.getEastStation10().length() > 0){
  138 + if(r.getEastStation10().length() == 0){
  139 + r.setEastStation10(rf.getEastStation10());
  140 + } else {
  141 + r.setEastStation10(add(r.getEastStation10(), rf.getEastStation10()));
  142 + }
  143 + }
  144 + if(rf.getOutStation0().length() > 0){
  145 + if(r.getOutStation0().length() == 0){
  146 + r.setOutStation0(rf.getOutStation0());
  147 + } else {
  148 + r.setOutStation0(add(r.getOutStation0(), rf.getOutStation0()));
  149 + }
  150 + }
  151 + if(rf.getOutStation10().length() > 0){
  152 + if(r.getOutStation10().length() == 0){
  153 + r.setOutStation10(rf.getOutStation10());
  154 + } else {
  155 + r.setOutStation10(add(r.getOutStation10(), rf.getOutStation10()));
  156 + }
  157 + }
  158 + } else {
  159 + keyList.add(key);
  160 + rMap.put(key, rf);
  161 + }
  162 + }
  163 +
  164 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  165 + for(String key : keyList){
  166 + Refuel r = rMap.get(key);
  167 + Map<String, Object> m = new HashMap<String, Object>();
  168 +
  169 + String realMileage = "", oil = "0", consume = "";
  170 + List<ScheduleRealInfo> temp = repository.scheduleByDate(date, r.getCar(), r.getDriver());
  171 + List<ScheduleRealInfo> temp2 = new ArrayList<ScheduleRealInfo>();
  172 + if(temp.size() > 0){
  173 + for(ScheduleRealInfo s : temp){
  174 + Set<ChildTaskPlan> cts = s.getcTasks();
  175 + if(cts != null && cts.size() > 0){
  176 + temp2.add(s);
  177 + }else{
  178 + if(s.getZdsjActual()!=null
  179 + && s.getFcsjActual()!=null){
  180 + temp2.add(s);
  181 + }
  182 + }
  183 + }
  184 + Double sjgl = culateMileageService.culateSjgl(temp2);
  185 + Double ksgl = culateMileageService.culateKsgl(temp);
  186 + Double jccgl = culateMileageService.culateJccgl(temp2);
  187 + Double ljgl = culateMileageService.culateLjgl(temp2);
  188 +
  189 + realMileage = add(add(sjgl, ksgl), add(jccgl, ljgl));
  190 + }
  191 +
  192 + if(r.getOutOil().length() > 0 && r.getInOil().length() > 0){
  193 + oil = new BigDecimal(r.getOutOil()).subtract(new BigDecimal(r.getInOil())).toString();
  194 + }
  195 + if(r.getInStation0().length() > 0){
  196 + oil = add(oil, r.getInStation0());
  197 + }
  198 + if(r.getInStation5().length() > 0){
  199 + oil = add(oil, r.getInStation5());
  200 + }
  201 + if(r.getOilCard0().length() > 0){
  202 + oil = add(oil, r.getOilCard0());
  203 + }
  204 + if(r.getOilCard10().length() > 0){
  205 + oil = add(oil, r.getOilCard10());
  206 + }
  207 + if(r.getEastStation0().length() > 0){
  208 + oil = add(oil, r.getEastStation0());
  209 + }
  210 + if(r.getEastStation10().length() > 0){
  211 + oil = add(oil, r.getEastStation10());
  212 + }
  213 + if(r.getOutStation0().length() > 0){
  214 + oil = add(oil, r.getOutStation0());
  215 + }
  216 + if(r.getOutStation10().length() > 0){
  217 + oil = add(oil, r.getOutStation10());
  218 + }
  219 +
  220 + if(realMileage.length() > 0 && oil.length() > 0 && !("0".equals(realMileage))){
  221 + consume = df.format(new BigDecimal(oil).divide(new BigDecimal(realMileage), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)));
  222 + }
  223 +
  224 + m.put("date", r.getDateStr());
  225 + m.put("line", r.getLineName());
  226 + m.put("car", r.getCar());
  227 + m.put("driver", r.getDriver());
  228 + m.put("realMileage", realMileage);
  229 + m.put("oil", oil);
  230 + m.put("consume", consume);
  231 +
  232 + resList.add(m);
  233 + }
  234 +
  235 + return resList;
  236 + }
  237 +
  238 + @Override
  239 + public String importExcel(File file) {
  240 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  241 + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  242 + List<String> textList = new ArrayList<String>();
  243 + try {
  244 + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
  245 + HSSFWorkbook wb = new HSSFWorkbook(fs);
  246 + HSSFSheet sheet = wb.getSheetAt(0);
  247 + // 取得总行数
  248 + int rowNum = sheet.getLastRowNum() + 1;
  249 + // 取得总列数
  250 + int cellNum = sheet.getRow(0).getLastCellNum();
  251 + HSSFRow row = null;
  252 + HSSFCell cell = null;
  253 +
  254 + String userName = "";
  255 + SysUser user = SecurityUtils.getCurrentUser();
  256 + if(user != null && user.getUserName() != null){
  257 + userName = user.getUserName();
  258 + }
  259 +
  260 + for(int i = 1; i < rowNum; i++){
  261 + row = sheet.getRow(i);
  262 + if (row == null){
  263 + continue;
  264 + }
  265 + String text = "";
  266 + for(int j = 0; j < cellNum; j++){
  267 + cell = row.getCell(j);
  268 + if(cell == null){
  269 + text += ",";
  270 + continue;
  271 + }
  272 + text += String.valueOf(cell) + ",";
  273 + }
  274 + String[] split = (text+";").split(",");
  275 + String str = "";
  276 + for(int j = 0; j < split.length && j < 14; j++){
  277 + str += split[j];
  278 + }
  279 + if(str.trim().length() == 0)
  280 + continue;
  281 + textList.add(text + ";");
  282 + }
  283 + for(int i = 0; i < textList.size(); i++){
  284 + String text = textList.get(i);
  285 + String[] split = text.split(",");
  286 + String rq = split[0].trim();
  287 + String line = split[1].trim();
  288 + String car = split[2].trim();
  289 + String driver = split[3].trim();
  290 + if((car + driver).trim().length() == 0){
  291 + continue;
  292 + }
  293 + String outOil = split[4].trim();
  294 + String inOil = split[5].trim();
  295 + String inStation0 = split[6].trim();
  296 + String inStation5 = split[7].trim();
  297 + String oilCard0 = split[8].trim();
  298 + String oilCard10 = split[9].trim();
  299 + String eastStation0 = split[10].trim();
  300 + String eastStation10 = split[11].trim();
  301 + String outStation0 = split[12].trim();
  302 + String outStation10 = split[13].trim();
  303 +
  304 + List<Refuel> list = repository.selectByDateAndCar(rq, line, car, driver);
  305 + if(list.size() > 0){
  306 + for(Refuel r : list){
  307 + if(r.getId() != null){
  308 + repository.update(r.getId(), rq, rq, line, car, driver, outOil, inOil, inStation0, inStation5,
  309 + oilCard0, oilCard10, eastStation0, eastStation10, outStation0, outStation10, userName, sd.format(new Date()));
  310 + }
  311 + }
  312 + } else {
  313 + repository.insertData(rq, rq, line, car, driver, outOil, inOil, inStation0, inStation5, oilCard0, oilCard10,
  314 + eastStation0, eastStation10, outStation0, outStation10, userName, sd.format(new Date()));
  315 + }
  316 + }
  317 + wb.close();
  318 + fs.close();
  319 + } catch (Exception e) {
  320 + // TODO Auto-generated catch block
  321 + e.printStackTrace();
  322 + return "文件导入失败";
  323 + } finally {
  324 + file.delete();
  325 + }
  326 + return "文件导入成功";
  327 + }
  328 +
  329 + public String add(Object v1, Object v2)
  330 + {
  331 + BigDecimal b1 = new BigDecimal(v1.toString());
  332 + BigDecimal b2 = new BigDecimal(v2.toString());
  333 + return b1.add(b2).toString();
  334 + }
  335 +
  336 +}
... ...
src/main/resources/static/pages/forms/export/refuel.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/statement/refuel.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px; }
  14 +
  15 + .table > tbody + tbody {
  16 + border-top: 1px solid; }
  17 + .btn-default{
  18 + margin-left: 5px;
  19 + }
  20 +</style>
  21 +
  22 +<div class="page-head">
  23 + <div class="page-title">
  24 + <h1>加注量</h1>
  25 + </div>
  26 +</div>
  27 +
  28 +<div class="row">
  29 + <div class="col-md-12">
  30 + <div class="portlet light porttlet-fit bordered">
  31 + <div class="portlet-title">
  32 + <form class="form-inline" action="" autocomplete="off">
  33 + <div style="display: inline-block;margin-left: 24px;">
  34 + <span class="item-label" style="width: 80px;">&nbsp;日期: </span>
  35 + <input class="form-control" type="text" id="date" style="width: 180px;"/>
  36 + </div>
  37 + <div style="display: inline-block;margin-left: 6px;">
  38 + <span class="item-label" style="width: 80px;">&nbsp;车号: </span>
  39 + <input class="form-control" type="text" id="car" style="width: 180px;"/>
  40 + </div>
  41 + <div style="display: inline-block;margin-left: 6px;">
  42 + <span class="item-label" style="width: 80px;">&nbsp;驾驶员: </span>
  43 + <input class="form-control" type="text" id="driver" style="width: 180px;"/>
  44 + </div>
  45 + <div class="form-group">
  46 + <input class="btn btn-default" type="button" id="query" value="筛选"/>
  47 + <input class="btn btn-default" type="button" id="upload" value="导入Excel"/>
  48 +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> -->
  49 + </div>
  50 + </form>
  51 + </div>
  52 + <div class="portlet-body">
  53 + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px">
  54 + <table class="table table-bordered table-hover table-checkable" id="forms">
  55 + <thead>
  56 + <tr>
  57 + <td>序号</td>
  58 + <td>日期</td>
  59 + <td>路别</td>
  60 + <td>车号</td>
  61 + <td>驾驶员</td>
  62 + <td>出场</td>
  63 + <td>进场</td>
  64 + <td>场内0号</td>
  65 + <td>场内B5#</td>
  66 + <td>油卡0号</td>
  67 + <td>油卡-10#</td>
  68 + <td>东站0#</td>
  69 + <td>东站-10#</td>
  70 + <td>场外0#</td>
  71 + <td>场外-10#</td>
  72 + </tr>
  73 + </thead>
  74 + <tbody id="tbody">
  75 +
  76 + </tbody>
  77 + </table>
  78 + </div>
  79 + </div>
  80 + </div>
  81 + </div>
  82 +</div>
  83 +
  84 +<script>
  85 + $(function(){
  86 +
  87 + // 关闭左侧栏
  88 + if (!$('body').hasClass('page-sidebar-closed'))
  89 + $('.menu-toggler.sidebar-toggler').click();
  90 +
  91 + $("#date").datetimepicker({
  92 + format : 'YYYY-MM-DD',
  93 + locale : 'zh-cn'
  94 + });
  95 +
  96 + var d = new Date();
  97 + var year = d.getFullYear();
  98 + var mon = (d.getMonth()+1)>9?(d.getMonth()+1):("0"+(d.getMonth()+1));
  99 + var day = d.getDate()>9?d.getDate():("0"+d.getDate());
  100 + $("#date").val(year + "-" + mon + "-" + day);
  101 +
  102 +
  103 + var date, car, driver;
  104 + $("#query").on("click",function(){
  105 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  106 + layer.msg("请选择日期");
  107 + return;
  108 + }
  109 + date = $("#date").val();
  110 + car = $("#car").val();
  111 + driver = $("#driver").val();
  112 + var i = layer.load(2);
  113 + $get('/refuel/query',{date:date,car:car,driver:driver,type:'query'},function(result){
  114 + // 把数据填充到模版中
  115 + var tbodyHtml = template('refuel',{list:result});
  116 + // 把渲染好的模版html文本追加到表格中
  117 + $('#tbody').html(tbodyHtml);
  118 + layer.close(i);
  119 + });
  120 + });
  121 +
  122 + $("#upload").on("click", function(){
  123 + $.get('refuelUpload.html', function(m){$(pjaxContainer).append(m);});
  124 + });
  125 +
  126 +});
  127 +</script>
  128 +<script type="text/html" id="refuel">
  129 + {{each list as obj i}}
  130 + <tr>
  131 + <td>{{i + 1}}</td>
  132 + <td>{{obj.dateStr}}</td>
  133 + <td>{{obj.lineName}}</td>
  134 + <td>{{obj.car}}</td>
  135 + <td>{{obj.driver}}</td>
  136 + <td>{{obj.outOil}}</td>
  137 + <td>{{obj.inOil}}</td>
  138 + <td>{{obj.inStation0}}</td>
  139 + <td>{{obj.inStation5}}</td>
  140 + <td>{{obj.oilCard0}}</td>
  141 + <td>{{obj.oilCard10}}</td>
  142 + <td>{{obj.eastStation0}}</td>
  143 + <td>{{obj.eastStation10}}</td>
  144 + <td>{{obj.outStation0}}</td>
  145 + <td>{{obj.outStation10}}</td>
  146 + </tr>
  147 + {{/each}}
  148 + {{if list.length == 0}}
  149 + <tr>
  150 + <td colspan="15"><h6 class="muted">没有找到相关数据</h6></td>
  151 + </tr>
  152 + {{/if}}
  153 +</script>
0 154 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/statement/refuelUpload.html 0 → 100644
  1 +<div class="modal fade" id="uploadFile" tabindex="-1" role="basic"
  2 + aria-hidden="true">
  3 + <div class="modal-dialog">
  4 + <div class="modal-content">
  5 + <div class="modal-header">
  6 + <button type="button" class="close" data-dismiss="modal"
  7 + aria-hidden="true"></button>
  8 + <h4 class="modal-title">导入Excel</h4>
  9 + </div>
  10 + <div class="modal-body">
  11 + <form class="form-horizontal" role="form" id="excelFile" method="post"
  12 + action="" enctype="multipart/form-data">
  13 + <div class="alert alert-danger display-hide">
  14 + <button class="close" data-close="alert"></button>
  15 + 您的输入有误,请检查下面的输入项
  16 + </div>
  17 + <div class="form-body">
  18 + <div class="form-group">
  19 + <label class="col-md-3 control-label">选择文件</label>
  20 + <div class="col-md-9">
  21 + <input type="file" name="file" id="file"
  22 + accept="application/vnd.ms-excel"/>
  23 + </div>
  24 + </div>
  25 + </div>
  26 + </form>
  27 + </div>
  28 + <div class="modal-footer">
  29 + <button type="button" class="btn default" id="downLoad">下载模板</button>
  30 + <button type="button" class="btn default" data-dismiss="modal">取消</button>
  31 + <button type="button" class="btn btn-primary" id="submit">确认导入</button>
  32 + </div>
  33 + </div>
  34 + </div>
  35 +</div>
  36 +<script src="/assets/js/ajaxfileupload/ajaxfileupload.js"></script>
  37 +<script id="res_tbody_temp" type="text/html">
  38 +
  39 +</script>
  40 +<script data-exclude=1>
  41 + $(function() {
  42 + var form = $('#excelFile');
  43 + var error = $('.alert-danger', form);
  44 + var user = '';
  45 +
  46 + //modal 显示事件
  47 + $('#uploadFile').on('show.bs.modal', function(){
  48 + })
  49 + .modal('show');
  50 +
  51 + $('#submit').on('click', function() {
  52 + if($("#file").val().trim().length == 0){
  53 + alert("请先选择文件");
  54 + return;
  55 + }
  56 + var j = layer.load(2);
  57 + var param = {};
  58 + param.user = user;
  59 + param.uploadDir = 'upload';
  60 + $.ajaxFileUpload({
  61 + url : '/refuel/uploadFile',
  62 + secureuri : false,
  63 + fileElementId : 'file',
  64 + dataType : 'json',
  65 + data : param,
  66 + success : function(data) {
  67 + layer.close(j);
  68 + if((data.result).indexOf('失败') > -1){
  69 + alert(data.result);
  70 + $("#file").val("");
  71 + } else {
  72 + alert(data.result);
  73 +// alert("文件导入成功");
  74 + $('#uploadFile').modal('hide');
  75 + $('tr.filter .filter-submit').click();
  76 + }
  77 + },
  78 + error : function(data, status, e) {
  79 + layer.close(j);
  80 + alert("文件导入失败");
  81 + }
  82 + })
  83 + });
  84 +
  85 + $('#downLoad').on('click', function(){
  86 + window.open("/downloadFile/downloadModel?fileName=refuel");
  87 + });
  88 +
  89 + function getCurrSelNode(){
  90 + return $.jstree.reference("#modules_tree").get_selected(true);
  91 + }
  92 +
  93 + });
  94 +</script>
0 95 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/statement/refuel_daily.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px; }
  14 +
  15 + .table > tbody + tbody {
  16 + border-top: 1px solid; }
  17 + .btn-default{
  18 + margin-left: 5px;
  19 + }
  20 +</style>
  21 +
  22 +<div class="page-head">
  23 + <div class="page-title">
  24 + <h1>油耗日报</h1>
  25 + </div>
  26 +</div>
  27 +
  28 +<div class="row">
  29 + <div class="col-md-12">
  30 + <div class="portlet light porttlet-fit bordered">
  31 + <div class="portlet-title">
  32 + <form class="form-inline" action="">
  33 + <div style="display: inline-block;margin-left: 24px;">
  34 + <span class="item-label" style="width: 80px;">&nbsp;日期: </span>
  35 + <input class="form-control" type="text" id="date" style="width: 180px;"/>
  36 + </div>
  37 + <div style="display: inline-block;margin-left: 6px;">
  38 + <span class="item-label" style="width: 80px;">&nbsp;车号: </span>
  39 + <input class="form-control" type="text" id="car" style="width: 180px;"/>
  40 + </div>
  41 + <div style="display: inline-block;margin-left: 6px;">
  42 + <span class="item-label" style="width: 80px;">&nbsp;驾驶员: </span>
  43 + <input class="form-control" type="text" id="driver" style="width: 180px;"/>
  44 + </div>
  45 + <div class="form-group">
  46 + <input class="btn btn-default" type="button" id="query" value="筛选"/>
  47 +<!-- <input class="btn btn-default" type="button" id="upload" value="导入Excel"/> -->
  48 +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> -->
  49 + </div>
  50 + </form>
  51 + </div>
  52 + <div class="portlet-body">
  53 + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px">
  54 + <table class="table table-bordered table-hover table-checkable" id="forms">
  55 + <thead>
  56 + <tr>
  57 + <td>序号</td>
  58 + <td>日期</td>
  59 + <td>路别</td>
  60 + <td>车号</td>
  61 + <td>驾驶员</td>
  62 + <td>加注量</td>
  63 + <td>行驶里程</td>
  64 + <td>百公里油耗</td>
  65 + </tr>
  66 + </thead>
  67 + <tbody id="tbody">
  68 +
  69 + </tbody>
  70 + </table>
  71 + </div>
  72 + </div>
  73 + </div>
  74 + </div>
  75 +</div>
  76 +
  77 +<script>
  78 + $(function(){
  79 +
  80 + // 关闭左侧栏
  81 + if (!$('body').hasClass('page-sidebar-closed'))
  82 + $('.menu-toggler.sidebar-toggler').click();
  83 +
  84 + $("#date").datetimepicker({
  85 + format : 'YYYY-MM-DD',
  86 + locale : 'zh-cn'
  87 + });
  88 +
  89 + var d = new Date();
  90 + var year = d.getFullYear();
  91 + var mon = (d.getMonth()+1)>9?(d.getMonth()+1):("0"+(d.getMonth()+1));
  92 + var day = d.getDate()>9?d.getDate():("0"+d.getDate());
  93 + $("#date").val(year + "-" + mon + "-" + day);
  94 +
  95 +
  96 + var date, car, driver;
  97 + $("#query").on("click",function(){
  98 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  99 + layer.msg("请选择日期");
  100 + return;
  101 + }
  102 + date = $("#date").val();
  103 + car = $("#car").val();
  104 + driver = $("#driver").val();
  105 + var i = layer.load(2);
  106 + $get('/refuel/queryDaily',{date:date,car:car,driver:driver,type:'query'},function(result){
  107 + // 把数据填充到模版中
  108 + var tbodyHtml = template('refuel_daily',{list:result});
  109 + // 把渲染好的模版html文本追加到表格中
  110 + $('#tbody').html(tbodyHtml);
  111 + layer.close(i);
  112 + });
  113 + });
  114 +
  115 + $("#upload").on("click", function(){
  116 + $.get('refuelUpload.html', function(m){$(pjaxContainer).append(m);});
  117 + });
  118 +
  119 +});
  120 +</script>
  121 +<script type="text/html" id="refuel_daily">
  122 + {{each list as obj i}}
  123 + <tr>
  124 + <td>{{i + 1}}</td>
  125 + <td>{{obj.date}}</td>
  126 + <td>{{obj.line}}</td>
  127 + <td>{{obj.car}}</td>
  128 + <td>{{obj.driver}}</td>
  129 + <td>{{obj.oil}}</td>
  130 + <td>{{obj.realMileage}}</td>
  131 + <td>{{obj.consume}}</td>
  132 + </tr>
  133 + {{/each}}
  134 + {{if list.length == 0}}
  135 + <tr>
  136 + <td colspan="15"><h6 class="muted">没有找到相关数据</h6></td>
  137 + </tr>
  138 + {{/if}}
  139 +</script>
0 140 \ No newline at end of file
... ...