生产订单管理模块(更改code)

highway
wws 1 year ago
parent ed1245fc5a
commit b3440cfbbb

@ -84,8 +84,8 @@ public class ProOrderController extends BaseController {
* @return
*/
@GetMapping("/getProdLineShift")
public AjaxResult getProdLineShift() {
return success(proOrderService.getProdLineShift());
public AjaxResult getProdLineShift(String type) {
return success(proOrderService.getProdLineShift(type));
}
/**

@ -123,6 +123,7 @@ public interface ProOrderMapper {
/**
* code线
*
* @param prodLineCode
* @return
*/
@ -131,9 +132,18 @@ public interface ProOrderMapper {
/**
* idlist
*
* @param workorderId
* @return
*/
@Select("SELECT powb.batch_code FROM pro_order_workorder_batch powb LEFT JOIN pro_order_workorder pow ON powb.workorder_id = pow.workorder_id WHERE pow.workorder_id = #{workorderId}")
List<String> selectBatchCodesById(String workorderId);
/**
* 线list
*
* @return
*/
@Select(" SELECT equipment_id AS 'key', equipment_name AS 'label' FROM base_equipment WHERE equipment_type_code = 'equ_type_bzx' ")
public List<ProLine> selectPackageLine();
}

@ -84,4 +84,13 @@ public interface ProOrderWorkorderMapper {
* @return
*/
List<ProOrderWorkorder> selectWorkOrderByTime(Date productDate);
/**
* idcode
*
* @param id
* @return
*/
@Select("select TOP 1 workorder_code FROM pro_order_workorder WHERE order_id = #{id} ORDER BY workorder_code DESC")
String selectEndWorkOrder(String id);
}

@ -21,7 +21,7 @@ public interface IProOrderService {
*
* @return
*/
public LineAndShiftVo getProdLineShift();
public LineAndShiftVo getProdLineShift(String type);
/**
*

@ -83,6 +83,9 @@ public class ProOrderServiceImpl implements IProOrderService {
// 生成对应工单表
// 一级
ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product);
// code
int endCode = getEndCode(product.getId());
firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode);
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder);
// 创建通用批次表对象
@ -100,6 +103,8 @@ public class ProOrderServiceImpl implements IProOrderService {
// 设置父工单
proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode());
ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product);
// code
secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1));
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder);
// 生成批次表并更新到数据库
@ -117,6 +122,8 @@ public class ProOrderServiceImpl implements IProOrderService {
ProOrderWorkorder thiWorkOrder = setWorkOrder(proOrderWorkorder, product);
// 设置为底层节点
thiWorkOrder.setIsEnd(1);
// code
thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2));
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder);
// 生成批次表并更新到数据库
@ -226,8 +233,12 @@ public class ProOrderServiceImpl implements IProOrderService {
*/
@Override
@DS("#header.poolName")
public LineAndShiftVo getProdLineShift() {
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift());
public LineAndShiftVo getProdLineShift(String type) {
if (type.equals("white")){
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift());
return lineAndShiftVo;
}
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), proOrderMapper.selectProShift());
return lineAndShiftVo;
}
@ -251,9 +262,6 @@ public class ProOrderServiceImpl implements IProOrderService {
@Override
@DS("#header.poolName")
public List<ProOrder> selectProOrderList(ProOrder proOrder) {
if (proOrder.getStatus() == null || proOrder.getStatus().equals(" ")){
proOrder.setStatus("1");
}
List<ProOrder> proOrderList = proOrderMapper.selectProOrderList(proOrder);
for (int i = 0; i < proOrderList.size(); i++) {
proOrderList.get(i).setStatus(changeStatus(proOrderList.get(i).getStatus()));
@ -270,8 +278,17 @@ public class ProOrderServiceImpl implements IProOrderService {
@Override
@DS("#header.poolName")
public int insertProOrder(ProOrder proOrder) {
// 获取当前时间
Date date = new Date();
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setCreateTime(DateUtils.getNowDate());
proOrder.setParentOrder("0");
proOrder.setStatus("o0");
proOrder.setOrderType(proOrder.getProdType());
proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
proOrder.setCreateBy(SecurityContextHolder.getUserName());
proOrder.setCreateTime(date);
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(date);
return proOrderMapper.insertProOrder(proOrder);
}
@ -328,8 +345,8 @@ public class ProOrderServiceImpl implements IProOrderService {
proOrderWorkorder.setProductDate(date);
// 产品(物料)编码
proOrderWorkorder.setProductCode(proOrder.getProdCode());
// TODO 产品(物料)名称
proOrderWorkorder.setProductName("测试ing");
// 产品(物料)名称
proOrderWorkorder.setProductName(proOrder.getProdDesc());
// 产品(物料)规格型号
proOrderWorkorder.setProductSpc(proOrder.getProdSpc());
// 产线
@ -337,8 +354,8 @@ public class ProOrderServiceImpl implements IProOrderService {
// 班次
proOrderWorkorder.setShiftId(shiftId);
// TODO 产品类型(pro_type)
// 单据状态(1为正常)
proOrderWorkorder.setStatus("1");
// 单据状态(1为已经下达0未下达)
proOrderWorkorder.setStatus("w0");
return proOrderWorkorder;
}
@ -355,15 +372,15 @@ public class ProOrderServiceImpl implements IProOrderService {
// 订单表更新时间/更新者
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(date);
// 设置订单状态
proOrder.setStatus("o1");
// 更新订单表
proOrderMapper.updateOrder(proOrder);
// 生成对应的工单表
// 生成id
proOrderWorkorder.setWorkorderId(IdUtils.fastSimpleUUID());
// 生成工单号
proOrderWorkorder.setWorkorderCode("GD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
// TODO 工单名称
proOrderWorkorder.setWorkorderName("测试ing");
proOrderWorkorder.setWorkorderCode(proOrder.getOrderCode());
// 订单id
proOrderWorkorder.setOrderId(proOrder.getId());
// 订单编码
@ -372,8 +389,6 @@ public class ProOrderServiceImpl implements IProOrderService {
proOrderWorkorder.setUnit(proOrder.getUnit());
// 已拆分数量
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
// TODO 工艺编码
// TODO 所有父节点
return proOrderWorkorder;
}
@ -384,7 +399,6 @@ public class ProOrderServiceImpl implements IProOrderService {
*/
private ProOrderWorkorderBatch setCommonBatchAttribute() {
ProOrderWorkorderBatch workBatch = new ProOrderWorkorderBatch();
Date date = new Date();
// 更新者
workBatch.setUpdateBy(SecurityContextHolder.getUserName());
// 创建者
@ -404,7 +418,7 @@ public class ProOrderServiceImpl implements IProOrderService {
private void setBatch(ProOrderWorkorderBatch workBatch, List<Batch> batchList, String workOrderId) {
// 工单id
workBatch.setWorkorderId(workOrderId);
// TODO 产品类型
// 产品类型
for (int i = 0; i < batchList.size(); i++) {
// 生成批次id
workBatch.setBatchId(IdUtils.fastSimpleUUID());
@ -425,12 +439,35 @@ public class ProOrderServiceImpl implements IProOrderService {
* @return
*/
private String changeStatus(String status) {
if (status.equals("0")){
if (status.equals("o0")){
return "未拆分";
}
if (status.equals("1")){
if (status.equals("o1")){
return "已拆分";
}
return status;
}
/**
* code
* @param id
* @return
*/
private int getEndCode(String id){
String workOrderCode = proOrderWorkorderMapper.selectEndWorkOrder(id);
if (workOrderCode == null || workOrderCode.equals("")){
return 1;
}
int hyphenIndex = workOrderCode.indexOf('-'); // 查找 '-' 的索引
if (hyphenIndex != -1) { // 如果找到了 '-' 字符
String substring = workOrderCode.substring(hyphenIndex + 1); // 从 '-' 的下一位开始截取到字符串的末尾
// 将截取到的字符串转换为整数
int endCode = Integer.parseInt(substring);
return endCode+1;
} else {
return 1;
}
}
}

@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</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="prodDesc != null and prodDesc != ''"> and prod_desc = #{prodDesc}</if>
<if test="prodDesc != null and prodDesc != ''"> and prod_desc like concat('%', #{prodDesc}, '%')</if>
<if test="quantity != null "> and quantity = #{quantity}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="workerOrder != null and workerOrder != ''"> and worker_order = #{workerOrder}</if>
@ -168,9 +168,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="atrr1 != null and quantitySplit != null">quantity_split += #{atrr1},</if>
<if test="quantitySplit == null">quantity_split = #{atrr1},</if>
<if test="updateBy != null">create_by = #{updateBy},</if>
<if test="updateTime != null">create_time = #{updateTime},</if>
status = 1,
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null">status = #{status},</if>
</trim>
where id = #{id}
</update>

@ -78,10 +78,8 @@
where workorder_id = #{workorderId}
</select>
<select id="selectFirWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult">
SELECT pow.*
FROM pro_order_workorder pow LEFT JOIN pro_order po
ON pow.order_id = po.id
WHERE po.id = #{id}
<include refid="selectProOrderWorkorderVo"/>
where order_id = #{id}
</select>
<select id="selectChildWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult">
<include refid="selectProOrderWorkorderVo"/>

Loading…
Cancel
Save