Commit 0fa39dbf by liuyang

2024-09-25

1.生产订单添加全部派工和全部改派
parent 2447ee0e
......@@ -24,6 +24,7 @@ import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -127,6 +128,80 @@ public class ServiceHGSC006A extends ServiceBase {
return inInfo;
}
@OperationLogAnnotation(operModul = "生产订单详情", operType = "全部派工", operDesc = "全部派工")
public EiInfo assignAll(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String orderCode = inInfo.getString("orderCode");
//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");
HGSC006 hgsc006 = HGSCTools.THGSC006.getByOrderCode(orderCode);
List<HGPZ005> hgpz005List = DaoBase.getInstance().query(HGPZ005.QUERY,new HashMap<String,Object>(){{
put("inventTypeDetail",queryMap.get("productType"));
}});
// 校验主订单是否已分派
List<HGSC006A> hgsc006As= dao.query(HGSC006A.QUERY,queryMap,EiConstant.defaultOffset, -999999);
///List<HGSC006A> hgsc006As= HGSCTools.THGSC006A.listByIds(Arrays.asList(orderDetailIds));
List<String> orderDetailIds = hgsc006As.stream().map(HGSC006A::getId).map(String::valueOf).collect(Collectors.toList());
// 锁主单号
HGSCTools.THGSC006A.lock(orderDetailIds);
for (HGSC006A hgsc006A : hgsc006As) {
// 校验主订单是否已分派
//HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(Long.parseLong(orderDetailId));
AssignStatusEnum assignStatusEnum = AssignStatusEnum.getEnumByCode(hgsc006A.getAssignStatus());
BigDecimal assignQuantity = BigDecimal.ZERO;
switch (assignStatusEnum){
case UNASSIGN:
assignQuantity = hgsc006A.getQuantity();
HGSCTools.checkAssignedNum(hgsc006A.getId(), hgsc006A.getQuantity());
break;
case PARTIAL_ASSIGN:
assignQuantity = hgsc006A.getUnassignQuantity();
HGSCTools.checkAssignedNum(hgsc006A.getId(), hgsc006A.getUnassignQuantity());
break;
case ASSIGNED:
AssertUtils.isTrue(true,String.format("生产订单[%s]%s已全部分派,不能在进行批量分派,请检查!",hgsc006A.getProcessName(), hgsc006A.getProductName()));
break;
default:
throw new PlatException(String.format("生产订单[%s]%s状态异常,请联系管理员!",hgsc006A.getProcessName(), hgsc006A.getProductName()));
}
HGPZ005 hgpz005 =hgpz005List.stream().filter(pz005 -> pz005.getInventCode().equals(hgsc006A.getProductCode())).findAny().get();
// 写入子表数据
HGSC007 hgsc007 = new HGSC007();
BeanUtils.copyProperties(hgsc006A,hgsc007);
cleanBaseInfo(hgsc007);
if (hgpz005 != null) {
hgsc007.setSpec(hgpz005.getSpec());
hgsc007.setLength(hgpz005.getLength());
}
hgsc007.setTaskCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC007_TASK_CODE));
hgsc007.setMatId(hgsc006.getMatId());
hgsc007.setOrderId(hgsc006.getId());
hgsc007.setOrderDetailId(hgsc006A.getId());
hgsc007.setQuantity(assignQuantity);
hgsc007.setUnfinishQuantity(assignQuantity);
hgsc007.setTotalWeight(hgsc006A.getSingleWeight().multiply(assignQuantity));
hgsc007.setUnfinishWeight(hgsc007.getTotalWeight());
hgsc007.setGroupCode(groupCode);
hgsc007.setGroupName(groupName);
hgsc007.setFactoryCode(factoryCode);
hgsc007.setFactoryName(factoryName);
DaoUtils.insert(HGSC007.INSERT, hgsc007);
// 写入派工人员明细
HgScUtils.HgSc007B.addGroupUser(hgsc007);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + hgsc006As.size() + "]条数据分派成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "分派失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "生产订单详情", operType = "批量改派", operDesc = "批量改派")
public EiInfo assignChange(EiInfo inInfo){
try {
......@@ -158,6 +233,41 @@ public class ServiceHGSC006A extends ServiceBase {
return inInfo;
}
@OperationLogAnnotation(operModul = "生产订单详情", operType = "全部改派", operDesc = "全部改派")
public EiInfo assignChangeAll(EiInfo inInfo){
try {
//String[] orderDetailIds = inInfo.getString("ids").split(",");
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
List<HGSC006A> hgsc006As= dao.query(HGSC006A.QUERY,queryMap,EiConstant.defaultOffset, -999999);
///List<HGSC006A> hgsc006As= HGSCTools.THGSC006A.listByIds(Arrays.asList(orderDetailIds));
List<String> orderDetailIds = hgsc006As.stream().map(HGSC006A::getId).map(String::valueOf).collect(Collectors.toList());
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(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);
// 写入派工人员明细
HgScUtils.HgSc007B.addGroupUser(hgsc007);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + hgsc006As.size() + "]条数据分派成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "改派失败");
}
return inInfo;
}
public EiInfo revocation(EiInfo inInfo){
try {
List<HGSC006A> hgsc006aList =MapUtils.toDaoEPBases(inInfo, HGSC006A.class);
......@@ -189,5 +299,18 @@ public class ServiceHGSC006A extends ServiceBase {
hgsc007.setDepName(null);
hgsc007.setId(null);
}
/**
* 查询全部订单产品类型
*/
public EiInfo queryProductType(EiInfo inInfo){
Map queryMap =EiInfoUtils.getFirstRow(inInfo);
List<HGSC006A> result = dao.query(HGSC006A.QUERY, queryMap,EiConstant.defaultOffset, -999999);
List<Integer> productTypes = result.stream().map(HGSC006A::getProductType).distinct().collect(Collectors.toList());
inInfo.set("productTypeSise", productTypes);
List<Integer> assignStatus = result.stream().map(HGSC006A::getAssignStatus).filter(status -> status ==0).distinct().collect(Collectors.toList());
inInfo.set("assignStatus", assignStatus);
return inInfo;
}
}
......@@ -28,8 +28,12 @@ $(function () {
$("#BNT_ASSIGN").on("click", assign);
// 批量改派
$("#BNT_ASSIGN_CHANGE").on("click", assignChange);
$("#BNT_REVOCA").on("click", revocate)
// 撤销派工
$("#BNT_REVOCA").on("click", revocate);
// 批量全部分派
$("#BNT_ASSIGN_ALL").on("click", assignAll);
// 批量全部改派
$("#BNT_CHANGE_ALL").on("click", assignChangeAll);
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'save'||e.eiInfo.extAttr.methodName == 'delete' ){
......@@ -117,6 +121,71 @@ function assign() {
}
/**
* 批量全部分派
*/
function assignAll() {
let rows = resultGrid.getDataItems();
let productType = "";
let orderCode = $("#inqu_status-0-orderCode").val();
let flag = true;
var info = initInquStatus();
EiCommunicator.send("HGSC006A", "queryProductType", info, {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
let product = ei.get("productTypeSise");
if(product.length > 1){
message(`生产订单不属于同一工种,无法改派!`)
flag = false;
return false;
}else if(product.length == 0){
message(`生产订单数据为空,无法改派!`)
flag = false;
return false;
}
productType = product[0];
}
}, onFail: function (ei) {
}
}, {async: 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 = initInquStatus();
info.set("orderCode",orderCode);
info.set("inqu_status-0-productType", productType);
info.set("factoryCode", row.factoryCode);
info.set("factoryName", row.factoryName);
info.set("groupCode", row.groupCode);
info.set("groupName", row.groupName);
EiCommunicator.send("HGSC006A", "assignAll", info, {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
NotificationUtil({
msg: ei.msg
});
// 刷新列表
resultGrid.dataSource.page(1);
// 关闭弹窗
JSColorbox.close();
}
}, onFail: function (ei) {
}
}, {async: false});
}
});
}
}
/**
* 批量改派
*/
function assignChange() {
......@@ -181,6 +250,77 @@ function assignChange() {
}
/**
* 全部改派
*/
function assignChangeAll() {
let rows = resultGrid.getDataItems();
let productType = "";
let flag = true;
var info = initInquStatus();
EiCommunicator.send("HGSC006A", "queryProductType", info, {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
let product = ei.get("productTypeSise");
if(product.length > 1){
message(`生产订单不属于同一工种,无法改派!`)
flag = false;
return false;
}else if(product.length == 0){
message(`生产订单数据为空,无法改派!`)
flag = false;
return false;
}
productType = product[0];
let assignStatus = ei.get("assignStatus");
if(assignStatus.includes(0)){
message(`生产订单有未派工数据,无法改派!`)
flag = false;
return false;
}
}
}, onFail: function (ei) {
}
}, {async: 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 = initInquStatus();
info.set("factoryCode", row.factoryCode);
info.set("factoryName", row.factoryName);
info.set("groupCode", row.groupCode);
info.set("groupName", row.groupName);
EiCommunicator.send("HGSC006A", "assignChangeAll", 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});
}
});
}
}
/**
* 撤销派工
*/
let revocate = function () {
......@@ -247,3 +387,16 @@ function separateAssignCallback(ei) {
JSColorbox.close();
}
}
let initInquStatus = function () {
var info = new EiInfo()
info.set("inqu_status-0-orderCode", $("#inqu_status-0-orderCode").val());
info.set("inqu_status-0-productCode", $("#inqu_status-0-productCode").val());
info.set("inqu_status-0-productName", $("#inqu_status-0-productName").val());
info.set("inqu_status-0-projName", $("#inqu_status-0-projName").val());
info.set("inqu_status-0-processName", $("#inqu_status-0-processName").val());
info.set("inqu_status-0-assignStatus", $("#inqu_status-0-assignStatus").val());
info.set("inqu_status-0-planStartDate", $("#inqu_status-0-planStartDate").val());
info.set("inqu_status-0-planEndDate", $("#inqu_status-0-planEndDate").val());
return info;
}
......@@ -21,6 +21,10 @@
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="order_code_block_id" valueField="valueField" textField="textField"/>
</EF:EFSelect>
<EF:EFSelect cname="派工状态" ename="inqu_status-0-assignStatus" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hggp.assignStatus"/>
</EF:EFSelect>
<EF:EFDateSpan startCname="计划开工日期" endCname="计划完工日期" blockId="inqu_status"
startName="planStartDate" endName="planEndDate" row="0" role="date"
format="yyyy-MM-dd" satrtRatio="4:8" endRatio="4:8">
......
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