fix:运维管理功能(项目和订单转移)
parent
c2bbeb7cdc
commit
27ac07ad0a
|
|
@ -0,0 +1,22 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询项目管理列表
|
||||
export function listProject(query) {
|
||||
return request({
|
||||
url: '/sip/project/vue/list',
|
||||
method: 'post',
|
||||
data: query,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 项目转移负责人
|
||||
export function transferProject(data) {
|
||||
return request({
|
||||
url: '/sip/dataProcess/projectTransfer',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,301 @@
|
|||
<template xmlns="http://www.w3.org/1999/html">
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="项目编号" prop="projectCode">
|
||||
<el-input
|
||||
v-model="queryParams.projectCode"
|
||||
placeholder="请输入项目编号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目名称" prop="projectName">
|
||||
<el-input
|
||||
v-model="queryParams.projectName"
|
||||
placeholder="请输入项目名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="代表处" prop="agentName">
|
||||
<el-input
|
||||
v-model="queryParams.agentName"
|
||||
placeholder="请输入代表处"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="汇智负责人" prop="hzSupportUserName">
|
||||
<el-input
|
||||
v-model="queryParams.hzSupportUserName"
|
||||
placeholder="请输入汇智负责人"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<br/>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
@click="handleTransfer"
|
||||
v-hasPermi="['sip:project:add']"
|
||||
>转移</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange" @sort-change="handleSortChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="项目编号" align="center" prop="projectCode" width="100" />
|
||||
<el-table-column label="项目名称" align="center" prop="projectName" width="300">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.projectName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最终客户" align="center" prop="customerName" width="200" />
|
||||
<el-table-column label="BG" align="center" prop="bgProperty" width="70">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.bg_type" :value="scope.row.bgProperty"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="行业" align="center" prop="industryType" width="70">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag v-if="scope.row.bgProperty === 'YYS'" :options="dict.type.bg_yys" :value="scope.row.industryType"/>
|
||||
<dict-tag v-else :options="dict.type.bg_hysy" :value="scope.row.industryType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="代表处" align="center" prop="agentName" width="70" />
|
||||
<el-table-column label="项目把握度" align="center" prop="projectGraspDegree" width="70" />
|
||||
<el-table-column label="预计金额(元)" align="center" prop="estimatedAmount" width="120" sortable="custom" :sort-orders="['descending', 'ascending']">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ formatAmountNumber(scope.row.estimatedAmount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="项目阶段" align="center" prop="projectStage" width="160">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.project_stage" :value="scope.row.projectStage"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="建设类型" align="center" prop="constructionType" width="120" />
|
||||
<el-table-column label="汇智负责人" align="center" prop="hzSupportUserName" width="100" />
|
||||
<el-table-column label="POC" align="center" prop="poc" width="60">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.poc === '1' ? '是' : '否' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="预计下单时间" align="center" prop="estimatedOrderTime" width="140" sortable="custom" :sort-orders="['descending', 'ascending']">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.estimatedOrderTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" align="center" prop="lastWorkUpdateTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.lastWorkUpdateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最后操作时间" align="center" prop="updateTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
|
||||
<el-dialog title="项目转移" :visible.sync="transferDialogVisible" width="500px" append-to-body>
|
||||
<el-form ref="transferForm" :model="transferForm" :rules="transferRules" label-width="100px">
|
||||
<el-form-item label="原汇智负责人">
|
||||
<el-input
|
||||
v-model="transferForm.originalHzSupportUserName"
|
||||
placeholder="原汇智负责人"
|
||||
readonly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新汇智负责人" prop="hzSupportUserName">
|
||||
<el-input
|
||||
v-model="transferForm.hzSupportUserName"
|
||||
placeholder="请选择新汇智负责人"
|
||||
readonly
|
||||
@click.native="openTransferUserSelect"
|
||||
/>
|
||||
<input type="hidden" v-model="transferForm.hzSupportUser" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="transferDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitTransfer">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<select-user :visible.sync="selectUserVisible" @user-selected="handleUserSelected" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {listProject, transferProject} from "@/api/dataProcess/projectTransfer";
|
||||
import SelectUser from "@/views/system/user/selectUser.vue";
|
||||
|
||||
export default {
|
||||
name: "Project",
|
||||
components: {
|
||||
SelectUser
|
||||
},
|
||||
dicts: ['bg_type', 'bg_yys', 'bg_hysy', 'project_stage'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 选中行数据
|
||||
selectedRows: [],
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 项目管理表格数据
|
||||
projectList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectCode: null,
|
||||
projectName: null,
|
||||
agentName: null,
|
||||
hzSupportUserName: null,
|
||||
isAsc: 'desc',
|
||||
orderByColumn: 'createTime',
|
||||
},
|
||||
selectUserVisible: false,
|
||||
transferDialogVisible: false,
|
||||
transferForm: {
|
||||
originalHzSupportUser: null,
|
||||
originalHzSupportUserName: null,
|
||||
hzSupportUser: null,
|
||||
hzSupportUserName: null,
|
||||
projectIdList: []
|
||||
},
|
||||
transferRules: {
|
||||
hzSupportUserName: [{ required: true, message: "请选择汇智负责人", trigger: "blur" }]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
handleSortChange(column) {
|
||||
this.queryParams.orderByColumn = column.prop;
|
||||
if (column.order === 'ascending') {
|
||||
this.queryParams.isAsc = 'asc';
|
||||
} else if (column.order === 'descending') {
|
||||
this.queryParams.isAsc = 'desc';
|
||||
} else {
|
||||
this.queryParams.isAsc = null;
|
||||
this.queryParams.orderByColumn = null;
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
/** 查询项目管理列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProject(this.queryParams).then(response => {
|
||||
this.projectList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.selectedRows = selection
|
||||
},
|
||||
handleTransfer() {
|
||||
if (!this.selectedRows || this.selectedRows.length === 0) {
|
||||
this.$modal.msgWarning("请至少选择一条数据");
|
||||
return;
|
||||
}
|
||||
const hasEmptyHzSupportUser = this.selectedRows.some(item => !item.hzSupportUser);
|
||||
if (hasEmptyHzSupportUser) {
|
||||
this.$modal.msgWarning("选中数据存在无汇智负责人的项目,无法转移");
|
||||
return;
|
||||
}
|
||||
const currentHzSupportUser = this.selectedRows[0].hzSupportUser;
|
||||
const isSameHzSupportUser = this.selectedRows.every(item => item.hzSupportUser === currentHzSupportUser);
|
||||
if (!isSameHzSupportUser) {
|
||||
this.$modal.msgWarning("请选择同一个汇智负责人的项目进行转移");
|
||||
return;
|
||||
}
|
||||
this.transferForm = {
|
||||
originalHzSupportUser: currentHzSupportUser,
|
||||
originalHzSupportUserName: this.selectedRows[0].hzSupportUserName,
|
||||
hzSupportUser: null,
|
||||
hzSupportUserName: null,
|
||||
projectIdList: [...this.ids]
|
||||
};
|
||||
this.transferDialogVisible = true;
|
||||
},
|
||||
openTransferUserSelect() {
|
||||
this.selectUserVisible = true;
|
||||
},
|
||||
handleUserSelected(user) {
|
||||
this.transferForm.hzSupportUser = user.userId;
|
||||
this.transferForm.hzSupportUserName = user.userName;
|
||||
},
|
||||
submitTransfer() {
|
||||
this.$refs["transferForm"].validate(valid => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
originalHzSupportUser: this.transferForm.originalHzSupportUser,
|
||||
originalHzSupportUserName: this.transferForm.originalHzSupportUserName,
|
||||
hzSupportUser: this.transferForm.hzSupportUser,
|
||||
hzSupportUserName: this.transferForm.hzSupportUserName,
|
||||
projectIdList: this.transferForm.projectIdList
|
||||
};
|
||||
transferProject(params).then(() => {
|
||||
this.$modal.msgSuccess("提交成功");
|
||||
this.transferDialogVisible = false;
|
||||
this.getList();
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 格式化金额 */
|
||||
formatAmountNumber(value) {
|
||||
if (value) {
|
||||
return Number(value).toLocaleString('en-US');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1,128 +1,41 @@
|
|||
package com.ruoyi.sip.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto;
|
||||
import com.ruoyi.sip.mapper.InventoryInfoMapper;
|
||||
import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
||||
import com.ruoyi.sip.service.IOmsPayableBillService;
|
||||
import com.ruoyi.sip.service.IOmsPurchaseOrderService;
|
||||
import com.ruoyi.sip.service.IProductInfoService;
|
||||
import com.ruoyi.sip.service.IVendorInfoService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import com.ruoyi.sip.dto.ProjectTransferRequest;
|
||||
import com.ruoyi.sip.service.IDataProcessService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据处理控制器
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/sip/dataProcess")
|
||||
public class DataProcessController {
|
||||
|
||||
@Autowired
|
||||
private OmsInventoryInnerMapper omsInventoryInnerMapper;
|
||||
|
||||
@Autowired
|
||||
private InventoryInfoMapper inventoryInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private IProductInfoService productInfoService;
|
||||
|
||||
@Autowired
|
||||
private IOmsPurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Autowired
|
||||
private IOmsPayableBillService payableBillService;
|
||||
|
||||
@Autowired
|
||||
private IVendorInfoService vendorInfoService;
|
||||
|
||||
@Value("${oms.inventory.innerTax:0.13}")
|
||||
private String defaultTax;
|
||||
private IDataProcessService dataProcessService;
|
||||
|
||||
//入库单生成应付单
|
||||
@Anonymous
|
||||
@GetMapping("/inventoryInnerGeneratePayableBill")
|
||||
void inventoryInnerGeneratePayableBill(@RequestParam("innerId") Long innerId) {
|
||||
if (innerId == null) {
|
||||
throw new ServiceException("innerId不能为空");
|
||||
}
|
||||
bindShiroUser(1L, "admin", "平台管理员");
|
||||
OmsInventoryInner omsInventoryInner = omsInventoryInnerMapper.selectOmsInventoryInnerById(innerId);
|
||||
List<InventoryInfo> inventoryInfoList = inventoryInfoMapper.selectInventoryInfoByInnerCodeList(Arrays.asList(omsInventoryInner.getInnerCode()));
|
||||
List<String> productCodeList = inventoryInfoList.stream().map(InventoryInfo::getProductCode).distinct().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
||||
List<ProductInfo> productInfos = productInfoService.selectProductInfoByCodeList(productCodeList);
|
||||
String vendorCode = productInfos.get(0).getVendorCode();
|
||||
OmsPayableBill payableBill = new OmsPayableBill();
|
||||
VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorCode(vendorCode);
|
||||
|
||||
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
//服务金额为单价* 数量 没有具体的详情
|
||||
BigDecimal totalPriceWithTax = Arrays.asList("3", "22").contains(omsInventoryInner.getProductType()) ?
|
||||
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
|
||||
: reduce;
|
||||
//生成应付单
|
||||
payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
|
||||
payableBill.setVendorCode(omsInventoryInner.getVendorCode());
|
||||
payableBill.setProductType(productInfos.get(0).getType());
|
||||
payableBill.setProductCode(omsInventoryInner.getProductCode());
|
||||
payableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||
payableBill.setOrderCode(omsInventoryInner.getOrderCode());
|
||||
payableBill.setProjectCode(omsInventoryInner.getProductCode());
|
||||
payableBill.setProjectName(omsInventoryInner.getProjectName());
|
||||
String purchaseNo = omsInventoryInner.getPurchaseNo();
|
||||
BigDecimal taxRate = null;
|
||||
if (StringUtils.isNotEmpty(purchaseNo)) {
|
||||
OmsPurchaseOrderItemDto query = new OmsPurchaseOrderItemDto();
|
||||
query.setPurchaseNo(purchaseNo);
|
||||
List<OmsPurchaseOrderItemDto> omsPurchaseOrderItemDtos = purchaseOrderService.listItem(query);
|
||||
Map<String, BigDecimal> decimalMap = omsPurchaseOrderItemDtos.stream().collect(Collectors.toMap(OmsPurchaseOrderItemDto::getProductCode, OmsPurchaseOrderItemDto::getTaxRate, (v1, v2) -> v1));
|
||||
taxRate = decimalMap.get(omsInventoryInner.getProductCode());
|
||||
|
||||
}
|
||||
BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate;
|
||||
BigDecimal withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add);
|
||||
payableBill.setTotalPriceWithoutTax(withoutTax);
|
||||
payableBill.setTaxRate(finalTaxRate);
|
||||
payableBill.setTaxAmount(totalPriceWithTax);
|
||||
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
|
||||
payableBillService.insertOmsPayableBill(payableBill, vendorInfo.getPayConfigDay());
|
||||
dataProcessService.inventoryInnerGeneratePayableBill(innerId);
|
||||
}
|
||||
|
||||
private void bindShiroUser(Long userId, String loginName, String userName) {
|
||||
SecurityManager securityManager = new DefaultSecurityManager();
|
||||
SecurityUtils.setSecurityManager(securityManager);
|
||||
ThreadContext.bind(securityManager);
|
||||
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
user.setLoginName(loginName);
|
||||
user.setUserName(userName);
|
||||
Subject subject = new Subject.Builder(securityManager)
|
||||
.principals(new SimplePrincipalCollection(user, "testRealm"))
|
||||
.buildSubject();
|
||||
ThreadContext.bind(subject);
|
||||
@PostMapping("/projectTransfer")
|
||||
public AjaxResult projectTransfer(@RequestBody ProjectTransferRequest request) {
|
||||
return dataProcessService.projectTransfer(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.sip.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProjectTransferRequest {
|
||||
|
||||
/** 原汇智负责人ID */
|
||||
private Long originalHzSupportUser;
|
||||
/** 原汇智负责人名称 */
|
||||
private String originalHzSupportUserName;
|
||||
/** 汇智负责人ID */
|
||||
private Long hzSupportUser;
|
||||
/** 汇智负责人名称 */
|
||||
private String hzSupportUserName;
|
||||
/** 项目ID列表 */
|
||||
private List<Long> projectIdList;
|
||||
|
||||
}
|
||||
|
|
@ -72,6 +72,7 @@ public interface ProjectInfoMapper
|
|||
|
||||
void updateOrderTimeById(Long projectId);
|
||||
void updateCustomerCodeByCode(@Param("oldValue") String oldValue, @Param("newValue")String newValue);
|
||||
int updateHzSupportUserByProjectIds(@Param("hzSupportUser") Long hzSupportUser, @Param("projectIds") List<Long> projectIds);
|
||||
|
||||
ProjectInfo selectProjectInfoByOrderCode(String orderCode);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,4 +88,9 @@ public interface ProjectOrderInfoMapper
|
|||
|
||||
List<InventoryDelivery> selectInentoryDeliveryByProjectOrderInfoId(@Param("id") Long id);
|
||||
|
||||
int updateDutyByProjectIds(@Param("duty") Long duty,
|
||||
@Param("dutyEmail") String dutyEmail,
|
||||
@Param("dutyPhone") String dutyPhone,
|
||||
@Param("projectIds") List<Long> projectIds);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.sip.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.sip.domain.ProjectUserCollectInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 产品库存Mapper接口
|
||||
|
|
@ -58,4 +59,13 @@ public interface ProjectUserCollectInfoMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteProjectUserCollectInfoByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 按项目ID批量删除收藏记录
|
||||
*
|
||||
* @param projectIds 项目ID集合
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProjectUserCollectInfoByProjectIds(@Param("projectIds") List<Long> projectIds, @Param("userId") Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ruoyi.sip.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.sip.dto.ProjectTransferRequest;
|
||||
|
||||
public interface IDataProcessService {
|
||||
|
||||
void inventoryInnerGeneratePayableBill(Long innerId);
|
||||
|
||||
AjaxResult projectTransfer(ProjectTransferRequest request);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
package com.ruoyi.sip.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.InventoryInfo;
|
||||
import com.ruoyi.sip.domain.OmsInventoryInner;
|
||||
import com.ruoyi.sip.domain.OmsPayableBill;
|
||||
import com.ruoyi.sip.domain.ProductInfo;
|
||||
import com.ruoyi.sip.domain.VendorInfo;
|
||||
import com.ruoyi.sip.dto.ProjectTransferRequest;
|
||||
import com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto;
|
||||
import com.ruoyi.sip.mapper.InventoryInfoMapper;
|
||||
import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectUserCollectInfoMapper;
|
||||
import com.ruoyi.sip.service.IDataProcessService;
|
||||
import com.ruoyi.sip.service.IOmsPayableBillService;
|
||||
import com.ruoyi.sip.service.IOmsPurchaseOrderService;
|
||||
import com.ruoyi.sip.service.IProductInfoService;
|
||||
import com.ruoyi.sip.service.IVendorInfoService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DataProcessServiceImpl implements IDataProcessService {
|
||||
|
||||
@Resource
|
||||
private OmsInventoryInnerMapper omsInventoryInnerMapper;
|
||||
|
||||
@Resource
|
||||
private InventoryInfoMapper inventoryInfoMapper;
|
||||
|
||||
@Resource
|
||||
private IProductInfoService productInfoService;
|
||||
|
||||
@Resource
|
||||
private IOmsPurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private IOmsPayableBillService payableBillService;
|
||||
|
||||
@Resource
|
||||
private IVendorInfoService vendorInfoService;
|
||||
|
||||
@Resource
|
||||
private ProjectUserCollectInfoMapper projectUserCollectInfoMapper;
|
||||
|
||||
@Resource
|
||||
private ProjectInfoMapper projectInfoMapper;
|
||||
@Resource
|
||||
private ProjectOrderInfoMapper projectOrderInfoMapper;
|
||||
|
||||
@Value("${oms.inventory.innerTax:0.13}")
|
||||
private String defaultTax;
|
||||
|
||||
@Override
|
||||
public void inventoryInnerGeneratePayableBill(Long innerId) {
|
||||
if (innerId == null) {
|
||||
throw new ServiceException("innerId不能为空");
|
||||
}
|
||||
bindShiroUser(1L, "admin", "平台管理员");
|
||||
OmsInventoryInner omsInventoryInner = omsInventoryInnerMapper.selectOmsInventoryInnerById(innerId);
|
||||
List<InventoryInfo> inventoryInfoList = inventoryInfoMapper.selectInventoryInfoByInnerCodeList(Arrays.asList(omsInventoryInner.getInnerCode()));
|
||||
List<String> productCodeList = inventoryInfoList.stream().map(InventoryInfo::getProductCode).distinct().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
||||
List<ProductInfo> productInfos = productInfoService.selectProductInfoByCodeList(productCodeList);
|
||||
String vendorCode = productInfos.get(0).getVendorCode();
|
||||
OmsPayableBill payableBill = new OmsPayableBill();
|
||||
VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorCode(vendorCode);
|
||||
|
||||
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalPriceWithTax = Arrays.asList("3", "22").contains(omsInventoryInner.getProductType()) ?
|
||||
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
|
||||
: reduce;
|
||||
payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
|
||||
payableBill.setVendorCode(omsInventoryInner.getVendorCode());
|
||||
payableBill.setProductType(productInfos.get(0).getType());
|
||||
payableBill.setProductCode(omsInventoryInner.getProductCode());
|
||||
payableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||
payableBill.setOrderCode(omsInventoryInner.getOrderCode());
|
||||
payableBill.setProjectCode(omsInventoryInner.getProductCode());
|
||||
payableBill.setProjectName(omsInventoryInner.getProjectName());
|
||||
String purchaseNo = omsInventoryInner.getPurchaseNo();
|
||||
BigDecimal taxRate = null;
|
||||
if (StringUtils.isNotEmpty(purchaseNo)) {
|
||||
OmsPurchaseOrderItemDto query = new OmsPurchaseOrderItemDto();
|
||||
query.setPurchaseNo(purchaseNo);
|
||||
List<OmsPurchaseOrderItemDto> omsPurchaseOrderItemDtos = purchaseOrderService.listItem(query);
|
||||
Map<String, BigDecimal> decimalMap = omsPurchaseOrderItemDtos.stream().collect(Collectors.toMap(OmsPurchaseOrderItemDto::getProductCode, OmsPurchaseOrderItemDto::getTaxRate, (v1, v2) -> v1));
|
||||
taxRate = decimalMap.get(omsInventoryInner.getProductCode());
|
||||
}
|
||||
BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate;
|
||||
BigDecimal withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add);
|
||||
payableBill.setTotalPriceWithoutTax(withoutTax);
|
||||
payableBill.setTaxRate(finalTaxRate);
|
||||
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
|
||||
payableBillService.insertOmsPayableBill(payableBill, vendorInfo.getPayConfigDay());
|
||||
}
|
||||
|
||||
private void bindShiroUser(Long userId, String loginName, String userName) {
|
||||
SecurityManager securityManager = new DefaultSecurityManager();
|
||||
SecurityUtils.setSecurityManager(securityManager);
|
||||
ThreadContext.bind(securityManager);
|
||||
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
user.setLoginName(loginName);
|
||||
user.setUserName(userName);
|
||||
Subject subject = new Subject.Builder(securityManager)
|
||||
.principals(new SimplePrincipalCollection(user, "testRealm"))
|
||||
.buildSubject();
|
||||
ThreadContext.bind(subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult projectTransfer(ProjectTransferRequest request) {
|
||||
if (request == null
|
||||
|| request.getHzSupportUser() == null
|
||||
|| StringUtils.isEmpty(request.getHzSupportUserName())
|
||||
|| request.getProjectIdList() == null
|
||||
|| request.getProjectIdList().isEmpty()) {
|
||||
return AjaxResult.error("参数不完整");
|
||||
}
|
||||
List<SysUser> sysUsers = projectInfoMapper.selectUserById(
|
||||
Arrays.asList(String.valueOf(request.getHzSupportUser())));
|
||||
if (sysUsers == null || sysUsers.isEmpty()) {
|
||||
return AjaxResult.error("汇智负责人不存在");
|
||||
}
|
||||
SysUser hzSupportUser = sysUsers.get(0);
|
||||
// 修改项目中的汇智负责人
|
||||
projectInfoMapper.updateHzSupportUserByProjectIds(request.getHzSupportUser(), request.getProjectIdList());
|
||||
// 修改订单中负责人信息
|
||||
projectOrderInfoMapper.updateDutyByProjectIds(request.getHzSupportUser(),
|
||||
hzSupportUser.getEmail(),
|
||||
hzSupportUser.getPhonenumber(),
|
||||
request.getProjectIdList());
|
||||
// 删除原负责人对应的收藏记录
|
||||
projectUserCollectInfoMapper.deleteProjectUserCollectInfoByProjectIds(request.getProjectIdList(), request.getOriginalHzSupportUser());
|
||||
return AjaxResult.success("项目转移成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -478,6 +478,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateHzSupportUserByProjectIds">
|
||||
update project_info
|
||||
set hz_support_user = #{hzSupportUser},
|
||||
update_time = now()
|
||||
where id in
|
||||
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteProjectInfoById" parameterType="Long">
|
||||
delete from project_info where id = #{id}
|
||||
</delete>
|
||||
|
|
|
|||
|
|
@ -880,6 +880,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update project_order_info set partner_code = #{newValue} where partner_code = #{oldValue}
|
||||
</update>
|
||||
|
||||
<update id="updateDutyByProjectIds">
|
||||
update project_order_info
|
||||
set duty = #{duty},
|
||||
duty_email = #{dutyEmail},
|
||||
duty_phone = #{dutyPhone},
|
||||
update_time = now()
|
||||
where project_id in
|
||||
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteProjectOrderInfoById" parameterType="Long">
|
||||
delete from project_order_info where id = #{id}
|
||||
</delete>
|
||||
|
|
|
|||
|
|
@ -66,4 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProjectUserCollectInfoByProjectIds">
|
||||
delete from project_user_collect_info where project_id in
|
||||
<foreach item="projectId" collection="projectIds" open="(" separator="," close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
and user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue