|  |  | 
 |  |  |         return R.ok().add(openService.queryStock()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @GetMapping("/syncAnfmeToWeight") | 
 |  |  |     public R syncAnfmeToWeight() { | 
 |  |  |         int count = openService.syncAnfmeToWeight(); | 
 |  |  |         return R.ok().add(count); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void auth(String appkey, Object obj, HttpServletRequest request) { | 
 |  |  |         log.info("{}接口被访问;appkey:{};请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj)); | 
 |  |  |         request.setAttribute("cache", obj); | 
 
 |  |  | 
 |  |  |      * @param param | 
 |  |  |      */ | 
 |  |  |     void syncMat(MatSyncParam param); | 
 |  |  |  | 
 |  |  |     int syncAnfmeToWeight(); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.time.LocalDate; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Calendar; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int syncAnfmeToWeight() { | 
 |  |  |         try { | 
 |  |  |             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |             Date date = format.parse("2025-06-24 00:00:00"); | 
 |  |  |             Date date2 = format.parse("2025-06-24 23:59:59"); | 
 |  |  |             List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
 |  |  |                     .ge("appe_time", format.format(date)) | 
 |  |  |                     .le("appe_time", format.format(date2)) | 
 |  |  |             ); | 
 |  |  |  | 
 |  |  |             int i = 0; | 
 |  |  |             for (LocDetl locDetl : locDetls) { | 
 |  |  |                 // 修改库存 | 
 |  |  |                 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 i; | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         return 0; | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |             invCountBodyVO.setCmaterialoid(inventoryCheckOrderDetl.getMatnr()); | 
 |  |  |             invCountBodyVO.setVbatchcode(inventoryCheckOrderDetl.getBatch()); | 
 |  |  |             invCountBodyVO.setNcountastnum(inventoryCheckOrderDetl.getCheckAnfme()); | 
 |  |  |             invCountBodyVO.setCstateid("1001A1100000000H0KJN"); | 
 |  |  |             invCountBodyVOList.add(invCountBodyVO); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |         data.put("InvCountHeaderVO", invCountHeaderVO); | 
 |  |  |         data.put("InvCountBodyVO", invCountBodyVOList); | 
 |  |  |         data.put("paper", "2"); | 
 |  |  |         data.put("splr", "1"); | 
 |  |  |         data.put("paper", "1"); | 
 |  |  |         data.put("splr", "0"); | 
 |  |  |  | 
 |  |  |         ArrayList<Map<String, Object>> list = new ArrayList<>(); | 
 |  |  |         list.add(data); | 
 
 |  |  | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.math.RoundingMode; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * Created by vincent on 2022/4/23 | 
 |  |  | 
 |  |  |         BigDecimal origin1 = new BigDecimal(split[1]); | 
 |  |  |         BigDecimal origin0 = new BigDecimal(split[0]); | 
 |  |  |  | 
 |  |  |         BigDecimal divideResult1 = anfmeBigDecimal.divide(origin1); | 
 |  |  |         BigDecimal weightBigDecimal = divideResult1.divide(origin0); | 
 |  |  |         BigDecimal divideResult1 = anfmeBigDecimal.divide(origin1, 9, RoundingMode.HALF_UP); | 
 |  |  |         BigDecimal weightBigDecimal = divideResult1.divide(origin0, 9, RoundingMode.HALF_UP); | 
 |  |  |         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(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     private Double ncountastnum;//盘点数量 | 
 |  |  |  | 
 |  |  |     private String cstateid; | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |                 return html; | 
 |  |  |             }} | 
 |  |  |         ,{field: 'modiUser$', align: 'center',title: '修改人员', hide:true} | 
 |  |  |         ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:true}) | 
 |  |  |         ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:false}) | 
 |  |  |     return cols; | 
 |  |  | } | 
 |  |  |  | 
 
 |  |  | 
 |  |  |                 return html; | 
 |  |  |             }} | 
 |  |  |         ,{field: 'modiUser$', align: 'center',title: '修改人员', hide:true} | 
 |  |  |         ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:true}) | 
 |  |  |         ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:false}) | 
 |  |  |     return cols; | 
 |  |  | } | 
 |  |  | layui.use(['table','laydate', 'form'], function(){ |