parent
3ca1431596
commit
36d2b6f7be
@ -0,0 +1,41 @@ |
||||
package com.dxhy.order.consumer.modules.commodity.controller; |
||||
|
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.CloneCompanyCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.SyncGroupCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.service.ICompanyCommodityCodeService; |
||||
import com.dxhy.order.consumer.modules.commodity.service.IGroupCommodityCodeService; |
||||
import com.dxhy.order.model.PageUtils; |
||||
import com.dxhy.order.model.R; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
/** |
||||
* @Description 公司物料库 |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/9 08:19 |
||||
**/ |
||||
@RequestMapping(value = "/companyCommodity") |
||||
@RestController |
||||
@Slf4j |
||||
public class CompanyCommodityCodeController { |
||||
|
||||
private final static String LOGGER_MSG = "(集团物料库)"; |
||||
|
||||
@Autowired |
||||
private ICompanyCommodityCodeService cloneCompanyCommodityCode; |
||||
|
||||
/** |
||||
* 克隆物料 |
||||
* |
||||
* @return |
||||
*/ |
||||
@PostMapping("/clone") |
||||
public R quote(@RequestBody @Validated CloneCompanyCommodityDTO dto) { |
||||
return cloneCompanyCommodityCode.cloneCompanyCommodityCode(dto); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.dxhy.order.consumer.modules.commodity.domain.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @Description 克隆物料DTO |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/15 20:50 |
||||
**/ |
||||
@Data |
||||
public class CloneCompanyCommodityDTO { |
||||
|
||||
// 克隆的目标公司税号
|
||||
private CloneCompanyCommodityDetailDTO from; |
||||
|
||||
// 被克隆的目标公司税号
|
||||
private CloneCompanyCommodityDetailDTO to; |
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.dxhy.order.consumer.modules.commodity.domain.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
|
||||
/** |
||||
* @Description |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/16 10:45 |
||||
**/ |
||||
@Data |
||||
public class CloneCompanyCommodityDetailDTO { |
||||
@NotBlank(message = "销方税号不能为空") |
||||
private String xhfNsrsbh; // 销方税号
|
||||
@NotBlank(message = "数据权限不能为空") |
||||
private String entId; // 数据权限id
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.dxhy.order.consumer.modules.commodity.service; |
||||
|
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.CloneCompanyCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.SyncGroupCommodityDTO; |
||||
import com.dxhy.order.model.PageUtils; |
||||
import com.dxhy.order.model.R; |
||||
|
||||
/** |
||||
* @Description 集团物料库 |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/9 10:06 |
||||
**/ |
||||
public interface ICompanyCommodityCodeService { |
||||
|
||||
/** |
||||
* 克隆物料 |
||||
* |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
R cloneCompanyCommodityCode(CloneCompanyCommodityDTO dto); |
||||
} |
@ -0,0 +1,52 @@ |
||||
package com.dxhy.order.consumer.modules.commodity.service.impl; |
||||
|
||||
import com.dxhy.order.baseservice.module.commodity.dao.GroupCommodityMapper; |
||||
import com.dxhy.order.consumer.dao.GroupCommodityCodeMapper; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.CloneCompanyCommodityDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.domain.dto.CloneCompanyCommodityDetailDTO; |
||||
import com.dxhy.order.consumer.modules.commodity.service.ICompanyCommodityCodeService; |
||||
import com.dxhy.order.consumer.utils.ValidateUtils; |
||||
import com.dxhy.order.model.R; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
||||
|
||||
/** |
||||
* @Description |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/15 21:08 |
||||
**/ |
||||
@Service |
||||
public class CompanyCommodityCodeServiceImpl implements ICompanyCommodityCodeService { |
||||
|
||||
@Autowired |
||||
private GroupCommodityCodeMapper groupCommodityMapper; |
||||
|
||||
/** |
||||
* 克隆物料 |
||||
* |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
@Override |
||||
@Transactional |
||||
public R cloneCompanyCommodityCode(CloneCompanyCommodityDTO dto) { |
||||
CloneCompanyCommodityDetailDTO to = dto.getTo(); |
||||
CloneCompanyCommodityDetailDTO from = dto.getFrom(); |
||||
ValidateUtils.validate(to); |
||||
ValidateUtils.validate(from); |
||||
|
||||
// 删除to公司下的所有物料
|
||||
groupCommodityMapper.deleteCommodityCodeByXhfNsrsbh(to); |
||||
|
||||
// 复制from公司下的所有物料到to
|
||||
if (groupCommodityMapper.cloneCommodityCode(from, to) <= 0) { |
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
||||
return R.error("克隆失败,请重新操作"); |
||||
} |
||||
|
||||
return R.ok(); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.dxhy.order.consumer.modules.taxcodematch.model.dto; |
||||
|
||||
import com.dxhy.order.consumer.modules.taxcodematch.entity.SdenergyTaxCodeMatch; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
|
||||
@Data |
||||
public class SdenergyTaxCodeMatchDeleteDTO { |
||||
@NotNull(message = "id不得为空") |
||||
private Long id; |
||||
} |
@ -0,0 +1,52 @@ |
||||
package com.dxhy.order.consumer.utils; |
||||
|
||||
import org.apache.commons.collections4.CollectionUtils; |
||||
|
||||
import javax.validation.ConstraintViolation; |
||||
import javax.validation.Valid; |
||||
import javax.validation.Validation; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @Description |
||||
* @Author 巩权林 |
||||
* @Date 2023/3/16 11:07 |
||||
**/ |
||||
public class ValidateUtils { |
||||
|
||||
/** |
||||
* 单纯参数校验 |
||||
* |
||||
* @param validateObject |
||||
* @param <T> |
||||
* @throws RuntimeException |
||||
*/ |
||||
public static <T> void validate(@Valid T validateObject) throws RuntimeException { |
||||
validate(validateObject, null); |
||||
} |
||||
|
||||
/** |
||||
* validate主动校验方式 |
||||
* |
||||
* @param validateObject 进行校验的对象 |
||||
* @param <T> 传递的校验类型 |
||||
* @param preMsg 错误信息的前部分要追加的内容 |
||||
* @throws RuntimeException 服务异常 |
||||
*/ |
||||
public static <T> void validate(@Valid T validateObject, String preMsg) throws RuntimeException { |
||||
Set<ConstraintViolation<@Valid T>> validateSet = Validation |
||||
.buildDefaultValidatorFactory() |
||||
.getValidator() |
||||
.validate(validateObject); |
||||
if (CollectionUtils.isNotEmpty(validateSet)) { |
||||
for (ConstraintViolation<@Valid T> i : validateSet) { |
||||
String msg = i.getPropertyPath() + i.getMessage(); |
||||
if (preMsg != null) { |
||||
msg = preMsg + msg; |
||||
} |
||||
throw new RuntimeException(msg); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue