Commit eef0e6df authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'master'

车企与单位数据同步

See merge request !8
parents 7cf6177a ddeac1ac
...@@ -4,9 +4,12 @@ import java.util.List; ...@@ -4,9 +4,12 @@ import java.util.List;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.web.request.AutomobileEnterpriseListRequest; import com.ruoyi.web.request.AutomobileEnterpriseListRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,6 +31,9 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter ...@@ -28,6 +31,9 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter
@Autowired @Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper; private AutomobileEnterpriseMapper automobileEnterpriseMapper;
@Autowired
private ISysDeptService deptService;
/** /**
* 查询车企信息 * 查询车企信息
* *
...@@ -71,7 +77,20 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter ...@@ -71,7 +77,20 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter
} }
automobileEnterprise.setCreateTime(DateUtils.getNowDate()); automobileEnterprise.setCreateTime(DateUtils.getNowDate());
automobileEnterprise.setCreateBy(String.valueOf(SecurityUtils.getUserId())); automobileEnterprise.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
return automobileEnterpriseMapper.insert(automobileEnterprise); automobileEnterpriseMapper.insert(automobileEnterprise);
SysDept dept = new SysDept();
dept.setOrderNum(0);
dept.setParentId(100l);
dept.setAncestors("0,100");
dept.setDeptType("enterprise");
dept.setDeptName(automobileEnterprise.getEnterpriseName());
dept.setAddress(automobileEnterprise.getAddress());
dept.setPostcode(automobileEnterprise.getPostcode());
dept.setLeader(automobileEnterprise.getEnterpriseContact());
dept.setPhone(automobileEnterprise.getContactNumber());
dept.setAutomobileEnterpriseId(automobileEnterprise.getId());
deptService.insertDept(dept);
return 1;
} }
/** /**
...@@ -93,7 +112,15 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter ...@@ -93,7 +112,15 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter
} }
automobileEnterprise.setUpdateTime(DateUtils.getNowDate()); automobileEnterprise.setUpdateTime(DateUtils.getNowDate());
automobileEnterprise.setUpdateBy(String.valueOf(SecurityUtils.getUserId())); automobileEnterprise.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
return automobileEnterpriseMapper.updateAutomobileEnterprise(automobileEnterprise); automobileEnterpriseMapper.updateAutomobileEnterprise(automobileEnterprise);
SysDept dept = deptService.getDeptByAutomobileEnterpriseId(automobileEnterprise.getId());
dept.setDeptName(automobileEnterprise.getEnterpriseName());
dept.setAddress(automobileEnterprise.getAddress());
dept.setPostcode(automobileEnterprise.getPostcode());
dept.setLeader(automobileEnterprise.getEnterpriseContact());
dept.setPhone(automobileEnterprise.getContactNumber());
deptService.updateDept(dept);
return 1;
} }
} }
...@@ -6,9 +6,11 @@ import javax.servlet.http.HttpServletResponse; ...@@ -6,9 +6,11 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Sample; import com.ruoyi.domain.Sample;
import com.ruoyi.service.SampleManagementService; import com.ruoyi.service.SampleManagementService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.web.request.AutomobileEnterpriseEditRequest; import com.ruoyi.web.request.AutomobileEnterpriseEditRequest;
import com.ruoyi.web.request.AutomobileEnterpriseGetInfoRequest; import com.ruoyi.web.request.AutomobileEnterpriseGetInfoRequest;
import com.ruoyi.web.request.AutomobileEnterpriseListRequest; import com.ruoyi.web.request.AutomobileEnterpriseListRequest;
...@@ -47,6 +49,9 @@ public class AutomobileEnterpriseController extends BaseController ...@@ -47,6 +49,9 @@ public class AutomobileEnterpriseController extends BaseController
@Autowired @Autowired
private SampleManagementService sampleManagementService; private SampleManagementService sampleManagementService;
@Autowired
private ISysDeptService deptService;
/** /**
* 查询车企信息列表 * 查询车企信息列表
*/ */
...@@ -122,6 +127,12 @@ public class AutomobileEnterpriseController extends BaseController ...@@ -122,6 +127,12 @@ public class AutomobileEnterpriseController extends BaseController
} }
} }
// 判断样品是否在此企业下 // 判断样品是否在此企业下
return R.ok(automobileEnterpriseService.removeBatchByIds(Arrays.asList(request.getIds()))); automobileEnterpriseService.removeBatchByIds(Arrays.asList(request.getIds()));
for (Long id : ids) {
SysDept dept = deptService.getDeptByAutomobileEnterpriseId(id);
deptService.deleteDeptById(dept.getDeptId());
}
return R.ok();
} }
} }
...@@ -23,7 +23,7 @@ import com.ruoyi.common.utils.StringUtils; ...@@ -23,7 +23,7 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
/** /**
* 部门信息 * 单位信息
* *
* @author ruoyi * @author ruoyi
*/ */
...@@ -35,7 +35,7 @@ public class SysDeptController extends BaseController ...@@ -35,7 +35,7 @@ public class SysDeptController extends BaseController
private ISysDeptService deptService; private ISysDeptService deptService;
/** /**
* 获取部门列表 * 获取单位列表
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:list')") @PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list") @GetMapping("/list")
...@@ -46,7 +46,7 @@ public class SysDeptController extends BaseController ...@@ -46,7 +46,7 @@ public class SysDeptController extends BaseController
} }
/** /**
* 查询部门列表(排除节点) * 查询单位列表(排除节点)
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:list')") @PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}") @GetMapping("/list/exclude/{deptId}")
...@@ -58,7 +58,7 @@ public class SysDeptController extends BaseController ...@@ -58,7 +58,7 @@ public class SysDeptController extends BaseController
} }
/** /**
* 根据部门编号获取详细信息 * 根据单位编号获取详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:query')") @PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}") @GetMapping(value = "/{deptId}")
...@@ -69,26 +69,26 @@ public class SysDeptController extends BaseController ...@@ -69,26 +69,26 @@ public class SysDeptController extends BaseController
} }
/** /**
* 新增部门 * 新增单位
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:add')") @PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT) @Log(title = "单位管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept) public AjaxResult add(@Validated @RequestBody SysDept dept)
{ {
if (!deptService.checkDeptNameUnique(dept)) if (!deptService.checkDeptNameUnique(dept))
{ {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("新增单位'" + dept.getDeptName() + "'失败,单位名称已存在");
} }
dept.setCreateBy(getUsername()); dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
/** /**
* 修改部门 * 修改单位
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:edit')") @PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE) @Log(title = "单位管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept) public AjaxResult edit(@Validated @RequestBody SysDept dept)
{ {
...@@ -96,35 +96,35 @@ public class SysDeptController extends BaseController ...@@ -96,35 +96,35 @@ public class SysDeptController extends BaseController
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) if (!deptService.checkDeptNameUnique(dept))
{ {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("修改单位'" + dept.getDeptName() + "'失败,单位名称已存在");
} }
else if (dept.getParentId().equals(deptId)) else if (dept.getParentId().equals(deptId))
{ {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return error("修改单位'" + dept.getDeptName() + "'失败,上级单位不能是自己");
} }
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{ {
return error("该部门包含未停用的子部门!"); return error("该单位包含未停用的子单位!");
} }
dept.setUpdateBy(getUsername()); dept.setUpdateBy(getUsername());
return toAjax(deptService.updateDept(dept)); return toAjax(deptService.updateDept(dept));
} }
/** /**
* 删除部门 * 删除单位
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:remove')") @PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE) @Log(title = "单位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}") @DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId) public AjaxResult remove(@PathVariable Long deptId)
{ {
if (deptService.hasChildByDeptId(deptId)) if (deptService.hasChildByDeptId(deptId))
{ {
return warn("存在下级部门,不允许删除"); return warn("存在下级单位,不允许删除");
} }
if (deptService.checkDeptExistUser(deptId)) if (deptService.checkDeptExistUser(deptId))
{ {
return warn("部门存在用户,不允许删除"); return warn("单位存在用户,不允许删除");
} }
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId)); return toAjax(deptService.deleteDeptById(deptId));
......
...@@ -59,6 +59,9 @@ public class SysDept extends BaseEntity ...@@ -59,6 +59,9 @@ public class SysDept extends BaseEntity
/** 邮编 */ /** 邮编 */
private String postcode; private String postcode;
/** 车企id */
private Long automobileEnterpriseId;
/** 子部门 */ /** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>(); private List<SysDept> children = new ArrayList<SysDept>();
...@@ -215,6 +218,14 @@ public class SysDept extends BaseEntity ...@@ -215,6 +218,14 @@ public class SysDept extends BaseEntity
this.deptType = deptType; this.deptType = deptType;
} }
public Long getAutomobileEnterpriseId() {
return automobileEnterpriseId;
}
public void setAutomobileEnterpriseId(Long automobileEnterpriseId) {
this.automobileEnterpriseId = automobileEnterpriseId;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
...@@ -235,6 +246,7 @@ public class SysDept extends BaseEntity ...@@ -235,6 +246,7 @@ public class SysDept extends BaseEntity
.append("address",getAddress()) .append("address",getAddress())
.append("postcode",getPostcode()) .append("postcode",getPostcode())
.append("deptType",getDeptType()) .append("deptType",getDeptType())
.append("automobileEnterpriseId",getAutomobileEnterpriseId())
.toString(); .toString();
} }
} }
...@@ -118,4 +118,6 @@ public interface SysDeptMapper ...@@ -118,4 +118,6 @@ public interface SysDeptMapper
* @return 结果 * @return 结果
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
SysDept getDeptByAutomobileEnterpriseId(@Param("automobileEnterpriseId") Long automobileEnterpriseId);
} }
...@@ -121,4 +121,6 @@ public interface ISysDeptService ...@@ -121,4 +121,6 @@ public interface ISysDeptService
* @return 结果 * @return 结果
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
public SysDept getDeptByAutomobileEnterpriseId(Long automobileEnterpriseId);
} }
...@@ -293,6 +293,11 @@ public class SysDeptServiceImpl implements ISysDeptService ...@@ -293,6 +293,11 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.deleteDeptById(deptId); return deptMapper.deleteDeptById(deptId);
} }
@Override
public SysDept getDeptByAutomobileEnterpriseId(Long automobileEnterpriseId) {
return deptMapper.getDeptByAutomobileEnterpriseId(automobileEnterpriseId);
}
/** /**
* 递归列表 * 递归列表
*/ */
......
...@@ -23,10 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -23,10 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="address" column="address" /> <result property="address" column="address" />
<result property="postcode" column="postcode" /> <result property="postcode" column="postcode" />
<result property="deptType" column="dept_type" /> <result property="deptType" column="dept_type" />
<result property="automobileEnterpriseId" column="automobile_enterprise_id" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.address, d.postcode, d.dept_type select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.address, d.postcode, d.dept_type, d.automobile_enterprise_id
from sys_dept d from sys_dept d
</sql> </sql>
...@@ -89,6 +90,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -89,6 +90,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select> </select>
<select id="getDeptByAutomobileEnterpriseId" resultType="com.ruoyi.common.core.domain.entity.SysDept">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.address, d.postcode, d.dept_type, d.automobile_enterprise_id
from sys_dept d
where d.automobile_enterprise_id = #{automobileEnterpriseId}
</select>
<insert id="insertDept" parameterType="SysDept"> <insert id="insertDept" parameterType="SysDept">
insert into sys_dept( insert into sys_dept(
...@@ -104,7 +110,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -104,7 +110,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="address != null and address != ''">address,</if> <if test="address != null and address != ''">address,</if>
<if test="postcode != null and postcode != ''">postcode,</if> <if test="postcode != null and postcode != ''">postcode,</if>
<if test="deptType != null and deptType != ''">deptType,</if> <if test="deptType != null and deptType != ''">dept_type,</if>
<if test="automobileEnterpriseId != null and automobileEnterpriseId != ''">automobile_enterprise_id,</if>
create_time create_time
)values( )values(
<if test="deptId != null and deptId != 0">#{deptId},</if> <if test="deptId != null and deptId != 0">#{deptId},</if>
...@@ -120,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -120,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="address != null and address != ''">#{address},</if> <if test="address != null and address != ''">#{address},</if>
<if test="postcode != null and postcode != ''">#{postcode},</if> <if test="postcode != null and postcode != ''">#{postcode},</if>
<if test="deptType != null and deptType != ''">#{deptType},</if> <if test="deptType != null and deptType != ''">#{deptType},</if>
<if test="automobileEnterpriseId != null and automobileEnterpriseId != ''">#{automobileEnterpriseId},</if>
sysdate() sysdate()
) )
</insert> </insert>
...@@ -138,7 +146,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -138,7 +146,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="address != null and address != ''">address = #{address},</if> <if test="address != null and address != ''">address = #{address},</if>
<if test="postcode != null and postcode != ''">postcode = #{postcode},</if> <if test="postcode != null and postcode != ''">postcode = #{postcode},</if>
<if test="deptType != null and deptType != ''">deptType = #{deptType},</if> <if test="deptType != null and deptType != ''">dept_type = #{deptType},</if>
<if test="automobileEnterpriseId != null and automobileEnterpriseId != ''">automobile_enterprise_id = #{automobileEnterpriseId},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where dept_id = #{deptId} where dept_id = #{deptId}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment