Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
612129d085
|
|
@ -27,9 +27,9 @@ public class PartType extends BaseEntity
|
|||
/** 类型ID */
|
||||
private Long id;
|
||||
|
||||
/** 类型名称 */
|
||||
@Excel(name = "名称")
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
/** 规格型号 */
|
||||
@Excel(name = "规格型号")
|
||||
@ApiModelProperty(value = "规格型号")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Size(max=30, message = "名称长度不能超过30")
|
||||
private String paName;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class MaTypeVo extends Type {
|
|||
private String itemType;
|
||||
|
||||
@Excel(name = "物资类型")
|
||||
@ApiModelProperty(value = "施工类型")
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
@Excel(name = "物资名称")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.material.ma.domain.vo;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.material.ma.domain.PartType;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PartTypeVo extends PartType {
|
||||
|
||||
@Excel(name = "配件类型")
|
||||
@ApiModelProperty(value = "配件类型")
|
||||
private String partType;
|
||||
|
||||
@Excel(name = "配件名称")
|
||||
@ApiModelProperty(value = "配件名称")
|
||||
private String partName;
|
||||
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ public interface TypeMapper {
|
|||
*/
|
||||
int logicDeleteTypeByTypeIds(Long[] typeIds);
|
||||
|
||||
Type queryByName(String typeName);
|
||||
Type queryByNameAndParentId(@Param("typeName") String typeName, @Param("parentId") Long parentId);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
|
|
|
|||
|
|
@ -290,8 +290,8 @@ public class TypeServiceImpl implements ITypeService {
|
|||
@Override
|
||||
public int insertType(Type type) {
|
||||
//根据类型名称判断,去重
|
||||
Type maType = typeMapper.queryByName(type.getTypeName());
|
||||
if (maType != null && maType.getParentId().equals(type.getParentId())) {
|
||||
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
|
||||
if (maType != null) {
|
||||
throw new RuntimeException("同级下类型名称存在重复!");
|
||||
}
|
||||
type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
|
||||
|
|
@ -318,8 +318,8 @@ public class TypeServiceImpl implements ITypeService {
|
|||
@Override
|
||||
public int updateType(Type type) {
|
||||
//根据类型名称判断,去重
|
||||
Type maType = typeMapper.queryByName(type.getTypeName());
|
||||
if (maType != null && !maType.getTypeId().equals(type.getTypeId()) && maType.getParentId().equals(type.getParentId())) {
|
||||
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
|
||||
if (maType != null && !maType.getTypeId().equals(type.getTypeId())) {
|
||||
throw new RuntimeException("同级下类型名称存在重复!");
|
||||
}
|
||||
type.setUpdateTime(DateUtils.getNowDate());
|
||||
|
|
|
|||
|
|
@ -57,6 +57,16 @@ public class PurchaseCheckInfo extends BaseEntity {
|
|||
@ApiModelProperty(value = "采购员")
|
||||
private Long purchaser;
|
||||
|
||||
/** 物资厂家id */
|
||||
@Excel(name = "物资厂家id")
|
||||
@ApiModelProperty(value = "物资厂家id")
|
||||
private Long supplierId;
|
||||
|
||||
/** 物资厂家名称 */
|
||||
@Excel(name = "物资厂家名称")
|
||||
@ApiModelProperty(value = "物资厂家名称")
|
||||
private String supplier;
|
||||
|
||||
/** 数据所属组织 */
|
||||
@Excel(name = "数据所属组织")
|
||||
@ApiModelProperty(value = "数据所属组织")
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ public interface PurchaseCheckDetailsMapper {
|
|||
*/
|
||||
int deletePurchaseCheckDetailsById(Long id);
|
||||
|
||||
int deletePurchaseCheckDetailsByParentIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除新购验收任务详细
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ import com.bonus.material.purchase.mapper.PurchaseCheckInfoMapper;
|
|||
import com.bonus.material.purchase.domain.PurchaseCheckInfo;
|
||||
import com.bonus.material.purchase.service.IPurchaseCheckInfoService;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -154,7 +153,8 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
*/
|
||||
public static BigDecimal calculateTaxPrice(BigDecimal purchaseNoTaxPrice, BigDecimal taxRate) {
|
||||
BigDecimal one = BigDecimal.ONE;
|
||||
return purchaseNoTaxPrice.multiply(one.add(taxRate)).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal divisor = BigDecimal.valueOf(100);
|
||||
return purchaseNoTaxPrice.multiply(one.add(taxRate.divide(divisor))).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,10 +164,10 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult insertPurchaseCheckInfo(PurchaseCheckDto purchaseCheckInfo) {
|
||||
// 赋值创建时间
|
||||
purchaseCheckInfo.getPurchaseCheckInfo().setCreateTime(DateUtils.getNowDate());
|
||||
purchaseCheckInfo.getPurchaseCheckInfo().setCreateBy(SecurityUtils.getLoginUser().getUsername());
|
||||
purchaseCheckInfo.getPurchaseCheckInfo().setCreateBy(SecurityUtils.getUsername());
|
||||
try {
|
||||
// 查询新购任务当月最大单号
|
||||
Integer thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), Long.valueOf(PurchaseTaskEnum.PURCHASE_TASK_STATUS_WAIT_NOTICE.getTaskTypeId()));
|
||||
|
|
@ -175,48 +175,14 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
thisMonthMaxOrder = Optional.ofNullable(thisMonthMaxOrder).orElse(0);
|
||||
// 生成单号
|
||||
TmTask tmTask = genderTaskCode(purchaseCheckInfo, thisMonthMaxOrder);
|
||||
Long taskId;
|
||||
|
||||
// 开启事务
|
||||
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
||||
if (tmTaskMapper.insertTmTask(tmTask) > 0) {
|
||||
taskId = tmTask.getTaskId();
|
||||
} else {
|
||||
transactionManager.rollback(transactionStatus);
|
||||
return AjaxResult.error("新增任务失败_task表插入0条");
|
||||
}
|
||||
|
||||
// tm_task 插入成功后,再往新购验收info表中插入数据
|
||||
tmTaskMapper.insertTmTask(tmTask);
|
||||
Long taskId = tmTask.getTaskId();
|
||||
purchaseCheckInfo.getPurchaseCheckInfo().setTaskId(taskId);
|
||||
if (purchaseCheckInfoMapper.insertPurchaseCheckInfo(purchaseCheckInfo.getPurchaseCheckInfo()) > 0) {
|
||||
purchaseCheckInfo.getPurchaseCheckDetailsList().forEach(
|
||||
details -> {
|
||||
details.setTaskId(taskId);
|
||||
details.setInputStatus("0");
|
||||
});
|
||||
// 批量插入详情数据
|
||||
boolean purchaseCheckDetailsListAddResult = purchaseCheckDetailsMapper.insertPurchaseCheckDetailsList(purchaseCheckInfo.getPurchaseCheckDetailsList()) > 0;
|
||||
|
||||
// 批量插入附件列表
|
||||
List<PurchaseCheckDetails> purchaseCheckDetailsList = purchaseCheckInfo.getPurchaseCheckDetailsList();
|
||||
for (PurchaseCheckDetails purchaseCheckDetails : purchaseCheckDetailsList) {
|
||||
List<BmFileInfo> bmFileInfos = purchaseCheckDetails.getBmFileInfos();
|
||||
if (!CollectionUtils.isEmpty(bmFileInfos)) {
|
||||
bmFileInfos.stream().forEach(o -> o.setTaskId(taskId));
|
||||
bmFileInfoMapper.insertBmFileInfos(bmFileInfos);
|
||||
}
|
||||
}
|
||||
|
||||
if (purchaseCheckDetailsListAddResult) {
|
||||
transactionManager.commit(transactionStatus);
|
||||
return AjaxResult.success("新增任务成功");
|
||||
int count = purchaseCheckInfoMapper.insertPurchaseCheckInfo(purchaseCheckInfo.getPurchaseCheckInfo());
|
||||
if (count > 0) {
|
||||
return insertPurchaseCheckDetails(purchaseCheckInfo.getPurchaseCheckDetailsList(), taskId);
|
||||
} else {
|
||||
transactionManager.rollback(transactionStatus);
|
||||
return AjaxResult.error("新增任务失败,详情表插入0条");
|
||||
}
|
||||
} else {
|
||||
transactionManager.rollback(transactionStatus);
|
||||
return AjaxResult.error("新增任务失败,info表插入0条");
|
||||
return AjaxResult.error("新增任务失败,purchase_check_info表插入0条");
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
return AjaxResult.error("数据库操作失败:" + e.getMessage());
|
||||
|
|
@ -225,6 +191,29 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
private AjaxResult insertPurchaseCheckDetails(List<PurchaseCheckDetails> purchaseCheckDetailsList, Long taskId) {
|
||||
if (!CollectionUtils.isEmpty(purchaseCheckDetailsList)) {
|
||||
for (PurchaseCheckDetails details : purchaseCheckDetailsList) {
|
||||
details.setTaskId(taskId);
|
||||
details.setInputStatus("0");
|
||||
List<BmFileInfo> bmFileInfos = details.getBmFileInfos();
|
||||
if (!CollectionUtils.isEmpty(bmFileInfos)) {
|
||||
bmFileInfos.stream().forEach(o -> o.setTaskId(taskId));
|
||||
bmFileInfoMapper.insertBmFileInfos(bmFileInfos);
|
||||
}
|
||||
}
|
||||
// 批量插入详情数据
|
||||
int count = purchaseCheckDetailsMapper.insertPurchaseCheckDetailsList(purchaseCheckDetailsList);
|
||||
if (count > 0) {
|
||||
return AjaxResult.success("新增任务成功");
|
||||
} else {
|
||||
return AjaxResult.error("新增任务失败,purchase_check_detail详情表插入0条");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.success("新增任务成功");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验收通过
|
||||
*
|
||||
|
|
@ -306,14 +295,14 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePurchaseCheckInfo(PurchaseCheckDto purchaseCheckDto) {
|
||||
purchaseCheckDto.getPurchaseCheckInfo().setUpdateTime(DateUtils.getNowDate());
|
||||
purchaseCheckDto.getPurchaseCheckInfo().setUpdateBy(SecurityUtils.getUsername());
|
||||
try {
|
||||
List<PurchaseCheckDetails> purchaseCheckDetailsList = purchaseCheckDto.getPurchaseCheckDetailsList();
|
||||
for (PurchaseCheckDetails purchaseCheckDetails : purchaseCheckDetailsList) {
|
||||
purchaseCheckDetailsMapper.updatePurchaseCheckDetails(purchaseCheckDetails);
|
||||
}
|
||||
Long[] ids = new Long[]{purchaseCheckDto.getPurchaseCheckInfo().getId()};
|
||||
purchaseCheckDetailsMapper.deletePurchaseCheckDetailsByParentIds(ids);
|
||||
insertPurchaseCheckDetails(purchaseCheckDto.getPurchaseCheckDetailsList(), purchaseCheckDto.getPurchaseCheckInfo().getTaskId());
|
||||
purchaseCheckInfoMapper.updatePurchaseCheckInfo(purchaseCheckDto.getPurchaseCheckInfo());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -328,7 +317,9 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deletePurchaseCheckInfoByIds(Long[] ids) {
|
||||
purchaseCheckDetailsMapper.deletePurchaseCheckDetailsByParentIds(ids);
|
||||
return purchaseCheckInfoMapper.deletePurchaseCheckInfoByIds(ids);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,11 +172,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getListByTypeName" resultType="com.bonus.material.ma.domain.PartType">
|
||||
<select id="getListByTypeName" resultType="com.bonus.material.ma.domain.vo.PartTypeVo">
|
||||
SELECT DISTINCT
|
||||
m.pa_id AS id,
|
||||
m.pa_name AS paName,
|
||||
m1.pa_name AS partName,
|
||||
m2.pa_name As partType,
|
||||
m.parent_id as parentId,
|
||||
m.unit_name as unitName,
|
||||
m.storage_num as storageNum,
|
||||
m.buy_price as buyPrice,
|
||||
m.LEVEL as level,
|
||||
m.remark as remark
|
||||
FROM
|
||||
|
|
|
|||
|
|
@ -513,11 +513,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</if>
|
||||
</select>
|
||||
<select id="queryByName" resultType="com.bonus.material.ma.domain.Type">
|
||||
<select id="queryByNameAndParentId" resultType="com.bonus.material.ma.domain.Type">
|
||||
select
|
||||
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
|
||||
from ma_type
|
||||
where type_name = #{typeName} and del_flag = '0'
|
||||
where type_name = #{typeName} and parent_id = #{parentId} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.bonus.material.ma.domain.Type">
|
||||
|
|
|
|||
|
|
@ -201,6 +201,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
delete from purchase_check_details where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePurchaseCheckDetailsByParentIds" parameterType="Long">
|
||||
delete from purchase_check_details where task_id in (
|
||||
select task_id
|
||||
from purchase_check_info
|
||||
where
|
||||
id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</delete>
|
||||
|
||||
<delete id="deletePurchaseCheckDetailsByIds" parameterType="String">
|
||||
delete from purchase_check_details where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="purchaseTime" column="purchase_time" />
|
||||
<result property="arrivalTime" column="arrival_time" />
|
||||
<result property="purchaser" column="purchaser" />
|
||||
<result property="supplierId" column="supplier_id" />
|
||||
<result property="supplier" column="supplier" />
|
||||
<result property="taxRate" column="tax_rate" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createUserName" column="purchaser_name" />
|
||||
|
|
@ -29,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<sql id="selectPurchaseCheckInfoBaseSQL">
|
||||
select
|
||||
id, task_id, purchase_time, arrival_time, purchaser, tax_rate, create_by,
|
||||
id, task_id, purchase_time, arrival_time, purchaser, supplier_id, tax_rate, create_by,
|
||||
create_time, update_by, update_time, remark, company_id
|
||||
from
|
||||
purchase_check_info
|
||||
|
|
@ -37,13 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<sql id="selectPurchaseCheckInfoJoinSQL">
|
||||
select
|
||||
pci.id, pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.tax_rate, pci.create_by,
|
||||
pci.id, pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.supplier_id, pci.tax_rate, pci.create_by,
|
||||
pci.create_time, pci.update_by, pci.update_time, pci.remark, pci.company_id,
|
||||
t.task_status, t.task_type, t.code, su.user_name as create_user_name
|
||||
t.task_status, t.task_type, t.code, su.user_name as create_user_name, msi.supplier
|
||||
from
|
||||
purchase_check_info pci
|
||||
left join tm_task t on t.task_id = pci.task_id
|
||||
left join sys_user su ON pci.create_by = su.user_id
|
||||
left join ma_supplier_info msi on pci.supplier_id = msi.supplier_id
|
||||
</sql>
|
||||
|
||||
<select id="selectPurchaseCheckInfoList" parameterType="com.bonus.material.purchase.domain.PurchaseCheckInfo" resultMap="PurchaseCheckInfoResult">
|
||||
|
|
@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="purchaseTime != null "> and purchase_time = #{purchaseTime}</if>
|
||||
<if test="arrivalTime != null "> and arrival_time = #{arrivalTime}</if>
|
||||
<if test="purchaser != null "> and purchaser = #{purchaser}</if>
|
||||
<if test="supplierId != null "> and supplier_id = #{supplierId}</if>
|
||||
<if test="taxRate != null "> and tax_rate = #{taxRate}</if>
|
||||
<if test="companyId != null "> and company_id = #{companyId}</if>
|
||||
</where>
|
||||
|
|
@ -70,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="purchaseTime != null">purchase_time,</if>
|
||||
<if test="arrivalTime != null">arrival_time,</if>
|
||||
<if test="purchaser != null">purchaser,</if>
|
||||
<if test="supplierId != null">supplier_id,</if>
|
||||
<if test="taxRate != null">tax_rate,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
|
|
@ -83,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="purchaseTime != null">#{purchaseTime},</if>
|
||||
<if test="arrivalTime != null">#{arrivalTime},</if>
|
||||
<if test="purchaser != null">#{purchaser},</if>
|
||||
<if test="supplierId != null">#{supplierId},</if>
|
||||
<if test="taxRate != null">#{taxRate},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
|
|
@ -100,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="purchaseTime != null">purchase_time = #{purchaseTime},</if>
|
||||
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
|
||||
<if test="purchaser != null">purchaser = #{purchaser},</if>
|
||||
<if test="supplierId != null">supplier_id = #{supplierId},</if>
|
||||
<if test="taxRate != null">tax_rate = #{taxRate},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
|
|
@ -129,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="purchaseTime != null "> and pci.purchase_time = #{purchaseTime}</if>
|
||||
<if test="arrivalTime != null "> and pci.arrival_time = #{arrivalTime}</if>
|
||||
<if test="purchaser != null "> and pci.purchaser = #{purchaser}</if>
|
||||
<if test="supplierId != null "> and pci.supplier_id = #{supplierId}</if>
|
||||
<if test="taxRate != null "> and pci.tax_rate = #{taxRate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue