16 changed files with 2297 additions and 10 deletions
-
12pom.xml
-
239src/main/java/com/srq/modules/jst/controller/JstController.java
-
191src/main/java/com/srq/modules/jst/dao/JstDao.java
-
313src/main/java/com/srq/modules/jst/dao/impl/JstDaoImpl.java
-
43src/main/java/com/srq/modules/jst/data/ColumnData.java
-
60src/main/java/com/srq/modules/jst/data/GetParamInData.java
-
70src/main/java/com/srq/modules/jst/data/JstExceptionData.java
-
57src/main/java/com/srq/modules/jst/data/SalesOrderBrandData.java
-
118src/main/java/com/srq/modules/jst/data/SalesOrderFileData.java
-
57src/main/java/com/srq/modules/jst/data/SalesOrderWarehouseData.java
-
256src/main/java/com/srq/modules/jst/data/ShopStoreData.java
-
137src/main/java/com/srq/modules/jst/service/JstService.java
-
482src/main/java/com/srq/modules/jst/service/impl/JstServiceImpl.java
-
114src/main/java/com/srq/modules/jst/util/ExcelListener.java
-
151src/main/java/com/srq/modules/jst/util/SalesOrderExcelListener.java
-
7src/main/resources/application.yml
@ -0,0 +1,239 @@ |
|||
package com.srq.modules.jst.controller; |
|||
|
|||
|
|||
import com.srq.common.utils.R; |
|||
import com.srq.modules.jst.data.*; |
|||
import com.srq.modules.jst.service.JstService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("/jst") |
|||
public class JstController { |
|||
|
|||
@Autowired |
|||
private JstService jstService; |
|||
private static final Logger logger = LoggerFactory.getLogger(JstController.class); |
|||
|
|||
|
|||
@RequestMapping(value = "/getSaleOrderFileHist") |
|||
public R getSaleOrderFileHist(@RequestBody SalesOrderFileData inData){ |
|||
List<SalesOrderFileData> resultList = jstService.getSaleOrderFileHist(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!") |
|||
.put("rows", resultList) |
|||
.put("total", resultList.size()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 文件上传 |
|||
* @author LR |
|||
* @date 2023/7/25 15:02 |
|||
* @version 1.0 |
|||
*/ |
|||
@PostMapping("/uploadSalesOrderFile") |
|||
public R uploadSalesOrderFile(@RequestParam("file") MultipartFile file, @ModelAttribute GetParamInData inData) throws Exception { |
|||
jstService.uploadSalesOrderFile(file, inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: excel批量导入数据表中 |
|||
* @author LR |
|||
* @date 2023/7/31 11:37 |
|||
* @version 1.0 |
|||
*/ |
|||
@PostMapping("/batchInsertSalesOrderItems") |
|||
public R batchInsertSalesOrderItems(@RequestBody SalesOrderFileData inData) throws Exception { |
|||
jstService.batchInsertSalesOrderItems(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 检查销售单信息 |
|||
* @author LR |
|||
* @date 2023/7/27 15:58 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/checkSalesOrderException") |
|||
public R checkSalesOrderException(){ |
|||
jstService.checkSalesOrderException(); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @description: 获取异常的信息 |
|||
* @author LR |
|||
* @date 2023/7/24 17:11 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/getExceptionList") |
|||
public R getExceptionList(@RequestBody JstExceptionData inData){ |
|||
List<JstExceptionData> resultList = jstService.getExceptionList(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!") |
|||
.put("rows", resultList) |
|||
.put("total", resultList.size()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 文件下载 |
|||
* @author LR |
|||
* @date 2023/7/31 18:58 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/downSalesOrder") |
|||
public void downSalesOrder(@ModelAttribute GetParamInData inData, HttpServletResponse response) throws Exception { |
|||
jstService.downSalesOrder(inData, response); |
|||
} |
|||
|
|||
/** |
|||
* @description: 获取当前的店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/2 18:08 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/getShopStores") |
|||
public R getShopStores(@RequestBody ShopStoreData inData){ |
|||
List<ShopStoreData> resultList = jstService.getShopStores(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!") |
|||
.put("rows", resultList) |
|||
.put("total", resultList.size()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 插入当前的店铺数据 |
|||
* @author LR |
|||
* @date 2023/8/3 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/insertShopStore") |
|||
public R insertShopStore(@RequestBody ShopStoreData inData){ |
|||
jstService.insertShopStore(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 修改店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/3 18:06 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/saveShopStore") |
|||
public R saveShopStore(@RequestBody ShopStoreData inData){ |
|||
jstService.saveShopStore(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 销售单的品牌信息 |
|||
* @author LR |
|||
* @date 2023/8/4 9:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/getSalesOrderBrand") |
|||
public R getSalesOrderBrand(@RequestBody SalesOrderBrandData inData){ |
|||
List<SalesOrderBrandData> resultList = jstService.getSalesOrderBrand(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!") |
|||
.put("rows", resultList) |
|||
.put("total", resultList.size()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 插入当前的品牌数据 |
|||
* @author LR |
|||
* @date 2023/8/3 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/insertSalesOrderBrand") |
|||
public R insertSalesOrderBrand(@RequestBody SalesOrderBrandData inData){ |
|||
jstService.insertSalesOrderBrand(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 修改品牌的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/3 18:06 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/saveSalesOrderBrand") |
|||
public R saveSalesOrderBrand(@RequestBody SalesOrderBrandData inData){ |
|||
jstService.saveSalesOrderBrand(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 获取销售明细的仓库 |
|||
* @author LR |
|||
* @date 2023/8/4 11:26 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/getSalesOrderWarehouse") |
|||
public R getSalesOrderWarehouse(@RequestBody SalesOrderWarehouseData inData){ |
|||
List<SalesOrderWarehouseData> resultList = jstService.getSalesOrderWarehouse(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!") |
|||
.put("rows", resultList) |
|||
.put("total", resultList.size()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 新增销售单的仓库信息 |
|||
* @author LR |
|||
* @date 2023/8/4 13:20 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/insertSalesOrderWarehouse") |
|||
public R insertSalesOrderWarehouse(@RequestBody SalesOrderWarehouseData inData){ |
|||
jstService.insertSalesOrderWarehouse(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 保存销售单的仓库信息 |
|||
* @author LR |
|||
* @date 2023/8/4 13:30 |
|||
* @version 1.0 |
|||
*/ |
|||
@RequestMapping(value = "/saveSalesOrderWarehouse") |
|||
public R saveSalesOrderWarehouse(@RequestBody SalesOrderWarehouseData inData){ |
|||
jstService.saveSalesOrderWarehouse(inData); |
|||
return R.ok() |
|||
.put("code", 200) |
|||
.put("msg", "操作成功!"); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,191 @@ |
|||
package com.srq.modules.jst.dao; |
|||
|
|||
import com.srq.modules.jst.data.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description: 接口dao |
|||
* @author LR |
|||
* @date 2023/7/24 16:23 |
|||
* @version 1.0 |
|||
*/ |
|||
public interface JstDao { |
|||
|
|||
/** |
|||
* @description: 查询当前的上传记录表 |
|||
* @author LR |
|||
* @date 2023/7/31 10:34 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderFileData> getSaleOrderFileHist(String fileName, String status); |
|||
|
|||
/** |
|||
* @description: 保存文件上传的记录数据 |
|||
* @author LR |
|||
* @date 2023/7/31 10:28 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertUploadFileHist(SalesOrderFileData salesOrderFile); |
|||
|
|||
/** |
|||
* @description: 获取销售单需要导入的key |
|||
* @author LR |
|||
* @date 2023/7/25 15:23 |
|||
* @version 1.0 |
|||
*/ |
|||
List<ColumnData> getSalesOrderColumns(); |
|||
|
|||
/** |
|||
* @description: 清空当前销售明细记录表 |
|||
* @author LR |
|||
* @date 2023/7/31 11:59 |
|||
* @version 1.0 |
|||
*/ |
|||
void clearSalesOrder(); |
|||
|
|||
/** |
|||
* @description: 批量保存当前的参数 |
|||
* @author LR |
|||
* @date 2023/7/27 10:00 |
|||
* @version 1.0 |
|||
*/ |
|||
void batchInsertSalesOrder(List<Map<String, String>> resultList); |
|||
|
|||
/** |
|||
* @description: 查询当前明细行数 |
|||
* @author LR |
|||
* @date 2023/7/31 13:30 |
|||
* @version 1.0 |
|||
*/ |
|||
int countSalesOrder(); |
|||
|
|||
/** |
|||
* @description: 修改导入的数量和时间信息 |
|||
* @author LR |
|||
* @date 2023/7/31 13:36 |
|||
* @version 1.0 |
|||
*/ |
|||
void updateSalesOrderFileInsertData(SalesOrderFileData salesOrderFile); |
|||
|
|||
/** |
|||
* @description: 修改销售单的检查信息 |
|||
* @author LR |
|||
* @date 2023/7/31 16:19 |
|||
* @version 1.0 |
|||
*/ |
|||
void updateSalesOrderFileCheckData(SalesOrderFileData salesOrderFile); |
|||
|
|||
/** |
|||
* @description: 获取异常的信息 |
|||
* @author LR |
|||
* @date 2023/7/24 17:13 |
|||
* @version 1.0 |
|||
*/ |
|||
List<JstExceptionData> getExceptionList(String exceptionType, String exceptionDes, String exceptionData); |
|||
|
|||
/** |
|||
* @description: 查询当前数据的集合 |
|||
* @author LR |
|||
* @date 2023/7/31 18:09 |
|||
* @version 1.0 |
|||
*/ |
|||
List<Map<String, Object>> getSaleOrderList(); |
|||
|
|||
/** |
|||
* @description: 查询店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/3 17:37 |
|||
* @version 1.0 |
|||
*/ |
|||
List<ShopStoreData> getShopStores(String shopId, String shopName); |
|||
|
|||
/** |
|||
* @description: 按照店铺的编号查询店铺信息 |
|||
* @author LR |
|||
* @date 2023/8/3 17:54 |
|||
* @version 1.0 |
|||
*/ |
|||
ShopStoreData getShopStoreByShopId(String shopId); |
|||
|
|||
/** |
|||
* @description: 新增一个店铺的信息 |
|||
* @author LR |
|||
* @date 2023/8/3 17:54 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertShopStore(ShopStoreData shopStore); |
|||
|
|||
/** |
|||
* @description: 保存店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/3 18:07 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveShopStore(ShopStoreData shopStore); |
|||
|
|||
/** |
|||
* @description: 销售单的品牌信息 |
|||
* @author LR |
|||
* @date 2023/8/4 9:54 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderBrandData> getSalesOrderBrand(String brandContract, String brandName); |
|||
|
|||
/** |
|||
* @description: 按照品牌的名称查询品牌 |
|||
* @author LR |
|||
* @date 2023/8/4 10:10 |
|||
* @version 1.0 |
|||
*/ |
|||
SalesOrderBrandData getSalesOrderBrandByBrandName(String brandName); |
|||
|
|||
/** |
|||
* @description: 新增的销售单品牌 |
|||
* @author LR |
|||
* @date 2023/8/4 10:14 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertSalesOrderBrand(SalesOrderBrandData inData); |
|||
|
|||
/** |
|||
* @description: 修改销售单的品牌域 |
|||
* @author LR |
|||
* @date 2023/8/4 10:53 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveSalesOrderBrand(SalesOrderBrandData inData); |
|||
|
|||
/** |
|||
* @description: 查询销售单的仓库数据 |
|||
* @author LR |
|||
* @date 2023/8/4 11:28 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderWarehouseData> getSalesOrderWarehouse(String warehouseName); |
|||
|
|||
/** |
|||
* @description: 按照仓库名查询仓库的信息 |
|||
* @author LR |
|||
* @date 2023/8/4 13:23 |
|||
* @version 1.0 |
|||
*/ |
|||
SalesOrderWarehouseData getSalesOrderWarehouseByWarehouseName(String warehouseName); |
|||
|
|||
/** |
|||
* @description: 插入销售单的仓库 |
|||
* @author LR |
|||
* @date 2023/8/4 13:25 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertSalesOrderWarehouse(SalesOrderWarehouseData inData); |
|||
|
|||
/** |
|||
* @description: 保存销售单的仓库 |
|||
* @author LR |
|||
* @date 2023/8/4 15:23 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveSalesOrderWarehouse(SalesOrderWarehouseData inData); |
|||
} |
|||
@ -0,0 +1,313 @@ |
|||
package com.srq.modules.jst.dao.impl; |
|||
|
|||
import com.srq.modules.jst.dao.JstDao; |
|||
import com.srq.modules.jst.data.*; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
|||
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Repository |
|||
public class JstDaoImpl implements JstDao { |
|||
|
|||
@Value("${jst.dataBaseName}") |
|||
private String dataBaseName; |
|||
@Autowired |
|||
private NamedParameterJdbcTemplate parameterJdbcTemplate; |
|||
|
|||
@Override |
|||
public List<SalesOrderFileData> getSaleOrderFileHist(String fileName, String status) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, file_name, file_path, status, upload_date, upload_by,"); |
|||
sql.append(" insert_date, insert_by, check_date, check_by, item_count"); |
|||
sql.append(" FROM " +dataBaseName+".sales_order_file sof"); |
|||
sql.append(" WHERE 1 = 1 "); |
|||
//判断查询的条件 |
|||
if(!(null == fileName || "".equals(fileName))){ |
|||
sql.append(" AND sof.file_name LIKE '%"+fileName+"%'"); |
|||
} |
|||
if(!(null == status || "".equals(status))){ |
|||
sql.append(" AND sof.status = :status"); |
|||
paramMap.put("status", status); |
|||
} |
|||
//添加排序 |
|||
sql.append(" ORDER BY sof.status, sof.id desc"); |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(SalesOrderFileData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public void insertUploadFileHist(SalesOrderFileData salesOrderFile) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("INSERT INTO "+dataBaseName+".sales_order_file(file_name, file_path, upload_by, upload_date, status)"); |
|||
sql.append(" VALUES(:fileName, :filePath, :uploadBy, :uploadDate, :status)"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(salesOrderFile)); |
|||
} |
|||
|
|||
@Override |
|||
public List<ColumnData> getSalesOrderColumns() { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT column_name, column_type, column_index"); |
|||
sql.append(" FROM " +dataBaseName+".sales_order_column"); |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(ColumnData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public void clearSalesOrder() { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("TRUNCATE TABLE " +dataBaseName+ ".sales_order"); |
|||
parameterJdbcTemplate.update(sql.toString(), paramMap); |
|||
} |
|||
|
|||
@Override |
|||
public void batchInsertSalesOrder(List<Map<String, String>> resultList) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("INSERT INTO "+dataBaseName+".sales_order(内部订单号, 标记多标签, 售后单号, 订单类型, 订单状态, 发货仓,"); |
|||
sql.append(" 店铺, 买家账号, 卖家备注, 订单日期, 发货日期, 付款日期,"); |
|||
sql.append(" 省, 市, 区县, 快递公司, 快递单号, 商品编码,"); |
|||
sql.append(" 产品分类, 品牌, 成本价, 销售数量, 赠品数量, 销售金额,"); |
|||
sql.append(" 销售成本, 当期退货数量, 当期退货金额, 商店站点, 订单来源, 店铺编号,"); |
|||
sql.append(" 业务员, 币种, 商品状态, 汇率, 是否进IFS, 是否是样品)"); |
|||
sql.append(" VALUES(:内部订单号, :标记多标签, :售后单号, :订单类型, :订单状态, :发货仓,"); |
|||
sql.append(" :店铺, :买家账号, :卖家备注, :订单日期, :发货日期, :付款日期,"); |
|||
sql.append(" :省, :市, :区县, :快递公司, :快递单号, :商品编码,"); |
|||
sql.append(" :产品分类, :品牌, :成本价, :销售数量, :赠品数量, :销售金额,"); |
|||
sql.append(" :销售成本, :当期退货数量, :当期退货金额, :商店站点, :订单来源, :店铺编号,"); |
|||
sql.append(" :业务员, :币种, :商品状态, :汇率, :是否进IFS, :是否是样品)"); |
|||
parameterJdbcTemplate.batchUpdate(sql.toString(), SqlParameterSourceUtils.createBatch(resultList.toArray())); |
|||
} |
|||
|
|||
@Override |
|||
public int countSalesOrder() { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT COUNT(1)"); |
|||
sql.append(" FROM " +dataBaseName+".sales_order"); |
|||
return parameterJdbcTemplate.queryForObject(sql.toString(), paramMap, Integer.class); |
|||
} |
|||
|
|||
@Override |
|||
public void updateSalesOrderFileInsertData(SalesOrderFileData salesOrderFile) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("UPDATE " +dataBaseName+ ".sales_order_file"); |
|||
sql.append(" SET insert_by = :insertBy, insert_date = :insertDate, item_count = :itemCount, status = :status"); |
|||
sql.append(" WHERE id = :id"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(salesOrderFile)); |
|||
} |
|||
|
|||
@Override |
|||
public void updateSalesOrderFileCheckData(SalesOrderFileData salesOrderFile) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("UPDATE " +dataBaseName+ ".sales_order_file"); |
|||
sql.append(" SET check_by = :checkBy, check_date = :checkDate, item_count = :itemCount, status = :status"); |
|||
sql.append(" WHERE id = :id"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(salesOrderFile)); |
|||
} |
|||
|
|||
@Override |
|||
public List<JstExceptionData> getExceptionList(String exceptionType, String exceptionDesc, String exceptionData) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, exception_type, exception_desc, exception_data, created_date exceptionTime"); |
|||
sql.append(" FROM " +dataBaseName+".sales_order_exception soc"); |
|||
sql.append(" WHERE 1 = 1 "); |
|||
//查询条件 |
|||
if(!(null == exceptionType || "".equals(exceptionType))){ |
|||
sql.append(" AND soc.exception_type = :exceptionType"); |
|||
paramMap.put("exceptionType", exceptionType); |
|||
} |
|||
if(!(null == exceptionDesc || "".equals(exceptionDesc))){ |
|||
sql.append(" AND soc.exception_desc = :exceptionDesc"); |
|||
paramMap.put("exceptionDesc", exceptionDesc); |
|||
} |
|||
if(!(null == exceptionData || "".equals(exceptionData))){ |
|||
sql.append(" AND soc.exception_data = :exceptionData"); |
|||
paramMap.put("exceptionData", exceptionData); |
|||
} |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(JstExceptionData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> getSaleOrderList() { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT 内部订单号, 标记多标签, 售后单号, 订单类型, 订单状态, 发货仓,"); |
|||
sql.append(" 店铺, 买家账号, 卖家备注, 订单日期, 发货日期, 付款日期,"); |
|||
sql.append(" 省, 市, 区县, 快递公司, 快递单号, 商品编码,"); |
|||
sql.append(" 产品分类, 品牌, 成本价, 销售数量, 赠品数量, 销售金额,"); |
|||
sql.append(" 销售成本, 当期退货数量, 当期退货金额, 商店站点, 订单来源, 店铺编号,"); |
|||
sql.append(" 业务员, 币种, 商品状态, 汇率, 是否进IFS, 是否是样品"); |
|||
sql.append(" FROM " +dataBaseName+".sales_order"); |
|||
return parameterJdbcTemplate.queryForList(sql.toString(), paramMap); |
|||
} |
|||
|
|||
@Override |
|||
public List<ShopStoreData> getShopStores(String shopId, String shopName) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, contract, shop_site, shop_id, shop_name, customer_no, ship_addr_no, bill_addr_no, ship_via_code,"); |
|||
sql.append(" free_of_chg_tax_pay_party, delivery_terms, salesman_code, region_code, district_code, market_code,"); |
|||
sql.append(" pay_term_id, jinsui_invoice_db, use_price_incl_tax_db, supply_country, tax_liability, tax_code,"); |
|||
sql.append(" currency_code, return_approver_id, pure_custom, distinguish_custom, consignment_flag, order_type"); |
|||
sql.append(" FROM " +dataBaseName+".shop_map_customer_info smc"); |
|||
sql.append(" WHERE 1 = 1"); |
|||
//判断查询条件 |
|||
if(!(null == shopId || "".equals(shopId))){ |
|||
sql.append(" AND smc.shop_id LIKE '%"+shopId+"%'"); |
|||
} |
|||
if(!(null == shopName || "".equals(shopName))){ |
|||
sql.append(" AND smc.shop_name LIKE '%"+shopName+"%'"); |
|||
} |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(ShopStoreData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public ShopStoreData getShopStoreByShopId(String shopId) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, contract, shop_site, shop_id, shop_name, customer_no, ship_addr_no, bill_addr_no, ship_via_code,"); |
|||
sql.append(" free_of_chg_tax_pay_party, delivery_terms, salesman_code, region_code, district_code, market_code,"); |
|||
sql.append(" pay_term_id, jinsui_invoice_db, use_price_incl_tax_db, supply_country, tax_liability, tax_code,"); |
|||
sql.append(" currency_code, return_approver_id, pure_custom, distinguish_custom, consignment_flag, order_type"); |
|||
sql.append(" FROM " +dataBaseName+".shop_map_customer_info smc"); |
|||
sql.append(" WHERE smc.shop_id = :shopId"); |
|||
paramMap.put("shopId", shopId); |
|||
List<ShopStoreData> resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(ShopStoreData.class)); |
|||
//判断结果集 |
|||
if(resultList.size() > 0){ |
|||
return resultList.get(0); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void insertShopStore(ShopStoreData shopStore) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("INSERT INTO "+dataBaseName+".shop_map_customer_info(contract, shop_site, shop_id, shop_name, customer_no, ship_addr_no, bill_addr_no, ship_via_code,"); |
|||
sql.append(" free_of_chg_tax_pay_party, delivery_terms, salesman_code,"); |
|||
sql.append(" pay_term_id, jinsui_invoice_db, use_price_incl_tax_db, supply_country, tax_liability, tax_code,"); |
|||
sql.append(" currency_code, return_approver_id, pure_custom, distinguish_custom, consignment_flag, order_type)"); |
|||
sql.append(" VALUES(:contract, :shopSite, :shopId, :shopName, :customerNo, :shipAddrNo, :billAddrNo, :shipViaCode,"); |
|||
sql.append(" :freeOfChgTaxPayParty, :deliveryTerms, :salesmanCode,"); |
|||
sql.append(" :payTermId, :jinsuiInvoiceDb, :usePriceInclTaxDb, :supplyCountry, :taxLiability, :taxCode,"); |
|||
sql.append(" :currencyCode, :returnApproverId, :pureCustom, :distinguishCustom, :consignmentFlag, :orderType)"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(shopStore)); |
|||
} |
|||
|
|||
@Override |
|||
public void saveShopStore(ShopStoreData shopStore) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("UPDATE "+dataBaseName+".shop_map_customer_info SET contract = :contract, shop_site = :shopSite,"); |
|||
sql.append(" shop_id = :shopId, shop_name = :shopName, customer_no = :customerNo, pure_custom = :pureCustom,"); |
|||
sql.append(" distinguish_custom = :distinguishCustom, consignment_flag = :consignmentFlag, order_type = :orderType"); |
|||
sql.append(" WHERE id = :id"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(shopStore)); |
|||
} |
|||
|
|||
@Override |
|||
public List<SalesOrderBrandData> getSalesOrderBrand(String brandContract, String brandName) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, brand_name, brand_contract, created_date"); |
|||
sql.append(" FROM " +dataBaseName+".sales_brand sab"); |
|||
sql.append(" WHERE 1 = 1"); |
|||
//判断查询条件 |
|||
if(!(null == brandContract || "".equals(brandContract))){ |
|||
sql.append(" AND sab.brand_contract = :brandContract"); |
|||
paramMap.put("brandContract", brandContract); |
|||
} |
|||
if(!(null == brandName || "".equals(brandName))){ |
|||
sql.append(" AND sab.brand_name LIKE '%"+brandName+"%'"); |
|||
} |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(SalesOrderBrandData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public SalesOrderBrandData getSalesOrderBrandByBrandName(String brandName) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, brand_name, brand_contract, created_date"); |
|||
sql.append(" FROM " +dataBaseName+".sales_brand sab"); |
|||
sql.append(" WHERE sab.brand_name = :brandName"); |
|||
paramMap.put("brandName", brandName); |
|||
List<SalesOrderBrandData> resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(SalesOrderBrandData.class)); |
|||
//判断结果集 |
|||
if(resultList.size() > 0){ |
|||
return resultList.get(0); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void insertSalesOrderBrand(SalesOrderBrandData inData) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("INSERT INTO "+dataBaseName+".sales_brand(brand_name, brand_contract, created_date)"); |
|||
sql.append(" VALUES(:brandName, :brandContract, :createdDate)"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); |
|||
} |
|||
|
|||
@Override |
|||
public void saveSalesOrderBrand(SalesOrderBrandData inData) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("UPDATE "+dataBaseName+".sales_brand SET brand_contract = :brandContract"); |
|||
sql.append(" WHERE id = :id"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); |
|||
} |
|||
|
|||
@Override |
|||
public List<SalesOrderWarehouseData> getSalesOrderWarehouse(String warehouseName) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, warehouse_name, warehouse_type, created_date"); |
|||
sql.append(" FROM " +dataBaseName+".sales_warehouse saw"); |
|||
sql.append(" WHERE 1 = 1"); |
|||
//判断查询条件 |
|||
if(!(null == warehouseName || "".equals(warehouseName))){ |
|||
sql.append(" AND saw.warehouse_name LIKE '%"+warehouseName+"%'"); |
|||
} |
|||
return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(SalesOrderWarehouseData.class)); |
|||
} |
|||
|
|||
@Override |
|||
public SalesOrderWarehouseData getSalesOrderWarehouseByWarehouseName(String warehouseName) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
sql.append("SELECT id, warehouse_name, warehouse_type, created_date"); |
|||
sql.append(" FROM " +dataBaseName+".sales_warehouse saw"); |
|||
sql.append(" WHERE saw.warehouse_name = :warehouseName"); |
|||
paramMap.put("warehouseName", warehouseName); |
|||
List<SalesOrderWarehouseData> resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(SalesOrderWarehouseData.class)); |
|||
//判断结果集 |
|||
if(resultList.size() > 0){ |
|||
return resultList.get(0); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void insertSalesOrderWarehouse(SalesOrderWarehouseData inData) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("INSERT INTO "+dataBaseName+".sales_warehouse(warehouse_name, warehouse_type, created_date)"); |
|||
sql.append(" VALUES(:warehouseName, :warehouseType, :createdDate)"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); |
|||
} |
|||
|
|||
@Override |
|||
public void saveSalesOrderWarehouse(SalesOrderWarehouseData inData) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("UPDATE "+dataBaseName+".sales_warehouse SET warehouse_type = :warehouseType"); |
|||
sql.append(" WHERE id = :id"); |
|||
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.srq.modules.jst.data; |
|||
|
|||
public class ColumnData { |
|||
private String columnName; |
|||
private String columnValue; |
|||
private String columnType; |
|||
private int columnIndex; |
|||
|
|||
public ColumnData() { |
|||
} |
|||
|
|||
public String getColumnName() { |
|||
return columnName; |
|||
} |
|||
|
|||
public void setColumnName(String columnName) { |
|||
this.columnName = columnName; |
|||
} |
|||
|
|||
public String getColumnValue() { |
|||
return columnValue; |
|||
} |
|||
|
|||
public void setColumnValue(String columnValue) { |
|||
this.columnValue = columnValue; |
|||
} |
|||
|
|||
public String getColumnType() { |
|||
return columnType; |
|||
} |
|||
|
|||
public void setColumnType(String columnType) { |
|||
this.columnType = columnType; |
|||
} |
|||
|
|||
public int getColumnIndex() { |
|||
return columnIndex; |
|||
} |
|||
|
|||
public void setColumnIndex(int columnIndex) { |
|||
this.columnIndex = columnIndex; |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
package com.srq.modules.jst.data; |
|||
|
|||
/** |
|||
* @author LR |
|||
* @version V1.0 |
|||
* @ClassName: GetParamInData |
|||
* @Description: get的请求参数入参 |
|||
* @date 2020年5月22日 |
|||
*/ |
|||
public class GetParamInData { |
|||
private String site; |
|||
private String orderNo;// 工单号 |
|||
private String objectID;// 设备编码 |
|||
private String remark;// 备注 |
|||
private String folder;// 文件名称 |
|||
|
|||
public GetParamInData() { |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
|
|||
public String getSite() { |
|||
return site; |
|||
} |
|||
|
|||
public void setSite(String site) { |
|||
this.site = site; |
|||
} |
|||
|
|||
public String getOrderNo() { |
|||
return orderNo; |
|||
} |
|||
|
|||
public void setOrderNo(String orderNo) { |
|||
this.orderNo = orderNo; |
|||
} |
|||
|
|||
public String getObjectID() { |
|||
return objectID; |
|||
} |
|||
|
|||
public void setObjectID(String objectID) { |
|||
this.objectID = objectID; |
|||
} |
|||
|
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
|
|||
public void setRemark(String remark) { |
|||
this.remark = remark; |
|||
} |
|||
|
|||
public String getFolder() { |
|||
return folder; |
|||
} |
|||
|
|||
public void setFolder(String folder) { |
|||
this.folder = folder; |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
package com.srq.modules.jst.data; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.apache.ibatis.type.Alias; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Alias("JstExceptionData") |
|||
public class JstExceptionData { |
|||
private String id; |
|||
private String exceptionType; |
|||
private String exceptionDesc; |
|||
private String exceptionData; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date exceptionTime; |
|||
private String dataBaseName; |
|||
|
|||
public JstExceptionData() { |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getExceptionType() { |
|||
return exceptionType; |
|||
} |
|||
|
|||
public void setExceptionType(String exceptionType) { |
|||
this.exceptionType = exceptionType; |
|||
} |
|||
|
|||
public String getExceptionDesc() { |
|||
return exceptionDesc; |
|||
} |
|||
|
|||
public void setExceptionDesc(String exceptionDesc) { |
|||
this.exceptionDesc = exceptionDesc; |
|||
} |
|||
|
|||
public String getExceptionData() { |
|||
return exceptionData; |
|||
} |
|||
|
|||
public void setExceptionData(String exceptionData) { |
|||
this.exceptionData = exceptionData; |
|||
} |
|||
|
|||
public Date getExceptionTime() { |
|||
return exceptionTime; |
|||
} |
|||
|
|||
public void setExceptionTime(Date exceptionTime) { |
|||
this.exceptionTime = exceptionTime; |
|||
} |
|||
|
|||
public String getDataBaseName() { |
|||
return dataBaseName; |
|||
} |
|||
|
|||
public void setDataBaseName(String dataBaseName) { |
|||
this.dataBaseName = dataBaseName; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
|
|||
package com.srq.modules.jst.data; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author LR |
|||
* @version 1.0 |
|||
* @description: 销售单的品牌配置 |
|||
* @date 2023/8/4 9:46 |
|||
*/ |
|||
public class SalesOrderBrandData { |
|||
private int id; |
|||
private String brandName; |
|||
private String brandContract; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date createdDate; |
|||
|
|||
public SalesOrderBrandData() { |
|||
} |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getBrandName() { |
|||
return brandName; |
|||
} |
|||
|
|||
public void setBrandName(String brandName) { |
|||
this.brandName = brandName; |
|||
} |
|||
|
|||
public String getBrandContract() { |
|||
return brandContract; |
|||
} |
|||
|
|||
public void setBrandContract(String brandContract) { |
|||
this.brandContract = brandContract; |
|||
} |
|||
|
|||
public Date getCreatedDate() { |
|||
return createdDate; |
|||
} |
|||
|
|||
public void setCreatedDate(Date createdDate) { |
|||
this.createdDate = createdDate; |
|||
} |
|||
} |
|||
@ -0,0 +1,118 @@ |
|||
|
|||
package com.srq.modules.jst.data; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.util.Date; |
|||
|
|||
public class SalesOrderFileData { |
|||
private int id; |
|||
private String fileName; |
|||
private String filePath; |
|||
private String uploadBy; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date uploadDate; |
|||
private String insertBy; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date insertDate; |
|||
private String checkBy; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date checkDate; |
|||
private String status; |
|||
private int itemCount;//明细行数 |
|||
|
|||
public SalesOrderFileData() { |
|||
} |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getFileName() { |
|||
return fileName; |
|||
} |
|||
|
|||
public void setFileName(String fileName) { |
|||
this.fileName = fileName; |
|||
} |
|||
|
|||
public String getFilePath() { |
|||
return filePath; |
|||
} |
|||
|
|||
public void setFilePath(String filePath) { |
|||
this.filePath = filePath; |
|||
} |
|||
|
|||
public String getUploadBy() { |
|||
return uploadBy; |
|||
} |
|||
|
|||
public void setUploadBy(String uploadBy) { |
|||
this.uploadBy = uploadBy; |
|||
} |
|||
|
|||
public Date getUploadDate() { |
|||
return uploadDate; |
|||
} |
|||
|
|||
public void setUploadDate(Date uploadDate) { |
|||
this.uploadDate = uploadDate; |
|||
} |
|||
|
|||
public String getInsertBy() { |
|||
return insertBy; |
|||
} |
|||
|
|||
public void setInsertBy(String insertBy) { |
|||
this.insertBy = insertBy; |
|||
} |
|||
|
|||
public Date getInsertDate() { |
|||
return insertDate; |
|||
} |
|||
|
|||
public void setInsertDate(Date insertDate) { |
|||
this.insertDate = insertDate; |
|||
} |
|||
|
|||
public String getCheckBy() { |
|||
return checkBy; |
|||
} |
|||
|
|||
public void setCheckBy(String checkBy) { |
|||
this.checkBy = checkBy; |
|||
} |
|||
|
|||
public Date getCheckDate() { |
|||
return checkDate; |
|||
} |
|||
|
|||
public void setCheckDate(Date checkDate) { |
|||
this.checkDate = checkDate; |
|||
} |
|||
|
|||
public String getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(String status) { |
|||
this.status = status; |
|||
} |
|||
|
|||
public int getItemCount() { |
|||
return itemCount; |
|||
} |
|||
|
|||
public void setItemCount(int itemCount) { |
|||
this.itemCount = itemCount; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
|
|||
package com.srq.modules.jst.data; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author LR |
|||
* @version 1.0 |
|||
* @description: 销售单的品牌配置 |
|||
* @date 2023/8/4 9:46 |
|||
*/ |
|||
public class SalesOrderWarehouseData { |
|||
private int id; |
|||
private String warehouseName; |
|||
private String warehouseType; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date createdDate; |
|||
|
|||
public SalesOrderWarehouseData() { |
|||
} |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getWarehouseName() { |
|||
return warehouseName; |
|||
} |
|||
|
|||
public void setWarehouseName(String warehouseName) { |
|||
this.warehouseName = warehouseName; |
|||
} |
|||
|
|||
public String getWarehouseType() { |
|||
return warehouseType; |
|||
} |
|||
|
|||
public void setWarehouseType(String warehouseType) { |
|||
this.warehouseType = warehouseType; |
|||
} |
|||
|
|||
public Date getCreatedDate() { |
|||
return createdDate; |
|||
} |
|||
|
|||
public void setCreatedDate(Date createdDate) { |
|||
this.createdDate = createdDate; |
|||
} |
|||
} |
|||
@ -0,0 +1,256 @@ |
|||
package com.srq.modules.jst.data; |
|||
|
|||
/** |
|||
* @description: 店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/2 18:08 |
|||
* @version 1.0 |
|||
*/ |
|||
public class ShopStoreData { |
|||
private int id; |
|||
private String contract; |
|||
private String shopSite; |
|||
private String shopId; |
|||
private String shopName; |
|||
private String customerNo; |
|||
private String shipAddrNo; |
|||
private String billAddrNo; |
|||
private String shipViaCode; |
|||
private String freeOfChgTaxPayParty; |
|||
private String deliveryTerms; |
|||
private String salesmanCode; |
|||
private String regionCode; |
|||
private String districtCode; |
|||
private String marketCode; |
|||
private String payTermId; |
|||
private String jinsuiInvoiceDb; |
|||
private String usePriceInclTaxDb; |
|||
private String supplyCountry; |
|||
private String taxLiability; |
|||
private String taxCode; |
|||
private String currencyCode; |
|||
private String returnApproverId; |
|||
private String pureCustom; |
|||
private String distinguishCustom; |
|||
private String consignmentFlag; |
|||
private String orderType; |
|||
|
|||
public ShopStoreData() { |
|||
} |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getContract() { |
|||
return contract; |
|||
} |
|||
|
|||
public void setContract(String contract) { |
|||
this.contract = contract; |
|||
} |
|||
|
|||
public String getShopSite() { |
|||
return shopSite; |
|||
} |
|||
|
|||
public void setShopSite(String shopSite) { |
|||
this.shopSite = shopSite; |
|||
} |
|||
|
|||
public String getShopId() { |
|||
return shopId; |
|||
} |
|||
|
|||
public void setShopId(String shopId) { |
|||
this.shopId = shopId; |
|||
} |
|||
|
|||
public String getShopName() { |
|||
return shopName; |
|||
} |
|||
|
|||
public void setShopName(String shopName) { |
|||
this.shopName = shopName; |
|||
} |
|||
|
|||
public String getCustomerNo() { |
|||
return customerNo; |
|||
} |
|||
|
|||
public void setCustomerNo(String customerNo) { |
|||
this.customerNo = customerNo; |
|||
} |
|||
|
|||
public String getShipAddrNo() { |
|||
return shipAddrNo; |
|||
} |
|||
|
|||
public void setShipAddrNo(String shipAddrNo) { |
|||
this.shipAddrNo = shipAddrNo; |
|||
} |
|||
|
|||
public String getBillAddrNo() { |
|||
return billAddrNo; |
|||
} |
|||
|
|||
public void setBillAddrNo(String billAddrNo) { |
|||
this.billAddrNo = billAddrNo; |
|||
} |
|||
|
|||
public String getShipViaCode() { |
|||
return shipViaCode; |
|||
} |
|||
|
|||
public void setShipViaCode(String shipViaCode) { |
|||
this.shipViaCode = shipViaCode; |
|||
} |
|||
|
|||
public String getFreeOfChgTaxPayParty() { |
|||
return freeOfChgTaxPayParty; |
|||
} |
|||
|
|||
public void setFreeOfChgTaxPayParty(String freeOfChgTaxPayParty) { |
|||
this.freeOfChgTaxPayParty = freeOfChgTaxPayParty; |
|||
} |
|||
|
|||
public String getDeliveryTerms() { |
|||
return deliveryTerms; |
|||
} |
|||
|
|||
public void setDeliveryTerms(String deliveryTerms) { |
|||
this.deliveryTerms = deliveryTerms; |
|||
} |
|||
|
|||
public String getSalesmanCode() { |
|||
return salesmanCode; |
|||
} |
|||
|
|||
public void setSalesmanCode(String salesmanCode) { |
|||
this.salesmanCode = salesmanCode; |
|||
} |
|||
|
|||
public String getRegionCode() { |
|||
return regionCode; |
|||
} |
|||
|
|||
public void setRegionCode(String regionCode) { |
|||
this.regionCode = regionCode; |
|||
} |
|||
|
|||
public String getDistrictCode() { |
|||
return districtCode; |
|||
} |
|||
|
|||
public void setDistrictCode(String districtCode) { |
|||
this.districtCode = districtCode; |
|||
} |
|||
|
|||
public String getMarketCode() { |
|||
return marketCode; |
|||
} |
|||
|
|||
public void setMarketCode(String marketCode) { |
|||
this.marketCode = marketCode; |
|||
} |
|||
|
|||
public String getPayTermId() { |
|||
return payTermId; |
|||
} |
|||
|
|||
public void setPayTermId(String payTermId) { |
|||
this.payTermId = payTermId; |
|||
} |
|||
|
|||
public String getJinsuiInvoiceDb() { |
|||
return jinsuiInvoiceDb; |
|||
} |
|||
|
|||
public void setJinsuiInvoiceDb(String jinsuiInvoiceDb) { |
|||
this.jinsuiInvoiceDb = jinsuiInvoiceDb; |
|||
} |
|||
|
|||
public String getUsePriceInclTaxDb() { |
|||
return usePriceInclTaxDb; |
|||
} |
|||
|
|||
public void setUsePriceInclTaxDb(String usePriceInclTaxDb) { |
|||
this.usePriceInclTaxDb = usePriceInclTaxDb; |
|||
} |
|||
|
|||
public String getSupplyCountry() { |
|||
return supplyCountry; |
|||
} |
|||
|
|||
public void setSupplyCountry(String supplyCountry) { |
|||
this.supplyCountry = supplyCountry; |
|||
} |
|||
|
|||
public String getTaxLiability() { |
|||
return taxLiability; |
|||
} |
|||
|
|||
public void setTaxLiability(String taxLiability) { |
|||
this.taxLiability = taxLiability; |
|||
} |
|||
|
|||
public String getTaxCode() { |
|||
return taxCode; |
|||
} |
|||
|
|||
public void setTaxCode(String taxCode) { |
|||
this.taxCode = taxCode; |
|||
} |
|||
|
|||
public String getCurrencyCode() { |
|||
return currencyCode; |
|||
} |
|||
|
|||
public void setCurrencyCode(String currencyCode) { |
|||
this.currencyCode = currencyCode; |
|||
} |
|||
|
|||
public String getReturnApproverId() { |
|||
return returnApproverId; |
|||
} |
|||
|
|||
public void setReturnApproverId(String returnApproverId) { |
|||
this.returnApproverId = returnApproverId; |
|||
} |
|||
|
|||
public String getPureCustom() { |
|||
return pureCustom; |
|||
} |
|||
|
|||
public void setPureCustom(String pureCustom) { |
|||
this.pureCustom = pureCustom; |
|||
} |
|||
|
|||
public String getDistinguishCustom() { |
|||
return distinguishCustom; |
|||
} |
|||
|
|||
public void setDistinguishCustom(String distinguishCustom) { |
|||
this.distinguishCustom = distinguishCustom; |
|||
} |
|||
|
|||
public String getConsignmentFlag() { |
|||
return consignmentFlag; |
|||
} |
|||
|
|||
public void setConsignmentFlag(String consignmentFlag) { |
|||
this.consignmentFlag = consignmentFlag; |
|||
} |
|||
|
|||
public String getOrderType() { |
|||
return orderType; |
|||
} |
|||
|
|||
public void setOrderType(String orderType) { |
|||
this.orderType = orderType; |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
package com.srq.modules.jst.service; |
|||
|
|||
import com.srq.modules.jst.data.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: 聚水潭的service |
|||
* @author LR |
|||
* @date 2023/7/24 16:23 |
|||
* @version 1.0 |
|||
*/ |
|||
public interface JstService { |
|||
|
|||
/** |
|||
* @description: 查询文件的上传记录信息 |
|||
* @author LR |
|||
* @date 2023/7/31 10:50 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderFileData> getSaleOrderFileHist(SalesOrderFileData inData); |
|||
|
|||
/** |
|||
* @description: 文件上传 |
|||
* @author LR |
|||
* @date 2023/7/25 15:03 |
|||
* @version 1.0 |
|||
*/ |
|||
void uploadSalesOrderFile(MultipartFile file, GetParamInData inData) throws Exception; |
|||
|
|||
/** |
|||
* @description: excel批量导入数据表中 |
|||
* @author LR |
|||
* @date 2023/7/31 11:38 |
|||
* @version 1.0 |
|||
*/ |
|||
void batchInsertSalesOrderItems(SalesOrderFileData inData) throws Exception; |
|||
|
|||
/** |
|||
* @description: 检查销售单的异常信息 |
|||
* @author LR |
|||
* @date 2023/7/31 13:08 |
|||
* @version 1.0 |
|||
*/ |
|||
void checkSalesOrderException(); |
|||
|
|||
/** |
|||
* @description: 获取异常的信息 |
|||
* @author LR |
|||
* @date 2023/7/24 17:12 |
|||
* @version 1.0 |
|||
*/ |
|||
List<JstExceptionData> getExceptionList(JstExceptionData inData); |
|||
|
|||
/** |
|||
* @description: 执行文件下载任务 |
|||
* @author LR |
|||
* @date 2023/7/31 17:43 |
|||
* @version 1.0 |
|||
*/ |
|||
void downSalesOrder(GetParamInData inData, HttpServletResponse response) throws Exception; |
|||
|
|||
/** |
|||
* @description: 获取当前的店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/2 18:09 |
|||
* @version 1.0 |
|||
*/ |
|||
List<ShopStoreData> getShopStores(ShopStoreData inData); |
|||
|
|||
/** |
|||
* @description: 插入当前的店铺数据 |
|||
* @author LR |
|||
* @date 2023/8/3 17:49 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertShopStore(ShopStoreData inData); |
|||
|
|||
/** |
|||
* @description: 修改店铺的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/3 18:06 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveShopStore(ShopStoreData inData); |
|||
|
|||
/** |
|||
* @description: 销售单的品牌信息 |
|||
* @author LR |
|||
* @date 2023/8/4 9:49 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderBrandData> getSalesOrderBrand(SalesOrderBrandData inData); |
|||
|
|||
/** |
|||
* @description: 插入当前的品牌数据 |
|||
* @author LR |
|||
* @date 2023/8/4 10:08 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertSalesOrderBrand(SalesOrderBrandData inData); |
|||
|
|||
/** |
|||
* @description: 修改品牌的相关信息 |
|||
* @author LR |
|||
* @date 2023/8/4 10:26 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveSalesOrderBrand(SalesOrderBrandData inData); |
|||
|
|||
/** |
|||
* @description: 获取销售明细的仓库 |
|||
* @author LR |
|||
* @date 2023/8/4 11:26 |
|||
* @version 1.0 |
|||
*/ |
|||
List<SalesOrderWarehouseData> getSalesOrderWarehouse(SalesOrderWarehouseData inData); |
|||
|
|||
/** |
|||
* @description: 新增销售单的仓库信息 |
|||
* @author LR |
|||
* @date 2023/8/4 13:20 |
|||
* @version 1.0 |
|||
*/ |
|||
void insertSalesOrderWarehouse(SalesOrderWarehouseData inData); |
|||
|
|||
/** |
|||
* @description: 保存销售单的仓库信息 |
|||
* @author LR |
|||
* @date 2023/8/4 15:18 |
|||
* @version 1.0 |
|||
*/ |
|||
void saveSalesOrderWarehouse(SalesOrderWarehouseData inData); |
|||
} |
|||
@ -0,0 +1,482 @@ |
|||
package com.srq.modules.jst.service.impl; |
|||
|
|||
import com.alibaba.excel.EasyExcel; |
|||
import com.srq.common.exception.XJException; |
|||
import com.srq.common.utils.DateUtils; |
|||
import com.srq.common.utils.RandomUtil; |
|||
import com.srq.modules.jst.dao.JstDao; |
|||
import com.srq.modules.jst.data.*; |
|||
import com.srq.modules.jst.service.JstService; |
|||
import com.srq.modules.jst.util.SalesOrderExcelListener; |
|||
import com.srq.modules.report.dao.ProcedureDao; |
|||
import com.srq.modules.sys.entity.SysUserEntity; |
|||
import org.apache.shiro.SecurityUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.*; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @description: 聚水潭的service实现 |
|||
* @author LR |
|||
* @date 2023/7/24 16:23 |
|||
* @version 1.0 |
|||
*/ |
|||
@Service |
|||
public class JstServiceImpl implements JstService { |
|||
|
|||
@Autowired |
|||
private JstDao jstDao; |
|||
@Value("${sys-file.file-path}") |
|||
private String filePath; |
|||
@Autowired |
|||
private ProcedureDao procedureDao; |
|||
@Value("${jst.dataBaseName}") |
|||
private String dataBaseName; |
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
@Override |
|||
public List<SalesOrderFileData> getSaleOrderFileHist(SalesOrderFileData inData) { |
|||
//公共参数 |
|||
String fileName = inData.getFileName(); |
|||
String status = inData.getStatus(); |
|||
return jstDao.getSaleOrderFileHist(fileName, status); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void uploadSalesOrderFile(MultipartFile file, GetParamInData inData) throws Exception { |
|||
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|||
//首先检查是否存在未导入的文件 |
|||
List<SalesOrderFileData> salesOrderFiles = jstDao.getSaleOrderFileHist("", "uploaded"); |
|||
//判断是否存在 |
|||
if(salesOrderFiles.size() > 0){ |
|||
throw new XJException("存在未导入的excel文件!"); |
|||
} |
|||
if (file.isEmpty()) { |
|||
throw new XJException("上传文件不能为空"); |
|||
} |
|||
//处理文件后缀 |
|||
int chartIndex = file.getOriginalFilename().lastIndexOf("."); |
|||
String suffix = ""; |
|||
String fileName = ""; |
|||
//判断是否存在 |
|||
if(chartIndex > 0){ |
|||
suffix = file.getOriginalFilename().substring(chartIndex); |
|||
fileName = file.getOriginalFilename().substring(0, chartIndex); |
|||
} |
|||
String newFileName = RandomUtil.getOrderNoByAtomic1("file")+suffix; |
|||
String basePath = filePath; |
|||
String baseDatePath = DateUtils.format(new Date()); |
|||
File targetFile = new File(basePath + "\\" + baseDatePath + "\\" + inData.getFolder()); |
|||
if (!targetFile.exists()) { |
|||
targetFile.mkdirs(); |
|||
} |
|||
//最终的目录 |
|||
String finalFileName = targetFile.getPath()+"\\" + newFileName; |
|||
try { |
|||
targetFile = multipartFileToFile(file, finalFileName); |
|||
}catch (Exception e){ |
|||
throw new XJException(e.getMessage()); |
|||
} |
|||
//获取当前行的数据 |
|||
SalesOrderFileData salesOrderFile = new SalesOrderFileData(); |
|||
salesOrderFile.setFileName(fileName); |
|||
salesOrderFile.setFilePath(finalFileName); |
|||
salesOrderFile.setUploadBy(sysUserEntity.getUsername()); |
|||
salesOrderFile.setUploadDate(new Date()); |
|||
salesOrderFile.setStatus("uploaded"); |
|||
//插入当前记录表的数据 |
|||
jstDao.insertUploadFileHist(salesOrderFile); |
|||
} |
|||
|
|||
@Override |
|||
//@Transactional |
|||
public void batchInsertSalesOrderItems(SalesOrderFileData inData) throws Exception{ |
|||
//首先检查是否存在未导入的文件 |
|||
List<SalesOrderFileData> salesOrderFiles = jstDao.getSaleOrderFileHist("", "uploaded"); |
|||
//判断是否存在 |
|||
if(salesOrderFiles.size() == 0){ |
|||
throw new XJException("不存在未导入的excel文件!"); |
|||
} |
|||
SalesOrderFileData salesOrderFile = salesOrderFiles.get(0); |
|||
//获取最终的文件名称 |
|||
String finalFileName = salesOrderFile.getFilePath(); |
|||
//组装的对象 |
|||
File targetFile = new File(finalFileName); |
|||
//2.清空当前销售单明细表 |
|||
jstDao.clearSalesOrder(); |
|||
//1.获取文件的固定数据 |
|||
List<ColumnData> salesOrderColumns = jstDao.getSalesOrderColumns(); |
|||
//2.执行分批保存的操作 |
|||
this.processExcelFileToList(targetFile, salesOrderColumns); |
|||
//查询当前明细行数 |
|||
int countNums = jstDao.countSalesOrder(); |
|||
//修改当前的当如数量 |
|||
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|||
salesOrderFile.setInsertBy(sysUserEntity.getUsername()); |
|||
salesOrderFile.setInsertDate(new Date()); |
|||
salesOrderFile.setItemCount(countNums); |
|||
salesOrderFile.setStatus("inserted"); |
|||
//修改导入的数量和时间信息 |
|||
jstDao.updateSalesOrderFileInsertData(salesOrderFile); |
|||
} |
|||
|
|||
@Override |
|||
public List<JstExceptionData> getExceptionList(JstExceptionData inData) { |
|||
//公共参数 |
|||
String exceptionType = inData.getExceptionType(); |
|||
String exceptionDesc = inData.getExceptionDesc(); |
|||
String exceptionData = inData.getExceptionData(); |
|||
return jstDao.getExceptionList(exceptionType, exceptionDesc, exceptionData); |
|||
} |
|||
|
|||
@Override |
|||
public void downSalesOrder(GetParamInData inData, HttpServletResponse response) throws Exception { |
|||
String newFileName = inData.getRemark()+".xlsx"; |
|||
//使用easyExcel下载excel |
|||
OutputStream os = responseInfo(response, newFileName); |
|||
List<ColumnData> salesOrderColumns = jstDao.getSalesOrderColumns(); |
|||
List<String> heads = new ArrayList<>(); |
|||
List<List<String>> columnHeaders = new ArrayList<>(); |
|||
//循环设置集合 |
|||
for(ColumnData columnData : salesOrderColumns){ |
|||
heads.add(columnData.getColumnName()); |
|||
columnHeaders.add(Arrays.asList(columnData.getColumnName())); |
|||
} |
|||
//查询现有集合数据 |
|||
List<Map<String, Object>> resultList = jstDao.getSaleOrderList(); |
|||
// |
|||
List<List<Object>> exportList = new ArrayList<>(); |
|||
for (Map<String, Object> tempMap : resultList) { |
|||
List<Object> objects = new ArrayList<>(); |
|||
for (String head : heads) { |
|||
Object value = tempMap.get(head); |
|||
if (value != null){ |
|||
objects.add(value.toString()); |
|||
}else { |
|||
objects.add(null); |
|||
} |
|||
} |
|||
exportList.add(objects); |
|||
} |
|||
EasyExcel.write(os).head(columnHeaders).sheet("销售数据明细").doWrite(exportList); |
|||
} |
|||
|
|||
/** |
|||
* @description: 文件下载流 |
|||
* @author LR |
|||
* @date 2023/7/31 17:50 |
|||
* @version 1.0 |
|||
*/ |
|||
public static OutputStream responseInfo(HttpServletResponse response, String fileName) throws IOException { |
|||
// 这里注意有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman |
|||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|||
response.setCharacterEncoding("utf-8"); |
|||
response.setHeader("Content-disposition", "attachment; filename*=utf-8''" + fileName); |
|||
OutputStream os = response.getOutputStream(); |
|||
return os; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void checkSalesOrderException() { |
|||
//首先判断当前是否存在导入的数据明细 |
|||
//查询当前明细行数 |
|||
int countNums = jstDao.countSalesOrder(); |
|||
if(countNums == 0){ |
|||
throw new RuntimeException("请先导入销售明细后再试!"); |
|||
} |
|||
//首先检查是否存在未导入的文件 |
|||
List<SalesOrderFileData> salesOrderFiles = jstDao.getSaleOrderFileHist("", "inserted"); |
|||
//判断是否存在 |
|||
if(salesOrderFiles.size() == 0){ |
|||
throw new XJException("不存在未导入的excel文件!"); |
|||
} |
|||
//判断导入完成后 首先调用不导入IFS数据的存储过程 |
|||
this.processNoIfsSalesOrder(); |
|||
//处理异常的存储过程 |
|||
this.procesSalesOrderExceptionData(); |
|||
SalesOrderFileData salesOrderFile = salesOrderFiles.get(0); |
|||
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|||
//统计删除后的数据 |
|||
countNums = jstDao.countSalesOrder(); |
|||
//设置参数 |
|||
salesOrderFile.setCheckBy(sysUserEntity.getUsername()); |
|||
salesOrderFile.setCheckDate(new Date()); |
|||
salesOrderFile.setItemCount(countNums); |
|||
salesOrderFile.setStatus("checked"); |
|||
jstDao.updateSalesOrderFileCheckData(salesOrderFile); |
|||
} |
|||
|
|||
/** |
|||
* @description: 处理异常销售明细的异常信息 |
|||
* @author LR |
|||
* @date 2023/7/31 14:16 |
|||
* @version 1.0 |
|||
*/ |
|||
public void procesSalesOrderExceptionData() { |
|||
List<Object> params = new ArrayList<>(); |
|||
procedureDao.execProduceData(dataBaseName+".processCheckSalesOrder", params); |
|||
} |
|||
|
|||
/** |
|||
* @description: TODO |
|||
* @author LR |
|||
* @date 2023/7/31 14:06 |
|||
* @version 1.0 |
|||
*/ |
|||
public void processNoIfsSalesOrder() { |
|||
List<Object> params = new ArrayList<>(); |
|||
procedureDao.execProduceData(dataBaseName+".processNoIfsSalesOrder", params); |
|||
} |
|||
|
|||
/** |
|||
* @description: 把excel表的数据处理的list数据 |
|||
* @author LR |
|||
* @date 2023/7/25 15:43 |
|||
* @version 1.0 |
|||
*/ |
|||
public List<Map<String, String>> processExcelFileToList(File targetFile, List<ColumnData> salesOrderColumns) throws Exception { |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
Map<String, Integer> columnMap = new HashMap<>(); |
|||
//list转Map |
|||
for(ColumnData columnData : salesOrderColumns){ |
|||
columnMap.put(columnData.getColumnName(), 0); |
|||
} |
|||
String fileName = targetFile.getName(); |
|||
int index = fileName.lastIndexOf("."); |
|||
if(-1 == index){ |
|||
throw new RuntimeException("文件类型有误!请重新选择!"); |
|||
} |
|||
String type = fileName.substring(index+1).toLowerCase(); |
|||
FileInputStream fis = null; |
|||
try { |
|||
fis = new FileInputStream(targetFile); |
|||
//使用监听器处理文件流 |
|||
SalesOrderExcelListener parseListener = new SalesOrderExcelListener(jstDao, columnMap, 1000); |
|||
logger.info("开始解析数据!"); |
|||
EasyExcel.read(fis, parseListener) |
|||
.sheet(0)//设置读取第几个sheet |
|||
.headRowNumber(1)// 设置总共有几行表头 |
|||
.doRead(); |
|||
logger.info("解析数据结束!"); |
|||
//获取Listenner缓存的数据结构 |
|||
List<Map<String, String>> excellist = parseListener.getExcelList(); |
|||
Map<Integer, String> headTitleMap = parseListener.getHeadTitleMap(); |
|||
} catch (Exception e) { |
|||
if(null != fis) { |
|||
fis.close(); |
|||
} |
|||
throw new RuntimeException(e.getMessage()); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
public static File multipartFileToFile(MultipartFile file ,String fileName) throws Exception { |
|||
File toFile = null; |
|||
if (file.equals("") || file.getSize() <= 0) { |
|||
file = null; |
|||
} else { |
|||
InputStream ins = null; |
|||
ins = file.getInputStream(); |
|||
if(fileName != null && !"".equals(fileName)){ |
|||
toFile = new File(fileName); |
|||
}else{ |
|||
toFile = new File(file.getOriginalFilename()); |
|||
} |
|||
inputStreamToFile(ins, toFile); |
|||
ins.close(); |
|||
} |
|||
return toFile; |
|||
} |
|||
|
|||
//获取流文件 |
|||
private static void inputStreamToFile(InputStream ins, File file) { |
|||
try { |
|||
OutputStream os = new FileOutputStream(file); |
|||
int bytesRead = 0; |
|||
byte[] buffer = new byte[8192]; |
|||
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { |
|||
os.write(buffer, 0, bytesRead); |
|||
} |
|||
os.close(); |
|||
ins.close(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public List<ShopStoreData> getShopStores(ShopStoreData inData) { |
|||
//公共参数 |
|||
String shopId = inData.getShopId(); |
|||
String shopName = inData.getShopName(); |
|||
return jstDao.getShopStores(shopId, shopName); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void insertShopStore(ShopStoreData inData) { |
|||
//公共参数 |
|||
String shopId = inData.getShopId(); |
|||
String pureCustom = inData.getPureCustom(); |
|||
String distinguishCustom = inData.getDistinguishCustom(); |
|||
//判断是否为空 |
|||
if(shopId == null || "".equals(shopId)){ |
|||
throw new XJException("店铺编号不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
ShopStoreData shopStore = jstDao.getShopStoreByShopId(shopId); |
|||
if(null != shopStore){ |
|||
throw new XJException("店铺编号已存在!"); |
|||
} |
|||
//判断是否区分客户 |
|||
if("Y".equalsIgnoreCase(distinguishCustom)){ |
|||
inData.setShipViaCode("10"); |
|||
inData.setFreeOfChgTaxPayParty("No Tax"); |
|||
inData.setDeliveryTerms("C&F"); |
|||
inData.setSalesmanCode(""); |
|||
inData.setJinsuiInvoiceDb("FALSE"); |
|||
inData.setUsePriceInclTaxDb("TRUE"); |
|||
inData.setSupplyCountry("CHINA"); |
|||
inData.setTaxLiability("TAX"); |
|||
inData.setTaxCode("XX-13"); |
|||
inData.setCurrencyCode("CNY"); |
|||
}else if("N".equalsIgnoreCase(distinguishCustom)){ |
|||
inData.setBillAddrNo("01"); |
|||
inData.setBillAddrNo("01"); |
|||
inData.setShipViaCode("10"); |
|||
inData.setFreeOfChgTaxPayParty("No Tax"); |
|||
inData.setDeliveryTerms("C&F"); |
|||
inData.setSalesmanCode(""); |
|||
inData.setPayTermId("FK05"); |
|||
inData.setJinsuiInvoiceDb("FALSE"); |
|||
inData.setUsePriceInclTaxDb("TRUE"); |
|||
inData.setSupplyCountry("CHINA"); |
|||
inData.setTaxLiability("TAX"); |
|||
inData.setTaxCode("XX-13"); |
|||
inData.setCurrencyCode("CNY"); |
|||
} |
|||
jstDao.insertShopStore(inData); |
|||
} |
|||
|
|||
@Override |
|||
public void saveShopStore(ShopStoreData inData) { |
|||
//公共参数 |
|||
String shopId = inData.getShopId(); |
|||
//判断是否为空 |
|||
if(shopId == null || "".equals(shopId)){ |
|||
throw new XJException("店铺编号不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
ShopStoreData shopStore = jstDao.getShopStoreByShopId(shopId); |
|||
if(null == shopStore){ |
|||
throw new XJException("店铺不存在!"); |
|||
} |
|||
jstDao.saveShopStore(inData); |
|||
} |
|||
|
|||
@Override |
|||
public List<SalesOrderBrandData> getSalesOrderBrand(SalesOrderBrandData inData) { |
|||
//公共参数 |
|||
String brandContract = inData.getBrandContract(); |
|||
String brandName = inData.getBrandName(); |
|||
return jstDao.getSalesOrderBrand(brandContract, brandName); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void insertSalesOrderBrand(SalesOrderBrandData inData) { |
|||
//公共参数 |
|||
String brandContract = inData.getBrandContract(); |
|||
String brandName = inData.getBrandName(); |
|||
//判断是否为空 |
|||
if(brandName == null || "".equals(brandName)){ |
|||
throw new XJException("品牌名称不能为空!"); |
|||
} |
|||
if(brandContract == null || "".equals(brandContract)){ |
|||
throw new XJException("品牌域不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
SalesOrderBrandData salesOrderBrand = jstDao.getSalesOrderBrandByBrandName(brandName); |
|||
if(null != salesOrderBrand){ |
|||
throw new XJException("品牌名称已存在!"); |
|||
} |
|||
//没有问题 直接保存数据 |
|||
inData.setCreatedDate(new Date()); |
|||
jstDao.insertSalesOrderBrand(inData); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void saveSalesOrderBrand(SalesOrderBrandData inData) { |
|||
//公共参数 |
|||
String brandContract = inData.getBrandContract(); |
|||
String brandName = inData.getBrandName(); |
|||
//判断是否为空 |
|||
if(brandContract == null || "".equals(brandContract)){ |
|||
throw new XJException("品牌域不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
SalesOrderBrandData salesOrderBrand = jstDao.getSalesOrderBrandByBrandName(brandName); |
|||
if(null == salesOrderBrand){ |
|||
throw new XJException("品牌名称不存在!"); |
|||
} |
|||
//没有问题 直接保存数据 |
|||
inData.setCreatedDate(new Date()); |
|||
jstDao.saveSalesOrderBrand(inData); |
|||
} |
|||
|
|||
@Override |
|||
public List<SalesOrderWarehouseData> getSalesOrderWarehouse(SalesOrderWarehouseData inData) { |
|||
//公共参数 |
|||
String warehouseName = inData.getWarehouseName(); |
|||
return jstDao.getSalesOrderWarehouse(warehouseName); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void insertSalesOrderWarehouse(SalesOrderWarehouseData inData) { |
|||
//公共参数 |
|||
String warehouseName = inData.getWarehouseName(); |
|||
//判断是否为空 |
|||
if(warehouseName == null || "".equals(warehouseName)){ |
|||
throw new XJException("仓库名称不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
SalesOrderWarehouseData salesOrderWarehouse = jstDao.getSalesOrderWarehouseByWarehouseName(warehouseName); |
|||
if(null != salesOrderWarehouse){ |
|||
throw new XJException("仓库名称已存在!"); |
|||
} |
|||
//没有问题 直接保存数据 |
|||
inData.setCreatedDate(new Date()); |
|||
jstDao.insertSalesOrderWarehouse(inData); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void saveSalesOrderWarehouse(SalesOrderWarehouseData inData) { |
|||
//公共参数 |
|||
String warehouseName = inData.getWarehouseName(); |
|||
//判断是否为空 |
|||
if(warehouseName == null || "".equals(warehouseName)){ |
|||
throw new XJException("仓库名称不能为空!"); |
|||
} |
|||
//判断当前的数据是否重复 |
|||
SalesOrderWarehouseData salesOrderWarehouse = jstDao.getSalesOrderWarehouseByWarehouseName(warehouseName); |
|||
if(null == salesOrderWarehouse){ |
|||
throw new XJException("仓库名称不存在!"); |
|||
} |
|||
jstDao.saveSalesOrderWarehouse(inData); |
|||
} |
|||
} |
|||
@ -0,0 +1,114 @@ |
|||
package com.srq.modules.jst.util; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.srq.modules.jst.dao.JstDao; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import javax.xml.crypto.Data; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @description: 自定义的excel的表头处理工具 |
|||
* @author LR |
|||
* @date 2023/7/26 17:41 |
|||
* @version 1.0 |
|||
*/ |
|||
public class ExcelListener extends AnalysisEventListener<Map<Integer, String>> { |
|||
//excel的数据缓存结构 |
|||
private List<Map<Integer, Map<Integer, String>>> excelList; |
|||
//最大的缓存数量 |
|||
private static final int BATCH_COUNT = 10000; |
|||
//写入数据的dao |
|||
private JstDao jstDao; |
|||
//Excel表头(列名)数据缓存结构 |
|||
private Map<Integer, String> headTitleMap = new HashMap<>(); |
|||
private Map<String, Integer> columnMap; |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
public ExcelListener(JstDao jstDao, Map<String, Integer> columnMap) { |
|||
this.excelList = new ArrayList<>(); |
|||
this.jstDao = jstDao; |
|||
this.columnMap = columnMap; |
|||
} |
|||
|
|||
/** |
|||
* @description: 解析表头外的所有行数据 |
|||
* @author LR |
|||
* @date 2023/7/26 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void invoke(Map<Integer, String> integerStringMap, AnalysisContext analysisContext) { |
|||
System.out.println("解析单行数据:" + JSON.toJSONString(integerStringMap)); |
|||
Map<Integer, Map<Integer, String>> tempMap = new HashMap<>(); |
|||
tempMap.put(analysisContext.readRowHolder().getRowIndex(), integerStringMap); |
|||
//解析的数据添加 |
|||
excelList.add(tempMap); |
|||
//判断是否达到最大的缓存的数量 |
|||
if(excelList.size() == BATCH_COUNT){ |
|||
saveExcelList(excelList); |
|||
//保存成功 清空集合 |
|||
excelList.clear(); |
|||
} |
|||
} |
|||
|
|||
private void saveExcelList(List<Map<Integer, Map<Integer, String>>> excelList) { |
|||
logger.info("{}条数据,开始存储数据库!", excelList.size()); |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
//循环读取参数 |
|||
for(int i = 0; i < excelList.size(); i++){ |
|||
Map<Integer, Map<Integer, String>> integerMap = excelList.get(i); |
|||
//一次循环拿行 |
|||
integerMap.forEach((key, value) ->{ |
|||
Map<String, String> excelMap = new LinkedHashMap<>(); |
|||
//二次缓存拿具体的数值 |
|||
value.forEach((key2, value2) ->{ |
|||
//关注的属性 处理 不关注的属性 不在处理 |
|||
if(columnMap.containsKey(headTitleMap.get(key2))){ |
|||
excelMap.put(headTitleMap.get(key2), value2); |
|||
} |
|||
}); |
|||
//添加当前的数据到结果集 |
|||
resultList.add(excelMap); |
|||
}); |
|||
} |
|||
jstDao.batchInsertSalesOrder(resultList); |
|||
logger.info("{}条数据,存储数据库结束!", excelList.size()); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @description: 解析完的后置操作 |
|||
* @author LR |
|||
* @date 2023/7/26 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
|||
System.out.println("所有数据解析完成"); |
|||
} |
|||
|
|||
/** |
|||
* @description: 解析表头的数据 |
|||
* @author LR |
|||
* @date 2023/7/26 17:52 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
|||
System.out.println("解析表头完成!"); |
|||
headTitleMap = headMap; |
|||
} |
|||
|
|||
public List<Map<Integer, Map<Integer, String>>> getExcelList() { |
|||
return excelList; |
|||
} |
|||
|
|||
public Map<Integer, String> getHeadTitleMap() { |
|||
return headTitleMap; |
|||
} |
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
package com.srq.modules.jst.util; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.alibaba.excel.metadata.Cell; |
|||
import com.alibaba.excel.metadata.data.ReadCellData; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.srq.modules.jst.dao.JstDao; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import javax.xml.crypto.Data; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @description: 自定义的excel的表头处理工具 |
|||
* @author LR |
|||
* @date 2023/7/26 17:41 |
|||
* @version 1.0 |
|||
*/ |
|||
public class SalesOrderExcelListener extends AnalysisEventListener<Map<Integer, String>> { |
|||
//excel的最终数据结果集 |
|||
private List<Map<String, String>> excelList; |
|||
//最大的缓存数量 |
|||
private int batchCount = 1000; |
|||
//写入数据的dao |
|||
private JstDao jstDao; |
|||
//Excel表头(列名)数据缓存结构 |
|||
private Map<Integer, String> headTitleMap = new HashMap<>(); |
|||
private Map<String, Integer> columnMap; |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
public SalesOrderExcelListener(JstDao jstDao, Map<String, Integer> columnMap, int batchCount) { |
|||
this.excelList = new ArrayList<>(); |
|||
this.jstDao = jstDao; |
|||
this.columnMap = columnMap; |
|||
this.batchCount = batchCount; |
|||
} |
|||
|
|||
/** |
|||
* @description: 解析表头外的所有行数据 |
|||
* @author LR |
|||
* @date 2023/7/26 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void invoke(Map<Integer, String> integerStringMap, AnalysisContext analysisContext) { |
|||
//System.out.println("解析单行数据:" + JSON.toJSONString(integerStringMap)); |
|||
//首先排除空白行 |
|||
int cellSize = analysisContext.readRowHolder().getCellMap().size(); |
|||
if(cellSize == 0){ |
|||
return; |
|||
} |
|||
//判断是否存在无效的数据行 |
|||
int orderNoIndex = columnMap.get("内部订单号"); |
|||
String orderNoValue = integerStringMap.get(orderNoIndex); |
|||
//如果当前数据为空或者“” 或者null |
|||
if(null == orderNoValue || "null".equalsIgnoreCase(orderNoValue) || "".equals(orderNoValue)){ |
|||
return ; |
|||
} |
|||
Map<String, String> excelMap = new LinkedHashMap<>(); |
|||
//转数据 |
|||
for(Map.Entry<Integer, String> entry : integerStringMap.entrySet()){ |
|||
int columnIndex = entry.getKey(); |
|||
//获取当前的列明 |
|||
String currentColumnName = headTitleMap.get(columnIndex); |
|||
//判读当前的参数是否当前的导入范围之内 |
|||
if(columnMap.containsKey(currentColumnName)){ |
|||
String columnValue = entry.getValue(); |
|||
//判断是否是内部订单号 |
|||
if("卖家备注".equals(currentColumnName)){ |
|||
//截取字符串 |
|||
if(!(columnValue == null || "".equals(columnValue))){ |
|||
//判断字符串的长度 |
|||
if(columnValue.length() > 200){ |
|||
excelMap.put(currentColumnName, columnValue.substring(0, 200)); |
|||
}else{ |
|||
excelMap.put(currentColumnName, columnValue); |
|||
} |
|||
}else { |
|||
excelMap.put(currentColumnName, ""); |
|||
} |
|||
}else if("销售数量".equals(currentColumnName) && null != columnValue){ |
|||
excelMap.put(currentColumnName, columnValue.replaceAll(",", "")); |
|||
}else if("销售金额".equals(currentColumnName) && null != columnValue){ |
|||
excelMap.put(currentColumnName, columnValue.replaceAll(",", "")); |
|||
}else if("成本价".equals(currentColumnName) && null != columnValue){ |
|||
excelMap.put(currentColumnName, columnValue.replaceAll(",", "")); |
|||
}else{ |
|||
excelMap.put(currentColumnName, columnValue); |
|||
} |
|||
} |
|||
} |
|||
excelList.add(excelMap); |
|||
//判断是否达到最大的缓存的数量 |
|||
if(excelList.size() == batchCount){ |
|||
saveExcelList(excelList); |
|||
//保存成功 清空集合 |
|||
excelList.clear(); |
|||
} |
|||
} |
|||
|
|||
private void saveExcelList(List<Map<String, String>> excelList) { |
|||
logger.info("{}条数据,开始存储数据库!", excelList.size()); |
|||
jstDao.batchInsertSalesOrder(excelList); |
|||
logger.info("{}条数据,存储数据库结束!", excelList.size()); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @description: 解析完的后置操作 |
|||
* @author LR |
|||
* @date 2023/7/26 17:48 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
|||
System.out.println("所有数据解析完成"); |
|||
saveExcelList(excelList); |
|||
} |
|||
|
|||
/** |
|||
* @description: 解析表头的数据 |
|||
* @author LR |
|||
* @date 2023/7/26 17:52 |
|||
* @version 1.0 |
|||
*/ |
|||
@Override |
|||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
|||
System.out.println("解析表头完成!"); |
|||
headTitleMap = headMap; |
|||
//填充各个列明的列序号 |
|||
for(Map.Entry<Integer, String> entry : headMap.entrySet()){ |
|||
int columnIndex = entry.getKey(); |
|||
String columnName = entry.getValue(); |
|||
//设置参数 |
|||
if(columnMap.containsKey(columnName)){ |
|||
columnMap.put(columnName, columnIndex); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, String>> getExcelList() { |
|||
return excelList; |
|||
} |
|||
|
|||
public Map<Integer, String> getHeadTitleMap() { |
|||
return headTitleMap; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue