批量导入数据
This commit is contained in:
@@ -12,6 +12,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/21 15:03
|
||||
@@ -20,4 +22,6 @@ import org.apache.ibatis.annotations.Select;
|
||||
public interface LpkCardBuildRecordMapper extends BaseMapper<LpkCardBuildRecord> {
|
||||
|
||||
IPage<LpkCardBuildRecordVo> recordListPage(IPage<LpkCardBuildRecord> page, @Param(Constants.WRAPPER) QueryWrapper<LpkCardBuildRecord> qw);
|
||||
|
||||
int saveRecords(@Param("records") List<LpkCardBuildRecord> records);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<select id="recordListPage" resultType="com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordVo">
|
||||
select
|
||||
r.sid,
|
||||
-- date_format(r.buildDate, '%Y-%m-%d') as buildDate,
|
||||
-- date_format(r.buildDate, '%Y-%m-%d') as buildDate,
|
||||
r.buildDate as buildDate,
|
||||
r.countNumber,
|
||||
r.startNumber,
|
||||
@@ -20,4 +20,11 @@
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<insert id="saveRecords" parameterType="java.util.List">
|
||||
insert into lpk_card_build_record(sid,createTime,giftbagSid,buildDate,countNumber,startNumber,endNumber)
|
||||
values
|
||||
<foreach collection="records" item="item" index="index" separator=",">
|
||||
(#{item.sid},#{item.createTime},#{item.giftbagSid},#{item.buildDate},#{item.countNumber},#{item.startNumber},#{item.endNumber})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -59,4 +59,7 @@ public class LpkCardBuildRecordService extends MybatisBaseService<LpkCardBuildRe
|
||||
}
|
||||
|
||||
|
||||
public int saveRecords(List<LpkCardBuildRecord> records) {
|
||||
return baseMapper.saveRecords(records);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.yxt.yyth.api.lpkcardqrcode.LpkCardQrcodeVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/21 15:03
|
||||
@@ -17,4 +19,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface LpkCardQrcodeMapper extends BaseMapper<LpkCardQrcode> {
|
||||
|
||||
IPage<LpkCardQrcodeVo> recordListPage(IPage<LpkCardQrcode> page, @Param(Constants.WRAPPER) QueryWrapper<LpkCardQrcode> qw);
|
||||
|
||||
int saveCodes(@Param("codes")List<LpkCardQrcode> codes);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
<insert id="saveCodes" parameterType="java.util.List">
|
||||
insert into lpk_card_qrcode(sid,createTime,cardSid,file)
|
||||
values
|
||||
<foreach collection="codes" item="item" index="index" separator=",">
|
||||
(#{item.sid},#{item.createTime},#{item.cardSid},#{item.file})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="recordListPage" resultType="com.yxt.yyth.api.lpkcardqrcode.LpkCardQrcodeVo">
|
||||
select
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/21 15:03
|
||||
@@ -55,4 +57,7 @@ public class LpkCardQrcodeService extends MybatisBaseService<LpkCardQrcodeMapper
|
||||
return rb.success().setMsg(sid);
|
||||
}
|
||||
|
||||
public int saveCodes(List<LpkCardQrcode> codes) {
|
||||
return baseMapper.saveCodes(codes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface LpkGiftBagMapper extends BaseMapper<LpkGiftBag> {
|
||||
|
||||
IPage<LpkGiftBagVo> giftBagListPage(IPage<LpkGiftBag> page, @Param(Constants.WRAPPER) QueryWrapper<LpkGiftBag> qw);
|
||||
List<LpkGiftBagVo> giftBagList();
|
||||
|
||||
int saveBags(@Param("bags") List<LpkGiftBag> bags);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
<insert id="saveBags" parameterType="java.util.List">
|
||||
insert into lpk_giftbag(sid,createTime,dateStart,dateEnd)
|
||||
values
|
||||
<foreach collection="bags" item="item" index="index" separator=",">
|
||||
(#{item.sid},#{item.createTime},#{item.dateStart},#{item.dateEnd})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="giftBagListPage" resultType="com.yxt.yyth.api.lpkgiftbag.LpkGiftBagVo">
|
||||
select
|
||||
sid,
|
||||
|
||||
@@ -189,4 +189,8 @@ public class LpkGiftBagService extends MybatisBaseService<LpkGiftBagMapper, LpkG
|
||||
baseMapper.updateById(bag);
|
||||
return rb.success().setMsg("修改成功");
|
||||
}
|
||||
|
||||
public int saveBags(List<LpkGiftBag> bags) {
|
||||
return baseMapper.saveBags(bags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,8 @@ public interface LpkGiftBagGoodsMapper extends BaseMapper<LpkGiftBagGoods> {
|
||||
@Select("select goods.name as goodsName,bads.goodsNumber ,bads.goodsSid,goods.picUrl,goods.price,goods.unitName,goods.remarks " +
|
||||
" from lpk_giftbag_goods bads left join lpk_goods goods on goods.sid =bads.goodsSid where bads.giftbagSid=#{sid}")
|
||||
List<LpkGiftBagGoodsVo> getGoodsByBagSid(String sid);
|
||||
|
||||
List<LpkGiftBagGoods> getRecordsByBagSid(@Param("sid") String sid);
|
||||
|
||||
int saveBagGoods(@Param("bagGoods") List<LpkGiftBagGoods> bagGoods);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,11 @@
|
||||
from lpk_giftbag_goods
|
||||
WHERE giftbagSid = #{sid}
|
||||
</select>
|
||||
<insert id="saveBagGoods" parameterType="java.util.List">
|
||||
insert into lpk_giftbag_goods(sid,createTime,giftbagSid,goodsSid,goodsNumber)
|
||||
values
|
||||
<foreach collection="bagGoods" item="item" index="index" separator=",">
|
||||
(#{item.sid},#{item.createTime},#{item.giftbagSid},#{item.goodsSid},#{item.goodsNumber})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -4,6 +4,7 @@ import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.yyth.api.lpkgiftbag.LpkGiftBag;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoods;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoodsVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,9 +23,13 @@ public class LpkGiftBagGoodsService extends MybatisBaseService<LpkGiftBagGoodsMa
|
||||
public List<LpkGiftBagGoods> getRecordsByBagSid(String sid) {
|
||||
return baseMapper.getRecordsByBagSid(sid);
|
||||
}
|
||||
|
||||
public List<LpkGiftBagGoodsVo> getGoodsByBagSid(String sid) {
|
||||
return baseMapper.getGoodsByBagSid(sid);
|
||||
}
|
||||
|
||||
|
||||
public int saveBagGoods(List<LpkGiftBagGoods> bagGoods) {
|
||||
return baseMapper.saveBagGoods(bagGoods);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,8 @@ public interface LpkGiftCardMapper extends BaseMapper<LpkGiftCard> {
|
||||
|
||||
// List<LpkGiftCardWordVo> selGiftCard(@Param("serialNumbers") List<Integer> serialNumbers);
|
||||
IPage<LpkGiftCardWordVo> selGiftCard(IPage<LpkGiftCard> page, @Param(Constants.WRAPPER) QueryWrapper<LpkGiftCard> qw);
|
||||
|
||||
String selctMaxSerNumForExport();
|
||||
|
||||
int saveCards(@Param("cards") List<LpkGiftCard> cards);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardMapper">
|
||||
|
||||
<!--
|
||||
insert into table(字段1,字段2) values(v1,v2),(v1,v2);
|
||||
-->
|
||||
<insert id="saveCards" parameterType="java.util.List">
|
||||
insert into lpk_giftcard(sid,createTime,recordSid,giftbagSid,serialNumber,code,codeKey,`state`)
|
||||
values
|
||||
<foreach collection="cards" item="item" index="index" separator=",">
|
||||
(#{item.sid},#{item.createTime},#{item.recordSid},#{item.giftbagSid},#{item.serialNumber},#{item.code},#{item.codeKey},#{item.state})
|
||||
</foreach>
|
||||
</insert>
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
@@ -121,16 +132,21 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
<!-- <select id="selGiftCard" resultType="com.yxt.yyth.api.lpkgiftcard.LpkGiftCardWordVo">-->
|
||||
<!-- select card.*,bag.name as bagName from lpk_giftcard card left join lpk_giftbag bag on bag.sid =card.giftbagSid where card.serialNumber in-->
|
||||
<!-- <foreach collection="serialNumbers" item="item" index="index" open="(" close=")" separator=",">-->
|
||||
<!-- #{item}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </select>-->
|
||||
<!-- <select id="selGiftCard" resultType="com.yxt.yyth.api.lpkgiftcard.LpkGiftCardWordVo">-->
|
||||
<!-- select card.*,bag.name as bagName from lpk_giftcard card left join lpk_giftbag bag on bag.sid =card.giftbagSid where card.serialNumber in-->
|
||||
<!-- <foreach collection="serialNumbers" item="item" index="index" open="(" close=")" separator=",">-->
|
||||
<!-- #{item}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </select>-->
|
||||
<select id="selGiftCard" resultType="com.yxt.yyth.api.lpkgiftcard.LpkGiftCardWordVo">
|
||||
select card.*,bag.name as bagName from lpk_giftcard card left join lpk_giftbag bag on bag.sid =card.giftbagSid
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<select id="selctMaxSerNumForExport" resultType="java.lang.String">
|
||||
SELECT MAX(c.serialNumber)
|
||||
FROM lpk_giftcard as c
|
||||
WHERE c.serialNumber >= '70000001'
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -25,10 +25,12 @@ import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecord;
|
||||
import com.yxt.yyth.api.lpkcardgrantrecord.LpkCardGrantRecordDto;
|
||||
import com.yxt.yyth.api.lpkcardqrcode.LpkCardQrcode;
|
||||
import com.yxt.yyth.api.lpkcardqrcode.LpkCardQrcodeDto;
|
||||
import com.yxt.yyth.api.lpkgiftbag.GiftBagGoods;
|
||||
import com.yxt.yyth.api.lpkgiftbag.LpkGiftBag;
|
||||
import com.yxt.yyth.api.lpkgiftbag.LpkGiftBagDto;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoods;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoodsVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.*;
|
||||
import com.yxt.yyth.api.lpkgoods.LpkGoods;
|
||||
@@ -1056,13 +1058,14 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
|
||||
importReturn.removeAll(Collections.singleton(null));
|
||||
String startNo = "";
|
||||
String endNo = "";
|
||||
//生成卡包
|
||||
if (!importReturn.isEmpty()) {
|
||||
for (int i = 0; i < importReturn.size(); i++) {
|
||||
ReturnExcelInfo info = importReturn.get(i);
|
||||
//生成礼包
|
||||
LpkGiftCardDto dtoCard = new LpkGiftCardDto();
|
||||
dtoCard.setCardArea("70");
|
||||
dtoCard.setNum("1");
|
||||
//生成卡片
|
||||
String cardSid = getCardByExcel(dtoCard);
|
||||
LpkGiftCard lpkGiftCard = fetchBySid(cardSid);
|
||||
String cardNo = "";
|
||||
@@ -1112,11 +1115,185 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
|
||||
lpkCardBuildRecordService.updateById(cardBuildRecord);
|
||||
}
|
||||
}
|
||||
return rb.success().setMsg("本次导入:"+importReturn.size()+"条数据,生成卡券共计"+importReturn.size()+"张;卡券序列号:"+startNo+"-"+endNo);
|
||||
return rb.success().setMsg("本次导入:" + importReturn.size() + "条数据,生成卡券共计" + importReturn.size() + "张;卡券序列号:" + startNo + "-" + endNo);
|
||||
}
|
||||
return rb.success().setMsg("导入成功");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultBean getExcelInfo3(String startDate, String endDate, MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String temp = request.getSession().getServletContext().getRealPath(File.separator) + "temp";// 临时目录
|
||||
File tempFile = new File(temp);
|
||||
if (!tempFile.exists()) {
|
||||
tempFile.mkdirs();
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
|
||||
return rb.fail().setMsg("上传文件不正确");
|
||||
}
|
||||
boolean isExcel2003 = true;
|
||||
if (fileName.matches("^.+\\.(?i)(xlsx)$")) {
|
||||
isExcel2003 = false;
|
||||
}
|
||||
InputStream is = file.getInputStream();
|
||||
Workbook wb = null;
|
||||
if (isExcel2003) {
|
||||
wb = new HSSFWorkbook(is);
|
||||
} else {
|
||||
wb = new XSSFWorkbook(is);
|
||||
}
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
ReturnMsg returnMsg = getSheetVal2(sheet);
|
||||
Set<String> setMsg = returnMsg.getSetMsg();
|
||||
StringBuffer sbMsg = new StringBuffer();
|
||||
if (null != setMsg && setMsg.size() > 0) {
|
||||
for (String s : setMsg) {
|
||||
sbMsg.append(s).append(",");
|
||||
}
|
||||
sbMsg.delete(sbMsg.length() - 1, sbMsg.length());
|
||||
if (StringUtils.isNotBlank(sbMsg.toString())) {
|
||||
return rb.setMsg(sbMsg.toString());
|
||||
}
|
||||
}
|
||||
List<ReturnExcelInfo> importReturn = returnMsg.getInfos();
|
||||
importReturn.removeAll(Collections.singleton(null));
|
||||
String startNo = "";
|
||||
String endNo = "";
|
||||
List<LpkGiftCard> cards = new ArrayList<>(); //卡片
|
||||
List<LpkGiftBagGoods> bagGoods = new ArrayList<>(); //卡片礼包关联
|
||||
List<LpkGiftBag> bags = new ArrayList<>(); //礼包
|
||||
List<LpkCardQrcode> codes = new ArrayList<>(); //二维码
|
||||
List<LpkCardBuildRecord> records = new ArrayList<>(); //二维码
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
int cardSerNum = 0;
|
||||
//生成卡包
|
||||
if (!importReturn.isEmpty()) {
|
||||
for (int i = 0; i < importReturn.size(); i++) {
|
||||
ReturnExcelInfo info = importReturn.get(i);
|
||||
LpkGiftCard card = new LpkGiftCard();
|
||||
LpkGiftBag bag = new LpkGiftBag();
|
||||
LpkCardQrcode code = new LpkCardQrcode();
|
||||
LpkCardBuildRecord record = new LpkCardBuildRecord();
|
||||
String serNum = baseMapper.selctMaxSerNumForExport();
|
||||
card.setCreateTime(new DateTime());//卡片生成时间
|
||||
bag.setCreateTime(new DateTime());//礼包生成时间
|
||||
code.setCreateTime(new DateTime());//二维码生成时间
|
||||
record.setCreateTime(new DateTime());//礼包记录生成时间
|
||||
record.setBuildDate(new DateTime());//礼包记录生成时间
|
||||
record.setGiftbagSid(bag.getSid());
|
||||
record.setCountNumber("1");
|
||||
if (StringUtils.isNotBlank(serNum)) {
|
||||
int serNumInt = Integer.parseInt(serNum);
|
||||
if (i == 0) {
|
||||
cardSerNum = serNumInt + 1;
|
||||
}
|
||||
} else {
|
||||
if (cardSerNum == 0) {
|
||||
cardSerNum = 70000001;
|
||||
}
|
||||
}
|
||||
card.setSerialNumber(String.valueOf(cardSerNum));
|
||||
record.setStartNumber(String.valueOf(cardSerNum));
|
||||
record.setEndNumber(String.valueOf(cardSerNum));
|
||||
bag.setName("家庭菜窖" + cardSerNum);
|
||||
card.setGiftbagSid(bag.getSid()); //卡片赋值关联礼包sid
|
||||
card.setRecordSid(record.getSid()); //卡片赋值关联生成卡记录sid
|
||||
card.setState("1");
|
||||
String uuid = UniqueIdGenerator.generateUniqueID();
|
||||
int randomNumber = new Random().nextInt(900000) + 100000;
|
||||
card.setCodeKey(String.valueOf(randomNumber)); //6位密码
|
||||
card.setCode(uuid); //20位提货码
|
||||
//生成二维码转base64
|
||||
String s = genarateQRCodesToBase64ForExport(card.getCode());
|
||||
code.setCardSid(card.getSid());
|
||||
code.setCreateTime(new DateTime());
|
||||
code.setFile(s);
|
||||
//------礼包信息赋值-------------
|
||||
try {
|
||||
bag.setDateStart(sdf.parse(startDate));
|
||||
bag.setDateEnd(sdf.parse(endDate));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
cards.add(card);
|
||||
bags.add(bag);
|
||||
codes.add(code);
|
||||
records.add(record);
|
||||
List<ReturnExcelInfoDetails> infoDetails = info.getInfoDetails();
|
||||
if (!infoDetails.isEmpty()) {
|
||||
for (ReturnExcelInfoDetails detail : infoDetails) {
|
||||
LpkGiftBagGoods giftBagGoods = new LpkGiftBagGoods();
|
||||
giftBagGoods.setCreateTime(new DateTime());
|
||||
if (StringUtils.isNotBlank(detail.getGoodNum()) && StringUtils.isNotBlank(detail.getGoodName())) {
|
||||
LpkGoods lpkGoods = lpkGoodsService.getGoodsByName(detail.getGoodName());
|
||||
if (null != lpkGoods) {
|
||||
giftBagGoods.setGoodsSid(lpkGoods.getSid());
|
||||
if (detail.getGoodNum().contains(".")) {
|
||||
String num = detail.getGoodNum().substring(0, detail.getGoodNum().indexOf("."));
|
||||
giftBagGoods.setGoodsNumber(num);
|
||||
} else {
|
||||
giftBagGoods.setGoodsNumber(detail.getGoodNum());
|
||||
}
|
||||
}
|
||||
giftBagGoods.setGiftbagSid(bag.getSid());
|
||||
bagGoods.add(giftBagGoods);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
startNo = String.valueOf(cardSerNum);
|
||||
}
|
||||
if (i == importReturn.size() - 1) {
|
||||
endNo = String.valueOf(cardSerNum);
|
||||
}
|
||||
cardSerNum = cardSerNum + 1;
|
||||
}
|
||||
//批量插入数据
|
||||
//卡片
|
||||
if (!cards.isEmpty()) {
|
||||
int i = baseMapper.saveCards(cards);
|
||||
}
|
||||
//卡记录
|
||||
if (!records.isEmpty()) {
|
||||
int i = lpkCardBuildRecordService.saveRecords(records);
|
||||
}
|
||||
//二维码
|
||||
if (!codes.isEmpty()) {
|
||||
int i = lpkCardQrcodeService.saveCodes(codes);
|
||||
}
|
||||
//礼包
|
||||
if (!bags.isEmpty()) {
|
||||
int i = lpkGiftBagService.saveBags(bags);
|
||||
}
|
||||
//礼包商品
|
||||
if (!bagGoods.isEmpty()) {
|
||||
int i = LpkGiftBagGoodsService.saveBagGoods(bagGoods);
|
||||
}
|
||||
return rb.success().setMsg("本次导入:" + importReturn.size() + "条数据,生成卡券共计" + importReturn.size() + "张;卡券序列号:" + startNo + "-" + endNo);
|
||||
}
|
||||
return rb.success().setMsg("导入成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 二维码转base64
|
||||
*/
|
||||
public String genarateQRCodesToBase64ForExport(String uuid) {
|
||||
BufferedImage bufferedImage = QrCodeUtil.generate(uuid, 300, 300);
|
||||
byte[] bytes = ImgUtil.toBytes(bufferedImage, "JPG");
|
||||
Base64Encoder base64Encoder = new Base64Encoder();
|
||||
String a = base64Encoder.encode(bytes);
|
||||
a = a.trim();
|
||||
a = a.replaceAll("\n", "").replaceAll("\r", "");
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验导入结果
|
||||
*
|
||||
* @param sheet
|
||||
* @return
|
||||
*/
|
||||
private ReturnMsg getSheetVal2(Sheet sheet) {
|
||||
ReturnMsg returnMsg = new ReturnMsg();
|
||||
List<ReturnExcelInfo> voList = new ArrayList<>();
|
||||
@@ -1168,12 +1345,12 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
|
||||
importVoList.add(details);
|
||||
}
|
||||
if (!isNum(temp)) {
|
||||
setMsg.add(r + "行菜品数量必须为整数");
|
||||
setMsg.add("第" + (r + 1) + "行菜品数量必须为大于0的整数");
|
||||
} else {
|
||||
if (temp.contains(".")) {
|
||||
String num = temp.substring(temp.indexOf(".") + 1);
|
||||
if (Integer.parseInt(num) != 0) {
|
||||
setMsg.add(r + "行菜品数量必须为整数");
|
||||
setMsg.add("第" + (r + 1) + "行菜品数量必须为大于0的整数");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1187,15 +1364,16 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
|
||||
if (!importVoList.isEmpty()) {
|
||||
voList.add(info);
|
||||
} else {
|
||||
setMsg.add(r + "行为空行");
|
||||
setMsg.add("第" + (r + 1) + "行为空行");
|
||||
}
|
||||
}
|
||||
returnMsg.setSetMsg(setMsg);
|
||||
returnMsg.setInfos(voList);
|
||||
return returnMsg;
|
||||
}
|
||||
public ResultBean DownLoadTemplate(){
|
||||
ResultBean rb=new ResultBean();
|
||||
|
||||
public ResultBean DownLoadTemplate() {
|
||||
ResultBean rb = new ResultBean();
|
||||
return rb.success().setData("");
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user