班次奶量
This commit is contained in:
parent
5c5a27bdea
commit
f999f00a6e
@ -0,0 +1,70 @@
|
||||
package com.zhyc.module.dairyProducts.controller;
|
||||
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
|
||||
import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/milkInOutStore")
|
||||
public class NpMilkInOutStoreController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private INpMilkInOutStoreService service;
|
||||
|
||||
/** 查询(日期区间)+ 动态列 */
|
||||
@PreAuthorize("@ss.hasPermi('milkInOutStore:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(
|
||||
@RequestParam(required=false) Date datetimeStart,
|
||||
@RequestParam(required=false) Date datetimeEnd
|
||||
) {
|
||||
startPage();
|
||||
List<Map<String, Object>> rows = service.selectWithDynamicColumns(datetimeStart, datetimeEnd);
|
||||
return getDataTable(rows);
|
||||
}
|
||||
|
||||
/** 导入 Excel */
|
||||
@Log(title="导入羊奶出入库", businessType=BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('milkInOutStore:import')")
|
||||
@PostMapping("/import")
|
||||
public AjaxResult importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<Map<String,Object>> list = service.parseImportExcel(file);
|
||||
service.batchInsertFromRows(list);
|
||||
return AjaxResult.success("导入成功");
|
||||
}
|
||||
|
||||
/** 导出 Excel */
|
||||
@PreAuthorize("@ss.hasPermi('milkInOutStore:export')")
|
||||
@Log(title="导出羊奶出入库", businessType=BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response,
|
||||
@RequestParam(required=false) Date datetimeStart,
|
||||
@RequestParam(required=false) Date datetimeEnd
|
||||
) {
|
||||
List<Map<String,Object>> rows = service.selectWithDynamicColumns(datetimeStart, datetimeEnd);
|
||||
// 解决方案:强制转换并压制警告
|
||||
@SuppressWarnings("unchecked")
|
||||
ExcelUtil<Map<String,Object>> util = new ExcelUtil<>((Class<Map<String,Object>>) (Class<?>) Map.class);
|
||||
}
|
||||
|
||||
/** 获取可选列定义(饲喂来源 + 销售去向) */
|
||||
@PreAuthorize("@ss.hasPermi('milkInOutStore:cols')")
|
||||
@GetMapping("/columns")
|
||||
public AjaxResult getColumns(){
|
||||
return AjaxResult.success(service.getAllColumnOptions());
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.zhyc.module.dairyProducts.controller;
|
||||
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis;
|
||||
import com.zhyc.module.dairyProducts.service.INpSheepMilkAnalysisService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dairyProducts/sheepMilkAnalysis")
|
||||
public class NpSheepMilkAnalysisController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private INpSheepMilkAnalysisService npSheepMilkAnalysisService;
|
||||
|
||||
/**
|
||||
* 查询奶产量分析列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(NpSheepMilkAnalysis analysis) {
|
||||
startPage();
|
||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个分析记录详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(npSheepMilkAnalysisService.selectNpSheepMilkAnalysisById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增奶产量分析记录
|
||||
*/
|
||||
@Log(title = "奶产量分析", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody NpSheepMilkAnalysis analysis) {
|
||||
return toAjax(npSheepMilkAnalysisService.insertNpSheepMilkAnalysis(analysis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改奶产量分析记录
|
||||
*/
|
||||
@Log(title = "奶产量分析", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody NpSheepMilkAnalysis analysis) {
|
||||
return toAjax(npSheepMilkAnalysisService.updateNpSheepMilkAnalysis(analysis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除奶产量分析记录
|
||||
*/
|
||||
@Log(title = "奶产量分析", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(npSheepMilkAnalysisService.deleteNpSheepMilkAnalysisByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出奶产量分析记录
|
||||
*/
|
||||
@Log(title = "奶产量分析", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(NpSheepMilkAnalysis analysis) {
|
||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
|
||||
ExcelUtil<NpSheepMilkAnalysis> util = new ExcelUtil<>(NpSheepMilkAnalysis.class);
|
||||
return util.exportExcel(list, "奶产量分析数据");
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package com.zhyc.module.dairyProducts.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
public class NpMilkInOutStore extends BaseEntity {
|
||||
private Integer id;
|
||||
|
||||
@Excel(name = "日期")
|
||||
private Date datetime;
|
||||
|
||||
@Excel(name = "羊数")
|
||||
private Integer num;
|
||||
|
||||
@Excel(name = "初乳羊")
|
||||
private Integer colostSheep;
|
||||
|
||||
@Excel(name = "商乳入库")
|
||||
private BigDecimal commercialIntake;
|
||||
|
||||
@Excel(name = "抗乳入库")
|
||||
private BigDecimal antiIntake;
|
||||
|
||||
@Excel(name = "初乳入库")
|
||||
private BigDecimal colostIntake;
|
||||
|
||||
@Excel(name = "入库小计")
|
||||
private BigDecimal intakeTotal;
|
||||
|
||||
@Excel(name = "商乳实验用奶")
|
||||
private BigDecimal commercialTest;
|
||||
|
||||
@Excel(name = "初乳实验用奶")
|
||||
private BigDecimal colostTest;
|
||||
|
||||
@Excel(name = "商乳调拨出库")
|
||||
private BigDecimal transferCommercial;
|
||||
|
||||
@Excel(name = "抗乳调拨出库")
|
||||
private BigDecimal transferAnti;
|
||||
|
||||
@Excel(name = "初乳调拨出库")
|
||||
private BigDecimal transferColost;
|
||||
|
||||
@Excel(name = "调拨小计")
|
||||
private BigDecimal transferTotal;
|
||||
|
||||
@Excel(name = "损耗")
|
||||
private BigDecimal loss;
|
||||
|
||||
@Excel(name = "商乳库存")
|
||||
private BigDecimal stockCommercial;
|
||||
|
||||
@Excel(name = "抗乳库存")
|
||||
private BigDecimal stockAnti;
|
||||
|
||||
@Excel(name = "初乳库存")
|
||||
private BigDecimal colost;
|
||||
|
||||
@Excel(name = "爱特退回鲜奶")
|
||||
private BigDecimal returnFresh;
|
||||
|
||||
@Excel(name = "爱特退回酸奶")
|
||||
private BigDecimal returnYogurt;
|
||||
|
||||
// --- getters and setters ---
|
||||
public Integer getId() { return id; }
|
||||
public void setId(Integer id) { this.id = id; }
|
||||
|
||||
public Date getDatetime() { return datetime; }
|
||||
public void setDatetime(Date datetime) { this.datetime = datetime; }
|
||||
|
||||
public Integer getNum() { return num; }
|
||||
public void setNum(Integer num) { this.num = num; }
|
||||
|
||||
public Integer getColostSheep() { return colostSheep; }
|
||||
public void setColostSheep(Integer colostSheep) { this.colostSheep = colostSheep; }
|
||||
|
||||
public BigDecimal getCommercialIntake() { return commercialIntake; }
|
||||
public void setCommercialIntake(BigDecimal commercialIntake) { this.commercialIntake = commercialIntake; }
|
||||
|
||||
public BigDecimal getAntiIntake() { return antiIntake; }
|
||||
public void setAntiIntake(BigDecimal antiIntake) { this.antiIntake = antiIntake; }
|
||||
|
||||
public BigDecimal getColostIntake() { return colostIntake; }
|
||||
public void setColostIntake(BigDecimal colostIntake) { this.colostIntake = colostIntake; }
|
||||
|
||||
public BigDecimal getIntakeTotal() { return intakeTotal; }
|
||||
public void setIntakeTotal(BigDecimal intakeTotal) { this.intakeTotal = intakeTotal; }
|
||||
|
||||
public BigDecimal getCommercialTest() { return commercialTest; }
|
||||
public void setCommercialTest(BigDecimal commercialTest) { this.commercialTest = commercialTest; }
|
||||
|
||||
public BigDecimal getColostTest() { return colostTest; }
|
||||
public void setColostTest(BigDecimal colostTest) { this.colostTest = colostTest; }
|
||||
|
||||
public BigDecimal getTransferCommercial() { return transferCommercial; }
|
||||
public void setTransferCommercial(BigDecimal transferCommercial) { this.transferCommercial = transferCommercial; }
|
||||
|
||||
public BigDecimal getTransferAnti() { return transferAnti; }
|
||||
public void setTransferAnti(BigDecimal transferAnti) { this.transferAnti = transferAnti; }
|
||||
|
||||
public BigDecimal getTransferColost() { return transferColost; }
|
||||
public void setTransferColost(BigDecimal transferColost) { this.transferColost = transferColost; }
|
||||
|
||||
public BigDecimal getTransferTotal() { return transferTotal; }
|
||||
public void setTransferTotal(BigDecimal transferTotal) { this.transferTotal = transferTotal; }
|
||||
|
||||
public BigDecimal getLoss() { return loss; }
|
||||
public void setLoss(BigDecimal loss) { this.loss = loss; }
|
||||
|
||||
public BigDecimal getStockCommercial() { return stockCommercial; }
|
||||
public void setStockCommercial(BigDecimal stockCommercial) { this.stockCommercial = stockCommercial; }
|
||||
|
||||
public BigDecimal getStockAnti() { return stockAnti; }
|
||||
public void setStockAnti(BigDecimal stockAnti) { this.stockAnti = stockAnti; }
|
||||
|
||||
public BigDecimal getColost() { return colost; }
|
||||
public void setColost(BigDecimal colost) { this.colost = colost; }
|
||||
|
||||
public BigDecimal getReturnFresh() { return returnFresh; }
|
||||
public void setReturnFresh(BigDecimal returnFresh) { this.returnFresh = returnFresh; }
|
||||
|
||||
public BigDecimal getReturnYogurt() { return returnYogurt; }
|
||||
public void setReturnYogurt(BigDecimal returnYogurt) { this.returnYogurt = returnYogurt; }
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.zhyc.module.dairyProducts.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class NpSheepMilkAnalysis {
|
||||
private String sheepId;
|
||||
private String manageEarTag;
|
||||
private String variety;
|
||||
private Date milkingStartTime;
|
||||
private Date dryEndTime;
|
||||
private Integer milkingDays;
|
||||
private Integer analysisDays;
|
||||
private Integer maxParity;
|
||||
private Double sumSystemMilk;
|
||||
private Double sumCorrectedMilk;
|
||||
private Double avgCorrectedDaily;
|
||||
private Double sumParity1Milk;
|
||||
private Double sumParity2Milk;
|
||||
private Double sumParity3Milk;
|
||||
private Double sumParity4Milk;
|
||||
private Double avgParity1Daily;
|
||||
private Double avgParity2Daily;
|
||||
private Double avgParity3Daily;
|
||||
private Double avgParity4Daily;
|
||||
private Integer lactationDays;
|
||||
private Double avgLast7Milk;
|
||||
private Double avgLast7Corrected;
|
||||
private Double avgLast14Milk;
|
||||
private Double avgLast30Milk;
|
||||
private String sheepCategory;
|
||||
private Date birthday;
|
||||
private Integer parity;
|
||||
private Integer monthAge;
|
||||
private Double currentWeight;
|
||||
private String breedStatus;
|
||||
private String fatherManageTags;
|
||||
private String motherManageTags;
|
||||
private String ranchName;
|
||||
private String family;
|
||||
private Integer motherMilkingDays;
|
||||
private Double motherSumCorrected;
|
||||
private Integer motherMaxParity;
|
||||
private Double motherAvgCorrectedDaily;
|
||||
private Date lastUpdate;
|
||||
|
||||
public String getSheepId() { return sheepId; }
|
||||
public void setSheepId(String sheepId) { this.sheepId = sheepId; }
|
||||
|
||||
public String getManageEarTag() { return manageEarTag; }
|
||||
public void setManageEarTag(String manageEarTag) { this.manageEarTag = manageEarTag; }
|
||||
|
||||
public String getVariety() { return variety; }
|
||||
public void setVariety(String variety) { this.variety = variety; }
|
||||
|
||||
public Date getMilkingStartTime() { return milkingStartTime; }
|
||||
public void setMilkingStartTime(Date milkingStartTime) { this.milkingStartTime = milkingStartTime; }
|
||||
|
||||
public Date getDryEndTime() { return dryEndTime; }
|
||||
public void setDryEndTime(Date dryEndTime) { this.dryEndTime = dryEndTime; }
|
||||
|
||||
public Integer getMilkingDays() { return milkingDays; }
|
||||
public void setMilkingDays(Integer milkingDays) { this.milkingDays = milkingDays; }
|
||||
|
||||
public Integer getAnalysisDays() { return analysisDays; }
|
||||
public void setAnalysisDays(Integer analysisDays) { this.analysisDays = analysisDays; }
|
||||
|
||||
public Integer getMaxParity() { return maxParity; }
|
||||
public void setMaxParity(Integer maxParity) { this.maxParity = maxParity; }
|
||||
|
||||
public Double getSumSystemMilk() { return sumSystemMilk; }
|
||||
public void setSumSystemMilk(Double sumSystemMilk) { this.sumSystemMilk = sumSystemMilk; }
|
||||
|
||||
public Double getSumCorrectedMilk() { return sumCorrectedMilk; }
|
||||
public void setSumCorrectedMilk(Double sumCorrectedMilk) { this.sumCorrectedMilk = sumCorrectedMilk; }
|
||||
|
||||
public Double getAvgCorrectedDaily() { return avgCorrectedDaily; }
|
||||
public void setAvgCorrectedDaily(Double avgCorrectedDaily) { this.avgCorrectedDaily = avgCorrectedDaily; }
|
||||
|
||||
public Double getSumParity1Milk() { return sumParity1Milk; }
|
||||
public void setSumParity1Milk(Double sumParity1Milk) { this.sumParity1Milk = sumParity1Milk; }
|
||||
|
||||
public Double getSumParity2Milk() { return sumParity2Milk; }
|
||||
public void setSumParity2Milk(Double sumParity2Milk) { this.sumParity2Milk = sumParity2Milk; }
|
||||
|
||||
public Double getSumParity3Milk() { return sumParity3Milk; }
|
||||
public void setSumParity3Milk(Double sumParity3Milk) { this.sumParity3Milk = sumParity3Milk; }
|
||||
|
||||
public Double getSumParity4Milk() { return sumParity4Milk; }
|
||||
public void setSumParity4Milk(Double sumParity4Milk) { this.sumParity4Milk = sumParity4Milk; }
|
||||
|
||||
public Double getAvgParity1Daily() { return avgParity1Daily; }
|
||||
public void setAvgParity1Daily(Double avgParity1Daily) { this.avgParity1Daily = avgParity1Daily; }
|
||||
|
||||
public Double getAvgParity2Daily() { return avgParity2Daily; }
|
||||
public void setAvgParity2Daily(Double avgParity2Daily) { this.avgParity2Daily = avgParity2Daily; }
|
||||
|
||||
public Double getAvgParity3Daily() { return avgParity3Daily; }
|
||||
public void setAvgParity3Daily(Double avgParity3Daily) { this.avgParity3Daily = avgParity3Daily; }
|
||||
|
||||
public Double getAvgParity4Daily() { return avgParity4Daily; }
|
||||
public void setAvgParity4Daily(Double avgParity4Daily) { this.avgParity4Daily = avgParity4Daily; }
|
||||
|
||||
public Integer getLactationDays() { return lactationDays; }
|
||||
public void setLactationDays(Integer lactationDays) { this.lactationDays = lactationDays; }
|
||||
|
||||
public Double getAvgLast7Milk() { return avgLast7Milk; }
|
||||
public void setAvgLast7Milk(Double avgLast7Milk) { this.avgLast7Milk = avgLast7Milk; }
|
||||
|
||||
public Double getAvgLast7Corrected() { return avgLast7Corrected; }
|
||||
public void setAvgLast7Corrected(Double avgLast7Corrected) { this.avgLast7Corrected = avgLast7Corrected; }
|
||||
|
||||
public Double getAvgLast14Milk() { return avgLast14Milk; }
|
||||
public void setAvgLast14Milk(Double avgLast14Milk) { this.avgLast14Milk = avgLast14Milk; }
|
||||
|
||||
public Double getAvgLast30Milk() { return avgLast30Milk; }
|
||||
public void setAvgLast30Milk(Double avgLast30Milk) { this.avgLast30Milk = avgLast30Milk; }
|
||||
|
||||
public String getSheepCategory() { return sheepCategory; }
|
||||
public void setSheepCategory(String sheepCategory) { this.sheepCategory = sheepCategory; }
|
||||
|
||||
public Date getBirthday() { return birthday; }
|
||||
public void setBirthday(Date birthday) { this.birthday = birthday; }
|
||||
|
||||
public Integer getParity() { return parity; }
|
||||
public void setParity(Integer parity) { this.parity = parity; }
|
||||
|
||||
public Integer getMonthAge() { return monthAge; }
|
||||
public void setMonthAge(Integer monthAge) { this.monthAge = monthAge; }
|
||||
|
||||
public Double getCurrentWeight() { return currentWeight; }
|
||||
public void setCurrentWeight(Double currentWeight) { this.currentWeight = currentWeight; }
|
||||
|
||||
public String getBreedStatus() { return breedStatus; }
|
||||
public void setBreedStatus(String breedStatus) { this.breedStatus = breedStatus; }
|
||||
|
||||
public String getFatherManageTags() { return fatherManageTags; }
|
||||
public void setFatherManageTags(String fatherManageTags) { this.fatherManageTags = fatherManageTags; }
|
||||
|
||||
public String getMotherManageTags() { return motherManageTags; }
|
||||
public void setMotherManageTags(String motherManageTags) { this.motherManageTags = motherManageTags; }
|
||||
|
||||
public String getRanchName() { return ranchName; }
|
||||
public void setRanchName(String ranchName) { this.ranchName = ranchName; }
|
||||
|
||||
public String getFamily() { return family; }
|
||||
public void setFamily(String family) { this.family = family; }
|
||||
|
||||
public Integer getMotherMilkingDays() { return motherMilkingDays; }
|
||||
public void setMotherMilkingDays(Integer motherMilkingDays) { this.motherMilkingDays = motherMilkingDays; }
|
||||
|
||||
public Double getMotherSumCorrected() { return motherSumCorrected; }
|
||||
public void setMotherSumCorrected(Double motherSumCorrected) { this.motherSumCorrected = motherSumCorrected; }
|
||||
|
||||
public Integer getMotherMaxParity() { return motherMaxParity; }
|
||||
public void setMotherMaxParity(Integer motherMaxParity) { this.motherMaxParity = motherMaxParity; }
|
||||
|
||||
public Double getMotherAvgCorrectedDaily() { return motherAvgCorrectedDaily; }
|
||||
public void setMotherAvgCorrectedDaily(Double motherAvgCorrectedDaily) { this.motherAvgCorrectedDaily = motherAvgCorrectedDaily; }
|
||||
|
||||
public Date getLastUpdate() { return lastUpdate; }
|
||||
public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; }
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.zhyc.module.dairyProducts.mapper;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface NpMilkInOutStoreMapper {
|
||||
List<Map<String,Object>> selectWithColumns(
|
||||
@Param("start") Date start, @Param("end") Date end,
|
||||
@Param("feedSources") List<String> feedSources,
|
||||
@Param("saleDestinations") List<String> saleDestinations
|
||||
);
|
||||
|
||||
int insertStore(NpMilkInOutStore store);
|
||||
void insertFeedRecord(@Param("storeId") Integer storeId, @Param("source") String source, @Param("amount") java.math.BigDecimal amount);
|
||||
void insertSaleRecord(@Param("storeId") Integer storeId, @Param("destination") String dest, @Param("amount") java.math.BigDecimal amount);
|
||||
|
||||
List<String> selectFeedSources();
|
||||
List<String> selectSaleDestinations();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.zhyc.module.dairyProducts.mapper;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis;
|
||||
import java.util.List;
|
||||
|
||||
public interface NpSheepMilkAnalysisMapper {
|
||||
|
||||
NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id);
|
||||
|
||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int deleteNpSheepMilkAnalysisById(Long id);
|
||||
|
||||
int deleteNpSheepMilkAnalysisByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.zhyc.module.dairyProducts.service;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface INpMilkInOutStoreService {
|
||||
List<Map<String,Object>> selectWithDynamicColumns(Date start, Date end);
|
||||
List<Map<String,Object>> getAllColumnOptions();
|
||||
List<Map<String,Object>> parseImportExcel(MultipartFile file) throws Exception;
|
||||
void batchInsertFromRows(List<Map<String,Object>> rows) throws Exception;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.zhyc.module.dairyProducts.service;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis;
|
||||
import java.util.List;
|
||||
|
||||
public interface INpSheepMilkAnalysisService {
|
||||
|
||||
NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id);
|
||||
|
||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis);
|
||||
|
||||
int deleteNpSheepMilkAnalysisById(Long id);
|
||||
|
||||
int deleteNpSheepMilkAnalysisByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.zhyc.module.dairyProducts.service.impl;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
|
||||
import com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper;
|
||||
import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
|
||||
|
||||
@Autowired
|
||||
private NpMilkInOutStoreMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) {
|
||||
List<String> feed = mapper.selectFeedSources();
|
||||
List<String> sale = mapper.selectSaleDestinations();
|
||||
return mapper.selectWithColumns(start, end, feed, sale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getAllColumnOptions() {
|
||||
Map<String,Object> m = new HashMap<>();
|
||||
m.put("feed", mapper.selectFeedSources());
|
||||
m.put("sale", mapper.selectSaleDestinations());
|
||||
return Collections.singletonList(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> parseImportExcel(MultipartFile file) throws Exception {
|
||||
// 用 Apache POI 解析 Excel 第一行标题,动态映射列名跟 unit cells
|
||||
InputStream in = file.getInputStream();
|
||||
Workbook wb = WorkbookFactory.create(in);
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
Row header = sheet.getRow(0);
|
||||
int cols = header.getLastCellNum();
|
||||
List<String> titles = new ArrayList<>();
|
||||
for (int i = 0; i < cols; i++) titles.add(header.getCell(i).getStringCellValue());
|
||||
List<Map<String,Object>> rows = new ArrayList<>();
|
||||
for (int r = 1; r <= sheet.getLastRowNum(); r++) {
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null) continue;
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
for (int c = 0; c < cols; c++) {
|
||||
Cell cell = row.getCell(c);
|
||||
map.put(titles.get(c), cell == null ? null : cell.toString());
|
||||
}
|
||||
rows.add(map);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsertFromRows(List<Map<String, Object>> rows) throws Exception {
|
||||
for (Map<String,Object> row : rows) {
|
||||
// 提取主表字段
|
||||
NpMilkInOutStore store = new NpMilkInOutStore();
|
||||
store.setDatetime(java.sql.Date.valueOf(row.get("日期").toString()));
|
||||
store.setNum(Integer.valueOf(row.get("羊数").toString()));
|
||||
// ... 设置其它固定字段 ...
|
||||
mapper.insertStore(store);
|
||||
Integer sid = store.getId();
|
||||
// 其余列为动态饲喂或销售,根据字典决定分类:
|
||||
for (Map.Entry<String,Object> ent: row.entrySet()) {
|
||||
String col = ent.getKey();
|
||||
BigDecimal amt = new BigDecimal(ent.getValue().toString());
|
||||
if (mapper.selectFeedSources().contains(col)) {
|
||||
mapper.insertFeedRecord(sid, col, amt);
|
||||
} else if (mapper.selectSaleDestinations().contains(col)) {
|
||||
mapper.insertSaleRecord(sid, col, amt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.zhyc.module.dairyProducts.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper;
|
||||
import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis;
|
||||
import com.zhyc.module.dairyProducts.service.INpSheepMilkAnalysisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisService {
|
||||
|
||||
@Autowired
|
||||
private NpSheepMilkAnalysisMapper npSheepMilkAnalysisMapper;
|
||||
|
||||
@Override
|
||||
public NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id) {
|
||||
return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis) {
|
||||
return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisList(analysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis) {
|
||||
return npSheepMilkAnalysisMapper.insertNpSheepMilkAnalysis(analysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis) {
|
||||
return npSheepMilkAnalysisMapper.updateNpSheepMilkAnalysis(analysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteNpSheepMilkAnalysisById(Long id) {
|
||||
return npSheepMilkAnalysisMapper.deleteNpSheepMilkAnalysisById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteNpSheepMilkAnalysisByIds(Long[] ids) {
|
||||
return npSheepMilkAnalysisMapper.deleteNpSheepMilkAnalysisByIds(ids);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper">
|
||||
<select id="selectWithColumns" resultType="map">
|
||||
SELECT s.datetime, s.num, s.colost_sheep, s.commercial_intake, s.anti_intake,
|
||||
s.colost_intake, s.intake_total, s.commercial_test, s.colost_test,
|
||||
s.transfer_commercial, s.transfer_anti, s.transfer_colost, s.transfer_total,
|
||||
s.loss, s.stock_commercial, s.stock_anti, s.colost, s.return_fresh, s.return_yogurt
|
||||
<foreach collection="feedSources" item="f" open="," separator="," close="">
|
||||
SUM(CASE WHEN fr.source_id = (SELECT id FROM np_milk_feed WHERE source_name = #{f}) THEN fr.amount ELSE NULL END) AS `${f}`
|
||||
</foreach>
|
||||
<foreach collection="saleDestinations" item="d" open="," separator="," close="">
|
||||
SUM(CASE WHEN sr.destination_id = (SELECT id FROM np_milk_sale WHERE destination_name = #{d}) THEN sr.amount ELSE NULL END) AS `${d}`
|
||||
</foreach>
|
||||
FROM np_milk_in_out_store s
|
||||
LEFT JOIN np_milk_feed_records fr ON fr.store_id = s.id
|
||||
LEFT JOIN np_milk_sale_records sr ON sr.store_id = s.id
|
||||
<where>
|
||||
<if test="start != null"> s.datetime >= #{start}</if>
|
||||
<if test="end != null"> AND s.datetime <= #{end}</if>
|
||||
</where>
|
||||
GROUP BY s.id
|
||||
ORDER BY s.datetime
|
||||
</select>
|
||||
|
||||
<select id="selectFeedSources" resultType="string">SELECT source_name FROM np_milk_feed</select>
|
||||
<select id="selectSaleDestinations" resultType="string">SELECT destination_name FROM np_milk_sale</select>
|
||||
|
||||
<insert id="insertStore" useGeneratedKeys="true" keyProperty="id" parameterType="com.zhyc.module.dairyProducts.domain.NpMilkInOutStore">
|
||||
INSERT INTO np_milk_in_out_store(datetime, num, colost_sheep, commercial_intake, anti_intake,
|
||||
colost_intake, intake_total, commercial_test, colost_test, transfer_commercial,
|
||||
transfer_anti, transfer_colost, transfer_total, loss, stock_commercial,
|
||||
stock_anti, colost, return_fresh, return_yogurt)
|
||||
VALUES (
|
||||
#{datetime}, #{num}, #{colostSheep}, #{commercialIntake}, #{antiIntake},
|
||||
#{colostIntake}, #{intakeTotal}, #{commercialTest}, #{colostTest},
|
||||
#{transferCommercial}, #{transferAnti}, #{transferColost}, #{transferTotal},
|
||||
#{loss}, #{stockCommercial}, #{stockAnti}, #{colost}, #{returnFresh}, #{returnYogurt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertFeedRecord">
|
||||
INSERT INTO np_milk_feed_records(store_id, source_id, amount)
|
||||
VALUES(#{storeId},
|
||||
(SELECT id FROM np_milk_feed WHERE source_name = #{source}),
|
||||
#{amount})
|
||||
</insert>
|
||||
|
||||
<insert id="insertSaleRecord">
|
||||
INSERT INTO np_milk_sale_records(store_id, destination_id, amount)
|
||||
VALUES(#{storeId},
|
||||
(SELECT id FROM np_milk_sale WHERE destination_name = #{destination}),
|
||||
#{amount})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
|
||||
|
||||
<resultMap id="NpSheepMilkAnalysisResultMap" type="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
<id column="id" property="id"/>
|
||||
<result column="manage_ear_tag" property="manageEarTag"/>
|
||||
<result column="variety" property="variety"/>
|
||||
<result column="milking_date" property="milkingDate"/>
|
||||
<result column="dry_date" property="dryDate"/>
|
||||
<result column="milking_days" property="milkingDays"/>
|
||||
<result column="max_parity" property="maxParity"/>
|
||||
<result column="total_milk" property="totalMilk"/>
|
||||
<result column="total_corrected_milk" property="totalCorrectedMilk"/>
|
||||
<result column="avg_daily_corrected_milk" property="avgDailyCorrectedMilk"/>
|
||||
<result column="parity1_total_milk" property="parity1TotalMilk"/>
|
||||
<result column="parity2_total_milk" property="parity2TotalMilk"/>
|
||||
<result column="parity3_total_milk" property="parity3TotalMilk"/>
|
||||
<result column="parity4_total_milk" property="parity4TotalMilk"/>
|
||||
<result column="parity1_avg_milk" property="parity1AvgMilk"/>
|
||||
<result column="parity2_avg_milk" property="parity2AvgMilk"/>
|
||||
<result column="parity3_avg_milk" property="parity3AvgMilk"/>
|
||||
<result column="parity4_avg_milk" property="parity4AvgMilk"/>
|
||||
<result column="lactation_days" property="lactationDays"/>
|
||||
<result column="last_7_avg_milk" property="last7AvgMilk"/>
|
||||
<result column="last_7_corrected_milk" property="last7CorrectedMilk"/>
|
||||
<result column="last_14_avg_milk" property="last14AvgMilk"/>
|
||||
<result column="last_30_avg_milk" property="last30AvgMilk"/>
|
||||
<result column="sheep_type" property="sheepType"/>
|
||||
<result column="birthday" property="birthday"/>
|
||||
<result column="current_parity" property="currentParity"/>
|
||||
<result column="month_age" property="monthAge"/>
|
||||
<result column="current_weight" property="currentWeight"/>
|
||||
<result column="breed_status" property="breedStatus"/>
|
||||
<result column="father_tag" property="fatherTag"/>
|
||||
<result column="mother_tag" property="motherTag"/>
|
||||
<result column="ranch" property="ranch"/>
|
||||
<result column="family" property="family"/>
|
||||
<result column="mother_milking_days" property="motherMilkingDays"/>
|
||||
<result column="mother_total_corrected_milk" property="motherTotalCorrectedMilk"/>
|
||||
<result column="mother_max_parity" property="motherMaxParity"/>
|
||||
<result column="mother_avg_corrected" property="motherAvgCorrected"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, manage_ear_tag, variety, milking_date, dry_date, milking_days,
|
||||
screen_days, max_parity, total_milk, total_corrected_milk,
|
||||
avg_daily_corrected_milk, parity1_total_milk, parity2_total_milk,
|
||||
parity3_total_milk, parity4_total_milk, parity1_avg_milk,
|
||||
parity2_avg_milk, parity3_avg_milk, parity4_avg_milk,
|
||||
lactation_days, last_7_avg_milk, last_7_corrected_milk,
|
||||
last_14_avg_milk, last_30_avg_milk, sheep_type, birthday,
|
||||
current_parity, month_age, current_weight, breed_status,
|
||||
father_tag, mother_tag, ranch, family, mother_milking_days,
|
||||
mother_total_corrected_milk, mother_max_parity,
|
||||
mother_avg_corrected
|
||||
</sql>
|
||||
|
||||
<select id="selectNpSheepMilkAnalysisById" resultMap="NpSheepMilkAnalysisResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM np_sheep_milk_analysis
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectNpSheepMilkAnalysisList" resultMap="NpSheepMilkAnalysisResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM np_sheep_milk_analysis
|
||||
<where>
|
||||
<if test="manageEarTag != null and manageEarTag != ''">
|
||||
AND manage_ear_tag LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||
</if>
|
||||
<!-- 可继续添加其他搜索条件 -->
|
||||
</where>
|
||||
ORDER BY milking_date DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertNpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
INSERT INTO np_sheep_milk_analysis (
|
||||
<include refid="Base_Column_List"/>
|
||||
) VALUES (
|
||||
#{id}, #{manageEarTag}, #{variety}, #{milkingDate}, #{dryDate},
|
||||
#{milkingDays}, #{screenDays}, #{maxParity}, #{totalMilk},
|
||||
#{totalCorrectedMilk}, #{avgDailyCorrectedMilk}, #{parity1TotalMilk},
|
||||
#{parity2TotalMilk}, #{parity3TotalMilk}, #{parity4TotalMilk},
|
||||
#{parity1AvgMilk}, #{parity2AvgMilk}, #{parity3AvgMilk},
|
||||
#{parity4AvgMilk}, #{lactationDays}, #{last7AvgMilk},
|
||||
#{last7CorrectedMilk}, #{last14AvgMilk}, #{last30AvgMilk},
|
||||
#{sheepType}, #{birthday}, #{currentParity}, #{monthAge},
|
||||
#{currentWeight}, #{breedStatus}, #{fatherTag}, #{motherTag},
|
||||
#{ranch}, #{family}, #{motherMilkingDays},
|
||||
#{motherTotalCorrectedMilk}, #{motherMaxParity},
|
||||
#{motherAvgCorrected}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateNpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
UPDATE np_sheep_milk_analysis
|
||||
SET manage_ear_tag = #{manageEarTag},
|
||||
variety = #{variety},
|
||||
milking_date = #{milkingDate},
|
||||
dry_date = #{dryDate},
|
||||
milking_days = #{milkingDays},
|
||||
screen_days = #{screenDays},
|
||||
max_parity = #{maxParity},
|
||||
total_milk = #{totalMilk},
|
||||
total_corrected_milk = #{totalCorrectedMilk},
|
||||
avg_daily_corrected_milk = #{avgDailyCorrectedMilk},
|
||||
parity1_total_milk = #{parity1TotalMilk},
|
||||
parity2_total_milk = #{parity2TotalMilk},
|
||||
parity3_total_milk = #{parity3TotalMilk},
|
||||
parity4_total_milk = #{parity4TotalMilk},
|
||||
parity1_avg_milk = #{parity1AvgMilk},
|
||||
parity2_avg_milk = #{parity2AvgMilk},
|
||||
parity3_avg_milk = #{parity3AvgMilk},
|
||||
parity4_avg_milk = #{parity4AvgMilk},
|
||||
lactation_days = #{lactationDays},
|
||||
last_7_avg_milk = #{last7AvgMilk},
|
||||
last_7_corrected_milk = #{last7CorrectedMilk},
|
||||
last_14_avg_milk = #{last14AvgMilk},
|
||||
last_30_avg_milk = #{last30AvgMilk},
|
||||
sheep_type = #{sheepType},
|
||||
birthday = #{birthday},
|
||||
current_parity = #{currentParity},
|
||||
month_age = #{monthAge},
|
||||
current_weight = #{currentWeight},
|
||||
breed_status = #{breedStatus},
|
||||
father_tag = #{fatherTag},
|
||||
mother_tag = #{motherTag},
|
||||
ranch = #{ranch},
|
||||
family = #{family},
|
||||
mother_milking_days = #{motherMilkingDays},
|
||||
mother_total_corrected_milk = #{motherTotalCorrectedMilk},
|
||||
mother_max_parity = #{motherMaxParity},
|
||||
mother_avg_corrected = #{motherAvgCorrected}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNpSheepMilkAnalysisById" parameterType="Long">
|
||||
DELETE FROM np_sheep_milk_analysis WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNpSheepMilkAnalysisByIds" parameterType="Long">
|
||||
DELETE FROM np_sheep_milk_analysis WHERE id IN
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user