ProductionheaderController.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.zjt.web;
  2. import com.zjt.entity.ProductionVariety;
  3. import com.zjt.service.IProductionVarietyDetailService;
  4. import com.zjt.service.IProductionVarietyService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import javax.annotation.Resource;
  9. /**
  10. * <p>
  11. * 前端控制器
  12. * </p>
  13. *
  14. * @author xxu
  15. * @since 2025-09-25
  16. */
  17. @Controller
  18. @RequestMapping("/entity/productionheader")
  19. public class ProductionheaderController {
  20. private static final String VIEW_VARIETY_LIST = "mypackage/varietyList";
  21. @Autowired
  22. private IProductionVarietyService productionVarietyService;
  23. @Autowired
  24. private IProductionVarietyDetailService productionVarietyDetailService;
  25. @RequestMapping("list")
  26. public String selectVarietyAll() {
  27. productionVarietyService.varietyList();
  28. productionVarietyDetailService.selectvarietyList();
  29. productionVarietyDetailService.selectvarietyDetails(1l);
  30. return VIEW_VARIETY_LIST;
  31. }
  32. @RequestMapping("add")
  33. public String varietyAdd(String materialTypeCode) {
  34. if (materialTypeCode == null || materialTypeCode.isEmpty()) {
  35. // 可以抛异常或返回错误页面,这里简化处理
  36. return VIEW_VARIETY_LIST;
  37. }
  38. ProductionVariety productionVariety = createProductionVariety(materialTypeCode);
  39. productionVarietyService.save(productionVariety);
  40. return VIEW_VARIETY_LIST;
  41. }
  42. @RequestMapping("update")
  43. public String varietyUpdate(String materialTypeCode) {
  44. if (materialTypeCode == null || materialTypeCode.isEmpty()) {
  45. return VIEW_VARIETY_LIST;
  46. }
  47. ProductionVariety productionVariety = createProductionVariety(materialTypeCode);
  48. productionVarietyService.saveOrUpdate(productionVariety);
  49. return VIEW_VARIETY_LIST;
  50. }
  51. private ProductionVariety createProductionVariety(String materialTypeCode) {
  52. ProductionVariety productionVariety = new ProductionVariety();
  53. productionVariety.setVariety(materialTypeCode);
  54. return productionVariety;
  55. }
  56. }