Commit 4853573f by wuwenlong

bugfix;

parent c52075a2
......@@ -69,6 +69,8 @@ public class HGConstant {
public static final String HGSC005_PLAN_CODE = "HGSC005_PLAN_CODE";
//生产订单
public static final String HGSC006_ORDER_CODE = "HGSC006_ORDER_CODE";
//生产任务
public static final String HGSC007_TASCK_CODE = "HGSC007_TASCK_CODE";
//生产任务订单
public static final String PROD_TASK_NO = "PROD_TASK_NO";
//售后维修单号
......
......@@ -503,17 +503,18 @@ public class HGSqlConstant {
* @author:songx
* @date:2024/2/5,10:16
*/
public class HPSC005 {
public class HGSC006A {
// 锁
public static final String LOCK = "HPSC005.lock";
// 查询
public static final String UPDATE_ASSIGN_NUM = "HPSC005.updateAssignNum";
public static final String LOCK = "HGSC006A.lock";
}
public static final String DELETE_BY_MAT = "HPSC005.deleteByMat";
public class HGSC007 {
// 锁
public static final String LOCK = "HGSC007.lock";
}
/**
* @author:songx
* @date:2024/2/5,10:16
......
......@@ -65,6 +65,7 @@ public class HGSC006 extends DaoEPBase {
public static final String INSERT = "HGSC006.insert";
public static final String UPDATE = "HGSC006.update";
public static final String DELETE = "HGSC006.delete";
public static final String UPDATE_ASSIGN_STATUS = "HGSC006.update_assign_status";
private Long id = new Long(0);
private Long matId = new Long(0); /* 物料清单ID*/
......
......@@ -155,6 +155,8 @@ public class ServiceHGSC001 extends ServiceBase {
AssertUtils.isEmpty(hgsc001.getPermissStartDate(), "请选择准许开工日期!");
AssertUtils.isEmpty(hgsc001.getStartDate(), "请选择开工日期!");
AssertUtils.isEmpty(hgsc001.getEndDate(), "请选择完工日期!");
AssertUtils.isTrue(DateUtil.toDate(hgsc001.getEndDate(),DateUtil.DATE10_PATTERN).compareTo(
DateUtil.toDate(hgsc001.getStartDate(),DateUtil.DATE10_PATTERN))>0,"完工日期不能大于开工日期!");
AssertUtils.isNull(hgsc001.getProjStatus(), "请选择项目状态!");
AssertUtils.isEmpty(hgsc001.getContractWorkTxt(), "请填写合同工作量!");
......
package com.baosight.hggp.hg.sc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.sc.domain.HGSC006;
import com.baosight.hggp.hg.sc.domain.HGSC006A;
import com.baosight.hggp.hg.sc.domain.HGSC007;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 拆单派工
*
*/
public class ServiceHGSC006C extends ServiceBase {
/**
* 画面初始化.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "拆单派工",operType = "查询",operDesc = "生产订单-拆单派工-初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String orderDetailId = MapUtils.getString(queryMap, HGSC006A.FIELD_id);
HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(Long.valueOf(orderDetailId));
inInfo.addBlock(CommonConstant.Field.DETAIL).addRow(hgsc006A);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGSC007().eiMetadata);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "初始化失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 查询操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "拆单派工",operType = "查询",operDesc = "生产订单-拆单派工-查询")
@Override
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HGSC007.QUERY, new HGSC007());
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 新增操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "拆单派工",operType = "新增",operDesc = "生产订单-拆单派工A-新增操作")
public EiInfo save(EiInfo inInfo) {
try {
Map detailMap = EiInfoUtils.getFirstRow(inInfo, CommonConstant.Field.DETAIL);
String orderCode = MapUtils.getString(detailMap, HGSC006A.FIELD_order_code);
Long orderDetailId = Long.valueOf(MapUtils.getString(detailMap, HGSC006A.FIELD_id));
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 生产任务号
List<Long> taskIds = ObjectUtils.listKey(resultRows, HGSC007.FIELD_id);
// 锁主单号
HGSCTools.THGSC006A.lock(orderDetailId);
// 锁子单
HGSCTools.THGSC007.lock(taskIds);
// 查询订单信息
HGSC006 hgsc006 = HGSCTools.THGSC006.getByOrderCode(orderCode);
HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(orderDetailId);
// 查询任务信息
List<HGSC007> hgsc007List = HGSCTools.THGSC007.list(taskIds);
// 写入数据
for (Map resultRow : resultRows) {
HGSC007 hgsc007 = new HGSC007();
hgsc007.fromMap(resultRow);
if (hgsc007.getId() == null || hgsc007.getId() == 0) {
this.add(hgsc006, hgsc006A, hgsc007);
} else {
this.modify(hgsc006A, hgsc007, hgsc007List);
}
}
inInfo = this.query(inInfo);
// 刷新主订单信息
inInfo = this.refreshOrderInfo(inInfo, orderDetailId);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据操作成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "新增失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 新增
*
* @param hgsc006A
* @param hgsc007
*/
private void add(HGSC006 hgsc006, HGSC006A hgsc006A, HGSC007 hgsc007) {
Long orderDetailId = hgsc006A.getId();
// 数据校验
AssertUtils.isEmpty(hgsc007.getFactoryCode(), "请选择厂区");
AssertUtils.isEmpty(hgsc007.getGroupCode(), "请选择生产组");
// 更新订单主表数量
HGSCTools.checkAssignedNum(orderDetailId, hgsc007.getQuantity());
hgsc007.setTaskCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC007_TASCK_CODE));
hgsc007.setOrderId(hgsc006.getId());
hgsc007.setMatId(hgsc006.getMatId());
hgsc007.setOrderDetailId(hgsc006A.getId());
hgsc007.setTotalWeight(hgsc007.getSingleWeight().multiply(new BigDecimal(hgsc007.getQuantity())));
DaoUtils.insert(HGSC007.INSERT, hgsc007);
}
/**
* 修改数据
*
* @param hgsc006A
* @param hgsc007
* @param hgsc007List
*/
private void modify(HGSC006A hgsc006A, 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()),
String.format("任务[%s]修改后的数量不能小于已完工的数量", hgsc007.getTaskCode()));
// 计算差异数量
Integer diffNum = hgsc007.getQuantity() - dbSc007.getQuantity();
// 更新订单主表数量
HGSCTools.checkAssignedNum(orderDetailId, diffNum);
// 更新子单
hgsc007.setTotalWeight(hgsc007.getSingleWeight().multiply(new BigDecimal(hgsc007.getQuantity())));
DaoUtils.update(HGSC007.UPDATE, dbSc007);
}
/**
* 删除操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "拆单派工",operType = "删除",operDesc = "生产订单-拆单派工A-删除操作")
public EiInfo delete(EiInfo inInfo) {
try {
Map detailMap = EiInfoUtils.getFirstRow(inInfo, CommonConstant.Field.DETAIL);
Long orderDetailId = Long.valueOf(MapUtils.getString(detailMap, HGSC006A.FIELD_id));
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HGSC007 hgsc007 = new HGSC007();
hgsc007.fromMap(resultRow);
HGSC007 dbsc007 = HGSCTools.THGSC007.getById(hgsc007.getId());
AssertUtils.isGt(new BigDecimal(dbsc007.getFinishQuantity()), BigDecimal.ZERO,
String.format("任务[%s]已存在完工数量不能删除", dbsc007.getTaskCode()));
// 更新订单主表数量
HGSCTools.checkAssignedNum(orderDetailId, -hgsc007.getQuantity());
// 删除子单
DaoUtils.update(HGSC007.DELETE, hgsc007);
}
inInfo = this.query(inInfo);
// 刷新主订单信息
inInfo = this.refreshOrderInfo(inInfo, orderDetailId);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "删除失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 刷新主订单信息
*
* @param inInfo
* @return
*/
private EiInfo refreshOrderInfo(EiInfo inInfo, Long orderDetailId) {
HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(orderDetailId);
inInfo.addBlock(CommonConstant.Field.DETAIL).addRow(hgsc006A);
return inInfo;
}
}
......@@ -115,6 +115,18 @@
<isNotEmpty prepend=" AND " property="unfinishQuantity">
unfinish_quantity = #unfinishQuantity#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="singleWeight">
single_weight = #singleWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="totalWeight">
total_weight = #totalWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="finishWeight">
finish_weight = #finishWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unfinishWeight">
unfinish_weight = #unfinishWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
account_code = #accountCode#
</isNotEmpty>
......@@ -152,8 +164,8 @@
invent_process_id as "inventProcessId", <!-- 存货工序ID,对应HGPZ005A.id -->
process_code as "processCode", <!-- 工序编码 -->
process_name as "processName", <!-- 工序名称 -->
process_order as "processOrder", <!-- 加工顺序 -->
company_code as "companyCode", <!-- 公司编码 -->
process_order as "processOrder", <!-- 加工顺序 -->
company_name as "companyName", <!-- 公司名称 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
......@@ -169,6 +181,10 @@
quantity as "quantity", <!-- 数量 -->
finish_quantity as "finishQuantity", <!-- 完工数量 -->
unfinish_quantity as "unfinishQuantity", <!-- 未完工数量 -->
single_weight as "singleWeight", <!-- 单重 -->
total_weight as "totalWeight", <!-- 总重 -->
finish_weight as "finishWeight", <!-- 完工重量 -->
unfinish_weight as "unfinishWeight", <!-- 未完工重量 -->
account_code as "accountCode", <!-- 帐套 -->
created_by as "createdBy", <!-- 创建人 -->
created_name as "createdName", <!-- 创建人名称 -->
......@@ -183,7 +199,7 @@
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
product_type asc ,plan_start_date asc
id asc
</isEmpty>
</dynamic>
......@@ -213,12 +229,18 @@
<isNotEmpty prepend=" AND " property="inventProcessId">
invent_process_id = #inventProcessId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processCode">
process_code = #processCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processName">
process_name = #processName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
company_code = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processOrder">
process_order = #processOrder#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
company_name = #companyName#
</isNotEmpty>
......@@ -264,6 +286,18 @@
<isNotEmpty prepend=" AND " property="unfinishQuantity">
unfinish_quantity = #unfinishQuantity#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="singleWeight">
single_weight = #singleWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="totalWeight">
total_weight = #totalWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="finishWeight">
finish_weight = #finishWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unfinishWeight">
unfinish_weight = #unfinishWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
account_code = #accountCode#
</isNotEmpty>
......@@ -294,10 +328,10 @@
tech_flow_id, <!-- 工艺流程ID -->
tech_flow_name, <!-- 工艺流程名称 -->
invent_process_id, <!-- 存货工序ID,对应HGPZ005A.id -->
process_code, <!-- 工序名称 -->
process_code, <!-- 工序编码 -->
process_name, <!-- 工序名称 -->
process_order, <!-- 工序名称 -->
company_code, <!-- 公司编码 -->
process_order, <!-- 加工顺序 -->
company_name, <!-- 公司名称 -->
dep_code, <!-- 部门编码 -->
dep_name, <!-- 部门名称 -->
......@@ -313,6 +347,10 @@
quantity, <!-- 数量 -->
finish_quantity, <!-- 完工数量 -->
unfinish_quantity, <!-- 未完工数量 -->
single_weight, <!-- 单重 -->
total_weight, <!-- 总重 -->
finish_weight, <!-- 完工重量 -->
unfinish_weight, <!-- 未完工重量 -->
account_code, <!-- 帐套 -->
created_by, <!-- 创建人 -->
created_name, <!-- 创建人名称 -->
......@@ -321,7 +359,7 @@
updated_name, <!-- 修改人名称 -->
updated_time <!-- 更新时间 -->
)
VALUES (#id#, #matId#, #matDetailId#, #techFlowId#, #techFlowName#, #inventProcessId#, #processCode#, #processName#, #processOrder#, #companyCode#, #companyName#, #depCode#, #depName#, #projCode#, #projName#, #planCode#, #productType#, #productCode#, #productName#, #finishDate#, #planStartDate#, #planEndDate#, #quantity#, #finishQuantity#, #unfinishQuantity#, #accountCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
VALUES (#id#, #matId#, #matDetailId#, #techFlowId#, #techFlowName#, #inventProcessId#, #processCode#, #processName#, #companyCode#, #processOrder#, #companyName#, #depCode#, #depName#, #projCode#, #projName#, #planCode#, #productType#, #productCode#, #productName#, #finishDate#, #planStartDate#, #planEndDate#, #quantity#, #finishQuantity#, #unfinishQuantity#, #singleWeight#, #totalWeight#, #finishWeight#, #unfinishWeight#, #accountCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
</insert>
<delete id="delete">
......@@ -337,10 +375,10 @@
tech_flow_id = #techFlowId#, <!-- 工艺流程ID -->
tech_flow_name = #techFlowName#, <!-- 工艺流程名称 -->
invent_process_id = #inventProcessId#, <!-- 存货工序ID,对应HGPZ005A.id -->
process_code = #processCode#, <!-- 工序名称 -->
process_code = #processCode#, <!-- 工序编码 -->
process_name = #processName#, <!-- 工序名称 -->
process_order = #processOrder#, <!-- 工序名称 -->
company_code = #companyCode#, <!-- 公司编码 -->
process_order = #processOrder#, <!-- 加工顺序 -->
company_name = #companyName#, <!-- 公司名称 -->
dep_code = #depCode#, <!-- 部门编码 -->
dep_name = #depName#, <!-- 部门名称 -->
......@@ -356,6 +394,10 @@
quantity = #quantity#, <!-- 数量 -->
finish_quantity = #finishQuantity#, <!-- 完工数量 -->
unfinish_quantity = #unfinishQuantity#, <!-- 未完工数量 -->
single_weight = #singleWeight#, <!-- 单重 -->
total_weight = #totalWeight#, <!-- 总重 -->
finish_weight = #finishWeight#, <!-- 完工重量 -->
unfinish_weight = #unfinishWeight#, <!-- 未完工重量 -->
account_code = #accountCode#, <!-- 帐套 -->
created_by = #createdBy#, <!-- 创建人 -->
created_name = #createdName#, <!-- 创建人名称 -->
......
......@@ -228,4 +228,22 @@
id = #id#
</update>
<!-- 公共修改字段 -->
<sql id="updateRevise">
updated_by = #updatedBy#, <!-- 修改人 -->
updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 修改时间 -->
</sql>
<update id="update_assign_status">
UPDATE ${hggpSchema}.HGSC006
SET
assign_status = #assignStatus#, <!-- 派工状态 0待派工;1部分派工;2已派工 -->
assign_quantity = #assignQuantity#, <!-- 派工数量 -->
unassign_quantity = #unassignQuantity#, <!-- 未派工数量 -->
<include refid="updateRevise"/>
WHERE order_code = #orderCode#
</update>
</sqlMap>
......@@ -9,6 +9,7 @@ import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ005A;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
......@@ -18,6 +19,7 @@ import com.baosight.hggp.hg.sj.tools.HGSJTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.BeanUtils;
import com.baosight.hggp.util.DateUtil;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
......@@ -29,6 +31,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.baosight.hggp.common.AssignStatusEnum.*;
import static java.math.BigDecimal.ROUND_DOWN;
/**
......@@ -37,6 +40,84 @@ import static java.math.BigDecimal.ROUND_DOWN;
*/
public class HGSCTools {
/**
* 拆单数量校正
*
* @param orderDetailId 生产订单编码
* @param assignNum 分派数量
*/
public static void checkAssignedNum(Long orderDetailId, Integer assignNum) {
// 生产订单
HGSC006A hgsc006A = HGSCTools.THGSC006A.getById(orderDetailId);
Integer jhNum = hgsc006A.getQuantity();
// 子单
Map queryMap = new HashMap();
queryMap.put(HGSC007.FIELD_order_detail_id, orderDetailId);
List<HGSC007> hgsc007List = DaoBase.getInstance().query(HGSC007.QUERY, queryMap, 0, -999999);
Integer totalNum = assignNum;
if(CollectionUtils.isNotEmpty(hgsc007List)){
for(HGSC007 dbsc007 : hgsc007List){
totalNum = totalNum + dbsc007.getQuantity();
}
}
// 判断数量是否超过订单数量
AssertUtils.isGt(new BigDecimal(totalNum), new BigDecimal(jhNum), "拆单的分派数量不能大于生产订单数量!");
Map updateMap = new HashMap();
updateMap.put(hgsc006A.FIELD_id, hgsc006A.getId());
updateMap.put(HGSC006A.FIELD_quantity, totalNum);
updateMap.put(HGSC006A.FIELD_unassign_quantity, jhNum - totalNum);
// 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 static void handleOrderAssignStatus(HGSC006A hgsc006A, AssignStatusEnum orderDetailAssignStatus){
List<HGSC006A> otherSc006AList = HGSCTools.THGSC006A.otherById(hgsc006A.getOrderCode(),hgsc006A.getId());
int unassignQuantity = 0;
int totalQuantity = 0;
if(CollectionUtils.isNotEmpty(otherSc006AList)){
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(unassignQuantity == 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);
}
public static class THGSC001A{
/**
......@@ -92,7 +173,7 @@ public class HGSCTools {
public static void deleteByProIds(List<Long> projIds){
if(CollectionUtils.isNotEmpty(projIds)) {
//删除历史数据
DaoUtils.update(HGSC001A.DELETE_BY_PROJIDS, new HashMap<String,Object>(){{put("proIds",projIds);}});
DaoUtils.update(HGSC001A.DELETE_BY_PROJIDS, new HashMap<String,Object>(){{put("projIds",projIds);}});
}
}
}
......@@ -349,6 +430,7 @@ public class HGSCTools {
hgsc005a.setFinishDate(hgsc005.getFinishDate());
hgsc005a.setUnfinishQuantity(hgsc005a.getQuantity());
hgsc005a.setFinishQuantity(0);
hgsc005a.setUnfinishWeight(hgsc005a.getTotalWeight());
return hgsc005a;
}
......@@ -466,12 +548,40 @@ public class HGSCTools {
hgsc006.setCompanyName(hgsc005.getCompanyName());
hgsc006.setProjCode(hgsc005.getProjCode());
hgsc006.setProjName(hgsc005.getProjName());
hgsc006.setAssignStatus(AssignStatusEnum.UNASSIGN.getCode());
hgsc006.setAssignStatus(UNASSIGN.getCode());
return hgsc006;
}
public static HGSC006 getByOrderCode(String orderCode) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
HGSC006 results = (HGSC006)DaoBase.getInstance().get(HGSC006.QUERY, HGSC006.FIELD_order_code, orderCode);
return results;
}
}
public static class THGSC006A{
/**
* 锁
*
* @param orderDetailId
* @return
*/
public static void lock(Long orderDetailId) {
if (Objects.isNull(orderDetailId)||orderDetailId<=0) {
return;
}
Map queryMap = new HashMap();
queryMap.put(HGSC006A.FIELD_id, orderDetailId);
DaoBase.getInstance().update(HGSqlConstant.HGSC006A.LOCK, queryMap);
}
public static HGSC006A getById(Long orderDetailId){
AssertUtils.isTrue(Objects.isNull(orderDetailId)||orderDetailId<=0, "订单明细ID不能为空!");
HGSC006A results = (HGSC006A)DaoBase.getInstance().get(HGSC006A.QUERY, HGSC006A.FIELD_id, orderDetailId);
return results;
}
public static List<HGSC006A> constructObj(HGSC006 hgsc006,List<HGSC005A> hgsc005AList){
List<HGSC006A> result = new ArrayList<>();
hgsc005AList.forEach(o -> {
......@@ -497,10 +607,72 @@ public class HGSCTools {
hgsc006a.setQuantity(o.getQuantity());
hgsc006a.setUnassignQuantity(o.getQuantity());
hgsc006a.setAssignQuantity(0);
hgsc006a.setSingleWeight(o.getSingleWeight());
hgsc006a.setTotalWeight(o.getTotalWeight());
hgsc006a.setUnassignWeight(hgsc006a.getTotalWeight());
result.add(hgsc006a);
});
return result;
}
public static List<HGSC006A> getByOrderCode(String orderCode) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
Map paramMap = new HashMap();
paramMap.put(HGSC006A.FIELD_order_code, orderCode);
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results;
}
public static List<HGSC006A> otherById(String orderCode,Long orderDetailId) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
AssertUtils.isTrue(Objects.isNull(orderDetailId)||orderDetailId<=0, "生产订单明细ID不能为空!");
Map paramMap = new HashMap();
paramMap.put(HGSC006A.FIELD_order_code, orderCode);
paramMap.put(HGSC006A.FIELD_id, orderDetailId);
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY_OTHER, paramMap);
return CollectionUtils.isEmpty(results) ? null : results;
}
}
public static class THGSC007{
public static HGSC007 getById(Long taskId){
AssertUtils.isTrue(Objects.isNull(taskId)||taskId<=0, "生产任务ID不能为空!");
HGSC007 results = (HGSC007)DaoBase.getInstance().get(HGSC006A.QUERY, HGSC007.FIELD_id, taskId);
return results;
}
/**
* 锁
*
* @param taskIds
* @return
*/
public static void lock(List<Long> taskIds) {
if (CollectionUtils.isEmpty(taskIds)) {
return;
}
Map queryMap = new HashMap();
queryMap.put("ids", taskIds);
DaoBase.getInstance().update(HGSqlConstant.HGSC007.LOCK, queryMap);
}
/**
* 查询信息
*
* @param taskIds
* @return
*/
public static List<HGSC007> list(List<Long> taskIds) {
if (CollectionUtils.isEmpty(taskIds)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("ids", taskIds);
return DaoBase.getInstance().query(HGSC007.QUERY, queryMap);
}
}
}
......@@ -93,7 +93,7 @@ function update() {
return;
}
if(rows[0].approvalStatus>0){
message("修改","项目已提交不可修改!");
message2("修改","项目已提交不可修改!");
return;
}
let id = rows[0].id;
......@@ -112,29 +112,39 @@ function remove() {
message2("删除","没有选中的行");
return;
}
IPLAT.confirm({
title:'删除',
message:'确认删除此数据么?',
okFn:function () {
var post = new EiInfo();
post.addBlock(resultGrid.getCheckedBlockData());
post.set("recursion", true);
EiCommunicator.send("HGSC001","delete",post,{
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
NotificationUtil(ei);
resultGrid.dataSource.query();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
let flag = true;
$.each(rows, function(index, item) {
if(item.approvalStatus > 0){
message2("完工","项目已提交不可删除!");
flag = false;
return;
}
})
});
if(flag) {
IPLAT.confirm({
title: '删除',
message: '确认删除此数据么?',
okFn: function () {
var post = new EiInfo();
post.addBlock(resultGrid.getCheckedBlockData());
post.set("recursion", true);
EiCommunicator.send("HGSC001", "delete", post, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
NotificationUtil(ei);
resultGrid.dataSource.query();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
}
});
}
}
function complete() {
......@@ -143,29 +153,39 @@ function complete() {
message2("完工","没有选中的行");
return;
}
IPLAT.confirm({
title:'完工',
message:'确认完工此数据么?',
okFn:function () {
var post = new EiInfo();
post.addBlock(resultGrid.getCheckedBlockData());
post.set("recursion", true);
EiCommunicator.send("HGSC001","complete",post,{
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
NotificationUtil(ei);
resultGrid.dataSource.query();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
let flag = true;
$.each(rows, function(index, item) {
if(item.approvalStatus==='0'){
message2("完工","项目未提交不可完工!");
flag = false;
return;
}
})
});
if(flag) {
IPLAT.confirm({
title: '完工',
message: '确认完工此数据么?',
okFn: function () {
var post = new EiInfo();
post.addBlock(resultGrid.getCheckedBlockData());
post.set("recursion", true);
EiCommunicator.send("HGSC001", "complete", post, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
NotificationUtil(ei);
resultGrid.dataSource.query();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
}
});
}
}
function commit() {
......
......@@ -132,9 +132,11 @@ function save(){
});
}
function saveCallBack(){
// 刷新列表
resultGrid.dataSource.page(1);
function saveCallBack(ei){
if (ei.getStatus() >= 0) {
// 刷新列表
resultGrid.dataSource.page(1);
}
}
/**
......
......@@ -41,6 +41,10 @@
dateFormat="yyyy-MM-dd" parseFormats="['yyyy-MM-dd']" />
<EF:EFColumn ename="assignQuantity" cname="派工数量" width="120" enable="true" align="center" readOnly="true"/>
<EF:EFColumn ename="unassignQuantity" cname="待派工数量" width="120" enable="true" align="center" readOnly="true"/>
<EF:EFComboColumn ename="assignStatus" cname="派工状态" width="80" align="center"
readonly="true">
<EF:EFCodeOption codeName="hggp.assignStatus"/>
</EF:EFComboColumn>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
let factoryGroupGlobalData = [];
$(function () {
IPLATUI.EFGrid = {
"result" : {
pageable: {
pageSize: 20,
pageSizes: [10, 20, 50, 70, 100],
},
columns: [{
field: "groupName",
attributes: {
class: "i-input-readonly"
}
}, {
field: "groupCode",
template: function (dataItem) {
for (let i = 0; i < factoryGroupGlobalData.length; i++) {
if (factoryGroupGlobalData[i]['valueField'] === dataItem['orgNo']) {
return factoryGroupGlobalData[i]['textField'];
}
}
return "";
},
editor: function (container, options) {
let inInfo = new EiInfo();
inInfo.set("result-0-parentOrgId", options.model["factoryCode"]);
// 1:生产组
inInfo.set("inqu_status-0-productType", 'prodGroup');
inInfo.set("serviceName", "HPXSOrg");
inInfo.set("methodName", "queryGroupComboBox");
inInfo.set("blockId", "group_record_block_id");
inInfo.set("field", options.field);
refreshSelect(container, inInfo);
}
},{
field: "createdTime",
attributes: {
class: "i-input-readonly"
},
defaultValue: function () {
return currShortDate();
}
}],
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
save();
},
onDelete: function (e) {
// 阻止后台删除请求,使用自定义删除
e.preventDefault();
deleteFunc();
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'save'
||e.eiInfo.extAttr.methodName == 'delete' ){
query();
}
}
}
}
$("#QUERY").on("click", query);
downKeyUp();
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 生产组名称
let inInfo = new EiInfo();
inInfo.set("inqu_status-0-productType", 'prodGroup');
EiCommunicator.send("HPXSOrg", "queryGroupComboBox", inInfo, {
onSuccess: function (ei) {
factoryGroupGlobalData = ei.getBlock("group_record_block_id").getMappedRows();
},
onFail: function (ei) {
}
}, {async: false});
// 查询
query();
});
/**
* 查询
*/
function query() {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
for (let i = 0; i < rows.length; i++) {
if (isBlank(rows[i]['factoryCode'])) {
message("勾选的第" + (i + 1) + "行\"厂区\",不能为空");
return;
}
if (isBlank(rows[i]['groupCode'])) {
message("勾选的第" + (i + 1) + "行\"生产组\",不能为空");
return;
}
if (isBlank(rows[i]['quantity'])) {
message("勾选的第" + (i + 1) + "行\"分派数量\",不能为空");
return;
}
if (!isPositiveInteger(rows[i]['quantity'])) {
message("勾选的第" + (i + 1) + "行\"分派数量\"必须是大于0的整数");
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGSC006C", "save", true);
}
});
}
/**
* 删除
*/
let deleteFunc = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGSC006C", "delete", true);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="拆单派工">
<EF:EFRegion id="inqu" title="订单详情">
<EF:EFInput ename="inqu_status-0-projCode" cname="项目号" type="hidden"/>
<EF:EFInput ename="inqu_status-0-productType" cname="产品类型" type="hidden"/>
<EF:EFInput ename="detail-0-id" cname="订单明细ID" type="hidden"/>
<div class="row">
<EF:EFInput ename="detail-0-projCode" cname="项目号" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-projName" cname="项目名称" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-orderNo" cname="生产订单号" colWidth="4" readonly="true"/>
</div>
<div class="row">
<EF:EFInput ename="detail-0-productCode" cname="产品编码" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-productName" cname="产品名称" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-processName" cname="工序" colWidth="4" readonly="true"/>
</div>
<div class="row">
<EF:EFInput ename="detail-0-planCompletionDate" cname="计划完成日期" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-quantity" cname="计划数量" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-totalWeight" cname="计划重量(kg)" colWidth="4" readonly="true"/>
</div>
<div class="row">
<EF:EFInput ename="detail-0-assignQuantity" cname="已派工数量" colWidth="4" readonly="true"/>
<EF:EFInput ename="detail-0-unassignQuantity" cname="待派工数量" colWidth="4" readonly="true"/>
<EF:EFSelect ename="detail-0-assignStatus" cname="状态" colWidth="4" readonly="true">
<EF:EFCodeOption codeName="hggp.assignStatus"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" checkMode="row" isFloat="true">
<EF:EFColumn ename="id" cname="任务ID" enable="false" width="80" align="center"/>
<EF:EFColumn ename="taskCode" cname="任务单号" enable="false" hidden="true"/>
<EF:EFComboColumn ename="factoryCode" cname="厂区" width="110" align="center" defaultValue="" required="true"
filter="contains" readonly="true">
<EF:EFOptions blockId="factory_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="factoryName" cname="工厂" enable="false" align="center" hidden="true"/>
<EF:EFComboColumn ename="groupCode" cname="生产组" width="110" align="center" defaultValue="" required="true"
filter="contains" readonly="true">
<EF:EFOptions blockId="group_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="groupName" cname="生产组名称" enable="false" align="center" hidden="true"/>
<EF:EFColumn ename="createdTime" cname="派工时间" enable="false" width="100" align="center"
editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/>
<EF:EFColumn ename="quantity" cname="分派数量" format="{0:N0}" required="true"/>
</EF:EFGrid>
<br/>
<span style='color: red;font-size: 13px;'>说明:厂区和生产组仅新增的时候可以编辑</span>
</EF:EFRegion>
</EF:EFPage>
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