| | |
| | | import org.springblade.modules.farmplant.entity.FarmProductStock; |
| | | import org.springblade.modules.farmplant.service.FarmProductStockService; |
| | | import org.springblade.modules.farmplant.vo.FarmProductStockVO; |
| | | import org.springblade.modules.process.service.IProcessService; |
| | | import org.springblade.modules.processInv.entity.ProcessInv; |
| | | import org.springblade.modules.processInv.service.IProcessInvService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 农产品库存控制器 |
| | | * @since 2022-05-18 |
| | | * |
| | | * @author zhongrj |
| | | * @since 2022-05-18 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | |
| | | public class FarmProductStockController extends BladeController { |
| | | |
| | | private final FarmProductStockService farmProductStockService; |
| | | private final IProcessInvService processInvService; |
| | | private final IProcessService processService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | return R.data(pages); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/strainCount") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入farmProductStock") |
| | | public R<IPage<FarmProductStockVO>> strainCount(FarmProductStockVO farmProductStock, Query query) { |
| | | IPage<FarmProductStockVO> pages = farmProductStockService.selectFarmProductStockPagesCount(Condition.getPage(query), farmProductStock); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | */ |
| | | @GetMapping("/pages") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入farmProductStock") |
| | | public R<List<FarmProductStockVO>> pages(FarmProductStockVO farmProductStock) { |
| | | List<FarmProductStockVO> pages = farmProductStockService.selectFarmProductStockPages(farmProductStock); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | @GetMapping("/getFarmProductStockByFarmIdAndStrainId") |
| | | public R<FarmProductStock> findFarmProductStockByFarmIdAndStrainId(String farmId,Integer strainId) { |
| | | List<FarmProductStock> farmProductStockList = farmProductStockService.findFarmProductStockByFarmIdAndStrainId(farmId,strainId); |
| | | if (farmProductStockList.size() == 0) { |
| | | return R.data(null); |
| | | } |
| | | return R.data(farmProductStockList.get(0)); |
| | | } |
| | | |
| | | /** |
| | | * 统计产量 |
| | | * |
| | | * @param farmProductStock |
| | | * @return |
| | | */ |
| | |
| | | * 大屏产量统计 |
| | | */ |
| | | @PostMapping("/selctProductCount") |
| | | public R selctProductCount( String year) { |
| | | public R selctProductCount(String year) { |
| | | return R.data(farmProductStockService.selctProductCount(year)); |
| | | } |
| | | |
| | | /** |
| | | * 小程序统计产量详情 |
| | | * |
| | | * @param farmProductStock |
| | | * @return |
| | | */ |
| | | @GetMapping("/statisticsProductx") |
| | | public R statisticsProductx(FarmProductStockVO farmProductStock, Query query) { |
| | | Double zwei = 0.0; |
| | | IPage<FarmProductStockVO> pages = farmProductStockService.statisticsProductx(Condition.getPage(query), farmProductStock); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | String weight = pages.getRecords().get(i).getWeight(); |
| | | Double a=Double.parseDouble(weight); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String format = df.format(a); |
| | | //产量 |
| | | Double wei = Double.parseDouble(format); |
| | | pages.getRecords().get(i).setWeight(format); |
| | | zwei += wei; |
| | | } |
| | | Map map = new HashMap(); |
| | | List list = new ArrayList(); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String format = df.format(zwei); |
| | | map.put("zwei", format); |
| | | list.add(map); |
| | | list.add(pages); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 大屏经营概况库存数量与年产量 |
| | | */ |
| | | @GetMapping("/statisticsStockAndYield") |
| | | public R statisticsStockAndYield(String year,String farmId) { |
| | | |
| | | //库存数量统计 |
| | | Map map = new HashMap(); |
| | | //统计当前库存农产品 |
| | | Map<String, String> sum = farmProductStockService.statisticsStock(year, farmId); |
| | | //统计当前库存加工产品 |
| | | // Map<String, String> jgsum = null; |
| | | Double jgsum = processInvService.statisticsStock(year,farmId); |
| | | Double jgNcl = processService.statistics(year,farmId); |
| | | if (sum != null){ |
| | | map.put("sum",sum.get("sum")); |
| | | map.put("ncpNcl", sum.get("cssum")); |
| | | }else{ |
| | | map.put("sum",0); |
| | | map.put("ncpNcl",0); |
| | | } |
| | | map.put("jgsum",jgsum); |
| | | |
| | | //农产品年产量统计 |
| | | // List<Map<String, Double>> Nsum = farmProductStockService.statisticsYield(year, deptId); |
| | | // double ncpNcl = Nsum.get(1).get("sum") + Nsum.get(0).get("sum"); |
| | | |
| | | |
| | | |
| | | //加工产品年产量统计 |
| | | map.put("jgNcl",jgNcl); |
| | | return R.data(map); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 按月份统计产量 |
| | | */ |
| | | @GetMapping("/statisticsStockMonth") |
| | | public R statisticsStockMonth(String year,String farmId) { |
| | | |
| | | //采收数量统计 |
| | | Map<String,List<Map<String, String>>> map = new HashMap(); |
| | | List<Map<String, String>> cssum = farmProductStockService.statisticsStockMonth(year, farmId); |
| | | //加工产品数量统计 |
| | | List<Map<String, String>> jgsum = processService.statisticsMonth(year,farmId); |
| | | |
| | | map.put("csssum",cssum); |
| | | map.put("jgsum",jgsum); |
| | | return R.data(map); |
| | | } |
| | | |
| | | /** |
| | | * 农产品监管 |
| | | */ |
| | | @GetMapping("/productsSupervise") |
| | | public R productsSupervise(String year,String farmId) { |
| | | |
| | | Map<String, String> cssum = farmProductStockService.productsSupervise(year, farmId); |
| | | |
| | | return R.data(cssum); |
| | | } |
| | | |
| | | @GetMapping("/getByLandId") |
| | | public R getByLandId(String strainId,String landId){ |
| | | FarmProductStock farmProductStock = farmProductStockService.selectBy2Id(strainId,landId); |
| | | return R.data(farmProductStock); |
| | | } |
| | | |
| | | } |