Compare commits

...

6 Commits

  1. 5
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/mapper/MaterialbaseMapper.java
  2. 14
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/mapper/MaterialbaseMapper.xml
  3. 3
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/service/IMaterialbaseService.java
  4. 9
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/service/impl/MaterialbaseServiceImpl.java
  5. 16
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/order/service/impl/OrderServiceImpl.java
  6. 2
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java
  7. 5
      acs/nladmin-system/nlsso-server/src/main/resources/mapper/MaterialbaseMapper.xml

5
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/mapper/MaterialbaseMapper.java

@ -3,6 +3,9 @@ package org.nl.acs.data.mapper;
import org.nl.acs.data.domain.Materialbase;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.Set;
/**
* <p>
* 物料基本信息表 Mapper 接口
@ -13,4 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface MaterialbaseMapper extends BaseMapper<Materialbase> {
List<Materialbase> findByCodes(Set<String> materialCodes);
}

14
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/mapper/MaterialbaseMapper.xml

@ -0,0 +1,14 @@
<?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.acs.data.mapper.MaterialbaseMapper">
<select id="findByCodes" resultType="org.nl.acs.data.domain.Materialbase"
parameterType="java.util.Set">
SELECT * FROM materialbase
WHERE material_code IN
<foreach item="code" collection="materialCodes" open="(" separator="," close=")">
#{code}
</foreach>
</select>
</mapper>

3
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/service/IMaterialbaseService.java

@ -11,6 +11,7 @@ import org.nl.acs.point.domain.AcsPoint;
import org.nl.acs.point.domain.PointQuery;
import org.nl.common.domain.query.PageQuery;
import java.util.Map;
import java.util.Set;
/**
@ -56,4 +57,6 @@ public interface IMaterialbaseService extends IService<Materialbase> {
JSONArray getBoxIvt();
Materialbase findByCode(String code);
Map<String, Materialbase> findByCodes(Set<String> materialCodes);
}

9
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/data/service/impl/MaterialbaseServiceImpl.java

@ -24,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* <p>
@ -112,4 +114,11 @@ public class MaterialbaseServiceImpl extends ServiceImpl<MaterialbaseMapper, Mat
LambdaQueryWrapper<Materialbase> wrapper = new LambdaQueryWrapper<Materialbase>().eq(Materialbase::getMaterial_code, code);
return materialbaseMapper.selectOne(wrapper);
}
@Override
public Map<String, Materialbase> findByCodes(Set<String> materialCodes) {
List<Materialbase> materialbases = materialbaseMapper.findByCodes(materialCodes);
return materialbases.stream()
.collect(Collectors.toMap(Materialbase::getMaterial_code, materialbase -> materialbase));
}
}

16
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/order/service/impl/OrderServiceImpl.java

@ -44,10 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -233,14 +230,19 @@ public class OrderServiceImpl extends CommonServiceImpl<OrderMapper, OrderDto> i
orderDto.setUpdate_time(DateUtil.now());
//生成配料任务
List<OrderDetailDto> list = orderDetailMapper.selectList(Wrappers.lambdaQuery(OrderDetailDto.class).eq(OrderDetailDto::getWorkorder_id, workorder_id));
Set<String> materialCodes = list.stream().map(OrderDetailDto::getMaterial_code).collect(Collectors.toSet());
Map<String, Materialbase> materialbaseMap = materialbaseService.findByCodes(materialCodes);
List<Work> works = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
OrderDetailDto orderDetailDto = list.get(i);
for (OrderDetailDto orderDetailDto : list) {
String material_code = orderDetailDto.getMaterial_code();
Materialbase materialbase = materialbaseService.findByCode(material_code);
if (material_code == null) {
throw new BadRequestException("物料编码不能为空");
}
Materialbase materialbase = materialbaseMap.get(material_code);
if (materialbase == null) {
throw new BadRequestException("不存在物料编码为" + material_code + "的物料!");
}
int count = (int) Math.ceil((double) orderDetailDto.getProductin_qty() / materialbase.getQty());
Work work = new Work();
work.setWork_id(IdUtil.getSnowflake(1, 1).nextId() + "")

2
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java

@ -80,7 +80,7 @@ public class ReadUtil {
/**
* 创建OPC UA客户端
*/
private static OpcUaClient createClient() throws Exception {
public static OpcUaClient createClient() throws Exception {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
String endPointUrl = paramService.findByCode(AcsConfig.OPCURL).getValue();
if (StrUtil.isEmpty(endPointUrl)){

5
acs/nladmin-system/nlsso-server/src/main/resources/mapper/MaterialbaseMapper.xml

@ -1,5 +0,0 @@
<?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.acs.data.mapper.MaterialbaseMapper">
</mapper>
Loading…
Cancel
Save