Commit f97e11c7 by yubin

Merge remote-tracking branch 'origin/master'

parents 1ce3e891 1df3492a
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
"vue": "2.6.12", "vue": "2.6.12",
"vue-count-to": "1.0.13", "vue-count-to": "1.0.13",
"vue-cropper": "0.5.5", "vue-cropper": "0.5.5",
"vue-print-nb": "^1.7.5",
"vue-router": "3.4.9", "vue-router": "3.4.9",
"vuedraggable": "2.24.3", "vuedraggable": "2.24.3",
"vuex": "3.6.0" "vuex": "3.6.0"
......
...@@ -39,6 +39,8 @@ import DictData from '@/components/DictData' ...@@ -39,6 +39,8 @@ import DictData from '@/components/DictData'
import PageWrapperSearch from '@/components/Search/PageWrapperSearch.vue' import PageWrapperSearch from '@/components/Search/PageWrapperSearch.vue'
import PageTitle from '@/components/PageTitle/index.vue' import PageTitle from '@/components/PageTitle/index.vue'
// 打印组件
import Print from 'vue-print-nb'
// 全局方法挂载 // 全局方法挂载
Vue.prototype.getDicts = getDicts Vue.prototype.getDicts = getDicts
...@@ -61,9 +63,11 @@ Vue.component('ImageUpload', ImageUpload) ...@@ -61,9 +63,11 @@ Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview) Vue.component('ImagePreview', ImagePreview)
Vue.component('PageWrapperSearch', PageWrapperSearch) Vue.component('PageWrapperSearch', PageWrapperSearch)
Vue.component('PageTitle', PageTitle) Vue.component('PageTitle', PageTitle)
// Vue.component('Print', Print)
Vue.use(directive) Vue.use(directive)
Vue.use(plugins) Vue.use(plugins)
Vue.use(Print)
DictData.install() DictData.install()
/** /**
......
...@@ -17,7 +17,7 @@ const service = axios.create({ ...@@ -17,7 +17,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分 // axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API, baseURL: process.env.VUE_APP_BASE_API,
// 超时 // 超时
timeout: 10000 timeout: 30000
}) })
// request拦截器 // request拦截器
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<el-button <el-button
type="warning" type="warning"
plain plain
icon="el-icon-upload" icon="el-icon-download"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
>导出</el-button> >导出</el-button>
...@@ -738,8 +738,9 @@ export default { ...@@ -738,8 +738,9 @@ export default {
// 导出 // 导出
handleExport() { handleExport() {
this.download('inventory/inbound_items/export', { this.download('inventory/inbound/export', {
...this.queryParams ...this.queryParams,
id: this.inboundOrderId
}, `inbound_items_${new Date().getTime()}.xlsx`) }, `inbound_items_${new Date().getTime()}.xlsx`)
}, },
......
...@@ -14,6 +14,7 @@ import com.alibaba.excel.exception.ExcelAnalysisException; ...@@ -14,6 +14,7 @@ import com.alibaba.excel.exception.ExcelAnalysisException;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.common.utils.uuid.UUID;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -24,6 +25,7 @@ import com.ruoyi.inventory.domain.vo.inboundVO.InboundTRDCTemplateVO; ...@@ -24,6 +25,7 @@ import com.ruoyi.inventory.domain.vo.inboundVO.InboundTRDCTemplateVO;
import com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO; import com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO;
import com.ruoyi.inventory.service.impl.InboundOrdersServiceImpl; import com.ruoyi.inventory.service.impl.InboundOrdersServiceImpl;
import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.system.service.ISysDictDataService;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -66,6 +68,10 @@ public class InboundOrdersController extends BaseController ...@@ -66,6 +68,10 @@ public class InboundOrdersController extends BaseController
List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders); List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders);
return getDataTable(list); return getDataTable(list);
} }
/**
* 获取字典映射表
*/
private Map<Object, Object> getDictMap(String dictType) { private Map<Object, Object> getDictMap(String dictType) {
List<SysDictData> dictList = iSysDictDataService.selectDictDataByType(dictType); List<SysDictData> dictList = iSysDictDataService.selectDictDataByType(dictType);
Map<Object, Object> dictMap = new HashMap<>(); Map<Object, Object> dictMap = new HashMap<>();
...@@ -80,32 +86,74 @@ public class InboundOrdersController extends BaseController ...@@ -80,32 +86,74 @@ public class InboundOrdersController extends BaseController
@PreAuthorize("@ss.hasPermi('inventory:inbound:export')") @PreAuthorize("@ss.hasPermi('inventory:inbound:export')")
@Log(title = "入库单主", businessType = BusinessType.EXPORT) @Log(title = "入库单主", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, InboundOrders inboundOrders) public void export(HttpServletResponse response, InboundOrders inboundOrders) {
{ // 1. 基础空值校验:查询结果为空时直接导出空表格,避免后续循环NPE
List<InboundItemsTO> list = inboundOrdersService.selectInboundOrdersAndItems(inboundOrders); List<InboundItemsTO> list = inboundOrdersService.selectInboundOrdersAndItems(inboundOrders);
if (list == null || list.isEmpty()) {
ExcelUtil<InboundItemsTO> util = new ExcelUtil<>(InboundItemsTO.class);
// 替换 List.of() 为 Java 8 兼容的空列表创建方式
util.exportExcel(response, new ArrayList<>(), "入库单导出数据");
return;
}
// 2. 字典映射表空值校验:避免字典表为空导致的NPE
Map<Object, Object> colorDictMap = getDictMap("label_color"); Map<Object, Object> colorDictMap = getDictMap("label_color");
colorDictMap = MapUtils.emptyIfNull(colorDictMap); // 空Map转为空集合,避免后续get操作NPE
// 3. 循环处理每条数据,增加全字段空值保护
for (InboundItemsTO inboundItem : list) { for (InboundItemsTO inboundItem : list) {
if (inboundItem != null) { // 跳过空对象
inboundItem.setPackageWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages())); if (inboundItem == null) {
inboundItem.setUnitWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages())); continue;
inboundItem.setLabelColorName((String) colorDictMap.get(inboundItem.getLabelColor()+"")); }
switch (inboundItem.getOrderTypeId()) {
case "1": // ========== 3.1 数学运算安全处理(避免除零/空值运算NPE) ==========
inboundItem.setRelocation(inboundItem.getRemark()); // 初始化默认值,避免空值运算
break; Double weight = inboundItem.getWeight() == null ? 0.0 : inboundItem.getWeight();
case "2": Double actualQuantity = inboundItem.getActualQuantity() == null ? 0.0 : inboundItem.getActualQuantity();
inboundItem.setFinishedLocation(inboundItem.getRemark()); Double actualPackages = inboundItem.getActualPackages() == null ? 1.0 : inboundItem.getActualPackages();
break;
case "3": // 安全除法:避免除零异常
inboundItem.setRemarkTrdc(inboundItem.getRemark()); double quantityPerPackage = actualPackages == 0 ? 0 : actualQuantity / actualPackages;
inboundItem.setFinishedSystemNo(inboundItem.getSystemNo()); // 计算重量(空值保护)
inboundItem.setFinishedOrderId(inboundItem.getOrderId()); double packageWeight = weight * quantityPerPackage;
break;
} // 赋值(避免setter传入null)
inboundItem.setPackageWeight(packageWeight);
inboundItem.setUnitWeight(packageWeight); // 与packageWeight值相同
// ========== 3.2 标签颜色名称映射(空值保护) ==========
String labelColor = inboundItem.getLabelColor() == null ? "" : inboundItem.getLabelColor().toString();
String labelColorName = (String) colorDictMap.get(labelColor);
inboundItem.setLabelColorName(StringUtils.defaultIfBlank(labelColorName, "")); // 空值转为空字符串
// ========== 3.3 订单类型分支处理(空值保护) ==========
String orderTypeId = StringUtils.defaultIfBlank(inboundItem.getOrderTypeId(), "-");
String remark = StringUtils.defaultIfBlank(inboundItem.getRemark(), "-");
String systemNo = StringUtils.defaultIfBlank(inboundItem.getSystemNo(), "-");
String orderId = StringUtils.defaultIfBlank(inboundItem.getOrderId(), "-");
switch (orderTypeId) {
case "1":
inboundItem.setRelocation(remark);
break;
case "2":
inboundItem.setFinishedLocation(remark);
break;
case "3":
inboundItem.setRemarkTrdc(remark);
inboundItem.setFinishedSystemNo(systemNo);
inboundItem.setFinishedOrderId(orderId);
break;
// 增加默认分支,避免未匹配的情况
default:
// 可选:记录日志或设置默认值
break;
} }
} }
ExcelUtil<InboundItemsTO> util = new ExcelUtil<InboundItemsTO>(InboundItemsTO.class); // 4. 导出Excel(最终兜底:确保传入非null列表)
ExcelUtil<InboundItemsTO> util = new ExcelUtil<>(InboundItemsTO.class);
util.exportExcel(response, list, "入库单导出数据"); util.exportExcel(response, list, "入库单导出数据");
} }
......
...@@ -127,7 +127,7 @@ referer: ...@@ -127,7 +127,7 @@ referer:
# 防盗链开关 # 防盗链开关
enabled: false enabled: false
# 允许的域名列表 # 允许的域名列表
allowed-domains: localhost,127.0.0.1 allowed-domains: localhost,127.0.0.1,172.19.1.150,http://wms.docmis.cn/
# 防止XSS攻击 # 防止XSS攻击
xss: xss:
......
...@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectInboundOrdersList" parameterType="InboundOrders" resultMap="InboundOrdersResult"> <select id="selectInboundOrdersList" parameterType="InboundOrders" resultMap="InboundOrdersResult">
<include refid="selectInboundOrdersVo"/> <include refid="selectInboundOrdersVo"/>
<where> <where>
<if test="id != null and Id != ''"> and id = #{Id}</if> <if test="id != null and id != ''"> and id = #{id}</if>
<if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%')</if> <if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%')</if>
<if test="systemNo != null and systemNo != ''"> and system_no like concat('%', #{systemNo}, '%')</if> <if test="systemNo != null and systemNo != ''"> and system_no like concat('%', #{systemNo}, '%')</if>
<if test="orderTypeId != null and orderTypeId != ''"> and order_type_id = #{orderTypeId}</if> <if test="orderTypeId != null and orderTypeId != ''"> and order_type_id = #{orderTypeId}</if>
...@@ -100,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -100,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if> <if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if> <if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</where> </where>
order by date(inbound_date) desc,create_time desc order by order_status asc, date(inbound_date) desc,create_time desc
</select> </select>
<select id="selectInboundOrdersById" parameterType="String" resultMap="InboundOrdersInboundOrderItemsResult"> <select id="selectInboundOrdersById" parameterType="String" resultMap="InboundOrdersInboundOrderItemsResult">
...@@ -334,11 +334,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -334,11 +334,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ioi.label_color, ioi.voucher_number, m.storage_temperature, ioi.label_color, ioi.voucher_number, m.storage_temperature,
m.hazard_id, io.order_id, io.system_no, io.owner_id, m.hazard_id, io.order_id, io.system_no, io.owner_id,
ioi.label_quantity, io.order_type, io.order_type_id, ioi.remark ioi.label_quantity, io.order_type, io.order_type_id, ioi.remark
from materials as m from inbound_order_items as ioi
inner join inbound_order_items as ioi on ioi.material_id = m.id left join materials as m on ioi.material_id = m.id
inner join inbound_orders as io on ioi.inbound_order_id = io.id left join inbound_orders as io on ioi.inbound_order_id = io.id
inner join storage_locations as sl on ioi.location_id = sl.id left join storage_locations as sl on ioi.location_id = sl.id
<where>
<if test="id != null and id != ''"> and io.id = #{id}</if>
<if test="orderId != null and orderId != ''"> and io.order_id like concat('%', #{orderId}, '%')</if>
<if test="systemNo != null and systemNo != ''"> and io.system_no like concat('%', #{systemNo}, '%')</if>
<if test="orderTypeId != null and orderTypeId != ''"> and io.order_type_id = #{orderTypeId}</if>
<if test="batchId != null and batchId != ''"> and ioi.batch_id like concat('%', #{batchId}, '%') </if>
<if test="ownerId != null and ownerId != ''"> and io.owner_id = #{ownerId}</if>
<if test="orderStatus != null "> and io.order_status = #{orderStatus}</if>
<!-- 新增按照日期范围查询-->
<if test="inboundDateStart != null">
AND date(inbound_date) &gt;= #{inboundDateStart}
</if>
<if test="inboundDateEnd != null">
AND date(inbound_date) &lt;= #{inboundDateEnd}
</if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
</where>
order by order_status asc, date(io.inbound_date) desc, io.create_time desc
</select> </select>
<resultMap id="InboundOrderAndItemsMap" type="com.ruoyi.inventory.domain.TO.InboundItemsTO"> <resultMap id="InboundOrderAndItemsMap" type="com.ruoyi.inventory.domain.TO.InboundItemsTO">
<!-- 基础字段映射:SQL字段名 -> Java实体类字段名 --> <!-- 基础字段映射:SQL字段名 -> Java实体类字段名 -->
<result column="inbound_date" property="inboundDate" /> <result column="inbound_date" property="inboundDate" />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论