Browse Source

消毒申请导出、月统计导出

lzm 2 years ago
parent
commit
1f151e17bb

+ 0 - 5
sp-admin/.idea/.gitignore

@@ -1,5 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/

+ 43 - 1
sp-admin/sa-view/tb-disinfect/tb-disinfect-list.html

@@ -28,6 +28,7 @@
 				<div class="fast-btn">
 <!--					<el-button size="mini" type="primary" @click="add()">新增</el-button>-->
 					<el-button size="mini" type="info" @click="sa.f5()">刷新</el-button>
+					<el-button type="warning" icon="el-icon-download" @click="exportFn()">导出</el-button>
 				</div>
 				<!-- ------------- 数据列表 ------------- -->
 				<el-table class="data-table" ref="data-table" :data="dataList" >
@@ -68,6 +69,21 @@
 				<!-- ------------- 分页 ------------- -->
 				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
 			</div>
+			<el-dialog title="提示" :visible.sync="emodel.visible" width="36%">
+				<span>日期范围:</span>
+				<el-form size="mini">
+					<div class="c-item">
+						<el-date-picker size="mini" v-model="dataTime" type="daterange" unlink-panels="false"
+										range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
+										format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
+						</el-date-picker>
+					</div>
+				</el-form>
+				<span slot="footer" class="dialog-footer">
+					<el-button @click="emodel.visible = false">取 消</el-button>
+					<el-button type="primary" @click="sureExport">确 定</el-button>
+				</span>
+			</el-dialog>
 		</div>
 		<script>
 			var app = new Vue({
@@ -108,9 +124,35 @@
 						sortType: 0		// 排序方式 
 					},
 					dataCount: 0,
-					dataList: [], // 数据集合 
+					dataList: [], // 数据集合
+					emodel: {
+						visible: false,
+						form: {
+							beginTime: '',
+							endTime: ''
+						}
+					},
+					dataTime: [],
 				},
 				methods: {
+					exportFn() {
+						Object.assign(this.emodel, {
+							visible: true,
+						})
+					},
+					sureExport() {
+						if (this.dataTime.length != 0) {
+							this.emodel.form.beginTime = this.dataTime[0];
+							this.emodel.form.endTime = this.dataTime[1];
+						} else{
+							sa.msg("请选择日期范围");
+							return;
+						}
+						sa.ajax('/TbDisinfect/export/disinfect', this.emodel.form,  function(resp) {
+							window.open(resp.data);
+							this.emodel.visible = false;
+						}.bind(this));
+					},
 					// 刷新
 					f5: function() {
 						sa.ajax('/TbDisinfect/getList', sa.removeNull(this.p), function(res) {

+ 33 - 0
sp-admin/sa-view/tb-fee-statistics/month-statistcs-list.html

@@ -45,6 +45,7 @@
 						</el-date-picker>
 					</div>
 					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
+					<el-button type="warning" icon="el-icon-download" @click="exportFn()">导出</el-button>
 					<br/>
 				</el-form>
 				<!-- ------------- 快捷按钮 ------------- -->
@@ -77,6 +78,17 @@
 				<!-- ------------- 分页 ------------- -->
 				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
 			</div>
+			<el-dialog title="提示" :visible.sync="emodel.visible" width="38%">
+				<!-- 日期选择器 -->
+				<div class="c-item">
+					<label class="c-label">月份:</label>
+					<el-date-picker type="month" value-format="yyyy-MM" v-model="emodel.form.exportMonth"  placeholder="选择月份"  ></el-date-picker>
+				</div>
+				<span slot="footer" class="dialog-footer">
+					<el-button @click="emodel.visible = false">取 消</el-button>
+					<el-button type="primary" @click="sureExport">确 定</el-button>
+				</span>
+			</el-dialog>
 		</div>
 		<script>
 			var app = new Vue({
@@ -111,8 +123,29 @@
 						beginMonth: '', //查询开始时间
 						endMonth: '', //查询结束时间
 					},
+					emodel: {
+						visible: false,
+						form: {
+							exportMonth: '', //导出月份
+						}
+					},
 				},
 				methods: {
+					exportFn() {
+						Object.assign(this.emodel, {
+							visible: true,
+						})
+					},
+					sureExport() {
+						if (this.emodel.form.exportMonth == '') {
+							sa.msg("请选择月份");
+							return;
+						}
+						sa.ajax('/TbFeeStatistics/export/monthStatistics', this.emodel.form,  function(resp) {
+							window.open(resp.data);
+							this.emodel.visible = false;
+						}.bind(this));
+					},
 					// 刷新
 					f5: function() {
 						if ( this.selectMonth != null && this.selectMonth.length != 0) {

+ 13 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -345,4 +345,17 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
       this.removeById(id);
         return AjaxJson.getSuccess();
     }
+
+    public List<TbBusinessCar> findInCarByDay(String day){
+        QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
+        qw.like("real_in_time", day);
+        List<TbBusinessCar> list = this.list(qw);
+        return list;
+    }
+    public List<TbBusinessCar> findOutCarByDay(String day){
+        QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
+        qw.like("real_out_time", day);
+        List<TbBusinessCar> list = this.list(qw);
+        return list;
+    }
 }

+ 138 - 0
sp-server/src/main/java/com/pj/project/tb_disinfect/ExportDisnfectDTO.java

@@ -0,0 +1,138 @@
+package com.pj.project.tb_disinfect;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+public class ExportDisnfectDTO {
+
+    private Integer index;
+
+    private String customerName;
+
+    /**
+     * 发货人
+     */
+    private String sendPeople;
+
+    /**
+     * 收货人
+     */
+    private String receivePeople;
+
+    /**
+     * 品名
+     */
+    private String goodsName;
+
+    /**
+     * 产地
+     */
+    private String origin;
+
+    /**
+     * 数量
+     */
+    private Integer num;
+
+    /**
+     * 重量
+     */
+    private String grossWeight;
+
+    /**
+     * 规格
+     */
+    private Double unit;
+
+    /**
+     * 包装
+     */
+    private String pack;
+
+    /**
+     * 标记
+     */
+    private String flag;
+
+    /**
+     * 号码
+     */
+    private String phone;
+
+    /**
+     * 启运地
+     */
+    private String sourceAddress;
+
+    /**
+     * 到达口岸
+     */
+    private String arrivePart;
+
+    /**
+     * 运输工具
+     */
+    private String carName;
+
+    /**
+     * 运输工具号码
+     */
+    private String carNo;
+
+    /**
+     * 中国运输工具
+     */
+    private String chinaCarName;
+
+    /**
+     * 中国运输号码
+     */
+    private String chinaCarNo;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 申请单位
+     */
+    private String applyUnit;
+
+    /**
+     * 申请人
+     */
+    private String declarePeople;
+
+    /**
+     * 申请人联系号码
+     */
+    private String declarePhone;
+
+    /**
+     * 申请时间
+     */
+    private String applyTime;
+
+    /**
+     * 受理人
+     */
+    private String acceptPeople;
+
+    /**
+     * 受理时间
+     */
+    private String acceptTime;
+
+    /**
+     * 计费(分)
+     */
+    private BigDecimal money;
+
+}

+ 5 - 0
sp-server/src/main/java/com/pj/project/tb_disinfect/TbDisinfectController.java

@@ -80,6 +80,11 @@ public class TbDisinfectController {
 		List<TbDisinfect> list = tbDisinfectService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
+    @RequestMapping("export/disinfect")
+    public AjaxJson exportDisinfect() throws Exception{
+        SoMap so = SoMap.getRequestSoMap();
+	    return AjaxJson.getSuccessData(tbDisinfectService.exportDisinfect(so));
+    }
 	
 	
 	

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_disinfect/TbDisinfectMapper.xml

@@ -72,6 +72,10 @@
 			<if test=' this.has("acceptPeople") '> and accept_people = #{acceptPeople} </if>
 			<if test=' this.has("acceptTime") '> and accept_time = #{acceptTime} </if>
 			<if test=' this.has("money") '> and money = #{money} </if>
+            <if test=' this.has("beginTime") and this.has("endTime") '>
+                and apply_time >= #{beginTime}
+                and apply_time  &lt;= #{endTime}
+            </if>
 		</where>
 		order by
 		<choose>

+ 62 - 1
sp-server/src/main/java/com/pj/project/tb_disinfect/TbDisinfectService.java

@@ -1,18 +1,32 @@
 package com.pj.project.tb_disinfect;
 
-import java.util.List;
+import java.io.File;
+import java.io.InputStream;
+import java.util.*;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.pj.current.config.MyConfig;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessMapper;
+import com.pj.project.tb_fee_details.ExportFeeDetailDTO;
+import com.pj.project4sp.uploadfile.UploadUtil;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 
 import com.pj.utils.sg.*;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
+
 /**
  * Service: tb_disinfect -- 消毒申请单
  * @author qzy 
@@ -24,6 +38,8 @@ public class TbDisinfectService extends ServiceImpl<TbDisinfectMapper, TbDisinfe
 	/** 底层 Mapper 对象 */
 	@Autowired
 	TbDisinfectMapper tbDisinfectMapper;
+	@Resource
+    MyConfig myConfig;
 
 	/** 增 */
 	void add(TbDisinfect t){
@@ -49,6 +65,51 @@ public class TbDisinfectService extends ServiceImpl<TbDisinfectMapper, TbDisinfe
 	List<TbDisinfect> getList(SoMap so) {
 		return tbDisinfectMapper.getList(so);	
 	}
+
+	public String exportDisinfect(SoMap so) throws Exception{
+        Date now = new Date();
+        String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
+        String beginTime = so.getString("beginTime");
+        String endTime = so.getString("endTime");
+        so.put("beginTime", beginTime + " 00:00:00");
+        so.put("endTime", endTime + " 23:59:59");
+        String time = beginTime + "至" + endTime;
+        Map<String, String> head = new HashMap<>();
+        head.put("time", time);
+        head.put("exportTime", nowStr);
+        List<ExportDisnfectDTO>  exportList = new ArrayList<>();
+        List<TbDisinfect> list = this.getList(so);
+        Integer index = 0;
+        for (TbDisinfect disinfect : list) {
+            ExportDisnfectDTO dto = new ExportDisnfectDTO();
+            BeanUtil.copyProperties(disinfect, dto);
+            Double grossWeight = disinfect.getGrossWeight()*1000;
+            dto.setIndex(++index).setGrossWeight(grossWeight.toString());
+            exportList.add(dto);
+        }
+        String separator = File.separator;
+        String today = DateUtil.today();
+        String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
+        String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
+        String extPath = "disinfect" + separator + today + separator;
+        String fileName = "消毒申请记录_" + time + ".xlsx";
+        String savePath = rootPath + separator + extPath;
+        File saveFIle = new File(savePath);
+        if (!saveFIle.exists()) {
+            saveFIle.mkdirs();
+        }
+        ClassPathResource classPathResource = new ClassPathResource("static/disinfect.xlsx");
+        InputStream tempInputStream =classPathResource.getInputStream();
+        ExcelWriter excelWriter = EasyExcel.write(savePath + fileName, ExportFeeDetailDTO.class)
+                .withTemplate(tempInputStream).build();
+        WriteSheet writeSheet = EasyExcel.writerSheet().build();
+        FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//换行
+        excelWriter.fill(head, writeSheet);
+        excelWriter.fill(exportList, fillConfig, writeSheet);
+        excelWriter.finish();
+        return prefix + "/disinfect/" + today + "/消毒申请记录_" + time + ".xlsx";
+
+    }
 	
 
 }

+ 28 - 0
sp-server/src/main/java/com/pj/project/tb_fee_statistics/ExportMonthDataDTO.java

@@ -0,0 +1,28 @@
+package com.pj.project.tb_fee_statistics;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @Auther: lzm
+ * @Date: 2022/05/09/9:56
+ * @Description:
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+public class ExportMonthDataDTO {
+
+    private String index;
+    private String day;
+    private Integer inNum;
+    private Integer outNum;
+    private Integer addNum;
+    private BigDecimal dayMoney;
+
+}

+ 6 - 0
sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsController.java

@@ -98,6 +98,12 @@ public class TbFeeStatisticsController {
         TbFeeStatistics feeStatistics = tbFeeStatisticsService.updateParkNum(day);
         return AjaxJson.getSuccessData(feeStatistics);
     }
+
+    @RequestMapping("export/monthStatistics")
+    public AjaxJson exportMonthStatistics() throws Exception{
+        SoMap so = SoMap.getRequestSoMap();
+        return AjaxJson.getSuccessData(tbFeeStatisticsService.exportMonthStatistics(so));
+    }
 	
 	
 	

+ 87 - 2
sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsService.java

@@ -1,26 +1,37 @@
 package com.pj.project.tb_fee_statistics;
 
+import java.io.File;
+import java.io.InputStream;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.date.Month;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.wx.bo.PriceBO;
+import com.pj.current.config.MyConfig;
 import com.pj.current.config.PartConfig;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessService;
 import com.pj.project.tb_business_car.TbBusinessCar;
 import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_business_item.TbBusinessItem;
+import com.pj.project.tb_fee_details.ExportFeeDetailDTO;
 import com.pj.project.tb_fee_details.TbFeeDetails;
 import com.pj.project.tb_fee_details.TbFeeDetailsService;
+import com.pj.project4sp.uploadfile.UploadUtil;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -51,6 +62,8 @@ public class TbFeeStatisticsService extends ServiceImpl<TbFeeStatisticsMapper, T
     TbFeeDetailsService tbFeeDetailsService;
     @Resource
     private PartConfig partConfig;
+    @Resource
+    private MyConfig myConfig;
 
     /**
      * 增
@@ -259,4 +272,76 @@ public class TbFeeStatisticsService extends ServiceImpl<TbFeeStatisticsMapper, T
         return feeStatistics;
     }
 
+    public String exportMonthStatistics(SoMap so) throws Exception{
+        String monthStr = so.getString("exportMonth");
+        so.put("month",monthStr);
+        Date month = DateUtil.parse(monthStr, "yyyy-MM");
+        Month monthEnum = DateUtil.monthEnum(month);
+        boolean leap = DateUtil.isLeapYear(DateUtil.year(month));
+        Integer lastDay = monthEnum.getLastDay(leap);
+        Map<String, ExportMonthDataDTO> dataMap = new TreeMap<>();
+        for(int i=1; i<=lastDay ; i++){
+            ExportMonthDataDTO data = new ExportMonthDataDTO();
+            String index = i<10 ? "0"+i : ""+i;
+            String day = monthStr + "-" + index;
+            data.setIndex(index).setDay(day);
+            dataMap.put(index, data);
+        }
+        List<TbFeeStatistics> list = this.getList(so);
+        Integer totalIn = 0;
+        Integer totalOut= 0;
+        Integer totalAdd = 0;
+        BigDecimal totalMoney = BigDecimal.valueOf(0);
+        for (TbFeeStatistics statistics : list) {
+            String day = statistics.getDay();
+            String key = StrUtil.sub(day, 8, 10);
+            ExportMonthDataDTO data = dataMap.get(key);
+            List<TbBusinessCar> inCarList = tbBusinessCarService.findInCarByDay(day);
+            List<TbBusinessCar> outCarList = tbBusinessCarService.findOutCarByDay(day);
+            Integer inNum = inCarList != null ? inCarList.size() : 0;
+            Integer outNum = outCarList != null ? outCarList.size() : 0;
+            Integer addNum = inNum - outNum;
+            data.setDay(day).setInNum(inNum).setOutNum(outNum).setAddNum(addNum).setDayMoney(statistics.getTaxMoney());
+            //dataMap.put(key, data);
+            totalIn += inNum;
+            totalOut += outNum;
+            totalAdd += addNum;
+            totalMoney = totalMoney.add(statistics.getTaxMoney());
+        }
+        List<ExportMonthDataDTO> exportList = new ArrayList<>(dataMap.values()) ;
+
+        Map<String, String> head = new HashMap<>();
+        Integer exportMonth = Integer.valueOf(StrUtil.sub(monthStr, 5,7));
+        String today = DateUtil.today();
+        head.put("exportMonth", exportMonth + "");
+        head.put("exportDay", today);
+        head.put("totalIn", totalIn + "");
+        head.put("totalOut", totalOut + "");
+        head.put("totalAdd", totalAdd + "");
+        head.put("totalMoney", totalMoney.toString());
+
+        String separator = File.separator;
+
+        String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
+        String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
+        String extPath = "feeStatistics_month" + separator + today + separator;
+        String fileName = "收费月统计表_" + monthStr + ".xlsx";
+        String savePath = rootPath + separator + extPath;
+        File saveFIle = new File(savePath);
+        if (!saveFIle.exists()) {
+            saveFIle.mkdirs();
+        }
+
+        ClassPathResource classPathResource = new ClassPathResource("static/month-fee.xlsx");
+        InputStream tempInputStream =classPathResource.getInputStream();
+        ExcelWriter excelWriter = EasyExcel.write(savePath + fileName, ExportFeeDetailDTO.class)
+                .withTemplate(tempInputStream).build();
+        WriteSheet writeSheet = EasyExcel.writerSheet().build();
+        FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//换行
+        excelWriter.fill(head, writeSheet);
+        excelWriter.fill(exportList, fillConfig, writeSheet);
+        excelWriter.finish();
+        return prefix + "/feeStatistics_month/" + today + "/收费月统计表_" + monthStr + ".xlsx";
+    }
+
 }

BIN
sp-server/src/main/resources/static/disinfect.xlsx


BIN
sp-server/src/main/resources/static/month-fee.xlsx