| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.chinaztt.ifs.api.feign.IfsFeignClient; |
| | | import com.chinaztt.mes.basic.dto.LocationDTO; |
| | | import com.chinaztt.mes.basic.dto.LocationIfsMoveDTO; |
| | | import com.chinaztt.mes.basic.entity.Factory; |
| | | import com.chinaztt.mes.basic.entity.Location; |
| | | import com.chinaztt.mes.basic.entity.Warehouse; |
| | | import com.chinaztt.mes.basic.excel.LocationData; |
| | | import com.chinaztt.mes.basic.mapper.FactoryMapper; |
| | | import com.chinaztt.mes.basic.mapper.LocationMapper; |
| | | import com.chinaztt.mes.basic.mapper.WarehouseMapper; |
| | | import com.chinaztt.mes.basic.service.LocationService; |
| | | import com.chinaztt.mes.basic.service.WarehouseService; |
| | | import com.chinaztt.mes.basic.util.DictUtils; |
| | | import com.chinaztt.ztt.admin.api.entity.SysDictItem; |
| | | import com.chinaztt.ztt.admin.api.feign.RemoteParamService; |
| | | import com.chinaztt.ztt.common.core.constant.SecurityConstants; |
| | | import com.chinaztt.ztt.common.core.util.R; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collector; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 库位基础数据 |
| | |
| | | @AllArgsConstructor |
| | | public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> implements LocationService { |
| | | private WarehouseMapper warehouseMapper; |
| | | private FactoryMapper factoryMapper; |
| | | private static final String LOCATION_QC_SEND_BACK = "LOCATION_QC_SEND_BACK"; |
| | | public static final String CONTRACT = "IFS_DOMAIN"; |
| | | private RemoteParamService remoteParamService; |
| | | private IfsFeignClient ifsFeignClient; |
| | | |
| | | private DictUtils dictUtils; |
| | | @Override |
| | | public IPage<List<Location>> getLoc(Page page, QueryWrapper<LocationDTO> ew) { |
| | | return baseMapper.getLoc(page, ew); |
| | |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return; |
| | | } |
| | | List<Factory> factories = factoryMapper.selectList(null); |
| | | List<Warehouse> warehouses = warehouseMapper.selectList(null); |
| | | List<SysDictItem> dict = dictUtils.getDict("warehouse_type"); |
| | | for (LocationData data : list) { |
| | | Location newLocation = new Location(); |
| | | newLocation.setFactoryId(data.getFactoryId()); |
| | | newLocation.setLocGroup(data.getLocGroup()); |
| | | dict.forEach(a->{ |
| | | if (a.getLabel().equals(data.getLocType())){ |
| | | newLocation.setLocType(a.getValue()); |
| | | } |
| | | }); |
| | | if("启用".equals(data.getLocState())){ |
| | | newLocation.setLocStatus(1); |
| | | }else{ |
| | | newLocation.setLocStatus(0); |
| | | } |
| | | for (int i = 0; i <factories.size() ; i++) { |
| | | if (factories.get(i).getFactoryName().equals(data.getFactoryName())){ |
| | | newLocation.setFactoryId(factories.get(i).getId()); |
| | | } |
| | | } |
| | | if (newLocation.getFactoryId()==null){ |
| | | log.error("工厂:" + data.getFactoryName() + "不存在"); |
| | | continue ; |
| | | } |
| | | for (int i = 0; i <warehouses.size() ; i++) { |
| | | if (warehouses.get(i).getWarehouseName().equals(data.getWarehouseName())){ |
| | | newLocation.setLocGroup(warehouses.get(i).getId()); |
| | | } |
| | | } |
| | | if (newLocation.getLocGroup()==null){ |
| | | log.error("仓库:" + data.getWarehouseName() + "不存在"); |
| | | continue ; |
| | | } |
| | | newLocation.setLocName(data.getLocName()); |
| | | newLocation.setLocNo(data.getLocNo()); |
| | | newLocation.setIfsLocation(data.getIfsLocation()); |
| | | baseMapper.insert(newLocation); |
| | | } |
| | | } |