Browse Source

Revert "Revert "[fix]""

This reverts commit 8656f3b3c2.
dev
王晓迪 2 months ago
parent
commit
42cbdf7606
  1. 140
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java
  2. 48
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java
  3. 81
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java
  4. 414
      ruoyi-admin/src/main/resources/templates/system/makeorder/addOutsourcePlan.html
  5. 52
      ruoyi-admin/src/main/resources/templates/system/makeorder/showProcesses.html

140
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

@ -201,83 +201,83 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
//保存所有加工方式为采购的物料 //保存所有加工方式为采购的物料
List<SysMakeorderBom> filterSysMakeorderBoms = insertedSysMakeorderBoms.stream().filter(bom -> "0".equals(bom.getProcessMethod())).collect(Collectors.toList()); List<SysMakeorderBom> filterSysMakeorderBoms = insertedSysMakeorderBoms.stream().filter(bom -> "0".equals(bom.getProcessMethod())).collect(Collectors.toList());
if(StringUtils.isNotEmpty(filterUniqueBoms)){
//所有数据的销售订单号相同,只需查一条的销售订单号
String quoteId = filterSysMakeorderBoms.get(0).getSalesOrderCode();
// 第一步:收集所有不同的salesOrderMaterialNo 利用set key值不重复的特性
Set<String> uniqueSalesOrderMaterialNos = new HashSet<>();
for (SysMakeorderBom filterSysMakeorderBom : filterSysMakeorderBoms) {
uniqueSalesOrderMaterialNos.add(filterSysMakeorderBom.getSalesOrderMaterialNo());
}
//所有数据的销售订单号相同,只需查一条的销售订单号 // 第二步:查询每个salesOrderMaterialNo对应的SalesOrder数据
String quoteId = filterSysMakeorderBoms.get(0).getSalesOrderCode(); Map<String, SysSalesOrderChild> salesOrderChildByMaterialNo = new HashMap<>();
for (String salesOrderMaterialNo : uniqueSalesOrderMaterialNos) {
// 第一步:收集所有不同的salesOrderMaterialNo 利用set key值不重复的特性 SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild();
Set<String> uniqueSalesOrderMaterialNos = new HashSet<>(); sysSalesOrderChild.setMaterialCode(salesOrderMaterialNo);
for (SysMakeorderBom filterSysMakeorderBom : filterSysMakeorderBoms) { sysSalesOrderChild.setQuoteId(quoteId);
uniqueSalesOrderMaterialNos.add(filterSysMakeorderBom.getSalesOrderMaterialNo()); SysSalesOrderChild salesOrderChild = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild);
} salesOrderChildByMaterialNo.put(salesOrderMaterialNo, salesOrderChild);
}
// 第二步:查询每个salesOrderMaterialNo对应的SalesOrder数据
Map<String, SysSalesOrderChild> salesOrderChildByMaterialNo = new HashMap<>();
for (String salesOrderMaterialNo : uniqueSalesOrderMaterialNos) {
SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild();
sysSalesOrderChild.setMaterialCode(salesOrderMaterialNo);
sysSalesOrderChild.setQuoteId(quoteId);
SysSalesOrderChild salesOrderChild = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild);
salesOrderChildByMaterialNo.put(salesOrderMaterialNo, salesOrderChild);
}
double purchasePlanMaterialSum = 0L; double purchasePlanMaterialSum = 0L;
// 第三步:计算purchasePlanNum // 第三步:计算purchasePlanNum
for (SysMakeorderBom filterSysMakeorderBom : filterSysMakeorderBoms) { for (SysMakeorderBom filterSysMakeorderBom : filterSysMakeorderBoms) {
String salesOrderMaterialNo = filterSysMakeorderBom.getSalesOrderMaterialNo(); String salesOrderMaterialNo = filterSysMakeorderBom.getSalesOrderMaterialNo();
SysSalesOrderChild sysSalesOrderChild = salesOrderChildByMaterialNo.get(salesOrderMaterialNo); SysSalesOrderChild sysSalesOrderChild = salesOrderChildByMaterialNo.get(salesOrderMaterialNo);
if (sysSalesOrderChild != null) { if (sysSalesOrderChild != null) {
//物料数量 //物料数量
long materialNum = sysSalesOrderChild.getMaterialNum(); long materialNum = sysSalesOrderChild.getMaterialNum();
//用量 //用量
Double useNum = filterSysMakeorderBom.getUseNum(); Double useNum = filterSysMakeorderBom.getUseNum();
//采购计划数 //采购计划数
double purchasePlanNum = materialNum * useNum; double purchasePlanNum = materialNum * useNum;
// 立即创建PurchasePlanChild对象 // 立即创建PurchasePlanChild对象
PurchasePlanChild purchasePlanChild = new PurchasePlanChild(); PurchasePlanChild purchasePlanChild = new PurchasePlanChild();
purchasePlanChild.setPurchasePlanCode(purchasePlanCode); purchasePlanChild.setPurchasePlanCode(purchasePlanCode);
purchasePlanChild.setMaterialCode(filterSysMakeorderBom.getMaterialNo()); purchasePlanChild.setMaterialCode(filterSysMakeorderBom.getMaterialNo());
PurchasePlanChild tempPurchasePlanChild = purchasePlanChildMapper.selectPurchasePlanChildByCodeAndNo(purchasePlanChild); PurchasePlanChild tempPurchasePlanChild = purchasePlanChildMapper.selectPurchasePlanChildByCodeAndNo(purchasePlanChild);
if (tempPurchasePlanChild != null){ if (tempPurchasePlanChild != null){
purchasePlanChild.setPurchasePlanChildId(tempPurchasePlanChild.getPurchasePlanChildId()); purchasePlanChild.setPurchasePlanChildId(tempPurchasePlanChild.getPurchasePlanChildId());
double addMaterialNum = tempPurchasePlanChild.getMaterialNum() + purchasePlanNum; double addMaterialNum = tempPurchasePlanChild.getMaterialNum() + purchasePlanNum;
//设置计划采购数 //设置计划采购数
purchasePlanChild.setMaterialNum(addMaterialNum); purchasePlanChild.setMaterialNum(addMaterialNum);
purchasePlanChildMapper.updatePurchasePlanChild(purchasePlanChild); purchasePlanChildMapper.updatePurchasePlanChild(purchasePlanChild);
}else { }else {
purchasePlanChild.setMaterialName(filterSysMakeorderBom.getMaterialName()); purchasePlanChild.setMaterialName(filterSysMakeorderBom.getMaterialName());
purchasePlanChild.setMaterialType(filterSysMakeorderBom.getMaterialType()); purchasePlanChild.setMaterialType(filterSysMakeorderBom.getMaterialType());
purchasePlanChild.setWarehouseDept(filterSysMakeorderBom.getWarehouseDept()); purchasePlanChild.setWarehouseDept(filterSysMakeorderBom.getWarehouseDept());
purchasePlanChild.setProcessMethod("0"); purchasePlanChild.setProcessMethod("0");
purchasePlanChild.setBrand(filterSysMakeorderBom.getBrand()); purchasePlanChild.setBrand(filterSysMakeorderBom.getBrand());
purchasePlanChild.setDescribe(filterSysMakeorderBom.getDescribe()); purchasePlanChild.setDescribe(filterSysMakeorderBom.getDescribe());
purchasePlanChild.setUnit(filterSysMakeorderBom.getUnit()); purchasePlanChild.setUnit(filterSysMakeorderBom.getUnit());
purchasePlanChild.setWarehouseDept(filterSysMakeorderBom.getWarehouseDept()); purchasePlanChild.setWarehouseDept(filterSysMakeorderBom.getWarehouseDept());
// 物料的计划采购数,使用计算出的purchasePlanNum // 物料的计划采购数,使用计算出的purchasePlanNum
purchasePlanChild.setMaterialNum(purchasePlanNum); purchasePlanChild.setMaterialNum(purchasePlanNum);
purchasePlanChild.setCreateBy(ShiroUtils.getLoginName()); purchasePlanChild.setCreateBy(ShiroUtils.getLoginName());
purchasePlanChild.setCreateTime(new Date()); purchasePlanChild.setCreateTime(new Date());
purchasePlanChild.setUnit(filterSysMakeorderBom.getUnit()); purchasePlanChild.setUnit(filterSysMakeorderBom.getUnit());
// 直接保存PurchasePlanChild对象 // 直接保存PurchasePlanChild对象
purchasePlanChildMapper.insertPurchasePlanChild(purchasePlanChild); purchasePlanChildMapper.insertPurchasePlanChild(purchasePlanChild);
}
// 更新总和
purchasePlanMaterialSum += purchasePlanNum;
} }
// 更新总和
purchasePlanMaterialSum += purchasePlanNum;
} }
}
// 创建采购计划主记录 // 创建采购计划主记录
PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode,materialAmount,purchasePlanMaterialSum); PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode,materialAmount,purchasePlanMaterialSum);
purchasePlanMapper.insertPurchasePlan(purchasePlan);
purchasePlanMapper.insertPurchasePlan(purchasePlan);
}
} }
/** /**

48
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java

@ -18,14 +18,12 @@ import com.ruoyi.erp.domain.ErpInboundOrder;
import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.financial.domain.FinancialReceivables; import com.ruoyi.financial.domain.FinancialReceivables;
import com.ruoyi.financial.domain.FinancialReceivablesRecords; import com.ruoyi.financial.domain.FinancialReceivablesRecords;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.SysMakeorderDept;
import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.dto.SysEquipDetailDto; import com.ruoyi.system.dto.SysEquipDetailDto;
import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysEquipMaterialDto;
import com.ruoyi.system.dto.SysMakeorderDeptDto; import com.ruoyi.system.dto.SysMakeorderDeptDto;
import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto;
import com.ruoyi.system.mapper.OutsourceMaterialMapper;
import com.ruoyi.system.service.ISysMakeOrderService; import com.ruoyi.system.service.ISysMakeOrderService;
import com.ruoyi.system.service.ISysMakeorderDeptService; import com.ruoyi.system.service.ISysMakeorderDeptService;
import com.ruoyi.system.service.ISysSalesOrderChildService; import com.ruoyi.system.service.ISysSalesOrderChildService;
@ -67,6 +65,8 @@ public class SysMakeOrderController extends BaseController
@Autowired @Autowired
private IAfterSalesShippingDeviceService salesShippingDeviceService; private IAfterSalesShippingDeviceService salesShippingDeviceService;
@Autowired
private OutsourceMaterialMapper outsourceMaterialMapper;
@GetMapping("/test") @GetMapping("/test")
public AjaxResult test(){ public AjaxResult test(){
@ -160,6 +160,46 @@ public class SysMakeOrderController extends BaseController
return prefix + "/addpick"; return prefix + "/addpick";
} }
/**
* 跳转创建委外计划页面
*/
@GetMapping("/addOutsourcePlan/{id}")
public String addOutsourcePlan(@PathVariable("id") Long id, ModelMap mmap)
{
mmap.put("currentUser", ShiroUtils.getSysUser());
SysMakeOrder sysMakeOrder = sysMakeOrderService.selectSysMakeOrderById(id);
SysSalesOrder sysSalesOrder = salesOrderService.selectSysSalesOrderBySalesOrderCode(sysMakeOrder.getSaleNo());
if(StringUtils.isNotNull(sysSalesOrder)){
sysMakeOrder.setOrderType(sysSalesOrder.getSalesOrderType());
sysMakeOrder.setSalesman(sysSalesOrder.getBusinessMembers());
sysMakeOrder.setCustomerName(sysSalesOrder.getEnterpriseName());
sysMakeOrder.setCustomerId(sysSalesOrder.getEnterpriseCode());
sysMakeOrder.setCustomerOderCode(sysSalesOrder.getSalesOrderNumber());
}
mmap.put("sysMakeOrder", sysMakeOrder);
return prefix + "/addOutsourcePlan";
}
/**
* 跳转委外工序显示页面
*/
@GetMapping("/showProcesses/{materialNo}")
public String showProcesses(@PathVariable("materialNo") String materialNo, ModelMap mmap)
{
List<OutsourceMaterial> materials = outsourceMaterialMapper.selectProcessNoByNo(materialNo);
mmap.put("materials", materials);
return prefix + "/showProcesses";
}
/**
* 保存添加委外计划
*/
// @RequiresPermissions("system:makeorder:edit")
// @Log(title = "生产订单", businessType = BusinessType.UPDATE)
@PostMapping("/addOutsourcePlan")
@ResponseBody
public AjaxResult addOutsourcePlan(@RequestBody OutsourcePlan outsourcePlan)
{
return toAjax(sysMakeOrderService.addOutsourcePlan(outsourcePlan));
}
/** /**
* 跳转创建委内加工入库单 * 跳转创建委内加工入库单
*/ */

81
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java

@ -20,15 +20,11 @@ import com.ruoyi.quality.domain.QualityOrderReport;
import com.ruoyi.quality.mapper.QualityOrderDetailMapper; import com.ruoyi.quality.mapper.QualityOrderDetailMapper;
import com.ruoyi.quality.mapper.QualityOrderMapper; import com.ruoyi.quality.mapper.QualityOrderMapper;
import com.ruoyi.quality.mapper.QualityOrderReportMapper; import com.ruoyi.quality.mapper.QualityOrderReportMapper;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.SysMakeorderBom;
import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.domain.SysSalesOrderVo;
import com.ruoyi.system.dto.SysEquipDetailDto; import com.ruoyi.system.dto.SysEquipDetailDto;
import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysEquipMaterialDto;
import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto;
import com.ruoyi.system.mapper.SysMakeOrderMapper; import com.ruoyi.system.mapper.*;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail;
@ -91,6 +87,17 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
@Autowired @Autowired
private QualityOrderReportMapper orderReportMapper; private QualityOrderReportMapper orderReportMapper;
@Autowired
private OutsourceMaterialMapper outsourceMaterialMapper;
@Autowired
private OutsourcePlanMapper outsourcePlanMapper;
@Autowired
private IOutsourcePlanService outsourcePlanService;
@Autowired
private SysMakeorderBomMapper makeorderBomMapper;
/** /**
* 查询生产订单 * 查询生产订单
* *
@ -525,4 +532,66 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
return qualityOrderReport; return qualityOrderReport;
} }
// 生成委外计划
@Override
public int addOutsourcePlan(OutsourcePlan outsourcePlan) {
String outsourcePlanCode = redisCache.generateBillNo("WWJH");
outsourcePlan.setOutsourcePlanCode(outsourcePlanCode);
outsourcePlan.setCreateTime(DateUtils.getNowDate());
outsourcePlan.setCreateBy(ShiroUtils.getLoginName());
List<OutsourcePlanDetail> planDetails = outsourcePlan.getOutsourcePlanDetailList();
if(StringUtils.isEmpty(planDetails)){
throw new BusinessException("委外计划物料集合为空!添加失败");
}
int materialAmount = 0;
int processAmount = 0;
BigDecimal materialSum = BigDecimal.ZERO;
Set<String> uniqueProcessNos = new HashSet<>(); // 用于存储唯一的 processNo
for (OutsourcePlanDetail detail:planDetails) {
materialAmount ++;
detail.setOutsourcePlanCode(outsourcePlanCode);
List<OutsourceMaterial> materials = outsourceMaterialMapper.selectProcessNoByNo(detail.getMaterialNo());
if(StringUtils.isEmpty(materials)){
throw new BusinessException("委外物料工序数量为空!添加失败");
}
for (OutsourceMaterial material : materials) {
uniqueProcessNos.add(material.getOutsourceProcessNo());
}
materialSum = materialSum.add(detail.getPlannedOutsourceAmount());
detail.setOutsourceProcessType(materials.size());
detail.setOutsourceProcessAmount(materials.size());
detail.setCreateBy(ShiroUtils.getLoginName());
detail.setCreateTime(DateUtils.getNowDate());
processAmount += detail.getOutsourceProcessAmount();
}
int batchResult = outsourcePlanMapper.batchOutsourcePlanDetail(planDetails);
if(batchResult <= 0){
throw new BusinessException("添加委外计划详情失败!");
}
// 更新生产订单bom的已委外数信息
changeOrderBomOutNum(planDetails,outsourcePlan.getAssociateOrderNo());
outsourcePlan.setMaterialAmount(materialAmount);
outsourcePlan.setTotalAmount(materialSum);
outsourcePlan.setOutsourceProcessType(uniqueProcessNos.size());
outsourcePlan.setOutsourceProcessAmount(processAmount);
outsourcePlan.setStatus("0");
outsourcePlan.setSource("1");
int insertResult = outsourcePlanMapper.insertOutsourcePlan(outsourcePlan);
return insertResult;
}
// 根据委外计划详情更新生产订单bom委外数
private int changeOrderBomOutNum(List<OutsourcePlanDetail> planDetails, String makeNo){
int updateResult = 0;
for (OutsourcePlanDetail detail: planDetails) {
SysMakeorderBom tempBom = new SysMakeorderBom();
tempBom.setMakeNo(makeNo);
tempBom.setMaterialNo(detail.getMaterialNo());
SysMakeorderBom makeorderBom = makeorderBomMapper.selectSysMakeorderBomByNo(tempBom);
makeorderBom.setHasOutNum(detail.getPlannedOutsourceAmount().intValue());
updateResult += makeorderBomMapper.updateSysMakeorderBom(makeorderBom);
}
return updateResult;
}
} }

414
ruoyi-admin/src/main/resources/templates/system/makeorder/addOutsourcePlan.html

@ -0,0 +1,414 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('添加委外计划单')" />
<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-makeorder-add-outsourcePlan" th:object="${sysMakeOrder}">
<div class="form-group">
<label class="col-sm-3 control-label">生产订单号:</label>
<div class="col-sm-8">
<input readonly id="makeNo" name="makeNo" th:field="*{makeNo}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">关联销售订单号:</label>
<div class="col-sm-8">
<input readonly id="saleNo" name="saleNo" th:field="*{saleNo}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">业务员:</label>
<div class="col-sm-8">
<input readonly name="Salesman" th:field="*{Salesman}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">订单类型:</label>
<div class="col-sm-8">
<select name="orderType" class="form-control" type="text" th:with="dictList=${@dict.getType('sys_order_type')}" th:field="*{orderType}" disabled required>
<option value="">请选择</option>
<option th:each="dict : ${dictList}" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"></option>
</select>
</div>
</div>
<!-- <div class="container">-->
<div class="col-xs-11">
<div class="col-sm-11 select-table table-striped">
<table id="bootstrap-sub-table-1"></table>
</div>
</div>
<!-- </div>-->
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var prefix = ctx + "system/makeorder";
var curUser = [[${currentUser}]];
var curUsrDeptNumber = curUser.dept.deptNumber;
var childTableIdList = [];
// 字典
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var levelDatas = [[${@dict.getType('bomLevel')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
// var subTableFormArray = [];
$(function(){
var options = {
url: ctx + "system/orderChild/list",
id: 'bootstrap-sub-table-1',
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
uniqueId: "id",
pagination: false, // 设置不分页
sidePagination: "client",
queryParams: queryParams,
detailView: true,
onExpandRow : function(index, row, $detail) {
initChildTable(index, row, $detail);
},
columns: [
{
field: 'id',
title: '主键id',
visible: false
},
{
field: 'quoteId',
title: '关联销售订单编号',
visible: false
},
{
field: 'bomId',
title: 'bom主键Id',
visible: false
},
{
field: 'materialCode',
align: 'center',
title: '料号'
},
{
field: 'materialName',
align: 'center',
title: '物料名称',
},
{
field: 'materialType',
align: 'center',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
field: 'unit',
align: 'center',
title: '单位',
formatter: function(value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value);
}
},
{
field: 'brand',
align: 'center',
title: '品牌'
},
{
field: 'describe',
align: 'center',
title: '描述'
},
{
field: 'processMethod',
align: 'center',
title: '半成品类型',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
field: 'deliveryTime',
align: 'center',
title: '客户期望交付时间'
},
{
field: 'materialNum',
align: 'center',
title: '订单数量'
},
{
field: 'finishNum',
align: 'center',
title: '已完成数'
}
]
};
$.table.init(options);
})
initChildTable = function(index, row, $detail) {
var parentRow = row;
var parentRowIndex = index;
var childTableId = 'child_table_'+index;
childTableIdList.push(childTableId);
var childFormTableId = 'child_form_table_'+index;
var childTableFormId = 'child_table_form_'+index;
// $detail.html('<form id="'+childTableFormId+'"><table id="'+childTableId+'"></table><table id="'+childFormTableId+'"></table></form>');
$detail.html('<table id="'+childTableId+'"></table>');
// BOM展示
$('#'+childTableId).bootstrapTable({
url: ctx + "system/makeorderbom/list",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
makeNo: $("#makeNo").val(),
salesOrderCode: $("#saleNo").val(),
salesOrderMaterialNo: parentRow.materialCode
},
columns: [{
field: 'id',
title: '主键id',
visible: false
},
{
field: 'level',
title: '阶层',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
}
},
{
field: 'bomNo',
title: 'BOM号',
formatter:function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'materialNo',
title: '料号',
formatter: function (value,row,index){
var curIndex = row.sortNo-1;
return '<input readonly class = "form-control" data-id = "materialNo_'+curIndex+'" name="pickDetails['+curIndex+'].materialNo" value="'+value+'"><input class = "hidden form-control" data-id = "makeorderBomId_'+curIndex+'" name="pickDetails['+curIndex+'].makeorderBomId" value="'+row.id+'">';
}
},
{
field: 'photoUrl',
title: '图片',
formatter: function(value, row, index) {
return $.table.imageView(value);
}
},
{
field: 'materialName',
title: '物料名称',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'materialType',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
field: 'describe',
title: '描述',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'brand',
title: '品牌',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'unit',
title: '单位',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'processMethod',
title: '加工方式',
align: 'center',
formatter: function(value, row, index) {
var label = $.table.selectDictLabel(processMethodDatas, value);
if (value === '2') {
var button = '<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.modal.open(\'委外工序\',\'' + prefix+"/showProcesses/"+row.materialNo + '\')">委外工序(' + row.processNum + ')</a>';
return label + ' ' + button;
} else {
return label;
}
}
},
{
field: 'useNum',
title: '用量',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'lossRate',
title: '损耗率',
},
{
field: 'processNum',
title: '委外工序数',
visible: false,
},
{
field: 'materialNum',
title: '订单用量',
formatter: function (value,row,index){
return parentRow.materialNum * row.useNum;
}
},
{
field: 'hasOutNum',
title: '已委外数量',
},
{
field: 'outsourceNum',
title: '本次委外数量',
formatter: function (value,row,index){
var processMethod = row.processMethod;
if(processMethod === "2"){
var curIndex = row.sortNo-1;
return '<input class = "form-control" data-id = "pickNum_'+curIndex+'" name="outsourceNum_'+curIndex+'">';
}
return " ";
}
},
{
field: 'makeNo',
title: '生产订单号',
visible: false,
},
{
field: 'salesOrderCode',
title: '销售订单号',
visible: false,
},
{
field: 'salesOrderMaterialNo',
title: '销售订单料号',
visible: false,
},
{
field: 'sortNo',
title: '排序',
visible: false
}],
// 当所有数据被加载时触发
onLoadSuccess: function(data) {
},
});
};
function queryParams(params) {
var curParams = {
// 传递参数查询参数
// pageSize: params.limit,
// pageNum: params.offset / params.limit + 1,
// searchValue: params.search,
// orderByColumn: params.sort,
// isAsc: params.order
};
// 额外传参
curParams.quoteId = $("#saleNo").val();
return curParams;
}
$("#form-makeorder-add-outsourcePlan").validate({
focusCleanup: true
});
function submitHandler() {
var makeNo = $("#makeNo").val();
var sales = $("input[name='Salesman']").val();
var outsourcePlan = {
associateOrderNo: makeNo,
outsourcePlanDetailList: [],
applicant: sales,
}
var hasValue = false;
childTableIdList.forEach(function (tableId,index){
var processDatas = $("#" + tableId).bootstrapTable('getData');
processDatas.forEach(function (data,i){
if(data.processNum != 0 && data.processMethod === "2"){
var outNum = $('#' + tableId ).find('input[name="outsourceNum_'+i+'"]').val();
if(outNum === null||outNum === ""){
return;
}
hasValue = true;
var process ={
materialNo: data.materialNo,
materialName: data.materialName,
materialType: data.materialType,
materialPhotourl: data.photoUrl,
description: data.describe,
brand: data.brand,
processMethod: data.processMethod,
unit: data.unit,
}
process.plannedOutsourceAmount = outNum;
outsourcePlan.outsourcePlanDetailList.push(process);
}
})
})
// console.log(outsourcePlan);
if(hasValue){
$.operate.saveJson(ctx + "system/makeorder/addOutsourcePlan", JSON.stringify(outsourcePlan));
}else{
$.modal.alertError("请至少添加一条有效的委外信息!");
}
}
</script>
</body>
</html>

52
ruoyi-admin/src/main/resources/templates/system/makeorder/showProcesses.html

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('委外工序列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-select-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
$(function() {
var options = {
id: "bootstrap-select-table",
modalName: "委外工序",
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
data: [[${materials}]],
columns: [
{
field: 'outsourceProcessId',
title: '委外工序主键',
visible: false
},
{
field: 'outsourceProcessNo',
title: '委外工序编号'
},
{
field: 'outsourceProcessName',
title: '委外工序名称'
},
{
field: 'remark',
title: '备注'
},
]
};
$.table.init(options);
});
</script>
</body>
</html>
Loading…
Cancel
Save