11 changed files with 276 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||||
|
package com.yxt.anrui.scm.api.scmvehiclereturn; |
||||
|
|
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetailsDto; |
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 9:40 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ScmVehicleReturnDto implements Dto { |
||||
|
private static final long serialVersionUID = -276598777097000627L; |
||||
|
@ApiModelProperty(value = "sid") |
||||
|
private String sid; |
||||
|
@ApiModelProperty(value = "申请人sid", required = true) |
||||
|
private String userSid; |
||||
|
@ApiModelProperty(value = "申请人", required = true) |
||||
|
private String name; |
||||
|
@ApiModelProperty(value = "申请日期", required = true) |
||||
|
private Date createTime; |
||||
|
@ApiModelProperty(value = "退库原因", required = true) |
||||
|
private String reason; |
||||
|
@ApiModelProperty(value = "车辆列表") |
||||
|
private List<ScmVehicleReturnDetailsDto> detailsList; |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.yxt.anrui.scm.api.scmvehiclereturndetails; |
||||
|
|
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 9:44 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ScmVehicleReturnDetailsDto implements Dto { |
||||
|
private static final long serialVersionUID = 1207686604123585151L; |
||||
|
@ApiModelProperty(value = "车架号") |
||||
|
private String vinNo; |
||||
|
@ApiModelProperty(value = "车型") |
||||
|
private String modelName; |
||||
|
@ApiModelProperty(value = "常用配置") |
||||
|
private String configName; |
||||
|
@ApiModelProperty(value = "入库日期") |
||||
|
private Date inboundDate; |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.yxt.anrui.scm.biz.scmvehiclereturn; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturn; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 10:37 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ScmVehicleReturnMapper extends BaseMapper<ScmVehicleReturn> { |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
<?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.yxt.anrui.scm.biz.scmvehiclereturn.ScmVehicleReturnMapper"> |
||||
|
</mapper> |
@ -0,0 +1,81 @@ |
|||||
|
package com.yxt.anrui.scm.biz.scmvehiclereturn; |
||||
|
|
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturn; |
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturnDto; |
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetails; |
||||
|
import com.yxt.anrui.scm.biz.scmvehiclereturndetails.ScmVehicleReturnDetailsService; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.beans.BeanUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 10:35 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturnMapper, ScmVehicleReturn> { |
||||
|
|
||||
|
@Autowired |
||||
|
private ScmVehicleReturnDetailsService scmVehicleReturnDetailsService; |
||||
|
|
||||
|
/** |
||||
|
* 采购退库新增编辑 |
||||
|
* |
||||
|
* @param scmVehicleReturnDto 数据传输对象 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public ResultBean saveOrUpdateVehicleReturn(ScmVehicleReturnDto scmVehicleReturnDto) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
String sid = scmVehicleReturnDto.getSid(); |
||||
|
if (StringUtils.isBlank(sid)) { |
||||
|
//新增
|
||||
|
ScmVehicleReturn scmVehicleReturn = new ScmVehicleReturn(); |
||||
|
BeanUtils.copyProperties(scmVehicleReturnDto, scmVehicleReturn, scmVehicleReturn.getSid()); |
||||
|
boolean isSave = save(scmVehicleReturn); |
||||
|
if (!isSave) { |
||||
|
return rb.setMsg("保存失败"); |
||||
|
} else { |
||||
|
sid = scmVehicleReturn.getSid(); |
||||
|
if (scmVehicleReturnDto.getDetailsList().size() > 0) { |
||||
|
scmVehicleReturnDetailsService.saveDetails(scmVehicleReturnDto.getDetailsList(), scmVehicleReturn.getSid()); |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
//编辑
|
||||
|
//验证数据是否可更改
|
||||
|
if (checkCouldChange(sid)) { |
||||
|
return rb.setMsg("该条信息不可更改"); |
||||
|
} |
||||
|
int i = updateBySid(scmVehicleReturnDto, sid); |
||||
|
//查询details中是否有关于return的该条sid数据
|
||||
|
List<ScmVehicleReturnDetails> scmVehicleReturnDetailsList = scmVehicleReturnDetailsService.selectByReturnSid(sid); |
||||
|
if (scmVehicleReturnDetailsList.size() > 0) { |
||||
|
scmVehicleReturnDetailsService.updateListByReturnSid(sid, scmVehicleReturnDto.getDetailsList()); |
||||
|
} |
||||
|
} |
||||
|
return rb.success().setData(sid); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 判断是否可删除 |
||||
|
* |
||||
|
* @param sid sid |
||||
|
* @return |
||||
|
*/ |
||||
|
private boolean checkCouldChange(String sid) { |
||||
|
ScmVehicleReturn scmVehicleReturn = fetchBySid(sid); |
||||
|
// 判断是否可以更改(是否走了流程,更改了状态)
|
||||
|
if (StringUtils.isNotBlank(scmVehicleReturn.getNodeState())) { |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.yxt.anrui.scm.biz.scmvehiclereturndetails; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetails; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 10:48 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ScmVehicleReturnDetailsMapper extends BaseMapper<ScmVehicleReturnDetails> { |
||||
|
/** |
||||
|
* 根据车辆采购退库sid查询退库详细的数据 |
||||
|
* |
||||
|
* @param sid 采购退库sid |
||||
|
* @return |
||||
|
*/ |
||||
|
List<ScmVehicleReturnDetails> selectByReturnSid(String sid); |
||||
|
|
||||
|
/** |
||||
|
* 删除详细数据 |
||||
|
* |
||||
|
* @param sid 采购退库sid |
||||
|
* @return |
||||
|
*/ |
||||
|
int deleteByReturnSid(String sid); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
<?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.yxt.anrui.scm.biz.scmvehiclereturndetails.ScmVehicleReturnDetailsMapper"> |
||||
|
<select id="selectByReturnSid" resultType="com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetails"> |
||||
|
select * |
||||
|
from scm_vehicle_return_details sd |
||||
|
where vehicleOutSid = #{sid} |
||||
|
</select> |
||||
|
|
||||
|
<delete id="deleteByReturnSid"> |
||||
|
delete |
||||
|
from scm_vehicle_return_details |
||||
|
where vehicleOutSid = #{sid} |
||||
|
</delete> |
||||
|
</mapper> |
@ -0,0 +1,57 @@ |
|||||
|
package com.yxt.anrui.scm.biz.scmvehiclereturndetails; |
||||
|
|
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetails; |
||||
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetailsDto; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import org.springframework.beans.BeanUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2022/4/7 10:47 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ScmVehicleReturnDetailsService extends MybatisBaseService<ScmVehicleReturnDetailsMapper, ScmVehicleReturnDetails> { |
||||
|
/** |
||||
|
* 新增 |
||||
|
* |
||||
|
* @param detailsList |
||||
|
* @param outSid |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void saveDetails(List<ScmVehicleReturnDetailsDto> detailsList, String outSid) { |
||||
|
ScmVehicleReturnDetails scmVehicleReturnDetails = null; |
||||
|
for (ScmVehicleReturnDetailsDto dto : detailsList) { |
||||
|
scmVehicleReturnDetails = new ScmVehicleReturnDetails(); |
||||
|
BeanUtils.copyProperties(dto, scmVehicleReturnDetails, scmVehicleReturnDetails.getSid()); |
||||
|
scmVehicleReturnDetails.setVehicleOutSid(outSid); |
||||
|
save(scmVehicleReturnDetails); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询 |
||||
|
* |
||||
|
* @param sid |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<ScmVehicleReturnDetails> selectByReturnSid(String sid) { |
||||
|
return baseMapper.selectByReturnSid(sid); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除原车辆退库详细并新增 |
||||
|
* |
||||
|
* @param sid 车辆退库sid |
||||
|
* @param detailsList 退库车辆详细 |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void updateListByReturnSid(String sid, List<ScmVehicleReturnDetailsDto> detailsList) { |
||||
|
baseMapper.deleteByReturnSid(sid); |
||||
|
saveDetails(detailsList, sid); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue