| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.lsw.entity.LswMaterial; |
| | | import org.jeecg.modules.lsw.enums.MaterialCategoryEnum; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialService; |
| | | import org.jeecg.modules.lsw.vo.MaterialScanResultVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "线边库物料信息-根据物料类型查询", notes = "线边库物料信息-根据物料类型查询") |
| | | @GetMapping(value = "/queryByMaterialCategory") |
| | | public Result<List<LswMaterial>> queryByMaterialCategory(@RequestParam("materialCategory") String materialCategory) { |
| | | if (StringUtils.isBlank(materialCategory)) { |
| | | return Result.ok(Collections.emptyList()); |
| | | } |
| | | String[] split = materialCategory.split(","); |
| | | LambdaQueryWrapper<LswMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(LswMaterial::getMaterialCategory, materialCategory); |
| | | queryWrapper.in(LswMaterial::getMaterialCategory, Arrays.asList(split)); |
| | | queryWrapper.eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1); |
| | | queryWrapper.orderByAsc(LswMaterial::getMaterialNumber); |
| | | List<LswMaterial> lswMaterialList = lswMaterialService.list(queryWrapper); |
| | | return Result.ok(lswMaterialList); |
| | | } |
| | | |
| | | @ApiOperation(value = "线边库物料信息-扫码", notes = "线边库物料信息-扫码") |
| | | @GetMapping(value = "/scan") |
| | | public Result<?> scan(@RequestParam("qrCode") String qrCode) { |
| | | if (StringUtils.isBlank(qrCode)) { |
| | | return Result.error("扫码信息为空!"); |
| | | } |
| | | MaterialScanResultVO result = parseQrCode(qrCode); |
| | | //查询物料数据 |
| | | LswMaterial material = lswMaterialService.queryByMaterialNumber(result.getMaterialNumber()); |
| | | if(material == null) { |
| | | return Result.error("根据物料编号未查询到物料!"); |
| | | } |
| | | result.setMaterialName(material.getMaterialName()); |
| | | result.setMaterialCategory(material.getMaterialCategory()); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | /** |
| | | * 解析二维码字符串 |
| | | * @param qrCode |
| | | * @return |
| | | */ |
| | | private static MaterialScanResultVO parseQrCode(String qrCode) { |
| | | MaterialScanResultVO vo = new MaterialScanResultVO(); |
| | | String[] split = qrCode.split("#"); |
| | | for (String str : split) { |
| | | if (StringUtils.isBlank(str)) { |
| | | //不符合规则 |
| | | continue; |
| | | } |
| | | String[] pairs = str.split("="); |
| | | if (pairs.length != 2) { |
| | | //不符合规则 |
| | | continue; |
| | | } |
| | | String key = pairs[0]; |
| | | String value = pairs[1]; |
| | | switch (key) { |
| | | case "FactoryCode": |
| | | vo.setFactoryCode(value); |
| | | break; |
| | | case "SkuCode": |
| | | vo.setMaterialNumber(value); |
| | | break; |
| | | case "Quantity": |
| | | vo.setQuantity(new BigDecimal(value)); |
| | | break; |
| | | case "TrackLot": |
| | | case "ProductionTracklot": |
| | | case "SupplierTrackLot": |
| | | vo.setBatchNumber(value); |
| | | break; |
| | | case "Section": |
| | | vo.setSection(value); |
| | | break; |
| | | } |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | } |