Browse Source

feat: 自动下发工单

master
李永德 1 year ago
parent
commit
019d5cf4aa
  1. 50
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/mybatis/MyStdOutImpl.java
  2. 10
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/autotask/AutoIssueWorkOrder.java
  3. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  4. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java
  5. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.java
  6. 16
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/dao/mapper/PdmBdWorkorderMapper.xml
  7. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  8. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java
  9. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.java
  10. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.xml
  11. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java
  12. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJSLTask.java
  13. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQKTask.java
  14. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java
  15. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/TaskUtils.java
  16. 7
      lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

50
lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/mybatis/MyStdOutImpl.java

@ -0,0 +1,50 @@
package org.nl.config.mybatis;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.logging.Log;
/**
* @Author: lyd
* @Description:
* @Date: 2023/11/16
*/
@Slf4j
public class MyStdOutImpl implements Log {
public MyStdOutImpl(String clazz) {
}
@Override
public boolean isDebugEnabled() {
return true;
}
@Override
public boolean isTraceEnabled() {
return true;
}
@Override
public void error(String s, Throwable e) {
log.error(s);
e.printStackTrace(System.err);
}
@Override
public void error(String s) {
log.error(s);
}
@Override
public void debug(String s) {
log.debug(s);
}
@Override
public void trace(String s) {
log.trace(s);
}
@Override
public void warn(String s) {
log.warn(s);
}
}

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

@ -47,15 +47,19 @@ public class AutoIssueWorkOrder {
try {
if (tryLock) {
// 获取每台设备的第一条工单
List<PdmBdWorkorder> workorderList = workorderService.getNeedCallMaterial();
List<PdmBdWorkorder> workorderList = workorderService.getNotIssueOrder();
// 查找该设备未生产的工单去下发
workorderList.forEach(s -> {
// 判断是否有工单
List<PdmBdWorkorder> lists = workorderService.getTheDayProducedWorkOrderByDevice(s.getPoint_code());
if (lists.size() > 0) return;
if (lists.size() > 0) {
return;
}
// 已生产就退出
if (s.getWorkorder_status().equals(WorkOrderStatusEnum.PRODUCING.getCode())
|| s.getWorkorder_code().equals(WorkOrderStatusEnum.ISSUED.getCode())) return;
|| s.getWorkorder_code().equals(WorkOrderStatusEnum.ISSUED.getCode())) {
return;
}
AcsWorkOrderVo acsWorkOrderVo = workorderService.toAcsWorkOrderById(s.getWorkorder_id());
// 获取一个下发
List<AcsWorkOrderVo> list = new CopyOnWriteArrayList<>();

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -509,6 +509,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.append(baseMaterial.getMaterial_spec() + "~" + baseMaterial.getMaterial_model()).append("##")
.append(baseMaterial.getMaterial_name()).append("##")
.append(custer.getCuster_name()).append("**");
log.info("打印的唛头信息:{}", sb);
return ApplyTaskResponse.responseOk(requestNo, sb.toString());
}
@ -540,6 +541,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
bdWorkorder.setRealproducestart_date(DateUtil.now());
TaskUtils.setWorkOrderUpdateByAcs(bdWorkorder);
workorderService.updateById(bdWorkorder);
log.info("人工排产确认:{}", bdWorkorder);
return BaseResponse.responseOk(requestNo);
}
@ -566,6 +568,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
bdWorkorder.setQualified_qty(qualified_qty);
bdWorkorder.setUnqualified_qty(unqualified_qty);
workorderService.updateById(bdWorkorder);
log.info("工单完成: {}", bdWorkorder);
try {
// todo: 统计当前设备的不合格位置的数量作为不合格数,并上报给mes
wmsToMesService.reportPressUnusedMaterial(bdWorkorder);

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

@ -127,4 +127,10 @@ public interface IPdmBdWorkorderService extends IService<PdmBdWorkorder> {
* @return
*/
AcsWorkOrderVo toAcsWorkOrderById(String workorderId);
/**
* 获取未生产
* @return
*/
List<PdmBdWorkorder> getNotIssueOrder();
}

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

@ -55,4 +55,6 @@ public interface PdmBdWorkorderMapper extends BaseMapper<PdmBdWorkorder> {
* @return
*/
List<PdmBdWorkorder> getNeedCallMaterial();
List<PdmBdWorkorder> getNotIssueOrder();
}

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

@ -124,7 +124,7 @@
FROM
`pdm_bd_workorder` w
WHERE w.point_code = #{s}
AND w.workorder_status != '5' AND w.workorder_status != '1'
AND w.workorder_status IN ('2', '3')
</select>
<select id="getNeedCallMaterial" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
SELECT ranked.*
@ -140,4 +140,18 @@
) AS ranked
WHERE row_num = 1
</select>
<select id="getNotIssueOrder" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
SELECT ranked.*
FROM (
SELECT
w.*,
ROW_NUMBER() OVER (PARTITION BY w.point_code ORDER BY w.workorder_status DESC, w.planproducestart_date) AS row_num
FROM
`pdm_bd_workorder` w
WHERE w.produce_date = CURDATE() AND w.region_code = 'YZ'
AND w.workorder_status = '1'
ORDER BY w.workorder_status DESC, w.planproducestart_date
) AS ranked
WHERE row_num = 1
</select>
</mapper>

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

@ -219,7 +219,7 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
}
// 修改工单数据
pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode());
TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder);
TaskUtils.setWorkOrderUpdateByPC(pdmBdWorkorder);
pdmBdWorkorderMapper.updateById(pdmBdWorkorder);
}
@ -330,4 +330,9 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
public AcsWorkOrderVo toAcsWorkOrderById(String workorderId) {
return pdmBdWorkorderMapper.toAcsWorkOrderById(workorderId);
}
@Override
public List<PdmBdWorkorder> getNotIssueOrder() {
return pdmBdWorkorderMapper.getNotIssueOrder();
}
}

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java

@ -67,4 +67,9 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
* @return
*/
List<SchBasePoint> getAllUnlockAbnormalPoints();
/**
* 行锁获取对应点位
* @return
*/
SchBasePoint selectByIdLock(String id);
}

7
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.java

@ -19,4 +19,11 @@ public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
void batchChangeUsed(List<String> pointCodes, Boolean used);
List<SchBasePoint> getAllUnlockAbnormalPoints();
/**
* 行锁获取id的点位
* @param id
* @return
*/
SchBasePoint selectByIdLock(String id);
}

8
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.xml

@ -20,4 +20,12 @@
LEFT JOIN sch_base_task t ON t.task_code = p.ing_task_code
WHERE p.ing_task_code IS NOT NULL AND p.ing_task_code != '' AND (t.task_status = '5' OR t.task_status = '6')
</select>
<select id="selectByIdLock" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
SELECT
p.*
FROM
`sch_base_point` p
WHERE p.point_code = #{id}
FOR UPDATE
</select>
</mapper>

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java

@ -208,4 +208,9 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
return pointMapper.getAllUnlockAbnormalPoints();
}
@Override
public SchBasePoint selectByIdLock(String id) {
return pointMapper.selectByIdLock(id);
}
}

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJSLTask.java

@ -220,9 +220,6 @@ public class FJSLTask extends AbstractTask {
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
if (ObjectUtil.isNotEmpty(endPointObj)) {
// 终点解锁
endPointObj.setIng_task_code("");
PointUtils.setUpdateByType(endPointObj, taskFinishedType);
// 记录库存并解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(vehicleCode);

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQKTask.java

@ -136,6 +136,7 @@ public class YZQKTask extends AbstractTask {
}
@Override
@Transactional(rollbackFor = Exception.class)
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getByCode(task_code);
@ -182,8 +183,8 @@ public class YZQKTask extends AbstractTask {
// 获取参数
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = taskObj.getPoint_code2(); // 获取起点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
SchBasePoint startPointObj = pointService.selectByIdLock(startPoint);
SchBasePoint endPointObj = pointService.selectByIdLock(endPoint);
// 起点清空
if (ObjectUtil.isNotEmpty(startPointObj)) {
PointUtils.setUpdateByType(startPointObj, taskFinishedType);

1
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java

@ -39,7 +39,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**

6
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/TaskUtils.java

@ -83,8 +83,10 @@ public class TaskUtils {
}
public static void setWorkOrderUpdateByPC(PdmBdWorkorder pdmBdWorkorder) {
pdmBdWorkorder.setUpdate_id(SecurityUtils.getCurrentUserId());
pdmBdWorkorder.setUpdate_name(SecurityUtils.getCurrentNickName());
pdmBdWorkorder.setUpdate_id(ObjectUtil.isNotEmpty(SecurityUtils.getCurrentUserId())
? SecurityUtils.getCurrentUserId() : "");
pdmBdWorkorder.setUpdate_name(ObjectUtil.isNotEmpty(SecurityUtils.getCurrentNickName())
? SecurityUtils.getCurrentNickName() : "");
pdmBdWorkorder.setUpdate_time(DateUtil.now());
}

7
lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

@ -62,7 +62,7 @@ https://juejin.cn/post/6844903775631572999
</appender>
<!--开发环境:打印控制台-->
<springProfile name="dev">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="asyncLuceneAppender"/>
</root>
@ -108,9 +108,12 @@ https://juejin.cn/post/6844903775631572999
<!--生产环境:打印控制台和输出到文件-->
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="asyncFileAppender"/>
<!-- <appender-ref ref="asyncFileAppender"/>-->
<appender-ref ref="asyncLuceneAppender"/>
</root>
<root level="DEBUG">
<appender-ref ref="asyncFileAppender"/>
</root>
<logger name="org.springframework" level="ERROR" additivity="false">
<appender-ref ref="asyncFileAppender"/>
</logger>

Loading…
Cancel
Save