Compare commits
2 Commits
7bce9a0774
...
094da396c1
| Author | SHA1 | Date | |
|---|---|---|---|
| 094da396c1 | |||
| d9a621d6a7 |
@@ -68,20 +68,27 @@ public class ScTransitionInfoController extends BaseController {
|
||||
/**
|
||||
* 新增转场
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('produce:transition_info:add')")
|
||||
// @Log(title = "转场", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) {
|
||||
// scTransitionInfo.setUserId(getUserId());
|
||||
// scTransitionInfo.setDeptId(getDeptId());
|
||||
// return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo));
|
||||
// }
|
||||
|
||||
//批量添加转场
|
||||
@PreAuthorize("@ss.hasPermi('produce:transition_info:add')")
|
||||
@Log(title = "转场", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) {
|
||||
scTransitionInfo.setUserId(getUserId());
|
||||
scTransitionInfo.setDeptId(getDeptId());
|
||||
return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo));
|
||||
}
|
||||
|
||||
//批量添加
|
||||
@PostMapping("/batch")
|
||||
public AjaxResult addBatch(@RequestBody List<ScTransitionInfo> transitionInfoList) {
|
||||
Long userId = getUserId();
|
||||
Long deptId = getDeptId();
|
||||
|
||||
for (ScTransitionInfo info : transitionInfoList) {
|
||||
info.setUserId(userId);
|
||||
info.setDeptId(deptId);
|
||||
}
|
||||
return toAjax(scTransitionInfoService.insertScTransitionInfoBatch(transitionInfoList));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface ScTransitionInfoMapper
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
|
||||
/**
|
||||
* 修改转场
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface IScTransitionInfoService {
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
|
||||
/**
|
||||
* 修改转场
|
||||
|
||||
@@ -67,26 +67,35 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
|
||||
* @param scTransitionInfo 转场
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo) {
|
||||
// 根据耳号查询羊只信息
|
||||
String manageTags = scTransitionInfo.getManageTags();
|
||||
if (StringUtils.isNotBlank(manageTags)) {
|
||||
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
|
||||
if (sheep == null) {
|
||||
throw new RuntimeException("耳号不存在,请检查输入");
|
||||
}
|
||||
scTransitionInfo.setSheepId(sheep.getId().intValue());
|
||||
scTransitionInfo.setVarietyId(sheep.getVarietyId());
|
||||
} else {
|
||||
throw new RuntimeException("耳号不能为空");
|
||||
}
|
||||
|
||||
scTransitionInfo.setStatus(0);
|
||||
scTransitionInfo.setCreateTime(DateUtils.getNowDate());
|
||||
return scTransitionInfoMapper.insertScTransitionInfo(scTransitionInfo);
|
||||
}
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo) {
|
||||
// // 根据耳号查询羊只信息
|
||||
// String manageTags = scTransitionInfo.getManageTags();
|
||||
// if (StringUtils.isNotBlank(manageTags)) {
|
||||
// BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
|
||||
// if (sheep == null) {
|
||||
// throw new RuntimeException("耳号不存在,请检查输入");
|
||||
// }
|
||||
// scTransitionInfo.setSheepId(sheep.getId().intValue());
|
||||
// scTransitionInfo.setVarietyId(sheep.getVarietyId());
|
||||
// if (scTransitionInfo.getSheepfoldId() == null && sheep.getSheepfoldId() != null) {
|
||||
// scTransitionInfo.setSheepfoldId(sheep.getSheepfoldId());
|
||||
// }
|
||||
// if (StringUtils.isBlank(scTransitionInfo.getTransFrom()) && sheep.getRanchId() != null) {
|
||||
// DaRanch ranch = daRanchService.selectDaRanchById(sheep.getRanchId());
|
||||
// if (ranch != null) {
|
||||
// scTransitionInfo.setTransFrom(ranch.getRanch());
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// throw new RuntimeException("耳号不能为空");
|
||||
// }
|
||||
//
|
||||
// scTransitionInfo.setStatus(0);
|
||||
// scTransitionInfo.setCreateTime(DateUtils.getNowDate());
|
||||
// return scTransitionInfoMapper.insertScTransitionInfo(scTransitionInfo);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@@ -141,6 +150,15 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
|
||||
}
|
||||
info.setSheepId(sheep.getId().intValue());
|
||||
info.setVarietyId(sheep.getVarietyId());
|
||||
if (info.getSheepfoldId() == null && sheep.getSheepfoldId() != null) {
|
||||
info.setSheepfoldId(sheep.getSheepfoldId());
|
||||
}
|
||||
if (StringUtils.isBlank(info.getTransFrom()) && sheep.getRanchId() != null) {
|
||||
DaRanch ranch = daRanchService.selectDaRanchById(sheep.getRanchId());
|
||||
if (ranch != null) {
|
||||
info.setTransFrom(ranch.getRanch());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("耳号不能为空");
|
||||
}
|
||||
|
||||
@@ -91,53 +91,54 @@
|
||||
WHERE t.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertScTransitionInfo" parameterType="ScTransitionInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_transition_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<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>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<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>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<!-- <insert id="insertScTransitionInfo" parameterType="ScTransitionInfo" useGeneratedKeys="true" keyProperty="id">-->
|
||||
<!-- insert into sc_transition_info-->
|
||||
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||
<!-- <if test="sheepId != null">sheep_id,</if>-->
|
||||
<!-- <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>-->
|
||||
<!-- <if test="createBy != null">create_by,</if>-->
|
||||
<!-- <if test="createTime != null">create_time,</if>-->
|
||||
<!-- <if test="userId != null">user_id,</if>-->
|
||||
<!-- <if test="deptId != null">dept_id,</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
|
||||
<!-- <if test="sheepId != null">#{sheepId},</if>-->
|
||||
<!-- <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>-->
|
||||
<!-- <if test="createBy != null">#{createBy},</if>-->
|
||||
<!-- <if test="createTime != null">#{createTime},</if>-->
|
||||
<!-- <if test="userId != null">#{userId},</if>-->
|
||||
<!-- <if test="deptId != null">#{deptId},</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- </insert>-->
|
||||
|
||||
<insert id="insertScTransitionInfoBatch">
|
||||
INSERT INTO sc_transition_info (
|
||||
sheep_id, variety_id, trans_to, trans_from,
|
||||
sheep_id,sheepfold_id, variety_id, trans_to, trans_from,
|
||||
event_type,trans_type, transition_date, technician, status, comment,
|
||||
create_by, create_time
|
||||
create_by, create_time,user_id,dept_id
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType},
|
||||
#{item.sheepId},#{item.sheepfoldId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType},
|
||||
#{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment},
|
||||
#{item.createBy}, now()
|
||||
#{item.createBy}, now(), #{item.userId},
|
||||
#{item.deptId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
Reference in New Issue
Block a user