diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java index ea7f4d8e..99738c8c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java @@ -9,6 +9,7 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.erp.domain.ErpBom; import com.ruoyi.erp.domain.ErpMaterial; import com.ruoyi.erp.domain.ErpMaterialVo; import com.ruoyi.erp.domain.vo.ErpMaterialPurchaseHistoryVo; @@ -16,10 +17,8 @@ import com.ruoyi.erp.domain.vo.ErpMaterialSalesHistoryVo; import com.ruoyi.erp.mapper.ErpMaterialMapper; import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.process.general.service.IProcessService; -import com.ruoyi.system.domain.SysCustomer; -import com.ruoyi.system.domain.SysCustomerOper; -import com.ruoyi.system.domain.SysErpMaterialSysTechnicalTeam; -import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.*; +import com.ruoyi.system.mapper.OutsourceMaterialMapper; import com.ruoyi.system.service.*; import com.ruoyi.warehouse.controller.WarehouseInventoryInquiryController; import com.ruoyi.warehouse.service.IWarehouseInventoryInquiryService; @@ -73,6 +72,10 @@ public class ErpMaterialController extends BaseController @Autowired private ErpMaterialMapper erpMaterialMapper; + + @Autowired + private OutsourceMaterialMapper outsourceMaterialMapper; + @Autowired private ISysUserService sysUserService; @@ -162,7 +165,7 @@ public class ErpMaterialController extends BaseController @Log(title = "物料信息", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(ErpMaterial erpMaterial) + public AjaxResult addSave(@RequestBody ErpMaterial erpMaterial) { SysUser sysUser = ShiroUtils.getSysUser(); List sysPostsList = sysPostService.selectPostsByUserId(sysUser.getUserId()); @@ -301,7 +304,7 @@ public class ErpMaterialController extends BaseController @Log(title = "物料信息", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(ErpMaterial erpMaterial) + public AjaxResult editSave(@RequestBody ErpMaterial erpMaterial) { SysUser sysUser = ShiroUtils.getSysUser(); List sysPostsList = sysPostService.selectPostsByUserId(sysUser.getUserId()); @@ -537,4 +540,15 @@ public class ErpMaterialController extends BaseController return getDataTable(list); } + /** + * 查询bom一阶列表 + */ + @PostMapping("/processList") + @ResponseBody + public TableDataInfo oneLevelList(OutsourceMaterial outsourceMaterial) + { + startPage(); + List list = outsourceMaterialMapper.selectOutsourceMaterialList(outsourceMaterial); + return getDataTable(list); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java index d549db64..9c23a9d1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java @@ -2,6 +2,7 @@ package com.ruoyi.erp.domain; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.system.domain.OutsourceProcess; import com.ruoyi.system.domain.SysTechnicalTeam; import org.apache.commons.lang.builder.ToStringBuilder; @@ -132,6 +133,9 @@ public class ErpMaterial extends BaseEntity } private List technicalTeams; + + private List processList; + public void setId(Long id) { this.id = id; @@ -436,6 +440,14 @@ public class ErpMaterial extends BaseEntity this.bomId = bomId; } + public List getProcessList() { + return processList; + } + + public void setProcessList(List processList) { + this.processList = processList; + } + @Override public String toString() { return new ToStringBuilder(this) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java index d6907ad7..dcc0f1fd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.service.ICommonService; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; @@ -24,6 +25,7 @@ import com.ruoyi.purchase.mapper.PurchaseOrderMapper; import com.ruoyi.purchase.mapper.PurchasePlanChildMapper; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.Vo.ExportCustomerQuoteChildVo; +import com.ruoyi.system.mapper.OutsourceMaterialMapper; import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.system.mapper.SysSalesOrderMapper; import com.ruoyi.system.mapper.SysUserMapper; @@ -101,6 +103,9 @@ public class ErpMaterialServiceImpl implements IErpMaterialService @Autowired private ISysCustomerOperService sysCustomerOperService; + @Autowired + private OutsourceMaterialMapper outsourceMaterialMapper; + private final static String RMB = "1"; //RMB /** @@ -247,9 +252,36 @@ public class ErpMaterialServiceImpl implements IErpMaterialService List fileIdList = Arrays.asList(fileIdStr.split(";")); attachFileService.updateAttachIdByIdList(attachId,fileIdList); } + if(erpMaterial.getProcessMethod().equals("2")){ + OutsourceMaterial outsourceMaterial = createOutsourceMaterial(erpMaterial); + List processes = erpMaterial.getProcessList(); + if(processes.size()<=0){ + throw new BusinessException("委外物料工序列表为空!"); + } + int insertResult = 0; + for (OutsourceProcess process: processes) { + outsourceMaterial.setOutsourceProcessNo(process.getOutsourceProcessNo()); + outsourceMaterial.setOutsourceProcessName(process.getOutsourceProcessName()); + insertResult += outsourceMaterialMapper.insertOutsourceMaterial(outsourceMaterial); + } + if(insertResult<=0){ + throw new BusinessException("插入委外物料信息失败!"); + } + } return result; } - +// 根据物料信息生成委外物料对象 + public OutsourceMaterial createOutsourceMaterial(ErpMaterial erpMaterial){ + OutsourceMaterial outMaterial = new OutsourceMaterial(); + outMaterial.setMaterialNo(erpMaterial.getMaterialNo()); + outMaterial.setMaterialName(erpMaterial.getMaterialName()); + outMaterial.setMaterialType(erpMaterial.getMaterialType()); + outMaterial.setProcessMethod(erpMaterial.getProcessMethod()); + outMaterial.setUnit(erpMaterial.getUnit()); + outMaterial.setBrand(erpMaterial.getBrand()); + outMaterial.setDescription(erpMaterial.getDescribe()); + return outMaterial; + } /** * 修改物料信息 * @@ -283,7 +315,25 @@ public class ErpMaterialServiceImpl implements IErpMaterialService } attachFileService.updateAttachIdByIdList(photoAttachId, fileIdList); } - return erpMaterialMapper.updateErpMaterial(erpMaterial); + int updateResult = erpMaterialMapper.updateErpMaterial(erpMaterial); + if(erpMaterial.getProcessMethod().equals("2")){ + List processes = erpMaterial.getProcessList(); + if(processes.size()<=0){ + throw new BusinessException("委外物料工序列表为空!"); + } + outsourceMaterialMapper.deleteOutsourceMaterialByNo(erpMaterial.getMaterialNo()); + OutsourceMaterial outsourceMaterial = createOutsourceMaterial(erpMaterial); + int insertResult = 0; + for (OutsourceProcess process: processes) { + outsourceMaterial.setOutsourceProcessNo(process.getOutsourceProcessNo()); + outsourceMaterial.setOutsourceProcessName(process.getOutsourceProcessName()); + insertResult += outsourceMaterialMapper.insertOutsourceMaterial(outsourceMaterial); + } + if(insertResult<=0){ + throw new BusinessException("插入委外物料信息失败!"); + } + } + return updateResult; } /** @@ -362,6 +412,8 @@ public class ErpMaterialServiceImpl implements IErpMaterialService erpMaterial.setApplyTime(DateUtils.getNowDate()); if(erpMaterial.getId() == null){ insertErpMaterial(erpMaterial); + }else{ + updateErpMaterial(erpMaterial); } // 启动流程 String applyTitle = user.getUserName()+"发起了物料信息提交审批-"+DateUtils.dateTimeNow(); diff --git a/ruoyi-admin/src/main/resources/templates/erp/material/add.html b/ruoyi-admin/src/main/resources/templates/erp/material/add.html index f0527646..713bbd0a 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/material/add.html +++ b/ruoyi-admin/src/main/resources/templates/erp/material/add.html @@ -37,13 +37,6 @@ -
- - -
-
@@ -81,8 +74,11 @@
- -
+ +
+
+ +
+
+ + +
+
+
+
+
+
@@ -172,9 +179,53 @@ var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; //获取工程员 $(function(){ + var options = { + id: "bootstrap-table-process", + pagination: false, + showSearch: false, + showRefresh: false, + showToggle: false, + showColumns: false, + striped: false, + sidePagination: "client", + columns: [ + { + field: 'outsourceProcessId', + align: 'center', + title: '委外工序主键', + visible: false, + }, + { + field: 'outsourceProcessCode', + align: 'center', + title: '委外工序ID', + visible: false, + }, + { + field: 'outsourceProcessNo', + align: 'center', + title: '委外工序编号', + }, + { + field: 'outsourceProcessName', + align: 'center', + title: '委外工序名称', + }, + { + title: '操作', + align: 'center', + formatter: function (value, row, index) { + var actions = []; + actions.push('删除 '); + return actions.join(''); + } + }] + }; + $.table.init(options); $("#businessMembers_add").val(loginName); engineer(); - $("#add-weiwai").hide(); + $("#add-process-text").hide(); + $("#add-process").hide(); }) function engineer(){ @@ -253,22 +304,107 @@ $("#selectWarehouseDept").removeAttr("disabled"); var materialType = $('#selectMaterialType').select2('val'); $('#materialType').val(materialType); - $.operate.save(prefix + "/add", $('#form-material-add').serialize()); + // console.log($('#form-material-add').serialize()); + // 获取表单数据 + const erpMaterialData = $("#form-material-add").serializeArray().reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + var erpMaterial = { + materialNo: erpMaterialData.materialNo, + materialName: erpMaterialData.materialName, + materialType: erpMaterialData.materialType, + processMethod: erpMaterialData.processMethod, + unit: erpMaterialData.unit, + brand: erpMaterialData.brand, + describe: erpMaterialData.describe, + warehouseDept: erpMaterialData.warehouseDept, + businessMembers: erpMaterialData.businessMembers, + fileIdStr: erpMaterialData.fileIdStr, + processList:[] + } + if(erpMaterialData.processMethod === "2"){ + var processDatas = $("#bootstrap-table-process").bootstrapTable('getData'); + if(processDatas.length === 0){ + $.modal.alertWarning("请至少添加一条委外工序再保存!"); + return; + }else{ + for(var i = 0; i' + - '删除' + - ''; - $(".bootstrap-table-sub-2").append(html); + // var html = '' + + // '' + + // '删除' + + // ''; + // $(".bootstrap-table-sub-2").append(html); + var url = "/system/outsource_quote/processadd"; + var options = { + title: '选择委外工序', + height: "500", + url: url, + callBack: doSubmit + }; + $.modal.openOptions(options); + } + // 插入工序信息 + function insertTable(rowData) { + var newRow = { + outsourceProcessNo: rowData.outsourceProcessNo, + // outsourceProcessCode: rowData.outsourceProcessCode, + outsourceProcessName: rowData.outsourceProcessName, + }; + // 将新行追加到表格末尾 + $("#bootstrap-table-process").bootstrapTable('append', newRow); + } + /* 选择委外工序回调 */ + function doSubmit(index, layero){ + // // 这里取到的是多行的 + var rowData = layero.find("iframe")[0].contentWindow.getSelections(); + //判断是否重复 + var data = $("#bootstrap-table-process").bootstrapTable('getData'); + var rows = data.length; + if(rows>0){ + for(var i=0;i
+ +
+
@@ -96,6 +99,14 @@
+
+ +
+
+
+
+
+
@@ -129,7 +140,7 @@