完善领料申请修改逻辑
This commit is contained in:
parent
d51ec0bbf3
commit
04d79ac8b0
|
|
@ -95,7 +95,7 @@ public class LeaseApplyDetails implements Serializable {
|
|||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@ApiModelProperty(value = "更新时间 ")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -275,14 +275,32 @@ public class TmTaskController extends BaseController {
|
|||
try {
|
||||
int taskResult = tmTaskService.updateByPrimaryKeySelective(task);
|
||||
if (taskResult > 0) {
|
||||
if (CollUtil.isNotEmpty(task.getLeaseApplyDetails())) {
|
||||
for (LeaseApplyDetails leaseApplyDetails : task.getLeaseApplyDetails()) {
|
||||
leaseApplyDetailsService.updateByPrimaryKeySelective(leaseApplyDetails);
|
||||
}
|
||||
return AjaxResult.success("修改成功");
|
||||
} else {
|
||||
return AjaxResult.error("任务表修改成功,但领料任务明细修改信息为空");
|
||||
if (CollUtil.isEmpty(task.getLeaseApplyInfoList())){
|
||||
return AjaxResult.error("任务表修改完成,但领料任务明细为空,执行失败!");
|
||||
}
|
||||
// 先删除原有的领料任务明细
|
||||
for (LeaseApplyInfo leaseApplyInfo : task.getLeaseApplyInfoList()) {
|
||||
if (leaseApplyInfo == null || leaseApplyInfo.getId() == null) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isEmpty(leaseApplyInfo.getLeaseApplyDetails())) {
|
||||
continue;
|
||||
}
|
||||
// 执行删除
|
||||
tmTaskService.deleteDetailsByParentId(String.valueOf(leaseApplyInfo.getId()));
|
||||
// 删除后,插入新地领料任务明细
|
||||
if (StringUtils.isNotNull(leaseApplyInfo.getId())) {
|
||||
for (LeaseApplyDetails leaseApplyDetails : leaseApplyInfo.getLeaseApplyDetails()) {
|
||||
leaseApplyDetails.setParenntId(leaseApplyInfo.getId()); // 设置领料任务ID
|
||||
}
|
||||
// 插入领料任务明细
|
||||
boolean addLeaseTaskDetailsResult = leaseApplyDetailsService.batchInsert(leaseApplyInfo.getLeaseApplyDetails()) > 0;
|
||||
System.out.println(addLeaseTaskDetailsResult ? "领料任务明细插入成功" : "领料任务明细插入失败");
|
||||
} else {
|
||||
return AjaxResult.error("领料任务ID为空,修改失败!");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("修改成功");
|
||||
} else {
|
||||
return AjaxResult.error("任务表修改失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import java.util.List;
|
|||
public interface LeaseApplyDetailsMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int deleteByParentId(String parentId);
|
||||
|
||||
int insert(LeaseApplyDetails record);
|
||||
|
||||
int insertOrUpdate(LeaseApplyDetails record);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ public interface TmTaskMapper {
|
|||
|
||||
int deleteDetailsByTaskId(@Param("id") String id);
|
||||
|
||||
int deleteDetailsByParentId(String parentId);
|
||||
|
||||
int insert(TmTask record);
|
||||
|
||||
int insertOrUpdate(TmTask record);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.bonus.sgzb.app.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* Description:
|
||||
* @Author 阮世耀
|
||||
|
|
@ -11,6 +12,7 @@ import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
|||
|
||||
public interface LeaseApplyDetailsService{
|
||||
|
||||
int deleteByParentId(String parentId);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public interface TmTaskService{
|
|||
|
||||
int deleteDetailsByTaskId(@Param("id") String id);
|
||||
|
||||
int deleteDetailsByParentId(String parentId);
|
||||
|
||||
int createTask(TmTask record);
|
||||
|
||||
int insertOrUpdate(TmTask record);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package com.bonus.sgzb.app.service.impl;
|
||||
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
|
||||
/**
|
||||
* Description:
|
||||
* @Author 阮世耀
|
||||
|
|
@ -24,6 +25,11 @@ public class LeaseApplyDetailsServiceImpl implements LeaseApplyDetailsService{
|
|||
return leaseApplyDetailsMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByParentId(String id) {
|
||||
return leaseApplyDetailsMapper.deleteByParentId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(LeaseApplyDetails record) {
|
||||
return leaseApplyDetailsMapper.insert(record);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,16 @@ public class TmTaskServiceImpl implements TmTaskService{
|
|||
return tmTaskMapper.deleteDetailsByTaskId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据parentID删除详情表配置的设备
|
||||
* @param parentId 所属ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDetailsByParentId(String parentId) {
|
||||
return tmTaskMapper.deleteDetailsByParentId(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createTask(TmTask record) {
|
||||
return tmTaskMapper.insert(record);
|
||||
|
|
|
|||
|
|
@ -29,11 +29,17 @@
|
|||
from lease_apply_details
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
<!--@mbg.generated-->
|
||||
delete from lease_apply_details
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByParentId" parameterType="java.lang.Integer">
|
||||
delete from lease_apply_details
|
||||
where parennt_id = #{parentId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.LeaseApplyDetails" useGeneratedKeys="true">
|
||||
<!--@mbg.generated-->
|
||||
insert into lease_apply_details (parennt_id, type_id, pre_num,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@
|
|||
delete from lease_apply_details where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDetailsByParentId" parameterType="java.lang.String">
|
||||
delete from lease_apply_details where parennt_id = #{parentId}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.sgzb.base.api.domain.TmTask" useGeneratedKeys="true">
|
||||
insert into tm_task (task_type, task_status, code, create_by, create_time, update_by, update_time, remark, company_id)
|
||||
values (#{taskType,jdbcType=INTEGER}, #{taskStatus,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
|
||||
|
|
|
|||
Loading…
Reference in New Issue