feat: 解包工单功能

This commit is contained in:
2025-07-22 09:03:45 +08:00
parent bdd0fe292c
commit f4641a148f
24 changed files with 2059 additions and 7 deletions

View File

@@ -0,0 +1,122 @@
package org.nl.common.utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* @Author: lyd
* @Description: 通用工具
* @Date: 2023/7/17
*/
@Slf4j
public class CommonUtils {
/**
* @param inStorageTime 入库时间
* @param standingTime 静置时间 / 分钟
* @return
*/
public static boolean isStandingFinish(String inStorageTime, Integer standingTime) {
// MDC.put("tag_name", TagNameEnum.STANDING_CHECK.getTag());
log.info("判断静置时间->入库时间{},静置时间{}", inStorageTime, standingTime);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime inStorageDateTime = LocalDateTime.parse(inStorageTime, formatter);
Duration standingDuration = Duration.ofMinutes(standingTime);
LocalDateTime currentTime = LocalDateTime.now();
LocalDateTime expiryTime = inStorageDateTime.plus(standingDuration);
log.info("时间转换:当前时间{}-期望时间{}", currentTime, expiryTime);
return currentTime.isAfter(expiryTime);
}
/**
* 还有几分钟静置完成
*
* @param inputDateString
* @param staticDurationMinutes
* @return
*/
public static String remainStandingFinishTime(String inputDateString, Integer staticDurationMinutes) {
// 创建SimpleDateFormat以解析日期时间字符串
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
// 将输入日期时间字符串解析为Date对象
Date inputDate = dateFormat.parse(inputDateString);
// 获取当前时间
Date currentDate = new Date();
// 计算距离静置完成还有多少毫秒
long timeDifferenceMillis = inputDate.getTime() + (staticDurationMinutes * 60 * 1000) - currentDate.getTime();
// 将毫秒转换为分钟
double timeDifferenceMinutes = (double) timeDifferenceMillis / (60 * 1000);
// 计算预计完成时间
Date estimatedCompletionTime = new Date(currentDate.getTime() + timeDifferenceMillis);
// 格式化预计完成时间为字符串
String estimatedCompletionTimeString = dateFormat.format(estimatedCompletionTime);
return "距离静置完成还有 " + String.format("%.2f", timeDifferenceMinutes) + " 分钟" + ", 预计完成时间为:" + estimatedCompletionTimeString;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 获取当前时间是白晚班
*
* @return
*/
public static String getDayShift() {
// 获取当前时间
LocalTime currentTime = LocalTime.now();
// 设置白班和晚班的时间范围
// 白班开始时间8:00 AM
LocalTime dayShiftStart = LocalTime.of(8, 0);
// 白班结束时间5:00 PM
LocalTime dayShiftEnd = LocalTime.of(15, 59);
// 小夜班开始时间5:00 PM
LocalTime nightShiftStart = LocalTime.of(16, 0);
// 小夜班结束时间11:59 PM
LocalTime nightShiftEnd = LocalTime.of(23, 59);
// 检查当前时间属于哪个班次
if (currentTime.isAfter(dayShiftStart) && currentTime.isBefore(dayShiftEnd)) {
return "白班";
} else if (currentTime.isAfter(nightShiftStart) && currentTime.isBefore(nightShiftEnd)) {
return "小夜班";
} else {
return "大夜班";
}
}
public static <T> T toJavaObject(String objectString, Class<T> clazz) {
JSONObject jsonObject = JSONObject.parseObject(objectString);
return jsonObject.toJavaObject(clazz);
}
public static BigDecimal dTOAMinutes(String data1, String data2) {
String dateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
try {
// 解析第一个时间字符串
Date date1 = sdf.parse(data1);
// 解析第二个时间字符串
Date date2 = sdf.parse(data2);
// 计算分钟差
long differenceInMilliseconds = date2.getTime() - date1.getTime();
long differenceInMinutes = differenceInMilliseconds / (60 * 1000);
return BigDecimal.valueOf(differenceInMinutes);
} catch (ParseException e) {
log.error("计算时间差出错-参数:{} - 异常信息:{}", data1+"-"+data2, e.getMessage());
e.printStackTrace();
}
return BigDecimal.valueOf(0);
}
}

View File

@@ -0,0 +1,41 @@
package org.nl.wms.pda_manage.sch_manage.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.pda_manage.sch_manage.service.PdaJBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 解包
* @Author: lyd
* @Date: 2025/7/21
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/pda/jb")
@Slf4j
public class PdaJBController {
@Autowired
private PdaJBService pdaJBService;
@PostMapping("/getOrderList")
@Log("获取工单信息")
@SaIgnore
public ResponseEntity<Object> getPoint(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(pdaJBService.getOrderList(whereJson), HttpStatus.OK);
}
@PostMapping("/callMaterial")
@Log("开工")
@SaIgnore
public ResponseEntity<Object> callMaterial(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(pdaJBService.callMaterial(whereJson), HttpStatus.OK);
}
}

View File

@@ -52,5 +52,17 @@ public class PdaSchPointController {
public ResponseEntity<Object> dissect(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(pdaSchPointService.dissect(whereJson), HttpStatus.OK);
}
@PostMapping("/regionList")
@Log("获取区域下拉框数组")
@SaIgnore
public ResponseEntity<Object> regionList(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(pdaSchPointService.regionList(whereJson), HttpStatus.OK);
}
@PostMapping("/pointList")
@Log("获取点位下拉框数组")
@SaIgnore
public ResponseEntity<Object> pointListByRegion(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(pdaSchPointService.pointListByRegion(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,14 @@
package org.nl.wms.pda_manage.sch_manage.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.pda_manage.util.PdaResponse;
/**
* @Author: lyd
* @Date: 2025/7/21
*/
public interface PdaJBService {
PdaResponse getOrderList(JSONObject whereJson);
PdaResponse callMaterial(JSONObject whereJson);
}

View File

@@ -46,4 +46,7 @@ public interface PdaSchPointService extends IService<SchBasePoint> {
*/
PdaResponse dissect(JSONObject whereJson);
PdaResponse regionList(JSONObject whereJson);
PdaResponse pointListByRegion(JSONObject whereJson);
}

View File

@@ -0,0 +1,35 @@
package org.nl.wms.pda_manage.sch_manage.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.pda_manage.sch_manage.service.PdaJBService;
import org.nl.wms.pda_manage.sch_manage.service.mapper.PdaJBMapper;
import org.nl.wms.pda_manage.util.PdaResponse;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: lyd
* @Date: 2025/7/21
*/
@Service
@Slf4j
public class PdaJBServiceImpl implements PdaJBService {
@Autowired
private PdaJBMapper pdaJBMapper;
@Override
public PdaResponse getOrderList(JSONObject whereJson) {
List<PdmBdWorkorder> workorders = pdaJBMapper.getUnProductOrderList(whereJson.getString("point_code"));
return PdaResponse.requestParamOk(workorders);
}
@Override
public PdaResponse callMaterial(JSONObject whereJson) {
// 1、创建出库单、明细
// 2、创建任务、下发
return null;
}
}

View File

@@ -1,17 +1,27 @@
package org.nl.wms.pda_manage.sch_manage.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.common.domain.vo.SelectItemVo;
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService;
import org.nl.wms.pda_manage.sch_manage.service.PdaSchPointService;
import org.nl.wms.pda_manage.util.PdaResponse;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 手持点位操作 实现类
@@ -28,6 +38,10 @@ public class PdaSchPointServiceImpl extends ServiceImpl<SchBasePointMapper, SchB
*/
@Autowired
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
@Autowired
private ISchBaseRegionService regionService;
@Autowired
private ISchBasePointService pointService;
@Override
public PdaResponse getPoint(JSONObject whereJson) {
@@ -60,4 +74,31 @@ public class PdaSchPointServiceImpl extends ServiceImpl<SchBasePointMapper, SchB
);
return PdaResponse.requestOk();
}
@Override
public PdaResponse regionList(JSONObject whereJson) {
List<SelectItemVo> list = regionService.list(new LambdaQueryWrapper<SchBaseRegion>()
.eq(SchBaseRegion::getIs_has_workder, true)
.orderByAsc(SchBaseRegion::getOrder_seq)).stream().map(p -> SelectItemVo
.builder()
.text(p.getRegion_name())
.value(p.getRegion_code())
.build())
.collect(Collectors.toList());
return PdaResponse.requestParamOk(list);
}
@Override
public PdaResponse pointListByRegion(JSONObject whereJson) {
List<SelectItemVo> list = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getIs_has_workder, true)
.eq(SchBasePoint::getRegion_code, whereJson.getString("region_code")))
.stream().map(p -> SelectItemVo
.builder()
.text(p.getPoint_name())
.value(p.getPoint_code())
.build())
.collect(Collectors.toList());
return PdaResponse.requestParamOk(list);
}
}

View File

@@ -0,0 +1,13 @@
package org.nl.wms.pda_manage.sch_manage.service.mapper;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import java.util.List;
/**
* @Author: lyd
* @Date: 2025/7/21
*/
public interface PdaJBMapper {
List<PdmBdWorkorder> getUnProductOrderList(String pointCode);
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.pda_manage.sch_manage.service.mapper.PdaJBMapper">
<select id="getUnProductOrderList" resultType="org.nl.wms.pm_manage.service.dao.PdmBdWorkorder">
SELECT
o.*,
mm.material_code,
mm.material_name
FROM
`pdm_bd_workorder` o
LEFT JOIN md_me_materialbase mm ON mm.material_id = o.material_id
WHERE o.workorder_status = '1'
AND o.point_code = #{pointCode}
</select>
</mapper>

View File

@@ -0,0 +1,74 @@
package org.nl.wms.pm_manage.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.annotation.Limit;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.pm_manage.service.IPdmBdWorkorderService;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import org.nl.wms.pm_manage.service.dto.PdmBdWorkorderQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Set;
/**
* @author lyd
* @date 2023-05-05
**/
@Slf4j
@RestController
@RequestMapping("/api/pdmBdWorkorder")
public class PdmBdWorkorderController {
@Autowired
private IPdmBdWorkorderService pdmBdWorkorderService;
@GetMapping
@Log("查询工单管理")
//@SaCheckPermission("@el.check('pdmBdWorkorder:list')")
public ResponseEntity<Object> query(PdmBdWorkorderQuery query, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(pdmBdWorkorderService.queryAll(query, page)), HttpStatus.OK);
}
@PostMapping
@Log("新增工单管理")
@SaIgnore
public ResponseEntity<Object> create(@Validated @RequestBody PdmBdWorkorder entity) {
pdmBdWorkorderService.create(entity);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改工单管理")
@Limit(period = 2, count = 1)
public ResponseEntity<Object> update(@Validated @RequestBody PdmBdWorkorder entity) {
pdmBdWorkorderService.update(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除工单管理")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
pdmBdWorkorderService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/forceFinish")
@Log("强制完工")
public ResponseEntity<Object> forceFinish(@RequestBody PdmBdWorkorder entity) {
pdmBdWorkorderService.forceFinish(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@GetMapping("/getStockMaterial")
@Log("获取库存物料")
public ResponseEntity<Object> getStockMaterial(PdmBdWorkorderQuery entity, PageQuery pageQuery) {
return new ResponseEntity<>(TableDataInfo.build(pdmBdWorkorderService.getStockMaterial(entity, pageQuery)), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,36 @@
package org.nl.wms.pm_manage.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Author: lyd
* @Description: 工单状态枚举
* @Date: 2023/6/16
*/
@Getter
@AllArgsConstructor
public enum WorkOrderStatusEnum {
/**
* 未生产
*/
UNPRODUCED("1", "未生产"),
/**
* 已下发 x
*/
ISSUED("2", "已下发"),
/**
* 生产中
*/
PRODUCING("3", "生产中"),
/**
* 暂停 x
*/
STOP("4", "暂停"),
/**
* 完成
*/
COMPLETE("5", "完成");
private final String code;
private final String name;
}

View File

@@ -0,0 +1,81 @@
package org.nl.wms.pm_manage.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import org.nl.wms.pm_manage.service.dto.PdmBdWorkorderQuery;
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
import java.util.List;
import java.util.Set;
/**
* @author lyd
* @description 服务接口
* @date 2023-05-05
**/
public interface IPdmBdWorkorderService extends IService<PdmBdWorkorder> {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param pageable 分页参数
* @return IPage<PdmBdWorkorder>
*/
IPage<PdmBdWorkorder> queryAll(PdmBdWorkorderQuery whereJson, PageQuery pageable);
/**
* 创建
*
* @param entity /
*/
void create(PdmBdWorkorder entity);
/**
* 编辑
*
* @param entity /
*/
void update(PdmBdWorkorder entity);
/**
* 多选删除
*
* @param ids /
*/
void deleteAll(Set<String> ids);
/**
* 根据工单编码获取工单信息
*
* @param orderCode 工单号
* @return /
*/
PdmBdWorkorder getByCode(String orderCode);
/**
* 用锁-根据工单编码获取工单信息
*
* @param orderCode 工单号
* @return /
*/
PdmBdWorkorder getByCodeLock(String orderCode);
/**
* 强制报工完成
*
* @param entity 工单
*/
void forceFinish(PdmBdWorkorder entity);
/**
* 分页查询获取库存可用的物料
* @param entity
* @param pageQuery
* @return
*/
IPage<GroupPlate> getStockMaterial(PdmBdWorkorderQuery entity, PageQuery pageQuery);
}

View File

@@ -0,0 +1,119 @@
package org.nl.wms.pm_manage.service.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lyd
* @description /
* @date 2023-05-05
**/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("pdm_bd_workorder")
public class PdmBdWorkorder implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "workorder_id", type = IdType.NONE)
private String workorder_id;
private String workorder_code;
private BigDecimal plan_qty;
private BigDecimal real_qty;
private BigDecimal plan_weight;
private BigDecimal real_weight;
private String material_id;
private String raw_material_code;
private String produce_order;
private String batch_no;
private String team;
private String produce_date;
private String vehicle_type;
private String planproducestart_date;
private String planproduceend_date;
private String realproducestart_date;
private String realproduceend_date;
private Integer standing_time;
private String struct_code;
private String point_code;
private String point_name;
private String region_code;
private String region_name;
private String workorder_status;
private Boolean is_needmove;
private String workorder_type;
@TableField(exist = false)
private String production_order;
private String passback_status;
private String workshop_code;
private String ext_id;
private String ext_data;
private Boolean is_delete;
private String create_id;
private String create_name;
private String create_time;
private String update_id;
private String update_name;
private String update_time;
private Boolean is_urgent;
private String operator;
private Integer qualified_qty;
private Integer unqualified_qty;
private Integer priority;
@TableField(exist = false)
private String material_name;
@TableField(exist = false)
private String material_code;
@TableField(exist = false)
private String material_spec;
}

View File

@@ -0,0 +1,18 @@
package org.nl.wms.pm_manage.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import org.nl.wms.pm_manage.service.dto.PdmBdWorkorderQuery;
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
/**
* @author lyd
* @date 2023-05-05
**/
public interface PdmBdWorkorderMapper extends BaseMapper<PdmBdWorkorder> {
IPage<PdmBdWorkorder> selectPageLeftJoin(IPage<PdmBdWorkorder> pages, PdmBdWorkorderQuery query);
IPage<GroupPlate> selectUseMaterialPageLeftJoin(IPage<GroupPlate> pages, PdmBdWorkorderQuery query);
}

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.pm_manage.service.dao.mapper.PdmBdWorkorderMapper">
<select id="selectPageLeftJoin" resultType="org.nl.wms.pm_manage.service.dao.PdmBdWorkorder">
SELECT wo.*
,ma.material_name
,ma.material_code
,ma.material_spec
FROM pdm_bd_workorder wo
LEFT JOIN md_me_materialbase ma ON ma.material_id = wo.material_id
<where>
<if test="query.more_order_status != null and query.more_order_status != ''">
workorder_status IN
<foreach collection="query.more_order_status" item="code" separator="," open="(" close=")">
#{code}
</foreach>
</if>
<if test="query.workorder_code != null and query.workorder_code != ''">
AND wo.workorder_code LIKE CONCAT('%', #{query.workorder_code}, '%')
</if>
<if test="query.point_code != null and query.point_code != ''">
AND LOWER(wo.point_code) LIKE LOWER(CONCAT('%', #{query.point_code}, '%'))
</if>
<if test="query.begin_time != null and query.begin_time != ''">
AND wo.create_time <![CDATA[ >= ]]> #{query.begin_time}
</if>
<if test="query.end_time != null and query.end_time != ''">
AND wo.create_time <![CDATA[ <= ]]> #{query.end_time}
</if>
</where>
ORDER BY wo.update_time DESC
</select>
<select id="selectUseMaterialPageLeftJoin" resultType="org.nl.wms.warehouse_manage.service.dao.GroupPlate">
SELECT
mg.*,
ss.struct_code,
mm.material_code,
mm.material_name
FROM
`md_pb_groupplate` mg
LEFT JOIN st_ivt_structattr ss ON ss.storagevehicle_code = mg.storagevehicle_code
LEFT JOIN md_me_materialbase mm ON mm.material_id = mg.material_id
WHERE mg.`status` = '01' AND mg.frozen_qty = 0 AND IFNULL(mg.storagevehicle_code,'') <![CDATA[ <> ]]> ''
AND IFNULL(ss.struct_code,'') <![CDATA[ <> ]]> ''
AND 0 = (SELECT COUNT(*) FROM pdm_bd_workorder po WHERE po.raw_material_code = mg.storagevehicle_code AND po.workorder_status <![CDATA[ <> ]]> '5')
<if test="query.stor_id != null and query.stor_id != ''">
AND ss.stor_id = #{query.stor_id}
</if>
<if test="query.blurry != null and query.blurry != ''">
AND (mm.material_code LIKE CONCAT('%', #{query.blurry}, '%') OR mm.material_name LIKE CONCAT('%',
#{query.blurry}, '%'))
</if>
</select>
</mapper>

View File

@@ -0,0 +1,166 @@
package org.nl.wms.pm_manage.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lyd
* @description /
* @date 2023-05-05
**/
@Data
public class PdmBdWorkorderDto implements Serializable {
/**
* 工单标识
*/
private String workorder_id;
/**
* 工单编号
*/
private String workorder_code;
/**
* 计划数量
*/
private BigDecimal plan_qty;
/**
* 实际数量
*/
private BigDecimal real_qty;
/**
* 物料标识
*/
private String material_id;
/**
* 原材料物料标识
*/
private String raw_material_id;
/**
* 载具类型
*/
private String vehicle_type;
/**
* 计划开始时间
*/
private String planproducestart_date;
/**
* 计划结束时间
*/
private String planproduceend_date;
/**
* 实际开始时间
*/
private String realproducestart_date;
/**
* 实际结束时间
*/
private String realproduceend_date;
/**
* 静置时间(分钟)
*/
private BigDecimal standing_time;
/**
* 点位编码
*/
private String point_code;
/**
* 点位名称
*/
private String point_name;
/**
* 区域编码
*/
private String region_code;
/**
* 区域名称
*/
private String region_name;
/**
* 工单状态
*/
private String workorder_status;
/**
* 是否需要AGV搬运
*/
private String is_needmove;
/**
* 工单类型
*/
private String workorder_type;
/**
* 回传MES状态
*/
private String passback_status;
/**
* 车间编码
*/
private String workshop_code;
/**
* 外部标识
*/
private String ext_id;
/**
* 外部标识
*/
private String ext_data;
/**
* 是否删除
*/
private Boolean is_delete;
/**
* 创建人
*/
private String create_id;
/**
* 创建人
*/
private String create_name;
/**
* 创建时间
*/
private String create_time;
/**
* 修改人
*/
private String update_id;
/**
* 修改人
*/
private String update_name;
/**
* 修改时间
*/
private String update_time;
}

View File

@@ -0,0 +1,23 @@
package org.nl.wms.pm_manage.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author lyd
* @date 2023-05-05
**/
@Data
public class PdmBdWorkorderQuery implements Serializable {
private String workorder_code;
private String point_code;
private String begin_time;
private String end_time;
private List<String> more_order_status;
private String materialId;
private String stor_id;
private String blurry;
}

View File

@@ -0,0 +1,182 @@
package org.nl.wms.pm_manage.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.CommonUtils;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.pm_manage.enums.WorkOrderStatusEnum;
import org.nl.wms.pm_manage.service.IPdmBdWorkorderService;
import org.nl.wms.pm_manage.service.dao.PdmBdWorkorder;
import org.nl.wms.pm_manage.service.dao.mapper.PdmBdWorkorderMapper;
import org.nl.wms.pm_manage.service.dto.PdmBdWorkorderQuery;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.system_manage.service.notice.ISysNoticeService;
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
/**
* @author lyd
* @description 服务实现
* @date 2023-05-05
**/
@Slf4j
@Service
@Lazy
public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper, PdmBdWorkorder> implements IPdmBdWorkorderService {
@Autowired
private PdmBdWorkorderMapper pdmBdWorkorderMapper;
@Autowired
private ISysNoticeService noticeService;
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private IMdPbGroupplateService groupplateService;
@Override
public IPage<PdmBdWorkorder> queryAll(PdmBdWorkorderQuery query, PageQuery page) {
IPage<PdmBdWorkorder> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = pdmBdWorkorderMapper.selectPageLeftJoin(pages, query);
return pages;
}
@SneakyThrows
@Override
@Transactional(rollbackFor = Exception.class)
public void create(PdmBdWorkorder entity) {
List<PdmBdWorkorder> list = this.list(new LambdaQueryWrapper<PdmBdWorkorder>()
.eq(PdmBdWorkorder::getStruct_code, entity.getStruct_code())
.ne(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.COMPLETE.getCode()));
if (list.size() > 0) {
throw new BadRequestException("该位置的物料已经存在工单!");
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
String today = DateUtil.format(DateUtil.date(), "yyyyMMdd");
// 点位编码和点位名称为父点位
entity.setWorkorder_id(IdUtil.getSnowflake(1, 1).nextIdStr());
entity.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
entity.setCreate_id(currentUserId);
entity.setCreate_name(nickName);
entity.setCreate_time(now);
entity.setTeam(CommonUtils.getDayShift());
entity.setProduce_date(today);
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
pdmBdWorkorderMapper.insert(entity);
}
@Override
public void update(PdmBdWorkorder entity) {
PdmBdWorkorder dto = pdmBdWorkorderMapper.selectById(entity.getWorkorder_id());
if (dto == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
SchBasePoint point = pointService.getById(entity.getPoint_code());
// 使用最新的状态
entity.setWorkorder_status(dto.getWorkorder_status());
// entity.setUpdate_id(GeneralDefinition.ACS_ID);
// entity.setUpdate_name(GeneralDefinition.ACS_NAME);
entity.setUpdate_time(DateUtil.now());
log.info("用户「{}」在PC触发更新工单更新数据{},数据库旧数据:{}", SecurityUtils.getCurrentNickName(), entity, dto);
pdmBdWorkorderMapper.updateById(entity);
}
@Override
public void deleteAll(Set<String> ids) {
// 真删除
pdmBdWorkorderMapper.deleteBatchIds(ids);
}
@Override
public PdmBdWorkorder getByCode(String orderCode) {
if (orderCode == null) {
return null;
}
LambdaQueryWrapper<PdmBdWorkorder> lam = new QueryWrapper<PdmBdWorkorder>().lambda();
lam.eq(PdmBdWorkorder::getWorkorder_code, orderCode);
return pdmBdWorkorderMapper.selectOne(lam);
}
@Override
public PdmBdWorkorder getByCodeLock(String orderCode) {
LambdaQueryWrapper<PdmBdWorkorder> lam = new QueryWrapper<PdmBdWorkorder>().lambda();
lam.eq(PdmBdWorkorder::getWorkorder_code, orderCode);
lam.last("FOR UPDATE");
return pdmBdWorkorderMapper.selectOne(lam);
}
@Override
public void forceFinish(PdmBdWorkorder entity) {
String workorderCode = entity.getWorkorder_code();
String today = DateUtil.format(DateUtil.date(), "yyyyMMdd");
if (workorderCode == null) {
throw new BadRequestException("工单标识不能为空!");
}
PdmBdWorkorder bdWorkorder = this.getByCode(workorderCode);
if (bdWorkorder == null) {
throw new BadRequestException("未找到工单号[" + workorderCode + "]的记录!");
}
if (isWorkOrderIssuedAndProduceDateToday(bdWorkorder)) {
throw new BadRequestException("工单号[" + workorderCode + "]未生产不能完成工!");
}
if (bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.COMPLETE.getCode())) {
throw new BadRequestException("工单号[" + workorderCode + "]已完工,不能重复完工!");
}
bdWorkorder.setWorkorder_status(WorkOrderStatusEnum.COMPLETE.getCode());
bdWorkorder.setRealproduceend_date(DateUtil.now());
// TaskUtils.setWorkOrderUpdateByAcs(bdWorkorder);
// 统计合不合格数量到工单字段中
// int qualified_qty = baseBrickInfoService.getCountQualifiedQty(bdWorkorder.getWorkorder_code());
// int unqualified_qty = baseBrickInfoService.getCountUnqualifiedQty(bdWorkorder.getWorkorder_code());
// bdWorkorder.setQualified_qty(qualified_qty);
// bdWorkorder.setUnqualified_qty(unqualified_qty);
this.updateById(bdWorkorder);
}
@Override
public IPage<GroupPlate> getStockMaterial(PdmBdWorkorderQuery query, PageQuery page) {
IPage<GroupPlate> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = pdmBdWorkorderMapper.selectUseMaterialPageLeftJoin(pages, query);
return pages;
}
/**
* 判断工单是否下发、当天工单
* 判断逻辑不能过于复杂,因此提取出来
*
* @param bdWorkorder 工单参数
* @return 结果
*/
private boolean isWorkOrderIssuedAndProduceDateToday(PdmBdWorkorder bdWorkorder) {
String today = DateUtil.format(DateUtil.date(), "yyyyMMdd");
boolean isWorkOrderIssued = bdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.ISSUED.getCode());
boolean isProduceDateToday = ObjectUtil.isNotEmpty(bdWorkorder.getProduce_date()) && bdWorkorder.getProduce_date().equals(today);
return isWorkOrderIssued && isProduceDateToday;
}
}

View File

@@ -172,11 +172,12 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
return this.list();
}
return pointMapper.selectList(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getRegion_code, region.getRegion_code()));
.eq(SchBasePoint::getRegion_code, region.getRegion_code())
.eq(SchBasePoint::getIs_has_workder, true));
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void changeLock(JSONObject points) {
JSONArray data = points.getJSONArray("data");
Boolean lockType = points.getBoolean("lock_type");

View File

@@ -1,5 +1,6 @@
package org.nl.wms.warehouse_manage.service.dao;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
@@ -32,6 +33,7 @@ public class GroupPlate implements Serializable {
* 载具编码
*/
private String storagevehicle_code;
private String storagevehicle_type;
/**
* 物料编码
@@ -113,4 +115,11 @@ public class GroupPlate implements Serializable {
* 来源单据类型
*/
private String ext_type;
@TableField(exist = false)
private String struct_code;
@TableField(exist = false)
private String material_code;
@TableField(exist = false)
private String material_name;
}