Browse Source

[fix]

工程管理 BOM信息
修改bom列表页面导出按钮绑定方法,新增获取多选选中bom信息导出数据方法;
修改ErpBom实体类,调整导出内容包含的字段及顺序,新增说明文件字段,修改时间类型的导出格式;
修改bom导出内容的后端接口;
修改mapper及接口,新增按bom号列表批量查询bom及阶层信息的方法
dev
王晓迪 7 months ago
parent
commit
c12ebe9169
  1. 8
      ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpBomController.java
  2. 31
      ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpBomMapper.java
  4. 2
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpBomService.java
  5. 17
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java
  6. 37
      ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml
  7. 78
      ruoyi-admin/src/main/resources/templates/erp/bom/bom.html

8
ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpBomController.java

@ -138,10 +138,12 @@ public class ErpBomController extends BaseController
@Log(title = "ErpBom", businessType = BusinessType.EXPORT) @Log(title = "ErpBom", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(ErpBomVo erpBom) public AjaxResult export(@RequestBody String[] bomNos)
{ {
erpBom.setParentId(0L); // erpBom.setParentId(0L);
List<ErpBom> list = erpBomService.getExportList(erpBom);
// List<ErpBom> list = erpBomService.getExportList(erpBom);
List<ErpBom> list = erpBomService.getExportListByNos(bomNos);
ExcelUtil<ErpBom> util = new ExcelUtil<ErpBom>(ErpBom.class); ExcelUtil<ErpBom> util = new ExcelUtil<ErpBom>(ErpBom.class);
return util.exportExcel(list, "bom数据"); return util.exportExcel(list, "bom数据");
} }

31
ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java

@ -1,5 +1,6 @@
package com.ruoyi.erp.domain; package com.ruoyi.erp.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
@ -26,40 +27,43 @@ public class ErpBom extends BaseEntity
private String delFlag; private String delFlag;
/** bom号 */ /** bom号 */
@Excel(name = "bom号",sort = 2)
private String bomNo; private String bomNo;
/** 料号 */ /** 料号 */
@Excel(name = "料号",sort = 2) @Excel(name = "料号",sort = 3)
private String materialNo; private String materialNo;
@Excel(name = "图片",sort = 9)
private String photoUrl; private String photoUrl;
/** 物料名称 */ /** 物料名称 */
@Excel(name = "品名",sort = 3) @Excel(name = "物料名称",sort = 4)
private String materialName; private String materialName;
/** 物料类型 */ /** 物料类型 */
@Excel(name="物料类型") // @Excel(name="物料类型")
private String materialType; private String materialType;
/** 加工方式 */ /** 加工方式 */
@Excel(name = "半成品类型",sort = 6,dictType = "processMethod") @Excel(name = "半成品类型",sort = 7,dictType = "processMethod")
private String processMethod; private String processMethod;
/** 单位 */ /** 单位 */
@Excel(name = "单位",sort = 7) @Excel(name = "单位",sort = 8)
private String unit; private String unit;
/** 品牌 */ /** 品牌 */
@Excel(name = "品牌",sort = 5) @Excel(name = "品牌",sort = 6)
private String brand; private String brand;
/** 描述 */ /** 描述 */
@Excel(name = "描述",sort = 4) @Excel(name = "描述",sort = 5)
private String describe; private String describe;
private String warehouseDept; private String warehouseDept;
/** 用量 */ /** 用量 */
@Excel(name = "用量",sort = 8) // @Excel(name = "用量",sort = 8)
private Long useNum; private Long useNum;
/** 损耗率 */ /** 损耗率 */
@ -75,7 +79,7 @@ public class ErpBom extends BaseEntity
/** 排序 */ /** 排序 */
private Long sortNo; private Long sortNo;
@Excel(name = "工程员",sort = 9) // @Excel(name = "工程员",sort = 9)
private String engineer; private String engineer;
/** 审核状态 */ /** 审核状态 */
@ -103,9 +107,12 @@ public class ErpBom extends BaseEntity
private String applyTitle; private String applyTitle;
/** 申请人 */ /** 申请人 */
@Excel(name = "申请人",sort = 10)
private String applyUser; private String applyUser;
/** 申请时间 */ /** 申请时间 */
@Excel(name = "申请时间",dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 11)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date applyTime; private Date applyTime;
private Long photoAttachId; private Long photoAttachId;
@ -114,10 +121,14 @@ public class ErpBom extends BaseEntity
private String removeFileIdStr; private String removeFileIdStr;
//上次更新时间
@Excel(name = "上次更新时间",dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 12)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** bom信息 */ /** bom信息 */
private List<ErpBom> erpBomList; private List<ErpBom> erpBomList;
@Excel(name = "说明文件",sort = 10) @Excel(name = "说明文件",sort = 13)
private String documents; private String documents;
public String getDocuments() { public String getDocuments() {

8
ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpBomMapper.java

@ -139,4 +139,12 @@ public interface ErpBomMapper
List<ErpBomVo> selectSubBomsByParentMaterialNo(Map<String, Object> params); List<ErpBomVo> selectSubBomsByParentMaterialNo(Map<String, Object> params);
List<ErpBomVo> selectErpBomByParentIds(Map<String, Object> params); List<ErpBomVo> selectErpBomByParentIds(Map<String, Object> params);
/**
* 查询bom列表
*
* @param bomNos bom
* @return bom集合
*/
public List<ErpBomVo> selectErpBomListByBomNos(String[] bomNos);
} }

2
ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpBomService.java

@ -112,6 +112,8 @@ public interface IErpBomService
List<ErpBom> getExportList(ErpBomVo erpBom); List<ErpBom> getExportList(ErpBomVo erpBom);
public List<ErpBom> getExportListByNos(String[] bomNos);
String importData(List<ErpBomImportVo> bomImportVos,boolean updateSupport); String importData(List<ErpBomImportVo> bomImportVos,boolean updateSupport);
public ProcessInstance submitApply(ErpBom erpBom); public ProcessInstance submitApply(ErpBom erpBom);

17
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java

@ -459,6 +459,23 @@ private ISysAttachService attachService;
return resultList; return resultList;
} }
@Override
public List<ErpBom> getExportListByNos(String[] bomNos) {
List<ErpBom> resultList = new ArrayList<>();
List<ErpBomVo> zeroLevelList = erpBomMapper.selectErpBomListByBomNos(bomNos);
if(CollectionUtils.isNotEmpty(zeroLevelList)){
for (ErpBomVo bom:zeroLevelList) {
bom.setParentId(0L);
resultList.add(bom);
ErpBom bom1 = new ErpBom();
bom1.setParentId(bom.getId());
List<ErpBom> subLevelList = selectErpBomAllLevelList(bom1);
resultList.addAll(subLevelList);
}
}
return resultList;
}
/** /**
* 导入数据 * 导入数据
* *

37
ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml

@ -521,4 +521,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
on erp_material.id = file.rel_id on erp_material.id = file.rel_id
where erp.parent_id in (#{parentId}) where erp.parent_id in (#{parentId})
</select> </select>
<select id="selectErpBomListByBomNos" parameterType="String" resultMap="ErpBomResult">
select erp.id, erp.del_flag, erp.create_by, erp.create_time, erp.update_by, erp.update_time,
erp.remark,erp.bom_no,erp.material_no,erp.material_name, erp.audit_status, erp.use_status,
erp.material_type, erp.process_method,erp.unit, erp.brand, erp.`describe`,erp.warehouseDept,erp.engineer,
erp.use_num,erp.loss_rate, erp.parent_id, erp.`level`, erp.sort_no, erp.instance_id,
erp.instance_type, processDict.dict_label as instance_type_name, erp.submit_instance_id,
erp.cancel_instance_id, erp.restore_instance_id,erp.apply_title,erp.apply_user,erp.apply_time,
file.url as photo_url,cate.name as material_type_name from erp_bom as erp
left join (
select id,material_no,material_name from erp_material
) erp_material
on erp.material_no = erp_material.material_no
left join(
select dict_value,dict_label from sys_dict_data
where dict_type = 'processType'
) processDict
on erp.instance_type = processDict.dict_value
left join (
select code,name from sys_category
where parent_id in(
select id from sys_category
where parent_id = (select id from sys_category where code = 'materialType') )
) cate
on erp.material_type = cate.code
left join (
select att.rel_id,file.url,min(file.create_time) as create_time from sys_attach as att
left join sys_attach_file as file
on att.id = file.attach_id
where att.source_type = 'erpMaterial' and att.source_sub_type = 'photo'
group by att.rel_id
) file
on erp_material.id = file.rel_id
where erp.bom_no in
<foreach item="bomNo" collection="array" open="(" separator="," close=")">
#{bomNo}
</foreach>
</select>
</mapper> </mapper>

78
ruoyi-admin/src/main/resources/templates/erp/bom/bom.html

@ -76,7 +76,7 @@
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="erp:bom:add"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="erp:bom:add">
<i class="fa fa-plus"></i> 添加 <i class="fa fa-plus"></i> 添加
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:bom:export"> <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="erp:bom:export">
<i class="fa fa-download"></i> 导出 <i class="fa fa-download"></i> 导出
</a> </a>
<a class="btn btn-info" onclick="$.table.importExcel()"> <a class="btn btn-info" onclick="$.table.importExcel()">
@ -126,6 +126,7 @@
sortStable: true, // 设置为 true 将获得稳定的排序 sortStable: true, // 设置为 true 将获得稳定的排序
modalName: "bom", modalName: "bom",
detailView: true, detailView: true,
adaptive: true,
fixedColumns: true, // 启用冻结列 fixedColumns: true, // 启用冻结列
rightFixedColumns:1, rightFixedColumns:1,
fixedRightNumber: 1, // 冻结右列个数 fixedRightNumber: 1, // 冻结右列个数
@ -144,47 +145,52 @@
columns: [{ columns: [{
checkbox: true checkbox: true
}, },
{ title: '主键ID',field: 'id'}, { title: '主键ID',field: 'id',visible: false},
{ title: 'bom号',field: 'bomNo', sortable: true,},
{ title: '料号',field: 'materialNo', sortable: true,},
{ title: '物料名称',field: 'materialName', sortable: true,},
{title: '描述',field: 'describe'},
{ title: '品牌',field: 'brand', sortable: true,},
{title: '半成品类型',field: 'processMethod',
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
},
{ title: '单位',field: 'unit'},
{ title: '流程实例ID',field: 'instanceId',visible: false}, { title: '流程实例ID',field: 'instanceId',visible: false},
{ title: '流程提交实例ID',field: 'submitInstanceId',visible: false}, { title: '流程提交实例ID',field: 'submitInstanceId',visible: false},
{ title: '流程作废实例ID', field: 'cancelInstanceId',visible: false}, { title: '流程作废实例ID', field: 'cancelInstanceId',visible: false},
{ title: '流程恢复实例ID',field: 'restoreInstanceId',visible: false}, { title: '流程恢复实例ID',field: 'restoreInstanceId',visible: false},
{ title: '流程实例类型',field: 'instanceTypeName', visible: false}, { title: '流程实例类型',field: 'instanceTypeName', visible: false},
{ title: '申请人ID',field: 'applyUser',visible: false}, { title: '图片',field: 'photoUrl',formatter: function(value, row, index) {return $.table.imageView(value);}},
{ title: '<span style="color: red;">申请人</span>',field: 'applyUserName', { title: '<span style="color: red;">申请人</span>',field: 'applyUserName',
formatter: function(value, row, index) {return '<span style="color: red;">' + (value ? value : "-") + '</span>';} formatter: function(value, row, index) {return '<span style="color: red;">' + (value ? value : "-") + '</span>';}
}, },
{ title: '申请时间',field: 'applyTime',sortable: true,}, { title: '申请时间',field: 'applyTime',sortable: true,},
{ title: '当前任务ID',field: 'taskId',visible: false,}, {title: '上次更新时间',field: 'updateTime',},
{ title: '待办用户ID',field: 'todoUserId',visible: false,}, { title: '当前状态',field: 'taskName',align: 'center',
{ title: '当前任务名称',field: 'taskName',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<span class="badge badge-primary">' + value + '</span>'; return '<span class="badge badge-primary">' + value + '</span>';
} }
}, },
{ title: '审核状态',field: 'auditStatus',sortable: true,
{ title: '申请人ID',field: 'applyUser',visible: false},
{ title: '当前任务ID',field: 'taskId',visible: false,},
{ title: '待办用户ID',field: 'todoUserId',visible: false,},
{ title: '审核状态',field: 'auditStatus',sortable: true,visible: false,
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusDatas, value); return $.table.selectDictLabel(auditStatusDatas, value);
} }
}, },
{ title: '使用状态',field: 'useStatus',sortable: true, { title: '使用状态',field: 'useStatus',sortable: true,visible: false,
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(useStatusDatas, value); return $.table.selectDictLabel(useStatusDatas, value);
} }
}, },
{ title: '工程员',field: 'engineer', sortable: true,}, { title: '工程员',field: 'engineer', sortable: true,visible: false},
{ title: 'bom号',field: 'bomNo', sortable: true,}, { title: '物料类型',field: 'materialType',sortable: true,visible: false,
{ title: '关联料号',field: 'materialNo', sortable: true,},
{ title: '图片',field: 'photoUrl',formatter: function(value, row, index) {return $.table.imageView(value);}},
{ title: '物料名称',field: 'materialName', sortable: true,},
{ title: '物料类型',field: 'materialType',sortable: true,
formatter: function(value, row, index) {return $.table.selectCategoryLabel(materialTypeDatas, value);}}, formatter: function(value, row, index) {return $.table.selectCategoryLabel(materialTypeDatas, value);}},
{ title: '加工方式',field: 'processMethod',sortable: true, { title: '加工方式',field: 'processMethod',sortable: true,visible: false,
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
}, },
{ title: '单位',field: 'unit', sortable: true,},
{ title: '品牌',field: 'brand', sortable: true,},
{title: '描述',field: 'describe', sortable: true,},
{ title: '父级id',field: 'parentId',visible:false }, { title: '父级id',field: 'parentId',visible:false },
{title: '层级',field: 'level', visible:false, {title: '层级',field: 'level', visible:false,
formatter: function(value, row, index) { formatter: function(value, row, index) {
@ -740,6 +746,42 @@
} }
}); });
} }
function exportExcel(formId) {
// $.table.set();
var bomNoData = [];
var selections = $("#bootstrap-table").bootstrapTable("getSelections");
if(selections.length === 0){
$.modal.alertWarning("请至少选择一条bom信息");
return;
}else {
$.modal.confirm("确定导出选中的所有" + table.options.modalName + "吗?", function () {
//·拼接单号
for(let i=0;i<selections.length;i++){
bomNoData.push(selections[i].bomNo);
}
var bomNos = JSON.stringify(bomNoData);
console.log(bomNos);
$.modal.loading("正在导出数据,请稍后...");
var config = {
url: prefix + '/export',
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: bomNos,
success: function(result) {
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
$.modal.alertSuccess("导出成功!")
$.modal.closeLoading();
},
error: function (result){
$.modal.alertError(result.msg);
}
};
$.ajax(config)
// $.operate.saveJson(prefix + "/export", bomNos);
});
}
};
</script> </script>
</body> </body>
<!-- 导入区域 --> <!-- 导入区域 -->

Loading…
Cancel
Save