冻精冻胚的非空校验,模糊查询,唯一性校验

This commit is contained in:
zyh 2025-12-08 19:08:39 +08:00
parent 68cc26d239
commit a49a4a0359
4 changed files with 61 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils; import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.frozen.mapper.DdFeMapper;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -26,18 +27,18 @@ import com.zhyc.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/frozen/embryo") @RequestMapping("/frozen/embryo")
public class DdFeController extends BaseController public class DdFeController extends BaseController {
{
@Autowired @Autowired
private IDdFeService ddFeService; private IDdFeService ddFeService;
@Autowired
private DdFeMapper ddFeMapper;
/** /**
* 查询冻胚库存列表 * 查询冻胚库存列表
*/ */
@PreAuthorize("@ss.hasPermi('frozen:embryo:list')") @PreAuthorize("@ss.hasPermi('frozen:embryo:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(DdFe ddFe) public TableDataInfo list(DdFe ddFe) {
{
startPage(); startPage();
List<DdFe> list = ddFeService.selectDdFeList(ddFe); List<DdFe> list = ddFeService.selectDdFeList(ddFe);
return getDataTable(list); return getDataTable(list);
@ -49,8 +50,7 @@ public class DdFeController extends BaseController
@PreAuthorize("@ss.hasPermi('frozen:embryo:export')") @PreAuthorize("@ss.hasPermi('frozen:embryo:export')")
@Log(title = "冻胚库存", businessType = BusinessType.EXPORT) @Log(title = "冻胚库存", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DdFe ddFe) public void export(HttpServletResponse response, DdFe ddFe) {
{
List<DdFe> list = ddFeService.selectDdFeList(ddFe); List<DdFe> list = ddFeService.selectDdFeList(ddFe);
ExcelUtil<DdFe> util = new ExcelUtil<DdFe>(DdFe.class); ExcelUtil<DdFe> util = new ExcelUtil<DdFe>(DdFe.class);
util.exportExcel(response, list, "冻胚库存数据"); util.exportExcel(response, list, "冻胚库存数据");
@ -61,8 +61,7 @@ public class DdFeController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('frozen:embryo:query')") @PreAuthorize("@ss.hasPermi('frozen:embryo:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return success(ddFeService.selectDdFeById(id)); return success(ddFeService.selectDdFeById(id));
} }
@ -72,8 +71,7 @@ public class DdFeController extends BaseController
@PreAuthorize("@ss.hasPermi('frozen:embryo:add')") @PreAuthorize("@ss.hasPermi('frozen:embryo:add')")
@Log(title = "冻胚库存", businessType = BusinessType.INSERT) @Log(title = "冻胚库存", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody DdFe ddFe) public AjaxResult add(@RequestBody DdFe ddFe) {
{
ddFe.setCreateBy(SecurityUtils.getUsername()); ddFe.setCreateBy(SecurityUtils.getUsername());
return toAjax(ddFeService.insertDdFe(ddFe)); return toAjax(ddFeService.insertDdFe(ddFe));
} }
@ -84,8 +82,7 @@ public class DdFeController extends BaseController
@PreAuthorize("@ss.hasPermi('frozen:embryo:edit')") @PreAuthorize("@ss.hasPermi('frozen:embryo:edit')")
@Log(title = "冻胚库存", businessType = BusinessType.UPDATE) @Log(title = "冻胚库存", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody DdFe ddFe) public AjaxResult edit(@RequestBody DdFe ddFe) {
{
return toAjax(ddFeService.updateDdFe(ddFe)); return toAjax(ddFeService.updateDdFe(ddFe));
} }
@ -94,9 +91,8 @@ public class DdFeController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('frozen:embryo:remove')") @PreAuthorize("@ss.hasPermi('frozen:embryo:remove')")
@Log(title = "冻胚库存", businessType = BusinessType.DELETE) @Log(title = "冻胚库存", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(ddFeService.deleteDdFeByIds(ids)); return toAjax(ddFeService.deleteDdFeByIds(ids));
} }
@ -126,13 +122,26 @@ public class DdFeController extends BaseController
Integer qty; Integer qty;
switch (grade) { switch (grade) {
case "A": qty = (Integer) flush.getOrDefault("gradeA", 0); break; case "A":
case "B": qty = (Integer) flush.getOrDefault("gradeB", 0); break; qty = (Integer) flush.getOrDefault("gradeA", 0);
case "C": qty = (Integer) flush.getOrDefault("gradeC", 0); break; break;
case "D": qty = (Integer) flush.getOrDefault("gradeD", 0); break; case "B":
case "囊胚": qty = (Integer) flush.getOrDefault("cell24", 0); break; qty = (Integer) flush.getOrDefault("gradeB", 0);
case "桑椹胚": qty = (Integer) flush.getOrDefault("cell8", 0); break; break;
default: qty = 0; case "C":
qty = (Integer) flush.getOrDefault("gradeC", 0);
break;
case "D":
qty = (Integer) flush.getOrDefault("gradeD", 0);
break;
case "囊胚":
qty = (Integer) flush.getOrDefault("cell24", 0);
break;
case "桑椹胚":
qty = (Integer) flush.getOrDefault("cell8", 0);
break;
default:
qty = 0;
} }
return success(qty); return success(qty);
} }
@ -153,4 +162,10 @@ public class DdFeController extends BaseController
}); });
return success(); return success();
} }
// 唯一性校验
@GetMapping("/checkCode")
public AjaxResult exist(@RequestParam String code) {
return success(ddFeMapper.existsByCode(code) > 0);
}
} }

View File

@ -72,4 +72,6 @@ public interface DdFeMapper
* 废弃更新只改状态出库日期废弃原因更新人 * 废弃更新只改状态出库日期废弃原因更新人
*/ */
int updateDiscard(DdFe dto); int updateDiscard(DdFe dto);
// 唯一性校验
int existsByCode(@Param("code") String code);
} }

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.StringUtils; import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.produce.breed.domain.ScEmbryoFlush; import com.zhyc.module.produce.breed.domain.ScEmbryoFlush;
@ -65,6 +66,9 @@ public class DdFeServiceImpl implements IDdFeService
@Override @Override
public int insertDdFe(DdFe ddFe) public int insertDdFe(DdFe ddFe)
{ {
if (ddFeMapper.existsByCode(ddFe.getCode()) > 0) {
throw new ServiceException("胚胎编号已存在,请勿重复录入");
}
ddFe.setCreateTime(DateUtils.getNowDate()); ddFe.setCreateTime(DateUtils.getNowDate());
return ddFeMapper.insertDdFe(ddFe); return ddFeMapper.insertDdFe(ddFe);
} }

View File

@ -59,8 +59,10 @@
<if test="code != null and code != ''">and code like concat('%', #{code}, '%')</if> <if test="code != null and code != ''">and code like concat('%', #{code}, '%')</if>
<if test="grade != null and grade != ''">and grade = #{grade}</if> <if test="grade != null and grade != ''">and grade = #{grade}</if>
<if test="status != null and status != ''">and status = #{status}</if> <if test="status != null and status != ''">and status = #{status}</if>
<if test="tech != null and tech != ''">and tech = #{tech}</if> <if test="tech != null and tech != ''">
<if test="outDate != null "> and out_date = #{outDate}</if> AND tech LIKE CONCAT('%', #{tech}, '%')
</if>
<if test="outDate != null ">and out_date = #{outDate}</if>
<if test="params.beginFreezeDate != null and params.endFreezeDate != null"> <if test="params.beginFreezeDate != null and params.endFreezeDate != null">
and freeze_date between #{params.beginFreezeDate} and #{params.endFreezeDate} and freeze_date between #{params.beginFreezeDate} and #{params.endFreezeDate}
</if> </if>
@ -164,23 +166,26 @@
</delete> </delete>
<select id="selectFlushByEwe" resultType="map"> <select id="selectFlushByEwe" resultType="map">
SELECT grade_a gradeA, SELECT grade_a gradeA,
grade_b gradeB, grade_b gradeB,
grade_c gradeC, grade_c gradeC,
grade_d gradeD, grade_d gradeD,
cell_2_4 cell24, cell_2_4 cell24,
cell_8 cell8, cell_8 cell8,
donor_male_no ramId donor_male_no ramId
FROM sc_embryo_flush FROM sc_embryo_flush
WHERE donor_female_no = #{eweNo} WHERE donor_female_no = #{eweNo}
ORDER BY flush_time DESC ORDER BY flush_time DESC LIMIT 1
LIMIT 1
</select> </select>
<update id="updateDiscard" parameterType="DdFe"> <update id="updateDiscard" parameterType="DdFe">
UPDATE dd_fe UPDATE dd_fe
SET status = #{status}, SET status = #{status},
discard_txt = #{discardTxt} discard_txt = #{discardTxt}
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<select id="existsByCode" resultType="int">
SELECT COUNT(*) FROM dd_fe WHERE code = #{code}
</select>
</mapper> </mapper>