Commit 20f897c9 by liuyang

2024-09-14

1.新增生产订单改派功能
2.生产订单拆单功能调整
parent d802110d
......@@ -122,6 +122,35 @@ public class ServiceHGSC006A extends ServiceBase {
return inInfo;
}
@OperationLogAnnotation(operModul = "生产订单详情", operType = "批量改派", operDesc = "批量改派")
public EiInfo assignChange(EiInfo inInfo){
try {
String[] orderDetailIds = inInfo.getString("ids").split(",");
String factoryCode = inInfo.getString("factoryCode");
String factoryName = inInfo.getString("factoryName");
String groupCode = inInfo.getString("groupCode");
String groupName = inInfo.getString("groupName");
List<HGSC007> hgsc007List = HGSCTools.THGSC007.listByOrderDetailId(Arrays.asList(orderDetailIds));
AssertUtils.isEmpty(hgsc007List, "未查询到生产任务数据!");
List<Long> taskIds = hgsc007List.stream().map(HGSC007::getId).collect(Collectors.toList());
List<HGSC008> hgsc008List = HGSCTools.THGSC008.getByTaskId(taskIds);
AssertUtils.isNotEmpty(hgsc008List, "生产任务存在已报工,改派失败!");
for (HGSC007 hgsc007 : hgsc007List) {
// 校验主订单是否已分派
hgsc007.setGroupCode(groupCode);
hgsc007.setGroupName(groupName);
hgsc007.setFactoryCode(factoryCode);
hgsc007.setFactoryName(factoryName);
DaoUtils.update(HGSC007.UPDATE, hgsc007);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + orderDetailIds.length + "]条数据分派成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "改派失败");
}
return inInfo;
}
private void cleanBaseInfo(HGSC007 hgsc007){
hgsc007.setCreatedBy(null);
hgsc007.setCreatedName(null);
......
package com.baosight.hggp.hg.sc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.AssignStatusEnum;
import com.baosight.hggp.common.ProductTypeEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
......@@ -26,6 +27,8 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static com.baosight.hggp.common.AssignStatusEnum.*;
/**
* 拆单派工
*
......@@ -140,25 +143,37 @@ public class ServiceHGSC006B extends ServiceBase {
// 生产任务号
List<Long> taskIds = ObjectUtils.listKey(resultRows, HGSC007.FIELD_id);
// 锁主单号
HGSCTools.THGSC006A.lock(orderDetailId);
//HGSCTools.THGSC006A.lock(orderDetailId);
// 锁子单
HGSCTools.THGSC007.lock(taskIds);
//HGSCTools.THGSC007.lock(taskIds);
// 查询订单信息
HGSC006 hgsc006 = HGSCTools.THGSC006.getByOrderCode(orderCode);
HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(orderDetailId);
List<HGSC007> hgsc007s = MapUtils.toDaoEPBases(resultRows, HGSC007.class);
// 判断数量是否超过订单数量
Integer totalNum = hgsc007s.stream().mapToInt(HGSC007::getQuantity).sum();
AssertUtils.isGt(new BigDecimal(totalNum), new BigDecimal(hgsc006A.getQuantity()), "拆单的分派数量不能大于生产订单数量!");
// 查询任务信息
List<HGSC007> hgsc007List = HGSCTools.THGSC007.list(taskIds);
//查询生产报工
List<HGSC008> hgsc008List = HGSCTools.THGSC008.getByTaskId(taskIds);
AssertUtils.isNotEmpty(hgsc008List, "生产任务存在已报工,拆单失败!");
HGPZ005 hgpz005 = HGPZTools.HgPz005.get(hgsc006A.getProductCode());
// 写入数据
for (Map resultRow : resultRows) {
HGSC007 hgsc007 = new HGSC007();
hgsc007.fromMap(resultRow);
if (hgsc007.getId() == null || hgsc007.getId() == 0) {
this.add(hgsc006, hgsc006A, hgsc007,hgpz005);
this.add(hgsc006, hgsc006A, hgsc007, hgpz005);
} else {
this.modify(hgsc006A, hgsc007, hgsc007List);
this.modify(hgsc007, hgsc007List);
}
}
// 更新订单主表数量
this.checkAssignedNum(hgsc006A, totalNum);
inInfo = this.query(inInfo);
// 刷新主订单信息
inInfo = this.refreshOrderInfo(inInfo, orderDetailId);
......@@ -166,7 +181,6 @@ public class ServiceHGSC006B extends ServiceBase {
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据操作成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "新增失败");
inInfo.setStatus(500);
}
return inInfo;
}
......@@ -177,13 +191,11 @@ public class ServiceHGSC006B extends ServiceBase {
* @param hgsc006A
* @param hgsc007
*/
private void add(HGSC006 hgsc006, HGSC006A hgsc006A, HGSC007 hgsc007,HGPZ005 hgpz005) {
private void add(HGSC006 hgsc006, HGSC006A hgsc006A, HGSC007 hgsc007, HGPZ005 hgpz005) {
Long orderDetailId = hgsc006A.getId();
// 数据校验
AssertUtils.isEmpty(hgsc007.getFactoryCode(), "请选择厂区");
AssertUtils.isEmpty(hgsc007.getGroupCode(), "请选择生产组");
// 更新订单主表数量
HGSCTools.checkAssignedNum(orderDetailId, hgsc007.getQuantity());
HGSC007 add007 = new HGSC007();
BeanUtils.copyProperties(hgsc006A,add007);
......@@ -222,12 +234,11 @@ public class ServiceHGSC006B extends ServiceBase {
/**
* 修改数据
*
* @param hgsc006A
* @param hgsc007
* @param hgsc007List
*/
private void modify(HGSC006A hgsc006A, HGSC007 hgsc007, List<HGSC007> hgsc007List) {
Long orderDetailId = hgsc006A.getId();
private void modify(HGSC007 hgsc007, List<HGSC007> hgsc007List) {
/*Long orderDetailId = hgsc006A.getId();
// 数据校验
HGSC007 dbSc007 = hgsc007List.stream().filter(o -> o.getId().compareTo(hgsc007.getId())==0).findAny().get();
AssertUtils.isGt(new BigDecimal(dbSc007.getFinishQuantity()), new BigDecimal(hgsc007.getQuantity()),
......@@ -235,10 +246,20 @@ public class ServiceHGSC006B extends ServiceBase {
// 计算差异数量
Integer diffNum = hgsc007.getQuantity() - dbSc007.getQuantity();
// 更新订单主表数量
HGSCTools.checkAssignedNum(orderDetailId, diffNum);
HGSCTools.checkAssignedNum(orderDetailId, diffNum);*/
// 更新子单
hgsc007.setTotalWeight(hgsc007.getSingleWeight().multiply(new BigDecimal(hgsc007.getQuantity())));
DaoUtils.update(HGSC007.UPDATE, hgsc007);
HGSC007 sc007 = hgsc007List.stream().filter(o -> o.getId().equals(hgsc007.getId())).findAny().get();
AssertUtils.isEmpty(Collections.singleton(sc007), "未找到生产任务!");
sc007.setGroupCode(hgsc007.getGroupCode());
sc007.setGroupName(hgsc007.getGroupName());
sc007.setFactoryCode(hgsc007.getFactoryCode());
sc007.setFactoryName(hgsc007.getFactoryName());
sc007.setQuantity(hgsc007.getQuantity());
sc007.setUnfinishQuantity(hgsc007.getQuantity());
sc007.setTotalWeight(sc007.getSingleWeight().multiply(new BigDecimal(hgsc007.getQuantity())));
sc007.setUnfinishWeight(sc007.getTotalWeight());
DaoUtils.update(HGSC007.UPDATE, sc007);
}
......@@ -249,6 +270,7 @@ public class ServiceHGSC006B extends ServiceBase {
* @return
*/
@OperationLogAnnotation(operModul = "拆单派工",operType = "删除",operDesc = "生产订单-拆单派工A-删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
try {
Map detailMap = EiInfoUtils.getFirstRow(inInfo, CommonConstant.Field.DETAIL);
......@@ -289,5 +311,75 @@ public class ServiceHGSC006B extends ServiceBase {
return inInfo;
}
/**
* 拆单数量校正
*
* @param hgsc006A 生产订单明细
* @param totalNum 任务数量
*/
public void checkAssignedNum(HGSC006A hgsc006A,Integer totalNum) {
// 生产订单
//HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(orderDetailId);
Integer jhNum = hgsc006A.getQuantity();
Map updateMap = new HashMap<>();
updateMap.put(HGSC006A.FIELD_id, hgsc006A.getId());
updateMap.put(HGSC006A.FIELD_assign_quantity, totalNum);
updateMap.put(HGSC006A.FIELD_unassign_quantity, jhNum - totalNum);
if(Objects.nonNull(hgsc006A.getSingleWeight())&&hgsc006A.getSingleWeight().compareTo(BigDecimal.ZERO)>0) {
BigDecimal assignWeight = hgsc006A.getSingleWeight().multiply(new BigDecimal(totalNum));
updateMap.put(HGSC006A.FIELD_assign_weight, assignWeight);
updateMap.put(HGSC006A.FIELD_unassign_weight, hgsc006A.getTotalWeight().subtract(assignWeight));
}
// 0.未派工,1.部分派工,2.全部派工
AssignStatusEnum orderDetailAssignStatus ;
if (jhNum - totalNum==0) {
orderDetailAssignStatus = ASSIGNED;
} else if (totalNum>0) {
orderDetailAssignStatus = PARTIAL_ASSIGN;
} else {
orderDetailAssignStatus = UNASSIGN;
}
updateMap.put(HGSC006A.FIELD_assign_status, orderDetailAssignStatus.getCode());
DaoUtils.update(HGSC006A.UPDATE_ASSIGN_NUM, updateMap);
handleOrderAssignStatus(hgsc006A,orderDetailAssignStatus);
}
private void handleOrderAssignStatus(HGSC006A hgsc006A, AssignStatusEnum orderDetailAssignStatus){
List<HGSC006A> otherSc006AList = HGSCTools.THGSC006A.otherById(hgsc006A.getOrderCode(),hgsc006A.getId());
int assignQuantity = 0;
int unassignQuantity = 0;
int totalQuantity = 0;
if(CollectionUtils.isNotEmpty(otherSc006AList)){
assignQuantity = otherSc006AList.stream().mapToInt(HGSC006A::getAssignQuantity).sum();
unassignQuantity = otherSc006AList.stream().mapToInt(HGSC006A::getUnassignQuantity).sum();
totalQuantity = otherSc006AList.stream().mapToInt(HGSC006A::getQuantity).sum();
}
AssignStatusEnum orderAssignStatus ;
switch (orderDetailAssignStatus){
case UNASSIGN:
if(unassignQuantity == totalQuantity){
orderAssignStatus = UNASSIGN;
}else{
orderAssignStatus = PARTIAL_ASSIGN;
}
break;
case PARTIAL_ASSIGN:
orderAssignStatus = PARTIAL_ASSIGN;
break;
case ASSIGNED:
if(assignQuantity == totalQuantity){
orderAssignStatus = ASSIGNED;
}else{
orderAssignStatus = PARTIAL_ASSIGN;
}
break;
default:
throw new PlatException("派工状态异常!");
}
Map updateMap = new HashMap();
updateMap.put(HGSC006.FIELD_order_code, hgsc006A.getOrderCode());
updateMap.put(HGSC006.FIELD_assign_status, orderAssignStatus.getCode());
DaoUtils.update(HGSC006.UPDATE_ASSIGN_STATUS, updateMap);
}
}
......@@ -177,6 +177,9 @@
<isNotEmpty prepend=" AND " property="ids">
id IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orderDetailIds">
order_detail_id IN <iterate close=")" open="(" conjunction="," property="orderDetailIds">#orderDetailIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCodes">
COMPANY_CODE IN <iterate close=")" open="(" conjunction="," property="companyCodes">#companyCodes[]#</iterate>
</isNotEmpty>
......
......@@ -55,6 +55,9 @@
<isNotEmpty prepend=" AND " property="taskId">
task_id = #taskId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="taskIds">
task_id IN <iterate close=")" open="(" conjunction="," property="taskIds">#taskIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="techFlowId">
tech_flow_id = #techFlowId#
</isNotEmpty>
......
......@@ -106,7 +106,7 @@ public class HGSCTools {
// 判断数量是否超过订单数量
AssertUtils.isGt(new BigDecimal(totalNum), new BigDecimal(jhNum), "拆单的分派数量不能大于生产订单数量!");
Map updateMap = new HashMap();
updateMap.put(hgsc006A.FIELD_id, hgsc006A.getId());
updateMap.put(HGSC006A.FIELD_id, hgsc006A.getId());
updateMap.put(HGSC006A.FIELD_assign_quantity, totalNum);
updateMap.put(HGSC006A.FIELD_unassign_quantity, jhNum - totalNum);
if(Objects.nonNull(hgsc006A.getSingleWeight())&&hgsc006A.getSingleWeight().compareTo(BigDecimal.ZERO)>0) {
......@@ -1540,6 +1540,21 @@ public class HGSCTools {
return DaoBase.getInstance().query(HGSC007.QUERY, queryMap);
}
/**
* 查询生产订单信息
*
* @param orderDetailIds
* @return
*/
public static List<HGSC007> listByOrderDetailId(List<String> orderDetailIds) {
if (CollectionUtils.isEmpty(orderDetailIds)) {
return null;
}
Map<String, Object> queryMap = new HashMap<>();
queryMap.put("orderDetailIds", orderDetailIds);
return DaoBase.getInstance().query(HGSC007.QUERY, queryMap);
}
}
/**
......@@ -1562,6 +1577,17 @@ public class HGSCTools {
return CollectionUtils.isEmpty(results) ? null : results;
}
public static List<HGSC008> getByTaskId(List<Long> taskIds) {
if (CollectionUtils.isEmpty(taskIds)) {
return null;
}
List<HGSC008> results = DaoBase.getInstance().query(HGSC008.QUERY,
new HashMap<String, Object>() {{
put("taskIds", taskIds);
}});
return CollectionUtils.isEmpty(results) ? null : results;
}
public static HGSC008 add(EiInfo info) {
Map resultMap = EiInfoUtils.getFirstRow(info, EiConstant.resultBlock);
String taskId = MapUtils.getString(resultMap, HGSC008.FIELD_task_id);
......
......@@ -16,10 +16,8 @@ $(function () {
field: "operator",
template: function (item) {
let template = "";
if(item.unassignQuantity > 0 ){
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="separateAssign(' + item.id + ')" >拆单派工</a>';
}
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' +
'onclick="showTaskInfo(' + item.id + ')" >任务详情</a>';
return template;
......@@ -28,6 +26,8 @@ $(function () {
loadComplete: function(grid) {
// 批量分派
$("#BNT_ASSIGN").on("click", assign);
// 批量改派
$("#BNT_ASSIGN_CHANGE").on("click", assignChange);
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'save'||e.eiInfo.extAttr.methodName == 'delete' ){
......@@ -83,8 +83,8 @@ function assign() {
JSColorbox.open({
href: "HGSC098?methodName=initLoad&inqu_status-0-companyCode=" + companyCode + "&inqu_status-0-productType=" + productType,
title: "<div style='text-align: center;'>选择组织</div>",
width: "90%",
height: "90%",
width: "75%",
height: "75%",
callbackName: function (row) {
var info = new EiInfo()
info.set("ids", ids.join(','));
......@@ -114,6 +114,67 @@ function assign() {
}
}
function assignChange() {
//重置全局变量
ids = [];
let rows = resultGrid.getCheckedRows()
if (rows.length < 1) {
message("请至少选择一条需要改派的数据");
return;
}
let productType = rows[0].get("productType");
let flag = true;
$.each(rows, function(index, item) {
let compareProductType = item.get("productType");
ids.push(item.id)
if(productType != compareProductType){
message(`选中第${index+1}行的生产订单不属于同一工种,无法改派!`)
flag = false;
return false;
}
if(item.assignStatus == 0){
message(`选中第${index+1}行的生产订单未派工,无法改派!`)
flag = false;
return false;
}
});
if(flag) {
let companyCode = rows[0].companyCode;
JSColorbox.open({
href: "HGSC098?methodName=initLoad&inqu_status-0-companyCode=" + companyCode + "&inqu_status-0-productType=" + productType,
title: "<div style='text-align: center;'>改派订单</div>",
width: "75%",
height: "75%",
callbackName: function (row) {
var info = new EiInfo()
info.set("ids", ids.join(','));
info.set("factoryCode", row.factoryCode);
info.set("factoryName", row.factoryName);
info.set("groupCode", row.groupCode);
info.set("groupName", row.groupName);
EiCommunicator.send("HGSC006A", "assignChange", info, {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
NotificationUtil({
msg: ei.msg
});
// 刷新列表
query();
// 关闭弹窗
JSColorbox.close();
}
}, onFail: function (ei) {
// 服务调用失败后的回调函数
NotificationUtil(ei, "error");
}
}, {async: false});
}
});
}
}
function separateAssign(orderDetailId){
JSColorbox.open({
......
......@@ -132,11 +132,13 @@ $(window).load(function () {
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
let rows = resultGrid.getDataItems();
if (rows.length < 1) {
message("请选择数据");
return;
}
let quantity = $("#detail-0-quantity").val();
let taskQuantity = 0;
for (let i = 0; i < rows.length; i++) {
if (isBlank(rows[i]['factoryCode'])) {
message("勾选的第" + (i + 1) + "行\"厂区\",不能为空");
......@@ -154,10 +156,15 @@ let save = function () {
message("勾选的第" + (i + 1) + "行\"分派数量\"必须是大于0的整数");
return;
}
taskQuantity += parseInt(rows[i]['quantity']);
}
if (taskQuantity > parseInt(quantity)){
message("分派数量不能大于订单数量");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGSC006B", "save", true);
JSUtils.submitGrid("result", "HGSC006B", "save", {isAlldata:true});
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment