Merge remote-tracking branch 'origin/master'

highway
A0010407 1 year ago
commit b21be8e910

@ -33,6 +33,20 @@ public class ProWhiteOrderController {
@Autowired
private IProWhiteOrderService proWhiteOrderService;
/**
* proOrder
* 1.
* 2.
* 3.
* 4.
* @param proOrder
* @return
*/
@PostMapping("/getSplitInfo")
public AjaxResult getSplitInfo(@RequestBody ProOrder proOrder) {
return proWhiteOrderService.getSplitInfo(proOrder);
}
/**
*
*/

@ -0,0 +1,51 @@
package com.op.plan.domain.vo;
import com.op.plan.domain.ProOrder;
import com.op.plan.domain.ProOrderWorkorder;
import com.op.plan.domain.ProRoute;
import com.op.plan.domain.ProShift;
import java.util.List;
// 白坯拆分VO
public class SplitProWhiteOrderVo {
private List<ProOrder> proOrderList;
private List<ProOrderWorkorder> proOrderWorkorderList;
private List<ProRoute> routeList;
private List<ProShift> proShiftList;
public List<ProOrder> getProOrderList() {
return proOrderList;
}
public void setProOrderList(List<ProOrder> proOrderList) {
this.proOrderList = proOrderList;
}
public List<ProOrderWorkorder> getProOrderWorkorderList() {
return proOrderWorkorderList;
}
public void setProOrderWorkorderList(List<ProOrderWorkorder> proOrderWorkorderList) {
this.proOrderWorkorderList = proOrderWorkorderList;
}
public List<ProRoute> getRouteList() {
return routeList;
}
public void setRouteList(List<ProRoute> routeList) {
this.routeList = routeList;
}
public List<ProShift> getProShiftList() {
return proShiftList;
}
public void setProShiftList(List<ProShift> proShiftList) {
this.proShiftList = proShiftList;
}
public SplitProWhiteOrderVo() {
}
}

@ -193,4 +193,10 @@ public interface ProOrderMapper {
Map<String, CascaderDTO> getEquipInfoByCodes(String equipCodes);
ProOrder getMaxPlanDate();
/**
* -code
* @param orderCode
*/
void updateOrderStatusByOrderCode(String orderCode);
}

@ -1,6 +1,9 @@
package com.op.plan.mapper;
import com.op.plan.domain.ProOrder;
import com.op.plan.domain.ProOrderWorkorder;
import com.op.plan.domain.ProRoute;
import com.op.plan.domain.ProShift;
import java.util.List;
@ -58,4 +61,25 @@ public interface ProWhiteOrderMapper {
* @return
*/
public int deleteProOrderByIds(String[] ids);
/**
* parentOrder
* @param parentOrder
* @return
*/
ProOrder selectProOrderByParentOrder(String parentOrder);
/**
* codelist
* @param orderCode
* @return
*/
List<ProOrderWorkorder> selectProWorkOrderByOrderCode(String orderCode);
/**
* list
* @return
*/
List<ProShift> selectProShift();
}

@ -1,5 +1,6 @@
package com.op.plan.service;
import com.op.common.core.web.domain.AjaxResult;
import com.op.plan.domain.ProOrder;
import java.util.List;
@ -58,4 +59,15 @@ public interface IProWhiteOrderService {
* @return
*/
public int deleteProOrderById(String id);
/**
* proOrder
* 1.
* 2.
* 3.
* 4.
* @param proOrder
* @return
*/
AjaxResult getSplitInfo(ProOrder proOrder);
}

@ -127,6 +127,69 @@ public class ProOrderServiceImpl implements IProOrderService {
// 如果不重复
if (checkout) {
// 如果是白坯订单
if (splitOrderDTO.getProduct().getProdType().equals("white")){
boolean flag = false;
// 母订单
ProOrder proOrderTemp = new ProOrder();
BeanUtils.copyProperties(splitOrderDTO.getProduct(),proOrderTemp);
// 母订单拆分数量
proOrderTemp.setUpdateTime(DateUtils.getNowDate());
proOrderTemp.setUpdateBy(SecurityContextHolder.getUserName());
proOrderTemp.setQuantitySplit(proOrderTemp.getQuantitySplit()+splitOrderDTO.getSplitNum());
// 拆分中
proOrderTemp.setStatus("o1");
// 全部更改为拆分中
proOrderMapper.updateOrderStatusByOrderCode(proOrderTemp.getOrderCode());
// 如果拆分完就更改状态为已拆分
if (proOrderTemp.getQuantitySplit() == proOrderTemp.getQuantity()) {
flag = true;
// TODO 更改子订单状态
proOrderTemp.setStatus("o2");
}
// 更新母订单
proOrderMapper.updateOrder(proOrderTemp);
// 创建订单对象并将信息copy进去
ProOrder proOrder = new ProOrder();
BeanUtils.copyProperties(splitOrderDTO.getProduct().getChildren().get(0),proOrder);
// 子订单
proOrder.setUpdateTime(DateUtils.getNowDate());
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setQuantitySplit(splitOrderDTO.getSplitNum());
proOrder.setQuantity(splitOrderDTO.getSplitNum());
proOrder.setStatus("o1");
if (flag) {
proOrder.setStatus("o2");
}
proOrderMapper.updateOrder(proOrder);
// 设置工单通用属性
ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(proOrder, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode());
// 设置批次表通用信息
ProOrderWorkorderBatch proOrderWorkorderBatch = setCommonBatchAttribute();
// 设置工单
proOrderWorkorder.setWorkorderId(IdUtils.fastSimpleUUID());
proOrderWorkorder.setWorkorderCode(proOrder.getOrderCode()+"-1");
proOrderWorkorder.setOrderId(proOrder.getId());
proOrderWorkorder.setOrderCode(proOrder.getOrderCode());
proOrderWorkorder.setUnit(proOrder.getUnit());
proOrderWorkorder.setQuantitySplit(splitOrderDTO.getSplitNum());
proOrderWorkorder.setProdType(proOrder.getProdType());
proOrderWorkorder.setParentOrder("0");
proOrderWorkorder.setEndFlag(1);
// 插入工单
proOrderWorkorderMapper.insertProOrderWorkorder(proOrderWorkorder);
setBatch(proOrderWorkorderBatch,splitOrderDTO.getFormFields(),proOrderWorkorder.getWorkorderId(),1L);
return success();
}else {
// 创建订单对象并将信息copy进去
ProOrder proOrder = new ProOrder();
BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder);
@ -155,11 +218,11 @@ public class ProOrderServiceImpl implements IProOrderService {
// 3.设置父工单
workOrder.setParentOrder(parentOrder.toString());
// 工单对应车数-白坯订单操作
if (proOrder.getProdType().equals("white")) {
int everyNum = (int) Math.ceil(proOrder.getQuantity() / proOrder.getCarNum());
int carNum = (int) Math.ceil(splitOrderDTO.getSplitNum() / everyNum);
workOrder.setCarNum(carNum);
}
// if (proOrder.getProdType().equals("white")) {
// int everyNum = (int) Math.ceil(proOrder.getQuantity() / proOrder.getCarNum());
// int carNum = (int) Math.ceil(splitOrderDTO.getSplitNum() / everyNum);
// workOrder.setCarNum(carNum);
// }
// 将工单信息更新至数据库
proOrderWorkorderMapper.insertProOrderWorkorder(workOrder);
// 生成批次表信息并更新至数据库
@ -186,6 +249,8 @@ public class ProOrderServiceImpl implements IProOrderService {
run = false;
}
}
}
// 关闭订单,判断是否拆分完成
// ProOrder order = proOrderMapper.selectProOrderById(splitOrderDTO.getProduct().getId());

@ -661,18 +661,20 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
}
proOrderWorkorder.setProdLineCodeArray(array);
String prodLineName = "";
String equipCods = "'";
StringBuilder prodLineName = new StringBuilder("");
StringBuilder equipCods = new StringBuilder("'");
for (int c = 0; c < codeArray.size(); c++) {
equipCods += codeArray.getJSONArray(c).getString(1) + "','";
equipCods.append(codeArray.getJSONArray(c).getString(1));
equipCods.append("','");
}
Map<String, CascaderDTO> equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典
Set<String> keys = equipMap.keySet();
for (String key : keys) {
prodLineName += equipMap.get(key).getLabel() + ",";
prodLineName.append(equipMap.get(key).getLabel());
prodLineName.append(",");
}
proOrderWorkorder.setProdLineCode(prodLineName);
proOrderWorkorder.setProdLineCode(prodLineName.toString());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());

@ -1,15 +1,31 @@
package com.op.plan.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.plan.domain.ProOrder;
import com.op.plan.domain.ProOrderWorkorder;
import com.op.plan.domain.ProRoute;
import com.op.plan.domain.ProShift;
import com.op.plan.domain.vo.CascaderDTO;
import com.op.plan.domain.vo.SplitProWhiteOrderVo;
import com.op.plan.mapper.ProOrderMapper;
import com.op.plan.mapper.ProOrderWorkorderMapper;
import com.op.plan.mapper.ProRouteMapper;
import com.op.plan.mapper.ProWhiteOrderMapper;
import com.op.plan.service.IProWhiteOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* Service
@ -22,6 +38,12 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
@Autowired
private ProWhiteOrderMapper proWhiteOrderMapper;
@Autowired
private ProRouteMapper proRouteMapper;
@Autowired
private ProOrderWorkorderMapper proOrderWorkorderMapper;
@Autowired
private ProOrderMapper proOrderMapper;
/**
*
@ -53,9 +75,89 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
* @return
*/
@Override
@DS("#header.poolName")
@Transactional
public int insertProOrder(ProOrder proOrder) {
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
int num = 1;
// 创建主订单
proOrder.setPlanFactoryCode(factory);
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setParentOrder("0");
proOrder.setStatus("o0");
proOrder.setQuantitySplit(0L);
proOrder.setOrderType(proOrder.getProdType());
proOrder.setOrderCode("DD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, DateUtils.getNowDate()));
proOrder.setCreateBy(SecurityContextHolder.getUserName());
proOrder.setCreateTime(DateUtils.getNowDate());
return proWhiteOrderMapper.insertProOrder(proOrder);
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(DateUtils.getNowDate());
// 存储主订单的Code
String orderCode = proOrder.getOrderCode();
// 存放物料code
String[] prodCodes = proOrder.getProdCode().split(",\\s*");
String[] prodDescs = proOrder.getProdDesc().split(",\\s*");
// 主订单插入数据库
proOrder.setProdCode("");
proOrder.setProdDesc("");
proWhiteOrderMapper.insertProOrder(proOrder);
System.out.println("源code---->"+proOrder.getProdCode());
System.out.println("源desc---->"+proOrder.getProdDesc());
System.out.println("code---------->");
for (String code : prodCodes) {
System.out.println(code);
}
System.out.println("desc----------->");
for (String desc : prodDescs) {
System.out.println(desc);
}
System.out.println("这里是母订单信息");
System.out.println("母订单code"+proOrder.getOrderCode());
System.out.println("这里是子订单信息");
// 设置子订单信息
for (int i = 0; i< prodCodes.length; i++){
ProOrder childProOrder = new ProOrder();
BeanUtils.copyProperties(proOrder,childProOrder);
childProOrder.setQuantity(0L);
childProOrder.setQuantitySplit(0L);
childProOrder.setProdDesc(prodDescs[i]);
childProOrder.setProdCode(prodCodes[i]);
childProOrder.setPlanFactoryCode(factory);
childProOrder.setId(IdUtils.fastSimpleUUID());
childProOrder.setParentOrder(orderCode);
childProOrder.setStatus("o0");
childProOrder.setOrderType(proOrder.getProdType());
childProOrder.setOrderCode(orderCode+"-"+num++);
childProOrder.setCreateBy(SecurityContextHolder.getUserName());
childProOrder.setCreateTime(DateUtils.getNowDate());
childProOrder.setUpdateBy(SecurityContextHolder.getUserName());
childProOrder.setUpdateTime(DateUtils.getNowDate());
// 将子订单插入数据库
proWhiteOrderMapper.insertProOrder(childProOrder);
System.out.println("子订单code"+i+childProOrder.getOrderCode());
System.out.println("子订单parentCode"+i+childProOrder.getParentOrder());
}
return 1;
}
/**
@ -92,4 +194,100 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
return proWhiteOrderMapper.deleteProOrderById(id);
}
/**
* proOrder
* 1.
* 2.
* 3.
* 4.
* @param proOrder
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult getSplitInfo(ProOrder proOrder) {
// 创建返回实体对象
SplitProWhiteOrderVo splitProWhiteOrderVo = new SplitProWhiteOrderVo();
// 获取订单信息list
ProOrder parentOrder = proWhiteOrderMapper.selectProOrderByParentOrder(proOrder.getParentOrder());
// 格式化订单信息
List<ProOrder> childOrderList = new ArrayList<>();
childOrderList.add(proOrder);
parentOrder.setChildren(childOrderList);
// 将订单信息放入返回实体
List<ProOrder> orderList = new ArrayList<>();
orderList.add(parentOrder);
splitProWhiteOrderVo.setProOrderList(orderList);
// 获取工单信息
List<ProOrderWorkorder> workOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
for (ProOrderWorkorder workOrder : workOrderList) {
formatProOrderWorkorder(workOrder);
}
// 将工单信息list放入返回实体
if (workOrderList.size() > 0) {
splitProWhiteOrderVo.setProOrderWorkorderList(workOrderList);
}
// 获取班次信息
List<ProShift> shiftList = proWhiteOrderMapper.selectProShift();
// 将班次信息list放入返回实体
splitProWhiteOrderVo.setProShiftList(shiftList);
// 获取工艺信息
List<ProRoute> routeList = proRouteMapper.selectRouteByItemCode(proOrder.getProdCode());
// 将工艺信息list放入返回实体
splitProWhiteOrderVo.setRouteList(routeList);
return AjaxResult.success(splitProWhiteOrderVo);
}
/**
*
*
* @param proOrderWorkorder
*/
private void formatProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) {
// 通过班次id查询班次名称
String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorder.getShiftId());
StringBuilder prodLineName = new StringBuilder("");
StringBuilder equipCods = new StringBuilder("'");
JSONArray codeArray = JSONArray.parseArray(proOrderWorkorder.getProdLineCode());
for(int c=0;c<codeArray.size();c++){
equipCods.append(codeArray.getJSONArray(c).getString(1));
equipCods.append("','");
}
Map<String, CascaderDTO> equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典
Set<String> keys = equipMap.keySet();
for (String key : keys) {
prodLineName.append(equipMap.get(key).getLabel());
prodLineName.append(",");
}
proOrderWorkorder.setProdLineCode(prodLineName.toString());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<StringBuilder> batchCodes = new ArrayList<>();
// 格式化数据
for (String batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode).append(";").append("\n"));
}
// 将查询结果设置到当前工单对象
proOrderWorkorder.setShiftDesc(shiftDesc);
proOrderWorkorder.setBatchCodeList(batchCodes);
// 通过母工单workorder_id查询子工单
List<ProOrderWorkorder> childWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorder.getWorkorderCode());
if (!childWorkorders.isEmpty()) {
for (ProOrderWorkorder childWorkorder : childWorkorders) {
formatProOrderWorkorder(childWorkorder); // 递归处理子工单
}
proOrderWorkorder.setChildren(childWorkorders); // 设置子工单列表
}
}
}

@ -315,6 +315,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where order_code = #{orderCode}
</update>
<update id="updateOrderStatusByOrderCode">
update pro_order set status = 'o1' where parent_order = #{orderCode}
</update>
<delete id="deleteProOrderById" parameterType="String">
delete from pro_order where id = #{id}
</delete>

@ -36,12 +36,13 @@
<select id="selectProOrderList" parameterType="ProOrder" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
<where>
<if test="planFactoryCode != null and planFactoryCode != ''"> and plan_factory_code = #{planFactoryCode}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
<if test="prodCode != null and prodCode != ''"> and prod_code = #{prodCode}</if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
<if test="orderCode != null and orderCode != ''"> and order_code like concat('%', #{orderCode}, '%')</if>
<if test="prodCode != null and prodCode != ''"> and prod_code like concat('%', #{prodCode}, '%')</if>
<if test="prodDesc != null and prodDesc != ''"> and prod_desc like concat('%', #{prodDesc}, '%')</if>
<if test="quantity != null "> and quantity = #{quantity}</if>
<if test="quantitySplit != null "> and quantity_split = #{quantitySplit}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="workerOrder != null and workerOrder != ''"> and worker_order = #{workerOrder}</if>
<if test="planProDate != null "> and plan_pro_date = #{planProDate}</if>
@ -51,9 +52,13 @@
<if test="atrr3 != null and atrr3 != ''"> and atrr3 = #{atrr3}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="parentOrder != null and parentOrder != ''"> and parent_order = #{parentOrder}</if>
and order_type = 'white' and prod_type = 'white'
<if test="prodType != null and prodType != ''"> and prod_type = #{prodType}</if>
<if test="prodSpc != null and prodSpc != ''"> and prod_spc = #{prodSpc}</if>
<if test="planDateStart != null "> and CONVERT(varchar(10),plan_pro_date, 120) >= '${planDateStart}'</if>
<if test="planDateEnd != null "> and '${planDateEnd}%' >= CONVERT(varchar(10),plan_pro_date, 120)</if>
</where>
ORDER BY plan_pro_date DESC
and prod_type = 'white'
ORDER BY plan_pro_date DESC , order_code ASC
</select>
<select id="selectProOrderById" parameterType="String" resultMap="ProOrderResult">
@ -61,6 +66,25 @@
where id = #{id}
</select>
<select id="selectProOrderByParentOrder" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where order_code = #{parentOrder}
</select>
<select id="selectProWorkOrderByOrderCode" resultType="com.op.plan.domain.ProOrderWorkorder">
select workorder_id, workorder_code, workorder_name, order_id, order_code, product_id, product_code, product_name,
product_spc, unit, quantity_produced, quantity_split, route_code, prod_line_code, product_date,
shift_id, parent_order, ancestors, status, remark, attr1, attr2, attr3, attr4, create_by, create_time,
update_by, update_time, prod_type, factory_code , end_flag , car_num
from pro_order_workorder
where order_code = #{orderCode}
</select>
<select id="selectProShift" resultType="com.op.plan.domain.ProShift">
SELECT bst.Shift_Id shiftId,bst.Shift_Desc_Global shiftDesc
FROM base_shifts_t bst
</select>
<insert id="insertProOrder" parameterType="ProOrder">
insert into pro_order
<trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save