Commit a9948db2 by 胡懿

修改出库报错的问题,升级poi,

parent df05c88c
...@@ -7,7 +7,7 @@ public class ExcelExportInfo { ...@@ -7,7 +7,7 @@ public class ExcelExportInfo {
private String remarks; private String remarks;
private int taskOrSend; // 0是收入,1是支出 private int taskOrSend; // 0是收入,1是支出
private String task; private String task;
private String mask; private String send;
private String num; private String num;
private String model; private String model;
private String userName; private String userName;
...@@ -60,12 +60,12 @@ public class ExcelExportInfo { ...@@ -60,12 +60,12 @@ public class ExcelExportInfo {
this.task = task; this.task = task;
} }
public String getMask() { public String getSend() {
return mask; return send;
} }
public void setMask(String mask) { public void setSend(String send) {
this.mask = mask; this.send = send;
} }
public String getNum() { public String getNum() {
......
...@@ -25,7 +25,6 @@ public class Ledger extends DataEntity<Ledger> { ...@@ -25,7 +25,6 @@ public class Ledger extends DataEntity<Ledger> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String name; // 物资名称 private String name; // 物资名称
private MaterialType type; // 类型 private MaterialType type; // 类型
private String model; // 型号
private String shelvesIds; // 货架id集合 private String shelvesIds; // 货架id集合
private Integer num; // 数量 private Integer num; // 数量
private BigDecimal sum; // 总价格 private BigDecimal sum; // 总价格
...@@ -41,10 +40,9 @@ public class Ledger extends DataEntity<Ledger> { ...@@ -41,10 +40,9 @@ public class Ledger extends DataEntity<Ledger> {
super(id); super(id);
} }
public Ledger(String name, MaterialType type, String model) { public Ledger(String name, MaterialType type) {
this.name = name; this.name = name;
this.type = type; this.type = type;
this.model = model;
} }
@NotNull(message="物资名称不能为空") @NotNull(message="物资名称不能为空")
...@@ -67,16 +65,6 @@ public class Ledger extends DataEntity<Ledger> { ...@@ -67,16 +65,6 @@ public class Ledger extends DataEntity<Ledger> {
this.type = type; this.type = type;
} }
@NotNull(message="型号不能为空")
@ExcelField(title="型号", align=2, sort=3)
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
@ExcelField(title="货架id集合", align=2, sort=4) @ExcelField(title="货架id集合", align=2, sort=4)
public String getShelvesIds() { public String getShelvesIds() {
return shelvesIds; return shelvesIds;
......
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
@MyBatisMapper @MyBatisMapper
public interface LedgerMapper extends BaseMapper<Ledger> { public interface LedgerMapper extends BaseMapper<Ledger> {
public Ledger findByTypeAndModel(Ledger ledger); public Ledger findByType(Ledger ledger);
//zlt 查询台账主表的货架集合 //zlt 查询台账主表的货架集合
public List<String> findShelvesListByLedgerId(@Param("id") String id); public List<String> findShelvesListByLedgerId(@Param("id") String id);
} }
\ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
a.id AS "id", a.id AS "id",
a.name AS "name", a.name AS "name",
a.type_id AS "type.id", a.type_id AS "type.id",
a.model AS "model",
a.shelvesids AS "shelvesIds", a.shelvesids AS "shelvesIds",
a.num AS "num", a.num AS "num",
a.sum AS "sum", a.sum AS "sum",
...@@ -103,7 +102,6 @@ ...@@ -103,7 +102,6 @@
id, id,
name, name,
type_id, type_id,
model,
shelvesids, shelvesids,
num, num,
sum, sum,
...@@ -117,7 +115,6 @@ ...@@ -117,7 +115,6 @@
#{id}, #{id},
#{name}, #{name},
#{type.id}, #{type.id},
#{model},
#{shelvesIds}, #{shelvesIds},
#{num}, #{num},
#{sum}, #{sum},
...@@ -134,7 +131,6 @@ ...@@ -134,7 +131,6 @@
UPDATE t_wh_ledger SET UPDATE t_wh_ledger SET
name = #{name}, name = #{name},
type_id = #{type.id}, type_id = #{type.id},
model = #{model},
shelvesids = #{shelvesIds}, shelvesids = #{shelvesIds},
num = #{num}, num = #{num},
sum = #{sum}, sum = #{sum},
...@@ -164,7 +160,7 @@ ...@@ -164,7 +160,7 @@
select * FROM t_wh_ledger where ${propertyName} = '${value}' select * FROM t_wh_ledger where ${propertyName} = '${value}'
</select> </select>
<select id="findByTypeAndModel" resultType="Ledger" > <select id="findByType" resultType="Ledger" >
SELECT SELECT
<include refid="ledgerColumns"/> <include refid="ledgerColumns"/>
FROM t_wh_ledger a FROM t_wh_ledger a
...@@ -172,7 +168,6 @@ ...@@ -172,7 +168,6 @@
<where> <where>
a.del_flag = #{DEL_FLAG_NORMAL} a.del_flag = #{DEL_FLAG_NORMAL}
AND a.type_id = #{type.id} AND a.type_id = #{type.id}
AND a.model = #{model}
</where> </where>
</select> </select>
<select id="findShelvesListByLedgerId" resultType="java.lang.String" parameterType="java.lang.String"> <select id="findShelvesListByLedgerId" resultType="java.lang.String" parameterType="java.lang.String">
......
...@@ -10,6 +10,7 @@ import java.math.BigDecimal; ...@@ -10,6 +10,7 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import com.jeeplus.common.utils.DateUtil; import com.jeeplus.common.utils.DateUtil;
import com.jeeplus.common.utils.Encodes;
import com.jeeplus.modules.sys.entity.User; import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.utils.UserUtils; import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.warehouse.ledger.Utils.ExcelStyleUtils; import com.jeeplus.modules.warehouse.ledger.Utils.ExcelStyleUtils;
...@@ -101,8 +102,8 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -101,8 +102,8 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void save(Ledger ledger) { public void save(Ledger ledger) {
Ledger oldLeger = mapper.findByTypeAndModel(ledger); Ledger oldLeger = mapper.findByType(ledger);
// 判断是否存在同名称、同类型、同型号的台账,如果不存在,做新增操作,如果存在,则做修改操作 // 判断是否存在同名称品名的台账,如果不存在,做新增操作,如果存在,则做修改操作
if (null == oldLeger || StringUtils.isBlank(oldLeger.getId())) { if (null == oldLeger || StringUtils.isBlank(oldLeger.getId())) {
super.save(ledger); super.save(ledger);
} else { } else {
...@@ -213,21 +214,50 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -213,21 +214,50 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
eei.setBatch(si.getStorage().getBatchNum()); eei.setBatch(si.getStorage().getBatchNum());
eei.setRemarks(si.getRemarks()); eei.setRemarks(si.getRemarks());
eei.setTaskOrSend(0); eei.setTaskOrSend(0);
eei.setTask(si.getInfoSum().toString()); eei.setTask(si.getAmount().multiply(new BigDecimal(si.getNum())).toString());
eei.setMask(""); eei.setSend("");
eei.setNum(si.getNum() + ""); eei.setNum(si.getNum() + "");
eei.setModel(si.getModel()); eei.setModel(si.getModel());
// modelMap Integer n = modelMap.get(si.getModel());
if (null == n) {
modelMap.put(si.getModel(), modelMap.size());
}
User user = UserUtils.get(si.getCreateBy().getId()); User user = UserUtils.get(si.getCreateBy().getId());
eei.setUserName(user.getLoginName()); eei.setUserName(user.getLoginName());
excelExportInfoList.add(eei); excelExportInfoList.add(eei);
} }
for (OutboundInfo oi : outboundInfoList) {
ExcelExportInfo eei = new ExcelExportInfo();
eei.setMonth(DateUtil.getMonth(oi.getCreateDate()) + "");
eei.setDay(DateUtil.getDay(oi.getCreateDate()) + "");
eei.setBatch(oi.getLedgerInfo().getBatchNum());
eei.setRemarks(oi.getRemarks());
eei.setTaskOrSend(1);
eei.setTask("");
eei.setSend(oi.getLedgerInfo().getAmount() + "");
eei.setNum(1 + "");
eei.setModel(oi.getLedgerInfo().getModel());
Integer n = modelMap.get(oi.getLedgerInfo().getModel());
if (null == n) {
modelMap.put(oi.getLedgerInfo().getModel(), modelMap.size());
}
User user = UserUtils.get(oi.getCreateBy().getId());
eei.setUserName(user.getLoginName());
excelExportInfoList.add(eei);
}
if (modelMap.size() == 0) {
modelMap.put(" ", 0);
}
Map<Integer, String> intModelMap = new HashMap<>();
for (Map.Entry<String, Integer> entry : modelMap.entrySet()) {
intModelMap.put(entry.getValue(), entry.getKey());
}
int sunRowNum = 5 + storageInfoList.size() + outboundInfoList.size(); int sunRowNum = 5 + storageInfoList.size() + outboundInfoList.size();
// 创建工作薄 // 创建工作薄
...@@ -241,12 +271,14 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -241,12 +271,14 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
int cellNUm = 8 + modelMap.size();
int num = cellNUm / 3; // 第二行使用的列数
//设置数据 //设置数据
for (int row = 0; row < sunRowNum; row++) { for (int row = 0; row < sunRowNum; row++) {
XSSFRow sheetRow = sheet.createRow(row); XSSFRow sheetRow = sheet.createRow(row);
if (0 == row) { if (0 == row) {
sheetRow.setHeightInPoints(30); sheetRow.setHeightInPoints(30);
for (int i = 0; i < 22; i ++) { for (int i = 0; i < cellNUm; i ++) {
if (0 == i) { if (0 == i) {
XSSFCell cell = sheetRow.createCell(i); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("被 装 物 资 库 房 帐"); cell.setCellValue("被 装 物 资 库 房 帐");
...@@ -259,16 +291,16 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -259,16 +291,16 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
} }
if (1 == row) { if (1 == row) {
sheetRow.setHeightInPoints(20); sheetRow.setHeightInPoints(20);
for (int i = 0; i < 22; i ++) { for (int i = 0; i < cellNUm; i ++) {
if (0 == i) { if (0 == i) {
XSSFCell cell = sheetRow.createCell(i); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("品名代码:" + materialType.getCode()); cell.setCellValue("品名代码:" + materialType.getCode());
cell.setCellStyle(twoStyle); cell.setCellStyle(twoStyle);
} else if (4 == i) { } else if (num == i) {
XSSFCell cell1 = sheetRow.createCell(i); XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("品名:" + materialType.getName()); cell1.setCellValue("品名:" + materialType.getName());
cell1.setCellStyle(twoStyle); cell1.setCellStyle(twoStyle);
} else if (12 == i) { } else if (num + num == i) {
XSSFCell cell2 = sheetRow.createCell(i); XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellValue("计量单位:" + materialType.getUnit()); cell2.setCellValue("计量单位:" + materialType.getUnit());
cell2.setCellStyle(twoStyle); cell2.setCellStyle(twoStyle);
...@@ -281,7 +313,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -281,7 +313,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
} }
if (2 == row) { if (2 == row) {
sheetRow.setHeightInPoints(15); sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) { for (int i = 0; i < cellNUm; i ++) {
if (0 == i) { if (0 == i) {
XSSFCell cell = sheetRow.createCell(i); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue(DateUtil.getYear(eTime) + " 年"); cell.setCellValue(DateUtil.getYear(eTime) + " 年");
...@@ -307,7 +339,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -307,7 +339,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
XSSFCell cell5 = sheetRow.createCell(i); XSSFCell cell5 = sheetRow.createCell(i);
cell5.setCellValue("结存"); cell5.setCellValue("结存");
cell5.setCellStyle(threeStyle); cell5.setCellStyle(threeStyle);
} else if (21 == i) { } else if (cellNUm - 1 == i) {
XSSFCell cell6 = sheetRow.createCell(i); XSSFCell cell6 = sheetRow.createCell(i);
cell6.setCellValue("登记人"); cell6.setCellValue("登记人");
cell6.setCellStyle(threeStyle); cell6.setCellStyle(threeStyle);
...@@ -319,69 +351,103 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -319,69 +351,103 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
} }
if (3 == row) { if (3 == row) {
sheetRow.setHeightInPoints(15); sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) { for (int i = 0; i < cellNUm; i ++) {
if (6 == i) { if (6 == i) {
XSSFCell cell2 = sheetRow.createCell(i); XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellValue("数量"); cell2.setCellValue("数量");
cell2.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell2.setCellStyle(threeStyle);
} else if (7 == i) { } else if (7 == i) {
XSSFCell cell3 = sheetRow.createCell(i); XSSFCell cell3 = sheetRow.createCell(i);
cell3.setCellValue("号型"); cell3.setCellValue("号型");
cell3.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell3.setCellStyle(threeStyle);
} else { } else {
XSSFCell cell3 = sheetRow.createCell(i); XSSFCell cell3 = sheetRow.createCell(i);
cell3.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell3.setCellStyle(threeStyle);
} }
} }
} }
if (4 == row) { if (4 == row) {
sheetRow.setHeightInPoints(15); sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) { for (int i = 0; i < cellNUm; i ++) {
if (0 == i) { if (0 == i) {
XSSFCell cell = sheetRow.createCell(i); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("月"); cell.setCellValue("月");
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell.setCellStyle(threeStyle);
} else if (1 == i) { } else if (1 == i) {
XSSFCell cell1 = sheetRow.createCell(i); XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("日"); cell1.setCellValue("日");
cell1.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell1.setCellStyle(threeStyle);
} else { } else if (i > 6 && i <= (6 + modelMap.size())) {
XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue(intModelMap.get(i - 7));
cell1.setCellStyle(threeStyle);
} else {
XSSFCell cell = sheetRow.createCell(i); XSSFCell cell = sheetRow.createCell(i);
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook)); cell.setCellStyle(threeStyle);
} }
} }
} }
if (row >= 5) {
ExcelExportInfo eei = excelExportInfoList.get(row - 5);
for (int i = 0; i < cellNUm; i ++) {
XSSFCell cell = sheetRow.createCell(i);
if (0 == i) {
cell.setCellValue(eei.getMonth());
} else if (1 == i) {
cell.setCellValue(eei.getDay());
} else if (2 == i) {
cell.setCellValue(eei.getBatch());
} else if (3 == i) {
cell.setCellValue(eei.getRemarks());
} else if (4 == i) {
cell.setCellValue(eei.getTask());
} else if (5 == i) {
cell.setCellValue(eei.getSend());
} else if (6 == i) {
cell.setCellValue(eei.getNum());
} else if (i > 6 && i <= (6 + modelMap.size())) {
if (i == modelMap.get(eei.getModel()) + 7) {
cell.setCellValue(eei.getModel());
}
} else if (i == cellNUm - 1) {
cell.setCellValue(eei.getUserName());
}
cell.setCellStyle(threeStyle);
}
}
// 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度 // 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度
} }
sheet.addMergedRegion(new CellRangeAddress(0,0,0,21)); sheet.addMergedRegion(new CellRangeAddress(0,0,0,cellNUm - 1));
sheet.addMergedRegion(new CellRangeAddress(1,1,0,num - 1));
sheet.addMergedRegion(new CellRangeAddress(1,1,num,num + num - 1));
sheet.addMergedRegion(new CellRangeAddress(1,1,num + num,cellNUm - 1));
sheet.addMergedRegion(new CellRangeAddress(1,1,0,3));
sheet.addMergedRegion(new CellRangeAddress(1,1,4,11));
sheet.addMergedRegion(new CellRangeAddress(1,1,12,21));
sheet.addMergedRegion(new CellRangeAddress(2,3,0,1)); sheet.addMergedRegion(new CellRangeAddress(2,3,0,1));
sheet.addMergedRegion(new CellRangeAddress(2,4,2,2)); sheet.addMergedRegion(new CellRangeAddress(2,4,2,2));
sheet.addMergedRegion(new CellRangeAddress(2,4,3,3)); sheet.addMergedRegion(new CellRangeAddress(2,4,3,3));
sheet.addMergedRegion(new CellRangeAddress(2,4,4,4)); sheet.addMergedRegion(new CellRangeAddress(2,4,4,4));
sheet.addMergedRegion(new CellRangeAddress(2,4,5,5)); sheet.addMergedRegion(new CellRangeAddress(2,4,5,5));
sheet.addMergedRegion(new CellRangeAddress(2,2,6,20)); sheet.addMergedRegion(new CellRangeAddress(2,2,6,6 + modelMap.size()));
sheet.addMergedRegion(new CellRangeAddress(2,4,21,21)); sheet.addMergedRegion(new CellRangeAddress(2,4,6 + modelMap.size() + 1,cellNUm - 1));
sheet.addMergedRegion(new CellRangeAddress(3,4,6,6)); sheet.addMergedRegion(new CellRangeAddress(3,4,6,6));
sheet.addMergedRegion(new CellRangeAddress(3,3,7,20)); if (modelMap.size() > 1) {
FileOutputStream out = null; sheet.addMergedRegion(new CellRangeAddress(3,3,7,7 + modelMap.size() - 1));
}
try { try {
out = new FileOutputStream(new File("D:/excel.xlsx")); //out = new FileOutputStream(new File("D:/excel.xlsx"));
workbook.write(out); //workbook.write(out);
respons.reset();
respons.setContentType("application/octet-stream; charset=utf-8");
respons.setHeader("Content-Disposition", "attachment; filename="+ Encodes.urlEncode(beginTime + "-" + endTime + "被装物资库房帐.xlsx"));
workbook.write(respons.getOutputStream());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (null != out) {
out.flush();
out.close();
}
workbook.close(); workbook.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
tpye.name AS "ledgerInfo.type.name", tpye.name AS "ledgerInfo.type.name",
ledgerInfo.model AS "ledgerInfo.model", ledgerInfo.model AS "ledgerInfo.model",
ledgerInfo.amount AS "ledgerInfo.amount", ledgerInfo.amount AS "ledgerInfo.amount",
ledgerInfo.batch_num AS "ledgerInfo.batchNum",
a.del_flag AS "delFlag" a.del_flag AS "delFlag"
</sql> </sql>
......
...@@ -189,15 +189,15 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe ...@@ -189,15 +189,15 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void inLedgerInfo(ProfitWarehousingInfo profitWarehousingInfo) { public void inLedgerInfo(ProfitWarehousingInfo profitWarehousingInfo) {
QrCode qrCode = qrCodeService.get(profitWarehousingInfo.getQrCode().getId()); QrCode qrCode = qrCodeService.get(profitWarehousingInfo.getQrCode().getId());
Ledger ledger = new Ledger(profitWarehousingInfo.getName(),profitWarehousingInfo.getType(),profitWarehousingInfo.getMarking()); Ledger ledger = new Ledger(profitWarehousingInfo.getName(),profitWarehousingInfo.getType());
Ledger oldLeger = ledgerMapper.findByTypeAndModel(ledger); Ledger oldLeger = ledgerMapper.findByType(ledger);
LedgerInfo ledgerInfo = new LedgerInfo(); LedgerInfo ledgerInfo = new LedgerInfo();
//名称 //名称
ledgerInfo.setName(ledger.getName()); ledgerInfo.setName(ledger.getName());
//类型 //类型
ledgerInfo.setType(ledger.getType()); ledgerInfo.setType(ledger.getType());
//型号 //型号
ledgerInfo.setModel(ledger.getModel()); //ledgerInfo.setModel(ledger.getModel());
//物资编码 //物资编码
ledgerInfo.setCode(qrCode.getCode()); ledgerInfo.setCode(qrCode.getCode());
//二维码id //二维码id
......
...@@ -33,7 +33,6 @@ public class StorageInfo extends DataEntity<StorageInfo> { ...@@ -33,7 +33,6 @@ public class StorageInfo extends DataEntity<StorageInfo> {
private String warehouseIds; // 仓库id集合 private String warehouseIds; // 仓库id集合
private BigDecimal amount; // 单价 private BigDecimal amount; // 单价
private int num; // 数量 private int num; // 数量
private BigDecimal infoSum; // 总价
private List<Shelves> shelvesList; // 货架id private List<Shelves> shelvesList; // 货架id
private List<Warehouse> warehouseList; // 仓库外键 private List<Warehouse> warehouseList; // 仓库外键
...@@ -164,13 +163,6 @@ public class StorageInfo extends DataEntity<StorageInfo> { ...@@ -164,13 +163,6 @@ public class StorageInfo extends DataEntity<StorageInfo> {
this.warehouseList = warehouseList; this.warehouseList = warehouseList;
} }
public BigDecimal getInfoSum() {
return infoSum;
}
public void setInfoSum(BigDecimal infoSum) {
this.infoSum = infoSum;
}
public Date getBeginTime() { public Date getBeginTime() {
return beginTime; return beginTime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment