Browse Source

feat: 定时获取工单与自动下发工单,工单选择物料优化

master
李永德 1 year ago
parent
commit
30e62c7737
  1. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/dao/mapper/MdBaseMaterialMapper.xml
  2. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/dto/MdBaseMaterialQuery.java
  3. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java
  4. 72
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java
  5. 25
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSynWorkOrderInfo.java
  6. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java
  7. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/service/dao/mapper/PdaMapper.xml
  8. 27
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java
  9. 27
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.java
  10. 83
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.xml
  11. 20
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  12. 11
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/CommonUtils.java
  13. 16
      lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/test.java
  14. 19
      lms/nladmin-ui/src/views/wms/sch/group/MaterialDialog.vue

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/dao/mapper/MdBaseMaterialMapper.xml

@ -17,8 +17,17 @@
LEFT JOIN sch_base_point p ON p.vehicle_code = vg.vehicle_code AND p.vehicle_type = vg.vehicle_type
WHERE
vg.group_bind_material_status = '2'
AND p.region_code = 'GTPHC'
AND p.point_status = '3'
AND p.region_code = 'GTPHC'
AND p.point_status = '3'
<if test="query.blurry != null">
AND mm.material_code LIKE '%${query.blurry}%' OR mm.material_name LIKE '%${query.blurry}%'
</if>
<if test="query.material_spec != null">
AND mm.material_spec LIKE '%${query.material_spec}%'
</if>
<if test="query.blurry != null">
AND mm.material_model LIKE '%${query.material_model}%'
</if>
) SELECT
CTE.material_id,
CTE.material_code,

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/dto/MdBaseMaterialQuery.java

@ -11,4 +11,6 @@ import java.io.Serializable;
@Data
public class MdBaseMaterialQuery implements Serializable {
private String blurry;
private String material_spec;
private String material_model;
}

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java

@ -51,11 +51,14 @@ public class MdBaseMaterialServiceImpl extends ServiceImpl<MdBaseMaterialMapper,
? whereJson.get("workshop_code").toString() : null;
String material_spec = ObjectUtil.isNotEmpty(whereJson.get("material_spec"))
? whereJson.get("material_spec").toString() : null;
String material_model = ObjectUtil.isNotEmpty(whereJson.get("material_model"))
? whereJson.get("material_model").toString() : null;
LambdaQueryWrapper<MdBaseMaterial> lam = new LambdaQueryWrapper<>();
lam.like(ObjectUtil.isNotEmpty(blurry), MdBaseMaterial::getMaterial_code, blurry)
.or(ObjectUtil.isNotEmpty(blurry),
l -> l.like(ObjectUtil.isNotEmpty(blurry), MdBaseMaterial::getMaterial_name, blurry))
.like(ObjectUtil.isNotEmpty(material_spec), MdBaseMaterial::getMaterial_spec, material_spec)
.like(ObjectUtil.isNotEmpty(material_model), MdBaseMaterial::getMaterial_model, material_model)
.eq(ObjectUtil.isNotEmpty(is_used), MdBaseMaterial::getIs_used, is_used)
.eq(ObjectUtil.isNotEmpty(workshop_code), MdBaseMaterial::getWorkshop_code, workshop_code);
IPage<MdBaseMaterial> pages = new Page<>(page.getPage() + 1, page.getSize());

72
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java

@ -0,0 +1,72 @@
package org.nl.wms.ext.acs.autotask;
import cn.hutool.http.HttpStatus;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.system.service.notice.ISysNoticeService;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
import org.nl.wms.util.TaskUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* @Author: lyd
* @Description: 自动下发工单给acs
* @Date: 2023/10/30
*/
@Slf4j
@Component
@Order(value = 1)
public class AutoIssueWorkOrder {
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private WmsToAcsService wmsToAcsService;
@Autowired
private ISysNoticeService noticeService;
@SneakyThrows
public void run() {
// 获取未有生产中的设备号
List<String> deviceCodes = workorderService.getTheDayUnProducedDevice();
// 查找该设备未生产的工单去下发
deviceCodes.forEach(s -> {
List<AcsWorkOrderVo> acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s);
if (acsWorkOrderVoList.size() == 0) return;
AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0);
// 获取一个下发
List<AcsWorkOrderVo> list = new CopyOnWriteArrayList<>();
list.add(acsWorkOrderVo);
AcsResponse resultForAcs;
try {
resultForAcs = wmsToAcsService.order(list);
} catch (Exception e) {
log.error("工单下发异常:" + e.getMessage());
// 通知
noticeService.createNotice("工单下发失败: " + e.getMessage(), "工单下发失败: "
+ acsWorkOrderVo.getWorkorder_code(), NoticeTypeEnum.EXCEPTION.getCode());
return;
}
if (resultForAcs.getCode() != HttpStatus.HTTP_OK) {
// 不成功
noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + acsWorkOrderVo.getWorkorder_code(),
NoticeTypeEnum.EXCEPTION.getCode());
return;
}
// 修改工单数据
PdmBdWorkorder pdmBdWorkorder = workorderService.getByCode(acsWorkOrderVo.getWorkorder_code());
pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode());
TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder);
workorderService.updateById(pdmBdWorkorder);
});
}
}

25
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSynWorkOrderInfo.java

@ -0,0 +1,25 @@
package org.nl.wms.ext.mes.autotask;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.mes.service.WmsToMesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* @Author: lyd
* @Description: 自动同步工单
* @Date: 2023/10/30
*/
@Slf4j
@Component
@Order(value = 1)
public class AutoSynWorkOrderInfo {
@Autowired
private WmsToMesService wmsToMesService;
@SneakyThrows
public void run() {
wmsToMesService.synchronizeWorkOrderInfo();
}
}

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java

@ -72,12 +72,13 @@ public class WmsToMesServiceImpl implements WmsToMesService {
public void synchronizeMaterialInfo() {
log.info("同步物料开始");
// 获取lms数据库中的最后获取时间
LambdaQueryWrapper<MdBaseMaterial> lmsMaterialTabQuery = new QueryWrapper<MdBaseMaterial>().lambda();
lmsMaterialTabQuery.isNotNull(MdBaseMaterial::getExt_id).ne(MdBaseMaterial::getExt_id, "")
.orderByDesc(MdBaseMaterial::getExt_time);
List<MdBaseMaterial> mdBaseMaterials = mdBaseMaterialService.list(lmsMaterialTabQuery);
String time = mdBaseMaterials.size() > 0 ? mdBaseMaterials.get(0).getExt_time() : "1970-01-01 00:00:00";
log.info("上次更新同步时间:{}", time);
// LambdaQueryWrapper<MdBaseMaterial> lmsMaterialTabQuery = new QueryWrapper<MdBaseMaterial>().lambda();
// lmsMaterialTabQuery.isNotNull(MdBaseMaterial::getExt_id).ne(MdBaseMaterial::getExt_id, "")
// .orderByDesc(MdBaseMaterial::getExt_time);
// List<MdBaseMaterial> mdBaseMaterials = mdBaseMaterialService.list(lmsMaterialTabQuery);
// String time = mdBaseMaterials.size() > 0 ? mdBaseMaterials.get(0).getExt_time() : "1970-01-01 00:00:00";
String time = "1970-01-01 00:00:00";
// log.info("上次更新同步时间:{}", time);
// 获取mes的物料数据
List<MdBaseMaterial> materials = mesRequestMapper.getMesMaterialInfos(time);
if (materials.size() == 0) {

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/service/dao/mapper/PdaMapper.xml

@ -137,7 +137,7 @@
mm.material_model
FROM
`md_base_material` mm
WHERE mm.material_code LIKE '%${material_code}%' OR mm.material_name LIKE '%ss%'
WHERE mm.material_code LIKE '%${material_code}%' OR mm.material_name LIKE '%${material_code}%'
</select>
<select id="getAllPressPoint" resultType="org.nl.wms.pda.service.dao.vo.DropdownListVo">
SELECT

27
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java

@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.ext.mes.service.dto.MesOrderInfo;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo;
import org.nl.wms.pdm.workorder.service.dto.PdmBdWorkorderQuery;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -79,4 +81,29 @@ public interface IPdmBdWorkorderService extends IService<PdmBdWorkorder> {
* @return
*/
boolean isEnoughCallEmpty(String deviceCode);
/**
* 获取当天未生产的工单
* @return
*/
List<PdmBdWorkorder> getTheDayUnProducedWorkOrder();
/**
* 获取当天需要下发的工单
* @return
*/
List<PdmBdWorkorder> getTheDayIssueWorkOrderList();
/**
* 获取未生产的设备
* @return
*/
List<String> getTheDayUnProducedDevice();
/**
* 获取当前设备未生产的工单
* @param s
* @return
*/
List<AcsWorkOrderVo> getAcsWorkOrderVos(String s);
}

27
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.java

@ -6,6 +6,8 @@ import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo;
import org.nl.wms.pdm.workorder.service.dto.PdmBdWorkorderQuery;
import java.util.List;
/**
* @author lyd
* @date 2023-05-05
@ -20,4 +22,29 @@ public interface PdmBdWorkorderMapper extends BaseMapper<PdmBdWorkorder> {
* @return
*/
AcsWorkOrderVo toAcsWorkOrderById(String workorderId);
/**
* 查询当前工单数据未生产计划开始时间排序
* @return
*/
List<PdmBdWorkorder> getTheDayUnProducedWorkOrder();
/**
* todo: 获取当天需要下发的工单
* @return
*/
List<PdmBdWorkorder> getTheDayIssueWorkOrderList();
/**
* 获取未生产的设备
* @return
*/
List<String> getTheDayUnProducedDevice();
/**
* 获取设备未生产的工单
* @param s
* @return
*/
List<AcsWorkOrderVo> getAcsWorkOrderVos(String device);
}

83
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.xml

@ -36,24 +36,85 @@
w.point_code AS device_code,
w.plan_qty,
m.half_material_code AS material_code,
1 AS product_code,
m.material_spec AS product_code,
m.material_spec AS brick_code,
"配方" AS formula,
0 AS a,
0 AS b,
0 AS h,
0 AS w,
m.material_model AS formula,
IF(LENGTH(m.a_long_side) > 0,m.a_long_side,0) AS a,
IF(LENGTH(m.b_short_side) > 0,m.b_short_side,0) AS b,
IF(LENGTH(m.h_height) > 0,m.h_height,0) AS h,
IF(LENGTH(m.w_thickness) > 0,m.w_thickness,0) AS w,
0 AS size_error,
0 AS single_weight,
0 AS standard_size_height1,
0 AS standard_size_height2,
0 AS standard_size_height3,
0 AS standard_size_height4,
0 AS standard_weight,
IF(LENGTH(m.standard_size_height1)>0,m.standard_size_height1,0) AS standard_size_height1,
IF(LENGTH(m.standard_size_height2)>0,m.standard_size_height2,0) AS standard_size_height2,
IF(LENGTH(m.standard_size_height3)>0,m.standard_size_height3,0) AS standard_size_height3,
IF(LENGTH(m.standard_size_height4)>0,m.standard_size_height4,0) AS standard_size_height4,
IF(LENGTH(m.single_weight)>0,m.single_weight,0) AS standard_weight,
0 AS detection_error
FROM
`pdm_bd_workorder` w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
WHERE w.workorder_id = #{workorderId}
</select>
<select id="getTheDayUnProducedWorkOrder" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
SELECT *
FROM pdm_bd_workorder
WHERE workorder_status = '1' AND produce_date = CURDATE()
ORDER BY planproducestart_date
</select>
<select id="getTheDayIssueWorkOrderList" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
SELECT pw.*
FROM pdm_bd_workorder pw
WHERE pw.point_code IN (
SELECT
p.point_code
FROM
`sch_base_point` p
LEFT JOIN pdm_bd_workorder w ON w.point_code = p.point_code AND w.workorder_status = '3'
WHERE
p.region_code = 'YZ' AND p.point_type = '1' AND p.is_has_workder = '1'
AND w.workorder_id IS NULL
) AND pw.workorder_status = '1' AND produce_date = CURDATE()
</select>
<select id="getTheDayUnProducedDevice" resultType="java.lang.String">
SELECT
p.point_code
FROM
`sch_base_point` p
LEFT JOIN pdm_bd_workorder w ON w.point_code = p.point_code AND w.workorder_status = '3' AND w.workorder_status = '2'
WHERE
p.region_code = 'YZ' AND p.point_type = '1' AND p.is_has_workder = '1'
AND w.workorder_id IS NULL
</select>
<select id="getAcsWorkOrderVos" resultType="org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo">
SELECT
w.workorder_code,
w.point_code AS device_code,
w.plan_qty,
m.half_material_code AS material_code,
m.material_spec AS product_code,
m.material_spec AS brick_code,
m.material_model AS formula,
IF(LENGTH(m.a_long_side) > 0,m.a_long_side,0) AS a,
IF(LENGTH(m.b_short_side) > 0,m.b_short_side,0) AS b,
IF(LENGTH(m.h_height) > 0,m.h_height,0) AS h,
IF(LENGTH(m.w_thickness) > 0,m.w_thickness,0) AS w,
0 AS size_error,
0 AS single_weight,
IF(LENGTH(m.standard_size_height1)>0,m.standard_size_height1,0) AS standard_size_height1,
IF(LENGTH(m.standard_size_height2)>0,m.standard_size_height2,0) AS standard_size_height2,
IF(LENGTH(m.standard_size_height3)>0,m.standard_size_height3,0) AS standard_size_height3,
IF(LENGTH(m.standard_size_height4)>0,m.standard_size_height4,0) AS standard_size_height4,
IF(LENGTH(m.single_weight)>0,m.single_weight,0) AS standard_weight,
0 AS detection_error
FROM
pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
WHERE
w.workorder_status = '1'
AND w.produce_date = CURDATE()
AND w.point_code = #{device}
ORDER BY w.planproducestart_date
</select>
</mapper>

20
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java

@ -249,4 +249,24 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
// 还可以叫空盘
return realQty.compareTo(planQty) < 0;
}
@Override
public List<PdmBdWorkorder> getTheDayUnProducedWorkOrder() {
return pdmBdWorkorderMapper.getTheDayUnProducedWorkOrder();
}
@Override
public List<PdmBdWorkorder> getTheDayIssueWorkOrderList() {
return pdmBdWorkorderMapper.getTheDayIssueWorkOrderList();
}
@Override
public List<String> getTheDayUnProducedDevice() {
return pdmBdWorkorderMapper.getTheDayUnProducedDevice();
}
@Override
public List<AcsWorkOrderVo> getAcsWorkOrderVos(String s) {
return pdmBdWorkorderMapper.getAcsWorkOrderVos(s);
}
}

11
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/CommonUtils.java

@ -7,6 +7,7 @@ import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
@ -109,4 +110,14 @@ public class CommonUtils {
list.add(putActionRequest);
return list;
}
public static String CurrentData() {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
// 格式化日期为"20231030"
String formattedDate = currentDate.format(formatter);
return formattedDate;
}
}

16
lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/test.java

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.checkerframework.checker.units.qual.A;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.acs.service.dto.to.wms.ApplyDeviceDto;
@ -19,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@ -117,5 +120,16 @@ public class test {
// System.out.println(5%3);
System.out.println(Double.parseDouble("0.0"));
}
@Test
// 测试场景:获取当前日期,格式化为"yyyyMMdd"
public void testGetFormattedDate() {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
// 格式化日期为"20231030"
String formattedDate = currentDate.format(formatter);
// 断言格式化后的日期是否符合预期
Assert.assertEquals("20231030", formattedDate);
}
}

19
lms/nladmin-ui/src/views/wms/sch/group/MaterialDialog.vue

@ -23,6 +23,24 @@
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="物料规格">
<el-input
v-model="query.material_spec"
clearable
size="mini"
placeholder="物料名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="物料型号">
<el-input
v-model="query.material_model"
clearable
size="mini"
placeholder="物料名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item :label="queryInfo">
<el-button icon="el-icon-sort" circle @click="queryMaterials"></el-button>
</el-form-item>
@ -54,6 +72,7 @@
<el-table-column prop="raw_material_code" label="泥料编码" width="160" />
<el-table-column prop="material_name" label="物料名称" width="180" show-overflow-tooltip />
<el-table-column prop="material_spec" label="物料规格" width="140" />
<el-table-column prop="material_model" label="物料型号" width="140" />
<el-table-column v-if="queryInfo === '库存顺序'" prop="total_material_qty" label="物料总数/块" width="140" />
<el-table-column prop="standing_time" label="静置时间(分钟)" width="130px" />
<el-table-column prop="update_name" label="修改人" />

Loading…
Cancel
Save