| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.stock.vo.StocksVO; |
| | | import org.springblade.modules.stockrecord.entity.Stockrecord; |
| | | import org.springblade.modules.stockrecord.service.IStockrecordService; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import org.springblade.modules.stock.service.IStockService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 农资库存表 控制器 |
| | |
| | | public class StockController extends BladeController { |
| | | |
| | | private final IStockService stockService; |
| | | private final IDictBizService dictService; |
| | | private final IStockrecordService stockrecordService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | |
| | | @ApiOperation(value = "分页", notes = "传入stock") |
| | | public R<IPage<StockVO>> page(StockVO stock, Query query) { |
| | | IPage<StockVO> pages = stockService.selectLists(Condition.getPage(query), stock); |
| | | for (int i=0;i<pages.getRecords().size();i++){ |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | String specs = pages.getRecords().get(i).getSpecs(); |
| | | Integer amount = pages.getRecords().get(i).getAmount(); |
| | | Integer num = Integer.parseInt(specs); |
| | | String dic1 = pages.getRecords().get(i).getDic1(); |
| | | String dic2 = pages.getRecords().get(i).getDic2(); |
| | | String s = specs+dic1 +"/"+ dic2; |
| | | String s = specs + dic1 + "/" + dic2; |
| | | pages.getRecords().get(i).setSpn(s); |
| | | pages.getRecords().get(i).setCnum(num * amount); |
| | | |
| | | } |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 自定义分页 农资库存表 |
| | | */ |
| | | @GetMapping("/pages") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入stock") |
| | | public R<List<StockVO>> pages(StockVO stock) { |
| | | List<StockVO> pages = stockService.selectListss(stock); |
| | | for (int i = 0; i < pages.size(); i++) { |
| | | String specs = pages.get(i).getSpecs(); |
| | | Integer amount = pages.get(i).getAmount(); |
| | | Integer num = Integer.parseInt(specs); |
| | | String dic1 = pages.get(i).getDic1(); |
| | | String dic2 = pages.get(i).getDic2(); |
| | | String s = specs + dic1 + "/" + dic2; |
| | | pages.get(i).setSpn(s); |
| | | pages.get(i).setCnum(num * amount); |
| | | |
| | | } |
| | | return R.data(pages); |
| | |
| | | stock.setState("0"); |
| | | stock.setSp1("stockSpecs1"); |
| | | stock.setSp2("stockSpecs2"); |
| | | return R.status(stockService.save(stock)); |
| | | boolean save = stockService.save(stock); |
| | | //农资记录表 |
| | | Stockrecord stockrecord = new Stockrecord(); |
| | | //农资ID |
| | | stockrecord.setSid(stock.getId()); |
| | | stockrecord.setStockId1(stock.getStockId()); |
| | | stockrecord.setAmount1(stock.getAmount()); |
| | | stockrecord.setTime1(stock.getTime()); |
| | | stockrecord.setType1(stock.getType()); |
| | | stockrecord.setStockType1(1); |
| | | stockrecord.setPicture1(stock.getPicture()); |
| | | stockrecord.setRemarks1(stock.getRemarks()); |
| | | stockrecord.setSpecs1(stock.getSpecs()); |
| | | stockrecord.setSpecsVal1(stock.getSpecsValue1()); |
| | | stockrecord.setSpecsVal2(stock.getSpecsValue2()); |
| | | stockrecord.setDeptId(stock.getDeptId()); |
| | | stockrecord.setSp1("stockSpecs1"); |
| | | stockrecord.setSp2("stockSpecs2"); |
| | | //统计公斤 |
| | | Integer amount = stock.getAmount(); |
| | | String specs = stock.getSpecs(); |
| | | int i = Integer.parseInt(specs); |
| | | Integer specsValue1 = stock.getSpecsValue1(); |
| | | double v = 0; |
| | | //克 |
| | | if (specsValue1 == 0) { |
| | | v = amount * i * 0.001; |
| | | } |
| | | //斤 |
| | | if (specsValue1 == 1) { |
| | | v = amount * i * 0.5; |
| | | } |
| | | //公斤 |
| | | if (specsValue1 == 2) { |
| | | v = amount * i; |
| | | } |
| | | //吨 |
| | | if (specsValue1 == 3) { |
| | | v = amount * i * 1000; |
| | | } |
| | | //毫升 |
| | | if (specsValue1 == 4) { |
| | | //毫升换成升 |
| | | double s = amount * i * 0.001; |
| | | //升换成公斤 |
| | | v = s; |
| | | } |
| | | //升 |
| | | if (specsValue1 == 5) { |
| | | v = amount * i; |
| | | } |
| | | stockrecord.setCensus(v); |
| | | stockrecordService.save(stockrecord); |
| | | return R.status(save); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.status(stockService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 数据统计 |
| | | * |
| | | * @param stock |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @PostMapping("/pagenum") |
| | | public R<IPage<StocksVO>> pagenum(StocksVO stock, Query query) { |
| | | IPage<StocksVO> pages = stockService.slectNum(Condition.getPage(query), stock); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | Double cgnum = pages.getRecords().get(i).getCgnum(); |
| | | Double dbrknum = pages.getRecords().get(i).getDbrknum(); |
| | | double v = cgnum + dbrknum; |
| | | pages.getRecords().get(i).setRknum(v); |
| | | Double lycknum = pages.getRecords().get(i).getLycknum(); |
| | | Double dbcknum = pages.getRecords().get(i).getDbcknum(); |
| | | Double bfcknum = pages.getRecords().get(i).getBfcknum(); |
| | | double v1 = lycknum + dbcknum + bfcknum; |
| | | pages.getRecords().get(i).setCknum(v1); |
| | | } |
| | | return R.data(pages); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 首页农资入库数量统计 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/StockCount") |
| | | public R StockCount(String deptId) { |
| | | List<Map<String, Object>> maps = stockService.StockCount(deptId); |
| | | //化肥0 |
| | | double hf = 0; |
| | | //有机肥1 |
| | | double yjf = 0; |
| | | //杀虫剂2 |
| | | double scj = 0; |
| | | //杀菌剂3 |
| | | double sjj = 0; |
| | | //饲料4 |
| | | double sl = 0; |
| | | for (int i = 0; i < maps.size(); i++) { |
| | | //规格 |
| | | String specs = maps.get(i).get("specs").toString(); |
| | | Integer specs1 = Integer.parseInt(specs); |
| | | //数量 |
| | | String amount = maps.get(i).get("amount").toString(); |
| | | Integer amount1 = Integer.parseInt(amount); |
| | | //规格类型 |
| | | String spe = maps.get(i).get("spe").toString(); |
| | | //类型 |
| | | String type = maps.get(i).get("type").toString(); |
| | | if (type.equals("0")) { |
| | | //克 |
| | | if (spe.equals("0")) { |
| | | hf += amount1 * specs1 * 0.001; |
| | | } |
| | | //斤 |
| | | if (spe.equals("1")) { |
| | | hf += amount1 * specs1 * 0.5; |
| | | } |
| | | //公斤 |
| | | if (spe.equals("2")) { |
| | | hf += amount1 * specs1; |
| | | } |
| | | //吨 |
| | | if (spe.equals("3")) { |
| | | hf += amount1 * specs1 * 1000; |
| | | } |
| | | //毫升 |
| | | if (spe.equals("4")) { |
| | | //毫升换成升 |
| | | double s = amount1 * specs1 * 0.001; |
| | | //升换成公斤 |
| | | hf += s; |
| | | } |
| | | //升 |
| | | if (spe.equals("5")) { |
| | | hf += amount1 * specs1; |
| | | } |
| | | } |
| | | if (type.equals("1")) { |
| | | //克 |
| | | if (spe.equals("0")) { |
| | | yjf += amount1 * specs1 * 0.001; |
| | | } |
| | | //斤 |
| | | if (spe.equals("1")) { |
| | | yjf += amount1 * specs1 * 0.5; |
| | | } |
| | | //公斤 |
| | | if (spe.equals("2")) { |
| | | yjf += amount1 * specs1; |
| | | } |
| | | //吨 |
| | | if (spe.equals("3")) { |
| | | yjf += amount1 * specs1 * 1000; |
| | | } |
| | | //毫升 |
| | | if (spe.equals("4")) { |
| | | //毫升换成升 |
| | | double s = amount1 * specs1 * 0.001; |
| | | //升换成公斤 |
| | | yjf += s; |
| | | } |
| | | //升 |
| | | if (spe.equals("5")) { |
| | | yjf += amount1 * specs1; |
| | | } |
| | | } |
| | | if (type.equals("2")) { |
| | | //克 |
| | | if (spe.equals("0")) { |
| | | scj += amount1 * specs1 * 0.001; |
| | | } |
| | | //斤 |
| | | if (spe.equals("1")) { |
| | | scj += amount1 * specs1 * 0.5; |
| | | } |
| | | //公斤 |
| | | if (spe.equals("2")) { |
| | | scj += amount1 * specs1; |
| | | } |
| | | //吨 |
| | | if (spe.equals("3")) { |
| | | scj += amount1 * specs1 * 1000; |
| | | } |
| | | //毫升 |
| | | if (spe.equals("4")) { |
| | | //毫升换成升 |
| | | double s = amount1 * specs1 * 0.001; |
| | | //升换成公斤 |
| | | scj += s; |
| | | } |
| | | //升 |
| | | if (spe.equals("5")) { |
| | | scj += amount1 * specs1; |
| | | } |
| | | } |
| | | if (type.equals("3")) { |
| | | //克 |
| | | if (spe.equals("0")) { |
| | | sjj += amount1 * specs1 * 0.001; |
| | | } |
| | | //斤 |
| | | if (spe.equals("1")) { |
| | | sjj += amount1 * specs1 * 0.5; |
| | | } |
| | | //公斤 |
| | | if (spe.equals("2")) { |
| | | sjj += amount1 * specs1; |
| | | } |
| | | //吨 |
| | | if (spe.equals("3")) { |
| | | sjj += amount1 * specs1 * 1000; |
| | | } |
| | | //毫升 |
| | | if (spe.equals("4")) { |
| | | //毫升换成升 |
| | | double s = amount1 * specs1 * 0.001; |
| | | //升换成公斤 |
| | | sjj += s; |
| | | } |
| | | //升 |
| | | if (spe.equals("5")) { |
| | | sjj += amount1 * specs1; |
| | | } |
| | | } |
| | | if (type.equals("4")) { |
| | | //克 |
| | | if (spe.equals("0")) { |
| | | sl += amount1 * specs1 * 0.001; |
| | | } |
| | | //斤 |
| | | if (spe.equals("1")) { |
| | | sl += amount1 * specs1 * 0.5; |
| | | } |
| | | //公斤 |
| | | if (spe.equals("2")) { |
| | | sl += amount1 * specs1; |
| | | } |
| | | //吨 |
| | | if (spe.equals("3")) { |
| | | sl += amount1 * specs1 * 1000; |
| | | } |
| | | //毫升 |
| | | if (spe.equals("4")) { |
| | | //毫升换成升 |
| | | double s = amount1 * specs1 * 0.001; |
| | | //升换成公斤 |
| | | sl += s; |
| | | } |
| | | //升 |
| | | if (spe.equals("5")) { |
| | | sl += amount1 * specs1; |
| | | } |
| | | } |
| | | } |
| | | Map map = new HashMap(); |
| | | map.put("name", "化肥"); |
| | | map.put("val", new BigDecimal(hf).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | Map map1 = new HashMap(); |
| | | map1.put("name", "有机肥"); |
| | | map1.put("val", new BigDecimal(String.valueOf(yjf)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | Map map2 = new HashMap(); |
| | | map2.put("name", "杀虫剂"); |
| | | map2.put("val", new BigDecimal(String.valueOf(scj)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | Map map3 = new HashMap(); |
| | | map3.put("name", "杀菌剂"); |
| | | map3.put("val", new BigDecimal(String.valueOf(sjj)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | Map map4 = new HashMap(); |
| | | map4.put("name", "饲料"); |
| | | map4.put("val", new BigDecimal(String.valueOf(sl)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | List list = new ArrayList(); |
| | | list.add(map); |
| | | list.add(map1); |
| | | list.add(map2); |
| | | list.add(map3); |
| | | list.add(map4); |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 小程序数据统计 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/pagenumx") |
| | | public R pagenumx(String deptId, String startTime, String endTime) { |
| | | Double rknu = 0.0; |
| | | Double cknu = 0.0; |
| | | List<StocksVO> pages = stockService.slectNumx(deptId, startTime, endTime); |
| | | for (int i = 0; i < pages.size(); i++) { |
| | | Double cgnum = pages.get(i).getCgnum(); |
| | | Double dbrknum = pages.get(i).getDbrknum(); |
| | | double v = cgnum + dbrknum; |
| | | pages.get(i).setRknum(v); |
| | | Double lycknum = pages.get(i).getLycknum(); |
| | | Double dbcknum = pages.get(i).getDbcknum(); |
| | | Double bfcknum = pages.get(i).getBfcknum(); |
| | | double v1 = lycknum + dbcknum + bfcknum; |
| | | pages.get(i).setCknum(v1); |
| | | } |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | Double rknum = pages.get(j).getRknum(); |
| | | Double cknum = pages.get(j).getCknum(); |
| | | rknu += rknum; |
| | | cknu += cknum; |
| | | } |
| | | Map map = new HashMap(); |
| | | DecimalFormat df = new DecimalFormat("#0.000"); |
| | | String format = df.format(rknu); |
| | | Double a = Double.parseDouble(format); |
| | | String format1 = df.format(cknu); |
| | | double b = Double.parseDouble(format1); |
| | | map.put("rknum", a); |
| | | map.put("cknum", b); |
| | | return R.data(map); |
| | | } |
| | | |
| | | /** |
| | | * 小程序农资数据统计详情 |
| | | * |
| | | * @param stock |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @GetMapping("/pagenums") |
| | | public R pagenums(StocksVO stock, Query query) { |
| | | Double rknu = 0.0; |
| | | Double cknu = 0.0; |
| | | IPage<StocksVO> pages = stockService.slectNum(Condition.getPage(query), stock); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | Double cgnum = pages.getRecords().get(i).getCgnum(); |
| | | Double dbrknum = pages.getRecords().get(i).getDbrknum(); |
| | | double v = cgnum + dbrknum; |
| | | pages.getRecords().get(i).setRknum(v); |
| | | Double lycknum = pages.getRecords().get(i).getLycknum(); |
| | | Double dbcknum = pages.getRecords().get(i).getDbcknum(); |
| | | Double bfcknum = pages.getRecords().get(i).getBfcknum(); |
| | | double v1 = lycknum + dbcknum + bfcknum; |
| | | pages.getRecords().get(i).setCknum(v1); |
| | | } |
| | | for (int j = 0; j < pages.getRecords().size(); j++) { |
| | | Double rknum = pages.getRecords().get(j).getRknum(); |
| | | Double cknum = pages.getRecords().get(j).getCknum(); |
| | | rknu += rknum; |
| | | cknu += cknum; |
| | | } |
| | | Map map = new HashMap(); |
| | | DecimalFormat df = new DecimalFormat("#0.000"); |
| | | String format = df.format(rknu); |
| | | Double a = Double.parseDouble(format); |
| | | String format1 = df.format(cknu); |
| | | double b = Double.parseDouble(format1); |
| | | map.put("rknum", a); |
| | | map.put("cknum", b); |
| | | List list = new ArrayList(); |
| | | list.add(map); |
| | | list.add(pages); |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | } |