| | |
| | | int i = 0; |
| | | for (LocDetl locDetl : locDetls) { |
| | | // 修改库存 |
| | | locDetlService.updateAnfme(locDetl.getAnfme(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getBrand(), |
| | | Double anfme = MatUtils.calcAnfmeFromWeight(locDetl.getMatnr(), locDetl.getAnfme()); |
| | | locDetlService.updateAnfme(anfme, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getBrand(), |
| | | locDetl.getStandby1(), locDetl.getStandby2(), locDetl.getStandby3(), locDetl.getBoxType1(), locDetl.getBoxType2(), locDetl.getBoxType3()); |
| | | i++; |
| | | } |
| | |
| | | return weightBigDecimal.doubleValue(); |
| | | } |
| | | |
| | | public static Double calcAnfmeFromWeight(String matnr, Double weight) { |
| | | MatService matService = SpringUtils.getBean(MatService.class); |
| | | //更新辅料 |
| | | Mat mat = matService.selectByMatnr(matnr); |
| | | if (mat == null) { |
| | | throw new CoolException("物料信息不存在"); |
| | | } |
| | | |
| | | //转换关系 |
| | | String origin = mat.getOrigin(); |
| | | if (Cools.isEmpty(origin)) { |
| | | throw new CoolException("主辅数量转换公式不存在"); |
| | | } |
| | | String[] split = origin.split("/"); |
| | | //辅单位 |
| | | |
| | | BigDecimal weightBigDecimal = BigDecimal.valueOf(weight); |
| | | BigDecimal origin1 = new BigDecimal(split[1]); |
| | | BigDecimal origin0 = new BigDecimal(split[0]); |
| | | |
| | | BigDecimal multiplyResult1 = weightBigDecimal.multiply(origin1); |
| | | BigDecimal anfmeBigDecimal = multiplyResult1.multiply(origin0); |
| | | return anfmeBigDecimal.doubleValue(); |
| | | } |
| | | |
| | | } |