内存验收接口优化
This commit is contained in:
parent
53d4cff77a
commit
89f79f9181
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
|
@ -18,7 +17,6 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.bonus.common.log.annotation.SysLog;
|
import com.bonus.common.log.annotation.SysLog;
|
||||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
|
||||||
import com.bonus.material.purchase.domain.PurchaseCheckInfo;
|
import com.bonus.material.purchase.domain.PurchaseCheckInfo;
|
||||||
import com.bonus.material.purchase.service.IPurchaseCheckInfoService;
|
import com.bonus.material.purchase.service.IPurchaseCheckInfoService;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
|
@ -95,15 +93,27 @@ public class PurchaseCheckInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验收API
|
* 外层批量验收API
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "外层批量验收API")
|
@ApiOperation(value = "外层批量验收API")
|
||||||
@PreventRepeatSubmit
|
@PreventRepeatSubmit
|
||||||
//@RequiresPermissions("purchase:info:edit")
|
//@RequiresPermissions("purchase:info:edit")
|
||||||
@SysLog(title = "新购验收任务", businessType = OperaType.UPDATE, module = "物资新购->外层批量验收API")
|
@SysLog(title = "新购验收任务", businessType = OperaType.UPDATE, module = "物资新购->外层批量验收API")
|
||||||
@PutMapping("/verify")
|
@PutMapping("/outerVerify")
|
||||||
public AjaxResult verify(@RequestBody PurchaseDto purchaseDto) {
|
public AjaxResult outerVerify(@RequestBody PurchaseDto purchaseDto) {
|
||||||
return purchaseCheckInfoService.verify(purchaseDto);
|
return purchaseCheckInfoService.outVerify(purchaseDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外层批量验收API
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "内层批量验收API")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
//@RequiresPermissions("purchase:info:edit")
|
||||||
|
@SysLog(title = "新购验收任务", businessType = OperaType.UPDATE, module = "物资新购->内层批量验收API")
|
||||||
|
@PutMapping("/innerVerify")
|
||||||
|
public AjaxResult innerVerify(@RequestBody PurchaseCheckDto purchaseCheckDto) {
|
||||||
|
return purchaseCheckInfoService.innerVerify(purchaseCheckDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class PurchaseDto {
|
||||||
private String keyWord;
|
private String keyWord;
|
||||||
|
|
||||||
@ApiModelProperty(value = "状态")
|
@ApiModelProperty(value = "状态")
|
||||||
private Integer status;
|
private Long status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "出厂日期")
|
@ApiModelProperty(value = "出厂日期")
|
||||||
private String productDate;
|
private String productDate;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,9 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
* @param taskId 任务id
|
* @param taskId 任务id
|
||||||
* @param newTaskStatus 新状态
|
* @param newTaskStatus 新状态
|
||||||
*/
|
*/
|
||||||
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId, @Param("newTaskStatus") Integer newTaskStatus);
|
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId, @Param("newTaskStatus") Long newTaskStatus);
|
||||||
|
|
||||||
|
int getCountOfNoneThisStatus(@Param("taskId") Long taskId, @Param("newTaskStatus") Long newTaskStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除新购验收任务详细
|
* 删除新购验收任务详细
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ public interface IPurchaseCheckInfoService {
|
||||||
// */
|
// */
|
||||||
// AjaxResult acceptance(List<Long> taskId);
|
// AjaxResult acceptance(List<Long> taskId);
|
||||||
|
|
||||||
AjaxResult verify(PurchaseDto purchaseDto);
|
AjaxResult outVerify(PurchaseDto purchaseDto);
|
||||||
|
|
||||||
|
AjaxResult innerVerify(PurchaseCheckDto purchaseCheckDto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务id查询验收单
|
* 根据任务id查询验收单
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,8 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult verify(PurchaseDto purchaseDto) {
|
@Transactional
|
||||||
|
public AjaxResult outVerify(PurchaseDto purchaseDto) {
|
||||||
try {
|
try {
|
||||||
AjaxResult result = new AjaxResult();
|
AjaxResult result = new AjaxResult();
|
||||||
purchaseDto.getTaskIds().removeIf(Objects::isNull);
|
purchaseDto.getTaskIds().removeIf(Objects::isNull);
|
||||||
|
|
@ -232,18 +233,40 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
||||||
boolean updateResult = tmTaskMapper.updateTmTaskStatusByTaskId(taskId,
|
boolean updateResult = tmTaskMapper.updateTmTaskStatusByTaskId(taskId,
|
||||||
purchaseDto.getStatus()
|
purchaseDto.getStatus()
|
||||||
) > 0;
|
) > 0;
|
||||||
|
|
||||||
if (updateResult) {
|
if (updateResult) {
|
||||||
result = purchaseCheckDetailsMapper.batchUpdateDetailsTaskStatus(taskId,
|
result = purchaseCheckDetailsMapper.batchUpdateDetailsTaskStatus(taskId,
|
||||||
purchaseDto.getStatus()
|
purchaseDto.getStatus()
|
||||||
) > 0 ? AjaxResult.success("验收通过,修改任务状态成功") : AjaxResult.error("修改任务明细失败");
|
) > 0 ? AjaxResult.success("验收状态更改成功") : AjaxResult.error("验收状态更改失败");
|
||||||
} else {
|
} else {
|
||||||
result = AjaxResult.error("SQL未报错,但修改任务0条");
|
result = AjaxResult.error("SQL未报错,但修改任务0条");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.error("修改任务失败,SQL异常报错:" + e.getMessage());
|
return AjaxResult.error("验收状态更改失败,异常报错:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult innerVerify(PurchaseCheckDto purchaseCheckDto) {
|
||||||
|
try {
|
||||||
|
AjaxResult result = new AjaxResult();
|
||||||
|
Long taskId = purchaseCheckDto.getPurchaseCheckInfo().getTaskId();
|
||||||
|
Long status = purchaseCheckDto.getPurchaseCheckDetailsList().get(0).getStatus();
|
||||||
|
for (PurchaseCheckDetails details : purchaseCheckDto.getPurchaseCheckDetailsList()) {
|
||||||
|
result = purchaseCheckDetailsMapper.batchUpdateDetailsTaskStatus(taskId,
|
||||||
|
details.getStatus()
|
||||||
|
) > 0 ? AjaxResult.success("details验收状态更改成功") : AjaxResult.error("details验收状态更改失败");
|
||||||
|
}
|
||||||
|
//查询是否这个taskId是否已全部验收通过,如果是的,更新整个task的任务状态
|
||||||
|
int count = purchaseCheckDetailsMapper.getCountOfNoneThisStatus(taskId, status);
|
||||||
|
if (count == 0) {
|
||||||
|
result = tmTaskMapper.updateTmTaskStatusByTaskId(taskId, status) > 0 ? AjaxResult.success("task验收状态更改成功") : AjaxResult.error("task验收状态更改失败");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("验收状态更改失败,异常报错:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public interface TmTaskMapper {
|
||||||
* @param taskId 任务id 必传
|
* @param taskId 任务id 必传
|
||||||
* @param newTaskStatus 新状态
|
* @param newTaskStatus 新状态
|
||||||
*/
|
*/
|
||||||
int updateTmTaskStatusByTaskId(@Param("taskId") Long taskId, @Param("newTaskStatus") Integer newTaskStatus);
|
int updateTmTaskStatusByTaskId(@Param("taskId") Long taskId, @Param("newTaskStatus") Long newTaskStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除任务
|
* 删除任务
|
||||||
|
|
|
||||||
|
|
@ -269,4 +269,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
del_flag = '0'
|
del_flag = '0'
|
||||||
and task_id = #{taskId}
|
and task_id = #{taskId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getCountOfNoneThisStatus" resultType="int">
|
||||||
|
select count(1)
|
||||||
|
from
|
||||||
|
purchase_check_details
|
||||||
|
where
|
||||||
|
`status` != #{newTaskStatus}
|
||||||
|
and del_flag = '0'
|
||||||
|
and task_id = #{taskId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue