| | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.LocDto; |
| | |
| | | import com.zy.common.model.OrderMergeVo; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.DataFormatter; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/3/26 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | public class OutController extends BaseController { |
| | | |
| | |
| | | for (TaskDto taskDto : taskDtos) { |
| | | String locNo = taskDto.getLocNo(); |
| | | List<String> groupOuterSingleLoc = Utils.getGroupOuterSingleLoc(locNo); |
| | | if (Utils.getBay(locNo)>=21){ |
| | | LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locNo)); |
| | | if (locMast1.getLocType2().equals((short)3)){ |
| | | groupOuterSingleLoc = Utils.getGroupOuterSingleLocLowFrequency(locNo); |
| | | } |
| | | for (String locNo1 : groupOuterSingleLoc){ |
| | |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | /** |
| | | * excel导入 |
| | | */ |
| | | @PostMapping(value = "/checkout/excel/import/auth") |
| | | @ManagerAuth(memo = "盘点导入") |
| | | @Transactional |
| | | public R cstmrExcelImport(MultipartFile file) throws IOException { |
| | | InputStream inStream = file.getInputStream(); |
| | | String fileMime = file.getContentType(); |
| | | int excelVersion = 2007; |
| | | if ("application/vnd.ms-excel".equals(fileMime)) { |
| | | excelVersion = 2003; |
| | | } |
| | | Workbook book = null; |
| | | try { |
| | | if (excelVersion == 2003) { |
| | | book = new HSSFWorkbook(inStream); |
| | | } |
| | | else { // 当 excel 是 2007 时 |
| | | book = new XSSFWorkbook(inStream); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | return R.error("导入文件格式错误,请使用xls后缀的文件!"); |
| | | } |
| | | |
| | | Sheet sheet = book.getSheetAt(0); |
| | | int totalRows = sheet.getLastRowNum() + 1; // 总 |
| | | Long userId = getUserId(); |
| | | Date now = new Date(); |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | for (int i = 1; i < totalRows; i++) { |
| | | Row row = sheet.getRow(i); |
| | | // 库位号 |
| | | String locno = dataFormatter.formatCellValue(row.getCell(0)); |
| | | // 出库站 |
| | | Integer outSite = Integer.parseInt(dataFormatter.formatCellValue(row.getCell(1))); |
| | | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locno)); |
| | | StockOutParam param = new StockOutParam(); |
| | | |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F")) { |
| | | List<LocDetl> locDetls = locDetlService.selectByLocNo(locno); |
| | | List<StockOutParam.LocDetl> locDes = new ArrayList<>(); |
| | | for (LocDetl locDetl : locDetls) { |
| | | StockOutParam.LocDetl SOlocDetl = new StockOutParam.LocDetl(locDetl.getLocNo(),locDetl.getMatnr(),locDetl.getBatch(),locDetl.getAnfme()); |
| | | locDes.add(SOlocDetl); |
| | | } |
| | | param.setLocDetls(locDes); |
| | | param.setOutSite(outSite); |
| | | workService.locCheckOut(param, getUserId()); |
| | | } else { |
| | | return R.error("出库失败"); |
| | | } |
| | | } |
| | | return R.ok("出库完成"); |
| | | } |
| | | |
| | | } |