实现BOM管理增删改查

master
baogq 6 years ago
parent d7c1081508
commit 7e7974efb7

@ -129,6 +129,9 @@ public class BaseBomInfoController extends BaseController
@ResponseBody
public AjaxResult addSave(BaseBomInfo baseBomInfo)
{
BaseBomInfo pbaseBomInfo = new BaseBomInfo();
pbaseBomInfo = baseBomInfoService.selectBaseBomInfoBymaterialName(baseBomInfo);
baseBomInfo.setpId(pbaseBomInfo.getBomId());
return toAjax(baseBomInfoService.insertBaseBomInfo(baseBomInfo));
}
@ -139,6 +142,8 @@ public class BaseBomInfoController extends BaseController
public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
{
BaseBomInfo baseBomInfo = baseBomInfoService.selectBaseBomInfoById(objid);
mmap.put("cbmaterialtypeInfo",baseMaterialtypeInfoService.selectEditBaseMaterialtypeInfoList(baseBomInfo.getMaterialTypeId()));
mmap.put("cbmaterialInfo",baseMaterialInfoService.selectEditBaseMaterialInfoList(baseBomInfo.getMaterialId()));
mmap.put("baseBomInfo", baseBomInfo);
return prefix + "/edit";
}
@ -158,12 +163,16 @@ public class BaseBomInfoController extends BaseController
/**
* BOM
*/
@RequiresPermissions("baseinfo:bominfo:remove")
@Log(title = "BOM基础信息", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{bomId}")
@ResponseBody
public AjaxResult remove(String ids)
public AjaxResult remove(@PathVariable("bomId") Long bomId)
{
return toAjax(baseBomInfoService.deleteBaseBomInfoByIds(ids));
if (baseBomInfoService.selectBomCount(bomId) > 0)
{
return AjaxResult.warn("存在下级节点,不允许删除");
}
return toAjax(baseBomInfoService.deleteBaseBomInfoById(bomId));
}
}

@ -23,19 +23,19 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料类型ID</label>
<label class="col-sm-3 control-label">物料类型名称</label>
<div class="col-sm-8">
<select name="materialTypeId" id="workingProcedureId" class="form-control ">
<option value="">--请选择物料类型--</option>
<option value="">--请选择物料类型名称--</option>
<option name="cbmaterialtypeInfo" th:each="materialTypeId:${cbmaterialtypeInfo}" th:value="${materialTypeId.materialTypeId}" th:text="${materialTypeId.materialTypeName}" th:disabled="${materialTypeId.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料ID</label>
<label class="col-sm-3 control-label">物料名称</label>
<div class="col-sm-8">
<select name="materialId" id="materialId" class="form-control ">
<option value="">--请选择物料类型--</option>
<option value="">--请选择物料名称--</option>
<option name="cbmaterialInfo" th:each="materialId:${cbmaterialInfo}" th:value="${materialId.materialId}" th:text="${materialId.materialName}" th:disabled="${materialId.status == '1'}"></option>
</select>
</div>

@ -10,10 +10,10 @@
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>父节点ID</label>
<input type="text" name="pId"/>
</li>
<!-- <li>-->
<!-- <label>父节点ID</label>-->
<!-- <input type="text" name="pId"/>-->
<!-- </li>-->
<li>
<label>物料类型:</label>
<select name="materialTypeId">
@ -114,8 +114,8 @@
align: "left",
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.bomId + '\')"><i class="fa fa-plus"></i>新增物料</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bomId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.bomId + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bomId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}

@ -2,11 +2,13 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改BOM基础信息')" />
<th:block th:include="include :: jasny-bootstrap-css" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-bominfo-edit" th:object="${baseBomInfo}">
<input name="objid" th:field="*{objid}" type="hidden">
<input name="bomId" th:field="*{bomId}" type="hidden">
<!-- <div class="form-group"> -->
<!-- <label class="col-sm-3 control-label">父节点ID</label>-->
<!-- <div class="col-sm-8">-->
@ -14,21 +16,27 @@
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="col-sm-3 control-label">物料类型ID</label>
<label class="col-sm-3 control-label">物料类型名称</label>
<div class="col-sm-8">
<select name="materialTypeId" class="form-control m-b">
<option value="">所有</option>
<select name="materialTypeId" th:id="materialTypeId" class="form-control m-b">
<option name="cbmaterialtypeInfo" th:each="materialTypeId:${cbmaterialtypeInfo}" th:value="${materialTypeId.materialTypeId}" th:text="${materialTypeId.materialTypeName}" th:selected="${materialTypeId.flag}" th:disabled="${materialTypeId.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料ID</label>
<label class="col-sm-3 control-label">物料名称</label>
<div class="col-sm-8">
<select name="materialId" class="form-control m-b">
<option value="">所有</option>
<select name="materialId" th:id="materialId" class="form-control m-b">
<option name="cbmaterialInfo" th:each="materialId:${cbmaterialInfo}" th:value="${materialId.materialId}" th:text="${materialId.materialName}" th:selected="${materialId.flag}" th:disabled="${materialId.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<input name="remark" th:field="*{remark}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态标志:</label>
<div class="col-sm-8">
@ -41,6 +49,8 @@
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: jasny-bootstrap-js" />
<script th:inline="javascript">
var prefix = ctx + "baseinfo/bominfo";
$("#form-bominfo-edit").validate({

@ -2,6 +2,8 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改设备基础信息')" />
<th:block th:include="include :: jasny-bootstrap-css" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -57,6 +59,8 @@
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: jasny-bootstrap-js" />
<script th:inline="javascript">
var prefix = ctx + "baseinfo/deviceinfo";
$("#form-deviceinfo-edit").validate({

@ -83,6 +83,7 @@
<script th:inline="javascript">
// 直接返回获取
var data = [[${data}]];
console.log(data);
$('#element').cxSelect({
selects: ['type', 'router'],
jsonValue: 'v',

@ -58,4 +58,20 @@ public interface BaseBomInfoMapper
* @return
*/
public int deleteBaseBomInfoByIds(String[] objids);
/**
* BOM
*
* @param materialName BOM
* @return
*/
public BaseBomInfo selectBaseBomInfoBymaterialName(BaseBomInfo baseBomInfo);
/**
* BOM
*
* @param parentId ID
* @return
*/
public int selectBomCount(BaseBomInfo baseBomInfo);
}

@ -58,4 +58,20 @@ public interface IBaseBomInfoService
* @return
*/
public int deleteBaseBomInfoById(Long objid);
/**
* BOM
*
* @param baseBomInfo BOM
* @return
*/
public BaseBomInfo selectBaseBomInfoBymaterialName(BaseBomInfo baseBomInfo);
/**
* BOM
*
* @param parentId ID
* @return
*/
public int selectBomCount(Long parentId);
}

@ -2,6 +2,7 @@ package com.ruoyi.baseinfo.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysDept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.baseinfo.mapper.BaseBomInfoMapper;
@ -94,4 +95,16 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService
{
return baseBomInfoMapper.deleteBaseBomInfoById(objid);
}
@Override
public BaseBomInfo selectBaseBomInfoBymaterialName(BaseBomInfo baseBomInfo) {
return baseBomInfoMapper.selectBaseBomInfoBymaterialName(baseBomInfo);
}
@Override
public int selectBomCount(Long parentId) {
BaseBomInfo baseBomInfo = new BaseBomInfo();
baseBomInfo.setpId(parentId);
return baseBomInfoMapper.selectBomCount(baseBomInfo);
}
}

@ -102,4 +102,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectBaseBomInfoBymaterialName" parameterType="BaseBomInfo" resultMap="BaseBomInfoResult">
select t1.bom_id, t1.p_id, t1.material_type_id,t2.material_type_name, t1.material_id,t3.material_name, t1.status, t1.remark, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.del_flag from base_bom_info t1
left join dbo.base_materialtype_info t2 on t1.material_type_id = t2.material_type_id
left join dbo.base_material_info t3 on t1.material_id = t3.material_id
<where>
<if test="pId != null and pId != ''"> and t1.p_id = #{pId}</if>
<if test="materialName != null and materialName != ''"> and t3.material_name = #{materialName}</if>
<if test="materialTypeId != null and materialTypeId != ''"> and t1.material_type_id = #{materialTypeId}</if>
<if test="materialId != null and materialId != ''"> and t1.material_id = #{materialId}</if>
<if test="status != null and status != ''"> and t1.status = #{status}</if>
</where>
</select>
<select id="selectBomCount" parameterType="BaseBomInfo" resultType="int">
select count(1) from base_bom_info
where del_flag = '0'
<if test="bomId != null and bomId != 0"> and bom_id = #{bomId} </if>
<if test="pId != null and pId != 0"> and p_id = #{pId} </if>
</select>
</mapper>

Loading…
Cancel
Save