巡检任务调整回一小时产生一条;成品订单编辑/删除功能优化

master
zhaoxiaolin 11 months ago
parent 27a1e2bba2
commit 217a7ee237

@ -155,7 +155,7 @@ public class RyTask {
}
/************质量管理系统定时任务开始*****************/
//过程巡检,改为整点0800-2000运行
//过程巡检,每3分钟执行检查一次
public void createProduceXJTask(){
logger.info("++质量管理系统+过程巡检+开始++createProduceXJTask+++++");
remoteQualityService.createProduceXJTask();

@ -107,6 +107,15 @@ public class MesReportWorkConsume extends BaseEntity {
private String productGroupName;
//上级物料
private String pMaterialCode;
private String workorderCodeSap;
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
public void setWorkorderCodeSap(String workorderCodeSap) {
this.workorderCodeSap = workorderCodeSap;
}
public String getpMaterialCode() {
return pMaterialCode;

@ -102,9 +102,11 @@
mrwc.quantity,
mrwc.unit,
mrwc.create_time createTime,
mrwc.recoil
mrwc.recoil,
pow.workorder_code_sap workorderCodeSap
from mes_report_work_consume mrwc
where mrwc.del_flag = '0'
left join pro_order_workorder pow on mrwc.workorder_code = pow.workorder_code
where mrwc.del_flag = '0' and pow.del_flag = '0'
and mrwc.workorder_code = #{workorderCode}
order by mrwc.recoil
</select>

@ -529,24 +529,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getReportList" resultType="com.op.mes.domain.MesReportWork">
select
id,
workorder_code workorderCode,
report_code reportCode,
batch,
quantity_feedback quantityFeedback,
unit,
work_time workTime,
use_man useMan,
create_time createTime
from mes_report_work
where del_flag='0'
mrw.id,
mrw.workorder_code workorderCode,
mrw.report_code reportCode,
mrw.batch,
mrw.quantity_feedback quantityFeedback,
mrw.unit,
mrw.work_time workTime,
mrw.use_man useMan,
mrw.create_time createTime,
pow.workorder_code_sap workorderCodeSap
from mes_report_work mrw
left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code
where mrw.del_flag='0' and pow.del_flag = '0'
<if test='parentOrder=="0"'>
and workorder_code = #{workorderCode}
and mrw.workorder_code = #{workorderCode}
</if>
<if test='parentOrder!="0"'>
and parent_order = #{workorderCode}
and mrw.parent_order = #{workorderCode}
</if>
order by end_report
order by mrw.end_report
</select>
<select id="getPrepareList" resultType="com.op.mes.domain.MesPrepareDetail">
select

@ -73,7 +73,7 @@ public interface OpenMapper {
List<QcCheckTaskDetailDTO> getTPByTypeGroup(QcCheckTypeProjectDTO qctp);
void insertQcCheckTaskProduce(QcCheckTaskProduceDTO qcCheckTaskProduce);
int insertQcCheckTaskProduce(QcCheckTaskProduceDTO qcCheckTaskProduce);
public int addBatch(@Param("list") List<QcCheckTaskDetailDTO> items);

@ -370,7 +370,7 @@ public class OpenServiceImpl implements OpenService {
}
/**qc_check_task_user**/
int m = openMapper.addCheckUsers(users);
logger.info("检查人新增" + m + "成功");
logger.info(qcCheckTaskProduce.getOrderNo()+":检查人新增" + m + "成功");
/**qc_check_type_project**/
List<QcCheckTaskDetailDTO> items = openMapper.getTPByTypeMaterial(qctp);
@ -378,7 +378,7 @@ public class OpenServiceImpl implements OpenService {
/**qc_material_group_detail**/
QcMaterialGroupDetailDTO group = openMapper.getGroupByMaterial(qcCheckTaskProduce.getMaterialCode());
if (group == null) {
logger.info(qcCheckTaskProduce.getMaterialCode()+"没有维护物料组检测项,检验任务生成失败");
logger.info(qcCheckTaskProduce.getOrderNo()+":"+qcCheckTaskProduce.getMaterialCode()+"没有维护物料组检测项,检验任务生成失败");
return 0;//没有找到检测项目
}
qctp.setGroupId(group.getGroupId());//共性
@ -400,7 +400,9 @@ public class OpenServiceImpl implements OpenService {
qcCheckTaskProduce.setSupplierName(qcCheckTaskProduce.getCarName());
qcCheckTaskProduce.setCheckManName(null);
qcCheckTaskProduce.setCheckManCode(null);
openMapper.insertQcCheckTaskProduce(qcCheckTaskProduce);
int m0 = openMapper.insertQcCheckTaskProduce(qcCheckTaskProduce);
logger.info(qcCheckTaskProduce.getOrderNo()+":qc_check_task新增" + m0 + "成功");
/**qc_check_task_detail**/
for (QcCheckTaskDetailDTO item : items) {
item.setRecordId(IdUtils.fastSimpleUUID());
@ -410,7 +412,9 @@ public class OpenServiceImpl implements OpenService {
item.setFactoryCode(factoryCode);
item.setStatus("Y");
}
return openMapper.addBatch(items);
int n = openMapper.addBatch(items);
logger.info(qcCheckTaskProduce.getOrderNo()+":qc_check_task_detail新增" + n + "成功");
return n;
}
@Override

@ -77,6 +77,19 @@ public class ProOrderWorkorderController extends BaseController {
return proOrderWorkorderService.subChangeWorkOrder(splitOrderDTO);
}
/**
*
*
* @param splitOrderDTO
* @return
*/
@PostMapping("/subChangeWorkOrderPro")
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "修改成品工单", businessType = BusinessType.UPDATE)
public AjaxResult subChangeWorkOrderPro(@RequestBody SplitOrderDTO splitOrderDTO) {
return proOrderWorkorderService.subChangeWorkOrderPro(splitOrderDTO);
}
/**
* -
*
@ -234,6 +247,7 @@ public class ProOrderWorkorderController extends BaseController {
return toAjax(1);
}
/**
* workorderIds
*/

@ -78,4 +78,5 @@ public interface ProOrderWorkorderBatchMapper {
*/
List<String> selectCodeByWorkOrderIds(String[] workorderIds);
public int deleteBatch(String[] workorderIds);
}

@ -129,4 +129,6 @@ public interface IProOrderWorkorderService {
List<ProOrderWorkorder> getWorkorderLevel0List(ProOrderWorkorder proOrderWorkorder);
List<ProOrderWorkorder> getNextLevelWorkOrderList(ProOrderWorkorder proOrderWorkorder);
AjaxResult subChangeWorkOrderPro(SplitOrderDTO splitOrderDTO);
}

@ -248,16 +248,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
ProOrderWorkorder work = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
if (work != null) {
workers.add(work);
ProOrderWorkorder bottomWork = work;
ProOrderWorkorder topWork = work;
Boolean run = true;
while (run) {
//
ProOrderWorkorder topworkers = proOrderWorkorderMapper.selectWorkOrderByCode(bottomWork.getParentOrder());
//
ProOrderWorkorder sonWorkers = proOrderWorkorderMapper.selectSonWorkOrder(topWork.getWorkorderCode());
//有上级code
if (topworkers != null) {
workers.add(topworkers);
delteIds.add(topworkers.getWorkorderId());
bottomWork.setParentOrder(topworkers.getParentOrder());
if (sonWorkers != null) {
workers.add(sonWorkers);
delteIds.add(sonWorkers.getWorkorderId());
topWork.setWorkorderCode(sonWorkers.getWorkorderCode());
} else {
run = false;
}
@ -268,7 +268,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
//删除工单(字母)pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(workorderIds0);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds0);
proOrderWorkorderBatchMapper.deleteBatch(workorderIds0);
}
if (!CollectionUtils.isEmpty(workers)) {
@ -831,7 +831,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
"订单数量变更结果:" + rSapChange.getCode() + "," + rSapChange.getMsg());
}
// 获得对应工单
// 获得对应工单----------------------------------------------------------------------------
ProOrderWorkorder proOrderWorkorder = workOrderList.get(--index);
// 更新订单
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
@ -882,9 +882,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 更新至数据库
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
// 测试
// System.out.println("这里是workorderId----------->"+workBatch.getWorkorderId());
// System.out.println("这里是拆分数量----------->"+workBatch.getBatchQuantity());
}
// 如果存在子节点
@ -900,7 +897,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
}
return success("变更成功");
// throw new RuntimeException();
}
@ -910,6 +906,192 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
return error(500, "批次号不能重复");
}
/**
*
*
* @param splitOrderDTO
* @return
*/
@Override
@DS("#header.poolName")
@Transactional
public AjaxResult subChangeWorkOrderPro(SplitOrderDTO splitOrderDTO) {
// 获得子工单对象——(这里没有用BeanUtils是因为若依与这个冲突造成死循环得到错误的结果)
ProOrderWorkorder proWorkOrder = splitOrderDTO.getProOrderWorkorder();
// 通过子工单获得所有工单信息,并将所有工单信息放入list中
List<ProOrderWorkorder> workOrderList = new ArrayList<>();
// 将获得的工单的id存放
List<String> ids = new ArrayList<>();
boolean getworkOrder = true;
// 将工单放入list
workOrderList.add(proWorkOrder);
// 将id放入
ids.add(proWorkOrder.getWorkorderId());
// 用于循环
ProOrderWorkorder childWorkOrder = new ProOrderWorkorder();
BeanUtils.copyProperties(proWorkOrder, childWorkOrder);
while (getworkOrder) {
// 通过parentOrder查询子工单信息
ProOrderWorkorder sonWorkOrder = proOrderWorkorderMapper.selectSonWorkOrder(childWorkOrder.getWorkorderCode());
if (sonWorkOrder != null) {
// 将重置对象
BeanUtils.copyProperties(sonWorkOrder, childWorkOrder);
// 将工单放入list
workOrderList.add(sonWorkOrder);
// 将id放入
ids.add(sonWorkOrder.getWorkorderId());
} else {
// 终止循环
getworkOrder = false;
}
}
boolean checkout = true;
// 校验批次编号是否存在(重复问题)
String[] workorderIds = (String[]) ids.toArray(new String[ids.size()]);
List<String> batchCodes = proOrderWorkorderBatchMapper.selectCodeByWorkOrderIds(workorderIds);
for (int i = 0; i < batchCodes.size(); i++) {
for (int j = 0; j < splitOrderDTO.getFormFields().size(); j++) {
if (batchCodes.get(i).equals(splitOrderDTO.getFormFields().get(j).getBatchCode())) {
checkout = false;
}
}
}
//校验各工序设备是否已选择
List<CascaderDTO> processes = proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode());
if (splitOrderDTO.getProdLineCodeArray().length == 0) {
checkout = false;
return error(500, "必须选择工单生产设备!");
} else {
String codeArray = JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray());
for (int i = 0; i < processes.size(); i++) {
if (codeArray.indexOf(processes.get(i).getValue()) < 0) {
checkout = false;
return error(500, "所有有工序节点都必须选择生产设备!");
}
}
String[][] array = splitOrderDTO.getProdLineCodeArray();
for (int m = 0; m < array.length; m++) {
if (array[m].length < 2) {
checkout = false;
return error(500, "工序没有生产设备可选择,请维护工艺!");
}
}
splitOrderDTO.setProdLineCode(codeArray);
}
if (checkout) {
// 删除所有工单s下的批次信息
int i = proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
// 删除湿料计划
proWetMaterialPlanDetailMapper.deleteProWetMaterialPlanDetailByWorkId(proWorkOrder.getWorkorderId());
// 创建订单信息并将信息copy进去
ProOrder proOrder = new ProOrder();
BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder);
// 设置换算基数,用于获得换算值
Long quantity = proOrder.getQuantity();
// 创建批次表通用对象
ProOrderWorkorderBatch workBatch = setCommonBatchAttribute();
boolean run = true;
// 获取单位换算值
Long conver = 1L;
int index = 0;
while (run) {
if (StringUtils.isBlank(proOrder.getParentOrder())) {
//推送sap订单更新信息
SapShopOrderQuery sapChange = new SapShopOrderQuery();
sapChange.setAufnr(proOrder.getOrderCode());//母订单号
BigDecimal newSapQuantityNum = new BigDecimal(proOrder.getQuantity())
.subtract(new BigDecimal(proOrder.getAtrr1()));
sapChange.setQuantity(newSapQuantityNum.toString());//母订单新数量
logger.info("母订单" + proOrder.getOrderCode() +
"订单数量变更:修改前" + proOrder.getQuantity() + "," +
"已拆数量" + proOrder.getAtrr1() + "," +
"给sap汇报数量" + newSapQuantityNum.toString());
R rSapChange = remoteSapService.shopUpdateSync(sapChange);//sap只能同步指定日期的数据
logger.info("母订单" + proOrder.getOrderCode() +
"订单数量变更结果:" + rSapChange.getCode() + "," + rSapChange.getMsg());
}
// 获得对应工单----------------------------------------------------------------------------
ProOrderWorkorder proOrderWorkorder = workOrderList.get(index++);
// 更新订单
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(DateUtils.getNowDate());
proOrder.setQuantitySplit(proOrder.getQuantitySplit() + Long.valueOf(proOrder.getAtrr1()));
if (proOrder.getQuantity().longValue() == proOrder.getQuantitySplit().longValue()) {
// 已拆分
proOrder.setStatus("o2");
} else {
// 拆分中
proOrder.setStatus("o1");
}
proOrderMapper.updateProOrder(proOrder);
// 设置工单信息
proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName());
proOrderWorkorder.setUpdateTime(DateUtils.getNowDate());
// 拆分数量
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
// 2.将工单信息更新至数据库
if (splitOrderDTO.getProdLineCode() != null) {
proOrderWorkorder.setProdLineCode(splitOrderDTO.getProdLineCode());
}
if (splitOrderDTO.getProductDate() != null) {
proOrderWorkorder.setProductDate(splitOrderDTO.getProductDate());
}
if (splitOrderDTO.getShiftId() != null) {
proOrderWorkorder.setShiftId(splitOrderDTO.getShiftId());
}
if (splitOrderDTO.getRouteCode() != null) {
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
}
proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
// 删除工单下对应批次信息
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(proOrderWorkorder.getWorkorderId());
// 生成对应批次表
workBatch.setWorkorderId(proOrderWorkorder.getWorkorderId());
// 生成批次表信息并更新至数据库
for (Batch batch : splitOrderDTO.getFormFields()) {
// 生成批次id
workBatch.setBatchId(IdUtils.fastSimpleUUID());
// 生成批次号
workBatch.setBatchCode(batch.getBatchCode());
// 生成批次数量
workBatch.setBatchQuantity(batch.getBatchQuantity() * conver);
// 更新至数据库
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
}
// 如果存在子节点
if (proOrder.getChildren().size() > 0) {
ProOrderDTO newProOrder = (ProOrderDTO) proOrder.getChildren().get(0);
// 更新换算值
conver = (newProOrder.getQuantity() / quantity);
// 将child信息重新赋值给proOrder
BeanUtils.copyProperties(newProOrder, proOrder);
} else {
// 结束循环
run = false;
}
}
return success("变更成功");
}
return error(500, "批次号不能重复");
}
/**
*
* 湿

@ -296,7 +296,7 @@
<if test="prodType != null">prod_type = #{prodType},</if>
<if test="prodSpc != null">prod_spc = #{prodSpc},</if>
from_sap_time = GETDATE(),
cegci = #{cegci},
<if test="cegci != null">cegci = #{cegci},</if>
<if test="syncUser != null">sync_user = #{syncUser},</if>
</trim>
where id = #{id}

@ -150,4 +150,13 @@
)
</delete>
<delete id="deleteBatch" parameterType="String">
update pro_order_workorder_batch
set del_flag = '1'
where workorder_id in
<foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId}
</foreach>
</delete>
</mapper>

@ -383,14 +383,14 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
for(QcCheckTaskProduce productTask:works){
productTask.setCheckType("checkTypeSCXJ");//过程检验-巡检
productTask.setOrderNo(productTask.getWorkorderCode());
// Date nowTime = DateUtils.getNowDate();
// Date startTime = productTask.getCreateTime();
Date nowTime = DateUtils.getNowDate();
Date startTime = productTask.getCreateTime();
// long mins = DateUtil.between(startTime, nowTime, DateUnit.MINUTE);
// if(mins>=60){
long mins = DateUtil.between(startTime, nowTime, DateUnit.MINUTE);
if(mins>=60){
int m = insertQcCheckTaskProduce(productTask);
logger.info("++++++++++++过程检验巡检任务生成" + m + "++++++++++++++");
// }
}
}
logger.info("++++++++++++" + poolName + "++++过程检验巡检结束++++++++++");
}

Loading…
Cancel
Save