Commit e1965a15 by yubin

owners管理

parent 9f1b332c
......@@ -94,6 +94,16 @@
v-hasPermi="['system:role:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['system:role:import']"
>导入</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
......@@ -248,16 +258,28 @@
<el-button @click="cancelDataScope">取 消</el-button>
</div>
</el-dialog>
<!-- 角色导入对话框 -->
<import-excel
ref="import"
title="角色导入"
import-url="/system/role/importData"
template-url="system/role/importTemplate"
template-name="role_template"
@success="getList"
/>
</div>
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role"
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"
import ImportExcel from "@/components/ImportExcel/index"
export default {
name: "Role",
dicts: ['sys_normal_disable'],
components: { ImportExcel },
data() {
return {
// 遮罩层
......@@ -599,6 +621,10 @@ export default {
this.download('system/role/export', {
...this.queryParams
}, `role_${new Date().getTime()}.xlsx`)
},
/** 导入按钮操作 */
handleImport() {
this.$refs.import.show()
}
}
}
......
package com.ruoyi.inventory.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.inventory.domain.Owners;
import com.ruoyi.inventory.service.IOwnersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 货主信息Controller
*
* @author ruoyi
* @date 2025-11-28
*/
@RestController
@RequestMapping("/inventory/owners")
public class OwnersController extends BaseController
{
@Autowired
private IOwnersService ownersService;
/**
* 查询货主信息列表
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:list')")
@GetMapping("/list")
public TableDataInfo list(Owners owners)
{
startPage();
List<Owners> list = ownersService.selectOwnersList(owners);
return getDataTable(list);
}
/**
* 导出货主信息列表
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:export')")
@Log(title = "货主信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Owners owners)
{
List<Owners> list = ownersService.selectOwnersList(owners);
ExcelUtil<Owners> util = new ExcelUtil<Owners>(Owners.class);
util.exportExcel(response, list, "货主信息数据");
}
@PreAuthorize("@ss.hasPermi('inventory:owners:import')")
@Log(title = "货主信息", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<Owners> util = new ExcelUtil<Owners>(Owners.class);
List<Owners> ownersList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = ownersService.importOwners(ownersList, updateSupport, operName);
return success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<Owners> util = new ExcelUtil<Owners>(Owners.class);
util.importTemplateExcel(response, "货主数据");
}
/**
* 获取货主信息详细信息
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(ownersService.selectOwnersById(id));
}
/**
* 新增货主信息
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:add')")
@Log(title = "货主信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Owners owners)
{
return toAjax(ownersService.insertOwners(owners));
}
/**
* 修改货主信息
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:edit')")
@Log(title = "货主信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Owners owners)
{
return toAjax(ownersService.updateOwners(owners));
}
/**
* 删除货主信息
*/
@PreAuthorize("@ss.hasPermi('inventory:owners:remove')")
@Log(title = "货主信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(ownersService.deleteOwnersByIds(ids));
}
}
package com.ruoyi.inventory.domain;
import com.fasterxml.jackson.annotation.JsonTypeId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 货主信息对象 owners
*
* @author ruoyi
* @date 2025-11-28
*/
public class Owners extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private String id;
/** 货主编码 检索条件 */
@Excel(name = "货主编码")
private String ownerCode;
/** 货主名称 检索条件 */
@Excel(name = "货主名称")
private String ownerName;
/** 货主类型 1-供应商 2-客户 3-内部 检索条件 */
@Excel(name = "货主类型 1-供应商 2-客户 3-内部 ")
private Long ownerType;
/** 联系人 */
@Excel(name = "联系人")
private String contactPerson;
/** 联系电话 */
@Excel(name = "联系电话")
private String contactPhone;
/** 邮箱 */
@Excel(name = "邮箱")
private String email;
/** 地址 */
@Excel(name = "地址")
private String address;
/** 税号 检索条件 */
@Excel(name = "税号")
private String taxNumber;
/** 银行账户 */
@Excel(name = "银行账户")
private String bankAccount;
/** 是否激活 1-是 0-否 检索条件 */
private Long isActive;
/** 排序 */
private Long sortNo;
/** 创建日期 */
private String createUserCode;
/** 排序号 */
private String updateUserCode;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setOwnerCode(String ownerCode)
{
this.ownerCode = ownerCode;
}
public String getOwnerCode()
{
return ownerCode;
}
public void setOwnerName(String ownerName)
{
this.ownerName = ownerName;
}
public String getOwnerName()
{
return ownerName;
}
public void setOwnerType(Long ownerType)
{
this.ownerType = ownerType;
}
public Long getOwnerType()
{
return ownerType;
}
public void setContactPerson(String contactPerson)
{
this.contactPerson = contactPerson;
}
public String getContactPerson()
{
return contactPerson;
}
public void setContactPhone(String contactPhone)
{
this.contactPhone = contactPhone;
}
public String getContactPhone()
{
return contactPhone;
}
public void setEmail(String email)
{
this.email = email;
}
public String getEmail()
{
return email;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress()
{
return address;
}
public void setTaxNumber(String taxNumber)
{
this.taxNumber = taxNumber;
}
public String getTaxNumber()
{
return taxNumber;
}
public void setBankAccount(String bankAccount)
{
this.bankAccount = bankAccount;
}
public String getBankAccount()
{
return bankAccount;
}
public void setIsActive(Long isActive)
{
this.isActive = isActive;
}
public Long getIsActive()
{
return isActive;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("ownerCode", getOwnerCode())
.append("ownerName", getOwnerName())
.append("ownerType", getOwnerType())
.append("contactPerson", getContactPerson())
.append("contactPhone", getContactPhone())
.append("email", getEmail())
.append("address", getAddress())
.append("taxNumber", getTaxNumber())
.append("bankAccount", getBankAccount())
.append("isActive", getIsActive())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.toString();
}
}
package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.inventory.domain.Owners;
import org.apache.ibatis.annotations.Mapper;
/**
* 货主信息Mapper接口
*
* @author ruoyi
* @date 2025-11-28
*/
@Mapper
public interface OwnersMapper
{
/**
* 查询货主信息
*
* @param id 货主信息主键
* @return 货主信息
*/
public Owners selectOwnersById(String id);
/**
* 查询货主信息列表
*
* @param owners 货主信息
* @return 货主信息集合
*/
public List<Owners> selectOwnersList(Owners owners);
/**
* 新增货主信息
*
* @param owners 货主信息
* @return 结果
*/
public int insertOwners(Owners owners);
/**
* 修改货主信息
*
* @param owners 货主信息
* @return 结果
*/
public int updateOwners(Owners owners);
/**
* 删除货主信息
*
* @param id 货主信息主键
* @return 结果
*/
public int deleteOwnersById(String id);
/**
* 批量删除货主信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteOwnersByIds(String[] ids);
}
package com.ruoyi.inventory.service;
import java.util.List;
import com.ruoyi.inventory.domain.Owners;
/**
* 货主信息Service接口
*
* @author ruoyi
* @date 2025-11-28
*/
public interface IOwnersService
{
/**
* 查询货主信息
*
* @param id 货主信息主键
* @return 货主信息
*/
public Owners selectOwnersById(String id);
/**
* 查询货主信息列表
*
* @param owners 货主信息
* @return 货主信息集合
*/
public List<Owners> selectOwnersList(Owners owners);
/**
* 新增货主信息
*
* @param owners 货主信息
* @return 结果
*/
public int insertOwners(Owners owners);
/**
* 新增货主信息
*
* @param ownersList 货主信息
* @return 结果
*/
public String importOwners(List<Owners> ownersList, Boolean isUpdateSupport, String operName);
/**
* 修改货主信息
*
* @param owners 货主信息
* @return 结果
*/
public int updateOwners(Owners owners);
/**
* 批量删除货主信息
*
* @param ids 需要删除的货主信息主键集合
* @return 结果
*/
public int deleteOwnersByIds(String[] ids);
/**
* 删除货主信息信息
*
* @param id 货主信息主键
* @return 结果
*/
public int deleteOwnersById(String id);
}
package com.ruoyi.inventory.service.impl;
import java.util.List;
import java.util.UUID;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.OwnersMapper;
import com.ruoyi.inventory.domain.Owners;
import com.ruoyi.inventory.service.IOwnersService;
/**
* 货主信息Service业务层处理
*
* @author ruoyi
* @date 2025-11-28
*/
@Service
public class OwnersServiceImpl implements IOwnersService
{
@Autowired
private OwnersMapper ownersMapper;
/**
* 查询货主信息
*
* @param id 货主信息主键
* @return 货主信息
*/
@Override
public Owners selectOwnersById(String id)
{
return ownersMapper.selectOwnersById(id);
}
/**
* 查询货主信息列表
*
* @param owners 货主信息
* @return 货主信息
*/
@Override
public List<Owners> selectOwnersList(Owners owners)
{
return ownersMapper.selectOwnersList(owners);
}
/**
* 新增货主信息
*
* @param owners 货主信息
* @return 结果
*/
@Override
public int insertOwners(Owners owners)
{
owners.setCreateTime(DateUtils.getNowDate());
return ownersMapper.insertOwners(owners);
}
@Override
public String importOwners(List<Owners> ownersList, Boolean isUpdateSupport, String operName)
{
if (StringUtils.isNull(ownersList) || ownersList.size() == 0)
{
throw new ServiceException("导入用户数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (Owners owners : ownersList)
{
try
{
owners.setId(UUID.randomUUID().toString());
ownersMapper.insertOwners(owners);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + owners.getOwnerName() + " 导入成功");
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + owners.getOwnerName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 修改货主信息
*
* @param owners 货主信息
* @return 结果
*/
@Override
public int updateOwners(Owners owners)
{
owners.setUpdateTime(DateUtils.getNowDate());
return ownersMapper.updateOwners(owners);
}
/**
* 批量删除货主信息
*
* @param ids 需要删除的货主信息主键
* @return 结果
*/
@Override
public int deleteOwnersByIds(String[] ids)
{
return ownersMapper.deleteOwnersByIds(ids);
}
/**
* 删除货主信息信息
*
* @param id 货主信息主键
* @return 结果
*/
@Override
public int deleteOwnersById(String id)
{
return ownersMapper.deleteOwnersById(id);
}
}
<?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.ruoyi.inventory.mapper.OwnersMapper">
<resultMap type="Owners" id="OwnersResult">
<result property="id" column="id" />
<result property="ownerCode" column="owner_code" />
<result property="ownerName" column="owner_name" />
<result property="ownerType" column="owner_type" />
<result property="contactPerson" column="contact_person" />
<result property="contactPhone" column="contact_phone" />
<result property="email" column="email" />
<result property="address" column="address" />
<result property="taxNumber" column="tax_number" />
<result property="bankAccount" column="bank_account" />
<result property="isActive" column="is_active" />
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
</resultMap>
<sql id="selectOwnersVo">
select id, owner_code, owner_name, owner_type, contact_person, contact_phone, email, address, tax_number, bank_account, is_active, sort_no, create_time, create_user_code, update_time, update_user_code from owners
</sql>
<select id="selectOwnersList" parameterType="Owners" resultMap="OwnersResult">
<include refid="selectOwnersVo"/>
<where>
<if test="ownerCode != null and ownerCode != ''"> and owner_code = #{ownerCode}</if>
<if test="ownerName != null and ownerName != ''"> and owner_name like concat('%', #{ownerName}, '%')</if>
<if test="ownerType != null "> and owner_type = #{ownerType}</if>
<if test="contactPerson != null and contactPerson != ''"> and contact_person = #{contactPerson}</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
<if test="email != null and email != ''"> and email = #{email}</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="taxNumber != null and taxNumber != ''"> and tax_number = #{taxNumber}</if>
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
<if test="isActive != null "> and is_active = #{isActive}</if>
<if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</where>
</select>
<select id="selectOwnersById" parameterType="String" resultMap="OwnersResult">
<include refid="selectOwnersVo"/>
where id = #{id}
</select>
<insert id="insertOwners" parameterType="Owners">
insert into owners
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="ownerCode != null">owner_code,</if>
<if test="ownerName != null">owner_name,</if>
<if test="ownerType != null">owner_type,</if>
<if test="contactPerson != null">contact_person,</if>
<if test="contactPhone != null">contact_phone,</if>
<if test="email != null">email,</if>
<if test="address != null">address,</if>
<if test="taxNumber != null">tax_number,</if>
<if test="bankAccount != null">bank_account,</if>
<if test="isActive != null">is_active,</if>
<if test="sortNo != null">sort_no,</if>
<if test="createTime != null">create_time,</if>
<if test="createUserCode != null">create_user_code,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateUserCode != null">update_user_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="ownerCode != null">#{ownerCode},</if>
<if test="ownerName != null">#{ownerName},</if>
<if test="ownerType != null">#{ownerType},</if>
<if test="contactPerson != null">#{contactPerson},</if>
<if test="contactPhone != null">#{contactPhone},</if>
<if test="email != null">#{email},</if>
<if test="address != null">#{address},</if>
<if test="taxNumber != null">#{taxNumber},</if>
<if test="bankAccount != null">#{bankAccount},</if>
<if test="isActive != null">#{isActive},</if>
<if test="sortNo != null">#{sortNo},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUserCode != null">#{createUserCode},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateUserCode != null">#{updateUserCode},</if>
</trim>
</insert>
<update id="updateOwners" parameterType="Owners">
update owners
<trim prefix="SET" suffixOverrides=",">
<if test="ownerCode != null">owner_code = #{ownerCode},</if>
<if test="ownerName != null">owner_name = #{ownerName},</if>
<if test="ownerType != null">owner_type = #{ownerType},</if>
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
<if test="email != null">email = #{email},</if>
<if test="address != null">address = #{address},</if>
<if test="taxNumber != null">tax_number = #{taxNumber},</if>
<if test="bankAccount != null">bank_account = #{bankAccount},</if>
<if test="isActive != null">is_active = #{isActive},</if>
<if test="sortNo != null">sort_no = #{sortNo},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUserCode != null">create_user_code = #{createUserCode},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateUserCode != null">update_user_code = #{updateUserCode},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteOwnersById" parameterType="String">
delete from owners where id = #{id}
</delete>
<delete id="deleteOwnersByIds" parameterType="String">
delete from owners where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论