Merge remote-tracking branch 'main/main'
This commit is contained in:
commit
a6cce5230d
@ -0,0 +1,236 @@
|
||||
package com.zhyc.module.feed.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.feed.domain.SgFeedPlan;
|
||||
import com.zhyc.module.feed.domain.SgFormulaManagement;
|
||||
import com.zhyc.module.feed.service.ISgFeedPlanService;
|
||||
import com.zhyc.module.feed.service.ISgFormulaManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
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.feed.domain.SgFeedList;
|
||||
import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 配料清单Controller
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feed/FeedList")
|
||||
public class SgFeedListController extends BaseController {
|
||||
private final ISgFeedListService sgFeedListService;
|
||||
|
||||
private final ISgFormulaManagementService sgFormulaManagementService;
|
||||
|
||||
private final ISgFeedPlanService sgFeedPlanService;
|
||||
|
||||
private final Map<String, SgFeedList> sgFeedListMap = new HashMap<>();
|
||||
|
||||
public static boolean refresh = true;
|
||||
|
||||
@Autowired
|
||||
public SgFeedListController(ISgFeedListService sgFeedListService, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
|
||||
this.sgFeedListService = sgFeedListService;
|
||||
this.sgFormulaManagementService = sgFormulaManagementService;
|
||||
this.sgFeedPlanService = sgFeedPlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:list')")
|
||||
@GetMapping("/list")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TableDataInfo list(SgFeedList sgFeedList) {
|
||||
/*
|
||||
刷新缓存
|
||||
当配方管理表出现更新 或 饲喂计划表出现增删改时会将refresh置为true 通知此处进行刷新
|
||||
*/
|
||||
if (refresh) {
|
||||
SyncFeedList();
|
||||
refresh = false;
|
||||
}
|
||||
startPage();
|
||||
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
|
||||
// 用 map 中已有的数据替换 list 中的元素
|
||||
List<SgFeedList> replacedList = new ArrayList<>();
|
||||
for (SgFeedList item : list) {
|
||||
String key = item.getFormulaId() + "_" + item.getFormulaBatchId();
|
||||
// 从缓存中取出完整对象
|
||||
SgFeedList itemInCache = sgFeedListMap.getOrDefault(key, item);
|
||||
// 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
|
||||
itemInCache.setId(item.getId());
|
||||
itemInCache.setFormulaBatchId(item.getFormulaBatchId());
|
||||
itemInCache.setFormulaId(item.getFormulaId());
|
||||
itemInCache.setZookeeper(item.getZookeeper());
|
||||
itemInCache.setDeployDate(item.getDeployDate());
|
||||
// 替换为 map 中的对象
|
||||
replacedList.add(itemInCache);
|
||||
}
|
||||
return getDataTable(replacedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配料清单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:export')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SgFeedList sgFeedList) {
|
||||
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
|
||||
ExcelUtil<SgFeedList> util = new ExcelUtil<>(SgFeedList.class);
|
||||
util.exportExcel(response, list, "配料清单数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配料清单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(sgFeedListService.selectSgFeedListById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:add')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SgFeedList sgFeedList) {
|
||||
return toAjax(sgFeedListService.insertSgFeedList(sgFeedList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:edit')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SgFeedList sgFeedList) {
|
||||
return toAjax(sgFeedListService.updateSgFeedList(sgFeedList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:remove')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(sgFeedListService.deleteSgFeedListByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
public void SyncFeedList() {
|
||||
// 清空旧缓存
|
||||
sgFeedListMap.clear();
|
||||
// 获取配方管理和现有配料清单内容
|
||||
List<SgFormulaManagement> formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
|
||||
List<SgFeedList> feedLists = sgFeedListService.selectSgFeedListList(new SgFeedList());
|
||||
// 将最新查询的配料清单加入缓存
|
||||
for (SgFeedList sgFeedList : feedLists) {
|
||||
sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
|
||||
}
|
||||
// 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
|
||||
for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
|
||||
// 匹配 但忽略模板配方
|
||||
if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
|
||||
// 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
|
||||
boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
|
||||
// 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
|
||||
boolean isPlan = true;
|
||||
// 设置缓存对象具体值
|
||||
SgFeedList sgFeedList = new SgFeedList();
|
||||
sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
|
||||
sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
|
||||
sgFeedList.setRootFormula(sgFormulaManagement);
|
||||
|
||||
|
||||
// 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
|
||||
SgFeedPlan rootPlanQuery = new SgFeedPlan();
|
||||
rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
|
||||
// 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
|
||||
if (sgFeedPlans.isEmpty()) {
|
||||
isPlan = false;
|
||||
} else {
|
||||
// rootPlan中存储的是该配方批号的总量
|
||||
SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
|
||||
|
||||
// 将计划实体对象设置到配料清单中
|
||||
sgFeedList.setRootPlan(rootPlan);
|
||||
|
||||
// 完整的配料清单对象加入缓存
|
||||
sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
|
||||
}
|
||||
|
||||
// 不存在则插入
|
||||
if (!isExist && isPlan) {
|
||||
sgFeedListService.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算某个配方某个批次的总和值
|
||||
*
|
||||
* @param sgFeedPlans 配方计划列表
|
||||
* @return 各个值总和
|
||||
*/
|
||||
private static SgFeedPlan computePlanTotal(List<SgFeedPlan> sgFeedPlans) {
|
||||
SgFeedPlan rootPlan = new SgFeedPlan();
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
int sheepCountTotal = 0;
|
||||
double sheepDailySize = 0.0;
|
||||
double planFeedMorningSize = 0.0;
|
||||
double planFeedNoonSize = 0.0;
|
||||
double planFeedAfternoonSize = 0.0;
|
||||
double planFeedTotalSize = 0.0;
|
||||
for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
|
||||
sheepCountTotal += sgFeedPlan.getSheepCount();
|
||||
sheepDailySize += sgFeedPlan.getPlanDailySize();
|
||||
planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
|
||||
planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
|
||||
planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
|
||||
planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
|
||||
}
|
||||
|
||||
rootPlan.setSheepCount(sheepCountTotal);
|
||||
rootPlan.setPlanDailySize(sheepDailySize);
|
||||
rootPlan.setPlanMorningSize(planFeedMorningSize);
|
||||
rootPlan.setPlanNoonSize(planFeedNoonSize);
|
||||
rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
|
||||
rootPlan.setPlanFeedTotal(planFeedTotalSize);
|
||||
|
||||
// 设置计划日期
|
||||
rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
|
||||
}
|
||||
return rootPlan;
|
||||
}
|
||||
}
|
@ -82,6 +82,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
sgFeedPlan.setCreateDate(new Date());
|
||||
// 计算其他字段值
|
||||
setPlan(sgFeedPlan);
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.insertSgFeedPlan(sgFeedPlan));
|
||||
}
|
||||
|
||||
@ -94,6 +96,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
public AjaxResult edit(@RequestBody SgFeedPlan sgFeedPlan) {
|
||||
// 根据修改后的值重新计算
|
||||
setPlan(sgFeedPlan);
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.updateSgFeedPlan(sgFeedPlan));
|
||||
}
|
||||
|
||||
@ -104,6 +108,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
@Log(title = "饲喂计划", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{createDates}")
|
||||
public AjaxResult remove(@PathVariable Date[] createDates) {
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.deleteSgFeedPlanByCreateDates(createDates));
|
||||
}
|
||||
|
||||
@ -111,7 +117,7 @@ public class SgFeedPlanController extends BaseController {
|
||||
* 设定计划值
|
||||
* 用于添加和修改
|
||||
*/
|
||||
private SgFeedPlan setPlan(SgFeedPlan sgFeedPlan) {
|
||||
private void setPlan(SgFeedPlan sgFeedPlan) {
|
||||
// 根据羊舍ID获取羊只数量
|
||||
int countByFoldId = sgFeedPlanService.getSheepCountByFoldId(sgFeedPlan.getSheepHouseId());
|
||||
sgFeedPlan.setSheepCount(countByFoldId);
|
||||
@ -121,6 +127,5 @@ public class SgFeedPlanController extends BaseController {
|
||||
sgFeedPlan.setPlanMorningSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioMorning() / 100));
|
||||
sgFeedPlan.setPlanNoonSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioNoon() / 100));
|
||||
sgFeedPlan.setPlanAfternoonSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioAfternoon() / 100));
|
||||
return sgFeedPlan;
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,9 @@ public class SgFormulaManagementController extends BaseController {
|
||||
sgFormulaListItem.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFormulaListService.insertSgFormulaList(sgFormulaListItem);
|
||||
}
|
||||
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFormulaManagementService.updateSgFormulaManagement(sgFormulaManagement));
|
||||
}
|
||||
|
||||
@ -167,6 +170,9 @@ public class SgFormulaManagementController extends BaseController {
|
||||
}
|
||||
// 前置检查完毕 执行删除
|
||||
sgFormulaManagement.setBatchId(batchId);
|
||||
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFormulaManagementService.deleteSgFormulaManagement(sgFormulaManagement));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.zhyc.module.feed.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 配料清单对象 sg_feed_list
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class SgFeedList extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 序号 */
|
||||
private Long id;
|
||||
|
||||
/** 配方编号 */
|
||||
@Excel(name = "配方编号")
|
||||
private String formulaId;
|
||||
|
||||
/** 配方批号 */
|
||||
@Excel(name = "配方批号")
|
||||
private String formulaBatchId;
|
||||
|
||||
/** 饲草班人员 */
|
||||
@Excel(name = "饲草班人员")
|
||||
private String zookeeper;
|
||||
|
||||
/** 配料日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "配料日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date deployDate;
|
||||
|
||||
private SgFormulaManagement rootFormula;
|
||||
|
||||
private SgFeedPlan rootPlan;
|
||||
|
||||
private Double morningTotal;
|
||||
private Double noonTotal;
|
||||
private Double afternoonTotal;
|
||||
|
||||
private List<SgFormulaList> formulaList;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("formulaId", getFormulaId())
|
||||
.append("formulaBatchId", getFormulaBatchId())
|
||||
.append("zookeeper", getZookeeper())
|
||||
.append("deployDate", getDeployDate())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.zhyc.module.feed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 配料清单Mapper接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Mapper
|
||||
public interface SgFeedListMapper
|
||||
{
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
SgFeedList selectSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单集合
|
||||
*/
|
||||
List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 删除配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.zhyc.module.feed.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
|
||||
/**
|
||||
* 配料清单Service接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface ISgFeedListService
|
||||
{
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
SgFeedList selectSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单集合
|
||||
*/
|
||||
List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的配料清单主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除配料清单信息
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListById(Long id);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.zhyc.module.feed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.feed.mapper.SgFeedListMapper;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
|
||||
/**
|
||||
* 配料清单Service业务层处理
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
{
|
||||
private final SgFeedListMapper sgFeedListMapper;
|
||||
|
||||
public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper) {
|
||||
this.sgFeedListMapper = sgFeedListMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public SgFeedList selectSgFeedListById(Long id)
|
||||
{
|
||||
return sgFeedListMapper.selectSgFeedListById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.selectSgFeedListList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.updateSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListByIds(Long[] ids)
|
||||
{
|
||||
return sgFeedListMapper.deleteSgFeedListByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配料清单信息
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListById(Long id)
|
||||
{
|
||||
return sgFeedListMapper.deleteSgFeedListById(id);
|
||||
}
|
||||
}
|
@ -5,8 +5,12 @@ import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.module.base.domain.BasSheepType;
|
||||
import com.zhyc.module.base.domain.BasSheepVariety;
|
||||
import com.zhyc.module.base.domain.DaRanch;
|
||||
import com.zhyc.module.base.service.IBasSheepTypeService;
|
||||
import com.zhyc.module.base.service.IBasSheepVarietyService;
|
||||
import com.zhyc.module.base.service.IDaRanchService;
|
||||
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
|
||||
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
@ -36,6 +40,11 @@ public class ScAddSheepController {
|
||||
private IDaSheepfoldService daSheepfoldMapper;
|
||||
@Autowired
|
||||
private IBasSheepVarietyService basSheepVarietyMapper;
|
||||
@Autowired
|
||||
private IBasSheepTypeService basSheepTypeService;
|
||||
@Autowired
|
||||
private IDaRanchService daRanchService;
|
||||
|
||||
//新增羊只验证
|
||||
@PreAuthorize("@ss.hasPermi('produce:add_sheep:add')")
|
||||
@Log(title = "新增", businessType = BusinessType.INSERT)
|
||||
@ -44,6 +53,9 @@ public class ScAddSheepController {
|
||||
if (scAddSheep.getEarNumber() == null || scAddSheep.getEarNumber().isEmpty()) {
|
||||
return AjaxResult.error("耳号不能为空");
|
||||
}
|
||||
if (scAddSheep.getRanchId() == null || scAddSheep.getRanchId() == 0) {
|
||||
return AjaxResult.error("牧场不能为空");
|
||||
}
|
||||
if (scAddSheep.getSheepfold() == null || scAddSheep.getSheepfold() == 0) {
|
||||
return AjaxResult.error("羊舍不能为空");
|
||||
}
|
||||
@ -79,8 +91,15 @@ public class ScAddSheepController {
|
||||
public void exportForm(HttpServletResponse response, @RequestBody ScAddSheep scAddSheep) throws IOException {
|
||||
ExcelUtil<ScAddSheep> util = new ExcelUtil<>(ScAddSheep.class);
|
||||
List<ScAddSheep> list = new ArrayList<>();
|
||||
|
||||
// 处理羊舍名称(原有逻辑)
|
||||
//处理牧场名称
|
||||
if (scAddSheep.getRanchId() != null) {
|
||||
// 根据牧场ID查询牧场信息
|
||||
DaRanch ranch = daRanchService.selectDaRanchById(scAddSheep.getRanchId().longValue());
|
||||
if (ranch != null) {
|
||||
scAddSheep.setRanchName(ranch.getRanch()); // 将牧场名称设置到实体中
|
||||
}
|
||||
}
|
||||
// 处理羊舍名称
|
||||
if (scAddSheep.getSheepfold() != null) {
|
||||
DaSheepfold fold = daSheepfoldMapper.selectDaSheepfoldById(scAddSheep.getSheepfold().longValue());
|
||||
if (fold != null) {
|
||||
@ -88,6 +107,7 @@ public class ScAddSheepController {
|
||||
}
|
||||
}
|
||||
|
||||
//处理羊只品种名称
|
||||
if (scAddSheep.getVarietyId() != null) {
|
||||
BasSheepVariety variety = basSheepVarietyMapper.selectBasSheepVarietyById(scAddSheep.getVarietyId().longValue());
|
||||
if (variety != null) {
|
||||
@ -95,9 +115,17 @@ public class ScAddSheepController {
|
||||
}
|
||||
}
|
||||
|
||||
//处理羊只类型名称
|
||||
if (scAddSheep.getTypeId() != null) {
|
||||
BasSheepType sheepType = basSheepTypeService.selectBasSheepTypeById(scAddSheep.getTypeId().intValue());
|
||||
if (sheepType != null) {
|
||||
scAddSheep.setTypeName(sheepType.getName());
|
||||
}
|
||||
}
|
||||
list.add(scAddSheep);
|
||||
util.exportExcel(response, list, "羊只信息");
|
||||
}
|
||||
|
||||
//导入
|
||||
@PostMapping("/importData")
|
||||
@PreAuthorize("@ss.hasPermi('produce:add_sheep:import')")
|
||||
|
@ -101,8 +101,8 @@ public class ScTransGroupController extends BaseController {
|
||||
/**
|
||||
* 审批转群记录
|
||||
*/
|
||||
@PutMapping("/approve")
|
||||
public AjaxResult approve(@RequestBody ScTransGroup scTransGroup) {
|
||||
return toAjax(scTransGroupService.approveScTransGroup(scTransGroup));
|
||||
}
|
||||
// @PutMapping("/approve")
|
||||
// public AjaxResult approve(@RequestBody ScTransGroup scTransGroup) {
|
||||
// return toAjax(scTransGroupService.approveScTransGroup(scTransGroup));
|
||||
// }
|
||||
}
|
||||
|
@ -110,6 +110,9 @@ public class ScTransitionInfoController extends BaseController {
|
||||
|
||||
@PutMapping("/approve")
|
||||
public AjaxResult approveScTransitionInfo(@RequestBody ScTransitionInfo scTransitionInfo) {
|
||||
if ("转场转入".equals(scTransitionInfo.getEventType()) && scTransitionInfo.getSheepfoldId() == null) {
|
||||
return AjaxResult.error("转场转入时,接收羊舍ID不能为空");
|
||||
}
|
||||
int rows = scTransitionInfoService.approveScTransitionInfo(scTransitionInfo);
|
||||
return toAjax(rows);
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ public class ScAddSheep extends BaseEntity {
|
||||
@Excel(name = "耳号")
|
||||
private String earNumber;
|
||||
|
||||
/** 牧场 */
|
||||
private Integer ranchId;
|
||||
@Excel(name = "牧场名称")
|
||||
private String ranchName;
|
||||
|
||||
/** 羊舍编号 */
|
||||
private Integer sheepfold;
|
||||
|
||||
@ -68,6 +73,11 @@ public class ScAddSheep extends BaseEntity {
|
||||
@Excel(name = "品种")
|
||||
private String varietyName;
|
||||
|
||||
/** 羊只类别 */
|
||||
private Long typeId;
|
||||
@Excel(name = "羊只类型")
|
||||
private String typeName;
|
||||
|
||||
/** 入群日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
|
||||
|
@ -27,8 +27,20 @@ public class ScChangeComment extends BaseEntity {
|
||||
* 羊只id
|
||||
*/
|
||||
private String sheepId;
|
||||
@Excel(name = "管理耳号")
|
||||
|
||||
private String manageTags;
|
||||
|
||||
/** 羊舍 */
|
||||
private Long sheepfoldId;
|
||||
@Excel(name = "羊舍")
|
||||
private String sheepfoldName;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* 新备注
|
||||
*/
|
||||
|
@ -28,6 +28,15 @@ public class ScChangeEar extends BaseEntity
|
||||
@Excel(name = "管理耳号")
|
||||
private String manageTags;
|
||||
|
||||
/** 羊舍 */
|
||||
private Long sheepfoldId;
|
||||
@Excel(name = "羊舍")
|
||||
private String sheepfoldName;
|
||||
|
||||
/** 事件类型(改管理耳号/改电子耳号) */
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/** 选择更改耳号类型(0电子耳号1管理耳号) */
|
||||
@Excel(name = "耳号类型", readConverterExp = "0=电子耳号,1=管理耳号")
|
||||
private Integer earType;
|
||||
|
@ -29,6 +29,17 @@ public class ScChangeVariety extends BaseEntity
|
||||
@Excel(name = "耳号")
|
||||
private String manageTags;
|
||||
|
||||
/** 羊舍 */
|
||||
private Long sheepfoldId;
|
||||
@Excel(name = "羊舍")
|
||||
private String sheepfoldName;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/** 原品种 */
|
||||
@Excel(name = "原品种")
|
||||
private String varietyOld;
|
||||
@ -41,10 +52,5 @@ public class ScChangeVariety extends BaseEntity
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
/** 创建日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,14 @@ public class ScTransGroup extends BaseEntity {
|
||||
|
||||
@Excel(name = "耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
* 事件类型(1-围产转群,2-普通转群,3-育肥转群,4-预售转群)
|
||||
*/
|
||||
private Integer eventType;
|
||||
@Excel(name = "事件类型")
|
||||
private String eventTypeText;
|
||||
|
||||
/**
|
||||
* 转入羊舍
|
||||
*/
|
||||
@ -40,18 +48,19 @@ public class ScTransGroup extends BaseEntity {
|
||||
*/
|
||||
private String foldFrom;
|
||||
|
||||
/**
|
||||
* 羊只类型
|
||||
*/
|
||||
private Integer sheepTypeId;
|
||||
@Excel(name = "羊只类型")
|
||||
private String sheepTypeName;
|
||||
|
||||
/**
|
||||
* 转出羊舍名称
|
||||
*/
|
||||
@Excel(name = "转出羊舍")
|
||||
private String foldFromName;
|
||||
|
||||
/**
|
||||
* 羊只类型ID
|
||||
*/
|
||||
private Integer sheepTypeId;
|
||||
// 羊只类型名称
|
||||
private String sheepTypeName;
|
||||
/**
|
||||
* 转入羊舍名称
|
||||
*/
|
||||
@ -77,6 +86,9 @@ public class ScTransGroup extends BaseEntity {
|
||||
@Excel(name = "转群原因")
|
||||
private String reasonText;
|
||||
|
||||
/** 转群日期 */
|
||||
@Excel(name = "转群日期")
|
||||
private String transDate;
|
||||
/**
|
||||
* 技术员
|
||||
*/
|
||||
|
@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 转场对象 sc_transition_info
|
||||
*
|
||||
@ -27,9 +29,27 @@ public class ScTransitionInfo extends BaseEntity {
|
||||
* 羊只id
|
||||
*/
|
||||
private Integer sheepId;
|
||||
|
||||
@Excel(name = "耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
|
||||
/**
|
||||
* 转场类型
|
||||
*/
|
||||
private Integer transType;
|
||||
@Excel(name = "转场类型")
|
||||
private String transTypeText;
|
||||
|
||||
/** 转场日期 */
|
||||
@Excel(name = "转场日期")
|
||||
private LocalDate transitionDate;
|
||||
|
||||
/**
|
||||
* 品种id
|
||||
*/
|
||||
@ -54,16 +74,9 @@ public class ScTransitionInfo extends BaseEntity {
|
||||
private String transFrom;
|
||||
|
||||
/**
|
||||
* 转场类型
|
||||
* 接收羊舍
|
||||
*/
|
||||
private Integer transType;
|
||||
|
||||
/**
|
||||
* 转场类型名称 只用于导出
|
||||
*/
|
||||
@Excel(name = "转场类型")
|
||||
private String transTypeText;
|
||||
|
||||
private Long sheepfoldId;
|
||||
/**
|
||||
* 技术员
|
||||
*/
|
||||
@ -76,6 +89,7 @@ public class ScTransitionInfo extends BaseEntity {
|
||||
private Integer status;
|
||||
@Excel(name = "状态")
|
||||
private String statusText;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -7,15 +7,15 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 转场Mapper接口
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public interface ScTransitionInfoMapper
|
||||
public interface ScTransitionInfoMapper
|
||||
{
|
||||
/**
|
||||
* 查询转场
|
||||
*
|
||||
*
|
||||
* @param id 转场主键
|
||||
* @return 转场
|
||||
*/
|
||||
@ -23,7 +23,7 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
/**
|
||||
* 查询转场列表
|
||||
*
|
||||
*
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 转场集合
|
||||
*/
|
||||
@ -31,7 +31,7 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
/**
|
||||
* 新增转场
|
||||
*
|
||||
*
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 结果
|
||||
*/
|
||||
@ -39,7 +39,7 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
/**
|
||||
* 修改转场
|
||||
*
|
||||
*
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 结果
|
||||
*/
|
||||
@ -47,7 +47,7 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
/**
|
||||
* 删除转场
|
||||
*
|
||||
*
|
||||
* @param id 转场主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -55,7 +55,7 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
/**
|
||||
* 批量删除转场
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@ -63,4 +63,5 @@ public interface ScTransitionInfoMapper
|
||||
|
||||
//批量转场
|
||||
int insertScTransitionInfoBatch(@Param("list") List<ScTransitionInfo> transitionInfoList);
|
||||
|
||||
}
|
||||
|
@ -70,4 +70,5 @@ public interface IScTransitionInfoService {
|
||||
|
||||
//审批转场
|
||||
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,11 @@ package com.zhyc.module.produce.manage_sheep.service.impl;
|
||||
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import com.zhyc.common.utils.StringUtils;
|
||||
import com.zhyc.module.base.domain.BasSheepType;
|
||||
import com.zhyc.module.base.domain.DaRanch;
|
||||
import com.zhyc.module.base.mapper.BasSheepVarietyMapper;
|
||||
import com.zhyc.module.base.service.IBasSheepTypeService;
|
||||
import com.zhyc.module.base.service.IDaRanchService;
|
||||
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
|
||||
import com.zhyc.module.produce.manage_sheep.mapper.ScAddSheepMapper;
|
||||
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
|
||||
@ -32,6 +36,11 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
@Autowired
|
||||
private BasSheepVarietyMapper basSheepVarietyMapper;
|
||||
|
||||
@Autowired
|
||||
private IBasSheepTypeService basSheepTypeService;
|
||||
|
||||
@Autowired
|
||||
private IDaRanchService daRanchService;
|
||||
//新增
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -47,6 +56,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
BasSheep bs = new BasSheep();
|
||||
bs.setManageTags(scAddSheep.getEarNumber());
|
||||
// bs.setElectronicTags(scAddSheep.getEarNumber());
|
||||
bs.setRanchId(scAddSheep.getRanchId().longValue());
|
||||
bs.setSheepfoldId(scAddSheep.getSheepfold().longValue());
|
||||
bs.setFatherId(null);
|
||||
bs.setMotherId(null);
|
||||
@ -64,7 +74,10 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
bs.setComment(scAddSheep.getComment());
|
||||
bs.setCreateBy(scAddSheep.getCreateBy());
|
||||
bs.setCreateTime(new Date());
|
||||
|
||||
if (scAddSheep.getTypeId() != null) {
|
||||
bs.setTypeId(scAddSheep.getTypeId().longValue());
|
||||
}
|
||||
bs.setStatusId(1L);
|
||||
basSheepService.insertBasSheep(bs);
|
||||
return true;
|
||||
}
|
||||
@ -101,7 +114,23 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ScAddSheep sheep = list.get(i);
|
||||
try {
|
||||
// 处理品种名称转换为品种ID
|
||||
if (StringUtils.isBlank(sheep.getRanchName())) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第").append(i + 1).append("行:牧场名称不能为空");
|
||||
continue;
|
||||
}
|
||||
DaRanch ranchParam = new DaRanch();
|
||||
ranchParam.setRanch(sheep.getRanchName().trim());
|
||||
List<DaRanch> ranchList = daRanchService.selectDaRanchList(ranchParam);
|
||||
|
||||
if (ranchList == null || ranchList.isEmpty()) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第").append(i + 1)
|
||||
.append("行:牧场名称不存在【").append(sheep.getRanchName()).append("】");
|
||||
continue;
|
||||
}
|
||||
sheep.setRanchId(ranchList.get(0).getId().intValue());
|
||||
|
||||
if (StringUtils.isNotBlank(sheep.getVarietyName())) {
|
||||
Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName());
|
||||
if (varietyId == null) {
|
||||
@ -122,10 +151,10 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 处理羊舍名称转换为羊舍ID
|
||||
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
|
||||
DaSheepfold param = new DaSheepfold();
|
||||
param.setSheepfoldName(sheep.getSheepfoldNameExcel());
|
||||
param.setRanchId(sheep.getRanchId().longValue());
|
||||
List<DaSheepfold> foldList = daSheepfoldMapper.selectDaSheepfoldList(param);
|
||||
if (foldList == null || foldList.isEmpty()) {
|
||||
failure++;
|
||||
@ -139,7 +168,23 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
sheep.setSheepfold(foldList.get(0).getId().intValue());
|
||||
}
|
||||
|
||||
// 校验耳号是否为空
|
||||
if (StringUtils.isNotBlank(sheep.getTypeName())) {
|
||||
BasSheepType typeQuery = new BasSheepType();
|
||||
typeQuery.setName(sheep.getTypeName().trim());
|
||||
List<BasSheepType> typeList = basSheepTypeService.selectBasSheepTypeList(typeQuery);
|
||||
|
||||
if (typeList == null || typeList.isEmpty()) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第")
|
||||
.append(i + 1)
|
||||
.append("行:羊只类型名称不存在【")
|
||||
.append(sheep.getTypeName())
|
||||
.append("】");
|
||||
continue;
|
||||
}
|
||||
sheep.setTypeId(typeList.get(0).getId().longValue());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(sheep.getEarNumber())) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第")
|
||||
@ -148,7 +193,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 核心校验:判断羊只基本信息表中是否存在未删除的同名耳号
|
||||
BasSheep existSheep = basSheepService.selectBasSheepByManageTags(sheep.getEarNumber().trim());
|
||||
if (existSheep != null) {
|
||||
failure++;
|
||||
@ -160,7 +204,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 执行导入(新增或更新)
|
||||
if (updateSupport && sheep.getId() != null) {
|
||||
sheep.setUpdateBy(operName);
|
||||
updateScAddSheep(sheep);
|
||||
|
@ -31,6 +31,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
private BasSheepMapper basSheepMapper;
|
||||
@Autowired
|
||||
private IBasSheepService basSheepService;
|
||||
|
||||
/**
|
||||
* 查询转群记录
|
||||
*
|
||||
@ -42,6 +43,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
ScTransGroup group = scTransGroupMapper.selectScTransGroupById(id);
|
||||
group.setReasonText(convertReason(group.getReason()));
|
||||
group.setStatusText(convertStatus(group.getStatus()));
|
||||
group.setEventTypeText(convertEventType(group.getEventType()));
|
||||
return group;
|
||||
}
|
||||
|
||||
@ -58,6 +60,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
list.forEach(group -> {
|
||||
group.setReasonText(convertReason(group.getReason()));
|
||||
group.setStatusText(convertStatus(group.getStatus()));
|
||||
group.setEventTypeText(convertEventType(group.getEventType()));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
@ -70,11 +73,21 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScTransGroup(ScTransGroup scTransGroup) {
|
||||
scTransGroup.setStatus(0);
|
||||
scTransGroup.setCreateTime(DateUtils.getNowDate());
|
||||
scTransGroup.setCreateBy(SecurityUtils.getUsername());
|
||||
return scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
int rows = scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
if (rows > 0) {
|
||||
try {
|
||||
updateSheepFold(scTransGroup);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("新增转群记录后更新羊舍失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
// return scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,9 +143,15 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
* 更新羊只所在羊舍
|
||||
*/
|
||||
private void updateSheepFold(ScTransGroup transGroup) {
|
||||
Long foldTo = Long.valueOf(transGroup.getFoldTo());
|
||||
if (foldTo == null) {
|
||||
throw new RuntimeException("转入羊舍不能为空");
|
||||
Object foldToObj = transGroup.getFoldTo();
|
||||
if (foldToObj == null) {
|
||||
throw new RuntimeException("转入羊舍ID为空,请检查前端提交的foldTo参数");
|
||||
}
|
||||
Long foldTo;
|
||||
try {
|
||||
foldTo = Long.valueOf(foldToObj.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("转入羊舍ID格式错误,应为数字,实际值:" + foldToObj);
|
||||
}
|
||||
|
||||
String manageTags = transGroup.getManageTags();
|
||||
@ -177,4 +196,18 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
return statusMap.getOrDefault(statusCode, "未知状态");
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换事件类型(1-围产转群,2-普通转群,3-育肥转群,4-预售转群)
|
||||
*/
|
||||
private String convertEventType(Integer eventType) {
|
||||
if (eventType == null) {
|
||||
return "未知";
|
||||
}
|
||||
Map<Integer, String> eventTypeMap = new HashMap<>();
|
||||
eventTypeMap.put(1, "围产转群");
|
||||
eventTypeMap.put(2, "普通转群");
|
||||
eventTypeMap.put(3, "育肥转群");
|
||||
eventTypeMap.put(4, "预售转群");
|
||||
return eventTypeMap.getOrDefault(eventType, "未知");
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,16 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo) {
|
||||
// 1. 查询当前记录的原始状态
|
||||
ScTransitionInfo existing = scTransitionInfoMapper.selectScTransitionInfoById(scTransitionInfo.getId());
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("转场记录不存在");
|
||||
}
|
||||
// 2. 校验状态:仅允许审批“待审批”的记录
|
||||
if (existing.getStatus() != 0) {
|
||||
throw new RuntimeException("该记录已完成审批,无法重复操作");
|
||||
}
|
||||
int rows = scTransitionInfoMapper.updateScTransitionInfo(scTransitionInfo);
|
||||
|
||||
if (rows > 0 && scTransitionInfo.getStatus() == 1) {
|
||||
updateSheepRanch(scTransitionInfo);
|
||||
}
|
||||
@ -157,6 +165,12 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
|
||||
}
|
||||
Long targetRanchId = matchedRanch.get().getId();
|
||||
|
||||
//获取接收羊舍
|
||||
Long targetSheepfoldId = transitionInfo.getSheepfoldId();
|
||||
if ("转场转入".equals(transitionInfo.getEventType()) && targetSheepfoldId == null) {
|
||||
throw new RuntimeException("转场转入时,接收羊舍不能为空");
|
||||
}
|
||||
|
||||
String manageTags = transitionInfo.getManageTags();
|
||||
if (StringUtils.isBlank(manageTags)) {
|
||||
throw new RuntimeException("耳号不能为空");
|
||||
@ -172,6 +186,9 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
|
||||
BasSheep updateSheep = new BasSheep();
|
||||
updateSheep.setId(sheep.getId());
|
||||
updateSheep.setRanchId(targetRanchId);
|
||||
if ("转场转入".equals(transitionInfo.getEventType())) {
|
||||
updateSheep.setSheepfoldId(targetSheepfoldId);
|
||||
}
|
||||
basSheepMapper.updateBasSheep(updateSheep);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,12 @@ public class ScCastrate extends BaseEntity {
|
||||
@Excel(name = "耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* 羊舍id
|
||||
*/
|
||||
|
@ -24,10 +24,15 @@ public class ScFixHoof extends BaseEntity
|
||||
|
||||
/** 羊只id */
|
||||
private Integer sheepId;
|
||||
/** 管理耳号(仅用于接收参数/返回视图) */
|
||||
@Excel(name = "管理耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/** 羊舍id */
|
||||
private Integer sheepfold;
|
||||
|
||||
|
@ -328,7 +328,7 @@
|
||||
SELECT COUNT(*)
|
||||
FROM bas_sheep
|
||||
WHERE manage_tags = #{tag}
|
||||
AND s.is_delete = 0
|
||||
AND is_delete = 0
|
||||
</select>
|
||||
|
||||
<select id="existsByElectronicTag" resultType="int">
|
||||
|
@ -0,0 +1,70 @@
|
||||
<?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.feed.mapper.SgFeedListMapper">
|
||||
|
||||
<resultMap type="SgFeedList" id="SgFeedListResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="formulaId" column="formula_id" />
|
||||
<result property="formulaBatchId" column="formula_batch_id" />
|
||||
<result property="zookeeper" column="zookeeper" />
|
||||
<result property="deployDate" column="deploy_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedListVo">
|
||||
select id, formula_id, formula_batch_id, zookeeper, deploy_date from sg_feed_list
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedListList" parameterType="SgFeedList" resultMap="SgFeedListResult">
|
||||
<include refid="selectSgFeedListVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
|
||||
<if test="deployDate != null "> and deploy_date = #{deployDate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedListById" parameterType="Long" resultMap="SgFeedListResult">
|
||||
<include refid="selectSgFeedListVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedList" parameterType="SgFeedList" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_feed_list
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id,</if>
|
||||
<if test="formulaBatchId != null">formula_batch_id,</if>
|
||||
<if test="zookeeper != null">zookeeper,</if>
|
||||
<if test="deployDate != null">deploy_date,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">#{formulaId},</if>
|
||||
<if test="formulaBatchId != null">#{formulaBatchId},</if>
|
||||
<if test="zookeeper != null">#{zookeeper},</if>
|
||||
<if test="deployDate != null">#{deployDate},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedList" parameterType="SgFeedList">
|
||||
update sg_feed_list
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id = #{formulaId},</if>
|
||||
<if test="formulaBatchId != null">formula_batch_id = #{formulaBatchId},</if>
|
||||
<if test="zookeeper != null">zookeeper = #{zookeeper},</if>
|
||||
<if test="deployDate != null">deploy_date = #{deployDate},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedListById" parameterType="Long">
|
||||
delete from sg_feed_list where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedListByIds" parameterType="String">
|
||||
delete from sg_feed_list where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -18,6 +18,8 @@
|
||||
<result property="parity" column="parity"/>
|
||||
<result property="varietyId" column="variety_id"/>
|
||||
<result property="varietyName" column="varietyName"/>
|
||||
<result property="typeId" column="type_id"/>
|
||||
<result property="typeName" column="type_name"/>
|
||||
<result property="joinDate" column="join_date"/>
|
||||
<result property="comment" column="comment"/>
|
||||
<result property="technician" column="technician"/>
|
||||
@ -29,10 +31,12 @@
|
||||
SELECT
|
||||
sas.*,
|
||||
sf.sheepfold_name AS sheepfoldName,
|
||||
bv.variety AS varietyName
|
||||
bv.variety AS varietyName,
|
||||
st.type_name AS typeName
|
||||
FROM sc_add_sheep sas
|
||||
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
|
||||
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
|
||||
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
|
||||
<where>
|
||||
<if test="earNumber != null and earNumber != ''">
|
||||
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
|
||||
@ -43,6 +47,9 @@
|
||||
<if test="varietyId != null">
|
||||
AND sas.variety_id = #{varietyId}
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
AND sas.type_id = #{typeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -54,18 +61,19 @@
|
||||
|
||||
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sc_add_sheep
|
||||
(ear_number, sheepfold, father, mother, born_weight, birthday,
|
||||
gender, parity, variety_id, join_date, comment, technician,
|
||||
create_by, create_time)
|
||||
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
|
||||
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
|
||||
#{comment}, #{technician}, #{createBy}, #{createTime})
|
||||
(ear_number, sheepfold, ranch_id, father, mother, born_weight, birthday,
|
||||
gender, parity, variety_id, type_id, join_date, comment, technician,
|
||||
create_by, create_time)
|
||||
VALUES (#{earNumber}, #{sheepfold}, #{ranchId}, #{father}, #{mother}, #{bornWeight},
|
||||
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{typeId}, #{joinDate},
|
||||
#{comment}, #{technician}, #{createBy}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateScAddSheep" parameterType="ScAddSheep">
|
||||
UPDATE sc_add_sheep
|
||||
<set>
|
||||
ear_number = #{earNumber},
|
||||
ranch_id = #{ranchId},
|
||||
sheepfold = #{sheepfold},
|
||||
father = #{father},
|
||||
mother = #{mother},
|
||||
@ -74,6 +82,7 @@
|
||||
gender = #{gender},
|
||||
parity = #{parity},
|
||||
variety_id = #{varietyId},
|
||||
type_id = #{typeId},
|
||||
join_date = #{joinDate},
|
||||
comment = #{comment},
|
||||
technician = #{technician},
|
||||
|
@ -8,6 +8,8 @@
|
||||
<result property="id" column="id"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="manageTags" column="manage_tags"/>
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="newComment" column="new_comment"/>
|
||||
<result property="oldComment" column="old_comment"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
@ -17,13 +19,16 @@
|
||||
<sql id="selectScChangeCommentVo">
|
||||
select scc.id,
|
||||
scc.sheep_id,
|
||||
bs.manage_tags as manage_tags,
|
||||
bs.manage_tags as manage_tags,
|
||||
sf.sheepfold_name as sheepfold_name,
|
||||
'改备注' as event_type,
|
||||
scc.new_comment,
|
||||
scc.old_comment,
|
||||
scc.create_by,
|
||||
scc.create_time
|
||||
from sc_change_comment scc
|
||||
left join bas_sheep bs on scc.sheep_id = bs.id
|
||||
left join da_sheepfold sf on bs.sheepfold_id = sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScChangeCommentList" parameterType="ScChangeComment" resultMap="ScChangeCommentResult">
|
||||
@ -32,6 +37,7 @@
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="newComment != null and newComment != ''">
|
||||
and scc.new_comment like concat('%', #{newComment}, '%')
|
||||
</if>
|
||||
|
@ -8,6 +8,8 @@
|
||||
<result property="id" column="sce_id"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="manageTags" column="manage_tags"/>
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="earType" column="ear_type"/>
|
||||
<result property="newTag" column="newTag"/>
|
||||
<result property="oldTag" column="oldTag"/>
|
||||
@ -20,6 +22,12 @@
|
||||
select sce.id as sce_id,
|
||||
sce.sheep_id,
|
||||
bs.manage_tags as manage_tags,
|
||||
sf.sheepfold_name as sheepfold_name,
|
||||
case
|
||||
when sce.ear_type = 0 then '改电子耳号'
|
||||
when sce.ear_type = 1 then '改管理耳号'
|
||||
else ''
|
||||
end as event_type,
|
||||
sce.ear_type,
|
||||
sce.newTag,
|
||||
sce.oldTag as oldTag,
|
||||
@ -28,6 +36,7 @@
|
||||
sce.create_time
|
||||
from sc_change_ear sce
|
||||
LEFT JOIN bas_sheep bs ON sce.sheep_id = bs.id
|
||||
LEFT JOIN da_sheepfold sf ON bs.sheepfold_id = sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScChangeEarList" parameterType="ScChangeEar" resultMap="ScChangeEarResult">
|
||||
@ -37,6 +46,10 @@
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
|
||||
</if>
|
||||
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="sheepfoldName != null and sheepfoldName != ''">
|
||||
and sf.sheepfold_name LIKE CONCAT('%', #{sheepfoldName}, '%')
|
||||
</if>
|
||||
<if test="earType != null ">and sce.ear_type = #{earType}</if>
|
||||
<if test="newTag != null and newTag != ''">
|
||||
and sce.newTag LIKE CONCAT('%', #{newTag}, '%')
|
||||
|
@ -8,6 +8,8 @@
|
||||
<result property="id" column="id"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="manageTags" column="manage_tags"/>
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="varietyOld" column="variety_old"/>
|
||||
<result property="varietyNew" column="variety_new"/>
|
||||
<result property="comment" column="comment"/>
|
||||
@ -18,7 +20,9 @@
|
||||
<sql id="selectScChangeVarietyVo">
|
||||
select scv.id,
|
||||
scv.sheep_id,
|
||||
bs.manage_tags as manage_tags,
|
||||
bs.manage_tags as manage_tags,
|
||||
sf.sheepfold_name as sheepfold_name,
|
||||
'改品种' as event_type,
|
||||
scv.variety_old,
|
||||
scv.variety_new,
|
||||
scv.comment,
|
||||
@ -26,6 +30,7 @@
|
||||
scv.create_time
|
||||
from sc_change_variety scv
|
||||
left join bas_sheep bs on scv.sheep_id = bs.id
|
||||
left join da_sheepfold sf on bs.sheepfold_id = sf.id
|
||||
</sql>
|
||||
|
||||
<select id="selectScChangeVarietyList" parameterType="ScChangeVariety" resultMap="ScChangeVarietyResult">
|
||||
@ -35,6 +40,7 @@
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="varietyOld != null and varietyOld != ''">
|
||||
and scv.variety_old like concat('%', #{varietyOld}, '%')
|
||||
</if>
|
||||
|
@ -25,18 +25,22 @@
|
||||
SELECT tg.id,
|
||||
tg.sheep_id,
|
||||
s.manage_tags AS manageTags,
|
||||
tg.event_type AS eventType,
|
||||
tg.trans_date AS transDate,
|
||||
tg.fold_to,
|
||||
tg.fold_from,
|
||||
tg.reason,
|
||||
tg.variety_id,
|
||||
bv.variety AS varietyName,
|
||||
tg.technician,
|
||||
st.id AS sheepTypeId,
|
||||
st.name AS sheepTypeName,
|
||||
tg.status,
|
||||
tg.comment,
|
||||
tg.create_by,
|
||||
tg.create_time,
|
||||
sf_from.sheepfold_name AS foldFromName,
|
||||
sf_to.sheepfold_name AS foldToName,
|
||||
tg.technician,
|
||||
st.id AS sheepTypeId,
|
||||
st.name AS sheepTypeName
|
||||
FROM sc_trans_group tg
|
||||
@ -54,10 +58,15 @@
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and s.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
<if test="eventType != null">and tg.event_type = #{eventType}</if>
|
||||
<if test="params.beginTransDate != null and params.beginTransDate != '' and params.endTransDate != null and params.endTransDate != ''">
|
||||
and tg.trans_date between #{params.beginTransDate} and #{params.endTransDate}
|
||||
</if>
|
||||
<if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if>
|
||||
<if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if>
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
|
||||
<if test="sheepTypeId != null">and st.id = #{sheepTypeId}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and tg.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
@ -75,6 +84,8 @@
|
||||
insert into sc_trans_group
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="eventType != null">event_type,</if>
|
||||
<if test="transDate != null and transDate != ''">trans_date,</if>
|
||||
<if test="foldTo != null and foldTo != ''">fold_to,</if>
|
||||
<if test="foldFrom != null and foldFrom != ''">fold_from,</if>
|
||||
<if test="varietyId != null">variety_id,</if>
|
||||
@ -87,6 +98,8 @@
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="eventType != null">#{eventType},</if>
|
||||
<if test="transDate != null and transDate != ''">#{transDate},</if>
|
||||
<if test="foldTo != null and foldTo != ''">#{foldTo},</if>
|
||||
<if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if>
|
||||
<if test="varietyId != null">#{varietyId},</if>
|
||||
@ -103,6 +116,8 @@
|
||||
update sc_trans_group
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="eventType != null">event_type = #{eventType},</if>
|
||||
<if test="transDate != null and transDate != ''">trans_date = #{transDate},</if>
|
||||
<if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if>
|
||||
<if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if>
|
||||
<if test="varietyId != null">variety_id = #{varietyId},</if>
|
||||
|
@ -6,12 +6,14 @@
|
||||
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo" id="ScTransitionInfoResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="varietyId" column="variety_id"/>
|
||||
<result property="varietyName" column="varietyName"/>
|
||||
<result property="transTo" column="trans_to"/>
|
||||
<result property="transFrom" column="trans_from"/>
|
||||
<result property="transType" column="trans_type"/>
|
||||
<result property="transTypeText" column="transTypeText"/>
|
||||
<result property="transitionDate" column="transition_date"/>
|
||||
<result property="technician" column="technician"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="comment" column="comment"/>
|
||||
@ -21,20 +23,22 @@
|
||||
|
||||
<sql id="selectScTransitionInfoVo">
|
||||
SELECT t.*,
|
||||
bv.variety AS varietyName,
|
||||
bs.manage_tags AS manageTags,
|
||||
bv.variety AS varietyName,
|
||||
bs.manage_tags AS manageTags,
|
||||
t.event_type AS eventType,
|
||||
t.transition_date AS transitionDate,
|
||||
CASE t.trans_type
|
||||
WHEN 0 THEN '内部调拨'
|
||||
WHEN 1 THEN '内部销售'
|
||||
WHEN 2 THEN '育肥调拨'
|
||||
ELSE '未知'
|
||||
END AS transTypeText,
|
||||
END AS transTypeText,
|
||||
CASE t.status
|
||||
WHEN 0 THEN '待审批'
|
||||
WHEN 1 THEN '已通过'
|
||||
WHEN 2 THEN '已驳回'
|
||||
ELSE '未知状态'
|
||||
END AS statusText
|
||||
END AS statusText
|
||||
FROM sc_transition_info t
|
||||
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
|
||||
LEFT JOIN bas_sheep_variety bv ON bs.variety_id = bv.id
|
||||
@ -47,6 +51,14 @@
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
|
||||
</if>
|
||||
<if test="eventType != null and eventType != ''">
|
||||
and t.event_type = #{eventType}
|
||||
</if>
|
||||
<if test="transType != null">and t.trans_type = #{transType}</if>
|
||||
<if test="params.beginTransitionDate != null and params.beginTransitionDate != ''
|
||||
and params.endTransitionDate != null and params.endTransitionDate != ''">
|
||||
and t.transition_date between #{params.beginTransitionDate} and #{params.endTransitionDate}
|
||||
</if>
|
||||
<if test="varietyId != null">and bs.variety_id = #{varietyId}</if>
|
||||
<if test="transTo != null and transTo != ''">and trans_to = #{transTo}</if>
|
||||
<if test="transFrom != null and transFrom != ''">and trans_from = #{transFrom}</if>
|
||||
@ -69,7 +81,9 @@
|
||||
<if test="varietyId != null">variety_id,</if>
|
||||
<if test="transTo != null and transTo != ''">trans_to,</if>
|
||||
<if test="transFrom != null and transFrom != ''">trans_from,</if>
|
||||
<if test="eventType != null and eventType != ''">event_type,</if>
|
||||
<if test="transType != null">trans_type,</if>
|
||||
<if test="transitionDate != null">transition_date,</if>
|
||||
<if test="technician != null and technician != ''">technician,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
@ -81,7 +95,9 @@
|
||||
<if test="varietyId != null">#{varietyId},</if>
|
||||
<if test="transTo != null and transTo != ''">#{transTo},</if>
|
||||
<if test="transFrom != null and transFrom != ''">#{transFrom},</if>
|
||||
<if test="eventType != null and eventType != ''">#{eventType},</if>
|
||||
<if test="transType != null">#{transType},</if>
|
||||
<if test="transitionDate != null">#{transitionDate},</if>
|
||||
<if test="technician != null and technician != ''">#{technician},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
@ -93,13 +109,13 @@
|
||||
<insert id="insertScTransitionInfoBatch">
|
||||
INSERT INTO sc_transition_info (
|
||||
sheep_id, variety_id, trans_to, trans_from,
|
||||
trans_type, technician, status, comment,
|
||||
event_type,trans_type, transition_date, technician, status, comment,
|
||||
create_by, create_time
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom},
|
||||
#{item.transType}, #{item.technician}, #{item.status}, #{item.comment},
|
||||
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType},
|
||||
#{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment},
|
||||
#{item.createBy}, now()
|
||||
)
|
||||
</foreach>
|
||||
@ -110,9 +126,12 @@
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="varietyId != null">variety_id = #{varietyId},</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id = #{sheepfoldId},</if>
|
||||
<if test="transTo != null and transTo != ''">trans_to = #{transTo},</if>
|
||||
<if test="transFrom != null and transFrom != ''">trans_from = #{transFrom},</if>
|
||||
<if test="eventType != null and eventType != ''">event_type = #{eventType},</if>
|
||||
<if test="transType != null">trans_type = #{transType},</if>
|
||||
<if test="transitionDate != null">transition_date = #{transitionDate},</if>
|
||||
<if test="technician != null and technician != ''">technician = #{technician},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
|
@ -4,10 +4,11 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.other.mapper.ScCastrateMapper">
|
||||
|
||||
<resultMap type="ScCastrate" id="ScCastrateResult">
|
||||
<resultMap type="com.zhyc.module.produce.other.domain.ScCastrate" id="ScCastrateResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="manageTags" column="manageTags"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="sheepfold" column="sheepfold"/>
|
||||
<result property="sheepfoldName" column="sheepfoldName"/>
|
||||
<result property="varietyId" column="variety_id"/>
|
||||
@ -22,6 +23,7 @@
|
||||
select sc.id,
|
||||
sc.sheep_id,
|
||||
bs.manage_tags as manageTags,
|
||||
'去势' as event_type,
|
||||
bs.sheepfold_id as sheepfold,
|
||||
sf.sheepfold_name as sheepfoldName,
|
||||
bs.variety_id as varietyId,
|
||||
|
@ -4,9 +4,10 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.other.mapper.ScFixHoofMapper">
|
||||
|
||||
<resultMap type="ScFixHoof" id="ScFixHoofResult">
|
||||
<resultMap type="com.zhyc.module.produce.other.domain.ScFixHoof" id="ScFixHoofResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="manageTags" column="manageTags"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="sheepfold" column="sheepfold"/>
|
||||
<result property="varietyId" column="variety_id"/>
|
||||
<result property="sheepfoldName" column="sheepfoldName"/>
|
||||
@ -19,6 +20,7 @@
|
||||
<sql id="selectScFixHoofVo">
|
||||
select fh.id,
|
||||
bs.manage_tags as manageTags,
|
||||
'修蹄' as event_type,
|
||||
bs.sheepfold_id as sheepfold,
|
||||
sf.sheepfold_name as sheepfoldName,
|
||||
bs.variety_id as varietyId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user