| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @TableLogic |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer deleted; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.example.security.UserContext; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | return new MetaObjectHandler() { |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | String username = UserContext.getCurrentUsername(); |
| | | this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "deleted", Integer.class, 0); |
| | | this.strictInsertFill(metaObject, "version", Integer.class, 1); |
| | | this.strictInsertFill(metaObject, "createBy", String.class, username != null ? username : "系统"); |
| | | this.strictInsertFill(metaObject, "updateBy", String.class, username != null ? username : "系统"); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | String username = UserContext.getCurrentUsername(); |
| | | this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictUpdateFill(metaObject, "updateBy", String.class, username != null ? username : "系统"); |
| | | } |
| | | }; |
| | | } |
| | |
| | | import com.example.security.UserContext; |
| | | import com.example.service.DataExcelService; |
| | | import com.example.service.DepartmentService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | public Result<PageResult<DataExcel>> page( |
| | | @RequestParam(defaultValue = "1") Long current, |
| | | @RequestParam(defaultValue = "10") Long size, |
| | | @RequestParam(required = false) String unitName, |
| | | @RequestParam(required = false) String unitCode, |
| | | @RequestParam(required = false) String transactionNo, |
| | | @RequestParam(required = false) String accountingPeriod) { |
| | | String currentDeptCode = UserContext.getCurrentDeptCode(); |
| | | List<String> permissionDeptCodes = departmentService.getChildDeptCodes(currentDeptCode); |
| | | IPage<DataExcel> page = dataExcelService.getDataExcelPage(current, size, unitName, transactionNo, accountingPeriod, permissionDeptCodes); |
| | | IPage<DataExcel> page = dataExcelService.getDataExcelPage(current, size, unitCode, transactionNo, accountingPeriod, permissionDeptCodes); |
| | | return Result.success(new PageResult<>(page.getTotal(), current, size, page.getRecords())); |
| | | } |
| | | |
| | |
| | | |
| | | @PostMapping |
| | | public Result<Boolean> save(@RequestBody DataExcel dataExcel) { |
| | | DataExcel dataExcel1 = new DataExcel(); |
| | | String currentDeptCode = UserContext.getCurrentDeptCode(); |
| | | List<String> permissionDeptCodes = departmentService.getChildDeptCodes(currentDeptCode); |
| | | if (!permissionDeptCodes.contains(dataExcel.getUnitCode())) { |
| | | return Result.error("无权限在该部门创建数据"); |
| | | } |
| | | return Result.success(dataExcelService.save(dataExcel)); |
| | | BeanUtils.copyProperties(dataExcel,dataExcel1); |
| | | return Result.success(dataExcelService.save(dataExcel1)); |
| | | } |
| | | |
| | | @PutMapping |
| | |
| | | import com.example.entity.Department; |
| | | import com.example.security.UserContext; |
| | | import com.example.service.DepartmentService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | @PostMapping |
| | | public Result<Boolean> save(@RequestBody Department department) { |
| | | Department dept1 = new Department(); |
| | | String currentDeptCode = UserContext.getCurrentDeptCode(); |
| | | List<String> deptCodes = departmentService.getChildDeptCodes(currentDeptCode); |
| | | if (!deptCodes.contains(department.getParentCode())) { |
| | |
| | | if (departmentService.checkDeptCodeExists(department.getDeptCode())) { |
| | | return Result.error("部门编码已存在"); |
| | | } |
| | | return Result.success(departmentService.save(department)); |
| | | BeanUtils.copyProperties(department, dept1); |
| | | return Result.success(departmentService.save(dept1)); |
| | | } |
| | | |
| | | @PutMapping |
| | |
| | | import com.example.service.DepartmentService; |
| | | import com.example.service.UserService; |
| | | import com.example.utils.Md5Util; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | @PostMapping |
| | | public Result<Boolean> save(@RequestBody User user) { |
| | | User user1 = new User(); |
| | | String currentDeptCode = UserContext.getCurrentDeptCode(); |
| | | List<String> deptCodes = departmentService.getChildDeptCodes(currentDeptCode); |
| | | if (!deptCodes.contains(user.getDeptCode())) { |
| | |
| | | } else { |
| | | user.setPassword(Md5Util.encrypt("123456")); |
| | | } |
| | | return Result.success(userService.save(user)); |
| | | BeanUtils.copyProperties(user,user1); |
| | | System.out.println(user1); |
| | | return Result.success(userService.save(user1)); |
| | | } |
| | | |
| | | @PutMapping |
| New file |
| | |
| | | package com.example.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.example.common.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("data_task") |
| | | public class DataTask extends BaseEntity { |
| | | private String unitCode; |
| | | |
| | | private String unitName; |
| | | private Integer status; |
| | | |
| | | private Integer taskCount; |
| | | |
| | | private Integer successCount; |
| | | |
| | | private String remark; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime lastTime; |
| | | |
| | | } |
| | |
| | | UserContext context = getUserContext(); |
| | | return context != null ? context.getDeptCode() : null; |
| | | } |
| | | |
| | | public static String getCurrentUsername() { |
| | | UserContext context = getUserContext(); |
| | | return context != null ? context.getUsername() : null; |
| | | } |
| | | } |
| | |
| | | |
| | | public interface DataExcelService extends IService<DataExcel> { |
| | | |
| | | IPage<DataExcel> getDataExcelPage(Long current, Long size, String unitName, String transactionNo, String accountingPeriod, List<String> permissionDeptCodes); |
| | | IPage<DataExcel> getDataExcelPage(Long current, Long size, String unitCode, String transactionNo, String accountingPeriod, List<String> permissionDeptCodes); |
| | | |
| | | String importData(MultipartFile file, List<String> permissionDeptCodes); |
| | | } |
| | |
| | | public class DataExcelServiceImpl extends ServiceImpl<DataExcelMapper, DataExcel> implements DataExcelService { |
| | | |
| | | @Override |
| | | public IPage<DataExcel> getDataExcelPage(Long current, Long size, String unitName, String transactionNo, String accountingPeriod, List<String> permissionDeptCodes) { |
| | | public IPage<DataExcel> getDataExcelPage(Long current, Long size, String unitCode, String transactionNo, String accountingPeriod, List<String> permissionDeptCodes) { |
| | | Page<DataExcel> page = new Page<>(current, size); |
| | | page.setOptimizeJoinOfCountSql(false); |
| | | page.setOptimizeCountSql(false); |
| | | LambdaQueryWrapper<DataExcel> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.like(unitName != null && !unitName.isEmpty(), DataExcel::getUnitName, unitName) |
| | | wrapper.eq(unitCode != null && !unitCode.isEmpty(), DataExcel::getUnitCode, unitCode) |
| | | .like(transactionNo != null && !transactionNo.isEmpty(), DataExcel::getTransactionNo, transactionNo) |
| | | .eq(accountingPeriod != null && !accountingPeriod.isEmpty(), DataExcel::getAccountingPeriod, accountingPeriod) |
| | | .in(permissionDeptCodes != null && !permissionDeptCodes.isEmpty(), DataExcel::getUnitCode, permissionDeptCodes) |
| | |
| | | List<DataExcel> updateList = new ArrayList<>(); |
| | | List<String> errorMsgs = new ArrayList<>(); |
| | | int[] counts = new int[2]; |
| | | int[] counts2 = new int[2]; |
| | | |
| | | try { |
| | | EasyExcel.read(file.getInputStream(), DataExcelImport.class, new ReadListener<DataExcelImport>() { |
| | |
| | | errorMsgs.add("第" + data.getSeqNo() + "行无权限导入部门编码: " + data.getUnitCode()); |
| | | return; |
| | | } |
| | | |
| | | |
| | | DataExcel entity = new DataExcel(); |
| | | entity.setSortNo(data.getSortNo()); |
| | | entity.setSeqNo(data.getSeqNo()); |
| | |
| | | entity.setBusinessRelation(data.getBusinessRelation()); |
| | | entity.setRemark(data.getRemark()); |
| | | entity.setStatus(1); |
| | | |
| | | |
| | | if (data.getSortNo() != null) { |
| | | DataExcel existData = baseMapper.selectBySortNo(data.getSortNo()); |
| | | if (existData != null) { |
| | | entity.setId(existData.getId()); |
| | | updateList.add(entity); |
| | | counts[1]++; |
| | | counts2[0]++; |
| | | } else { |
| | | insertList.add(entity); |
| | | counts[0]++; |
| | |
| | | if (counts[0] > 0) { |
| | | result.append("成功新增 ").append(counts[0]).append(" 条记录"); |
| | | } |
| | | if (counts[1] > 0) { |
| | | if (counts2[0] > 0) { |
| | | if (result.length() > 0) { |
| | | result.append(","); |
| | | } |
| | | result.append("成功更新 ").append(counts[1]).append(" 条记录"); |
| | | result.append("成功更新 ").append(counts2[0]).append(" 条记录"); |
| | | } |
| | | if (!errorMsgs.isEmpty()) { |
| | | if (result.length() > 0) { |
| | |
| | | } |
| | | result.append("导入部分失败: ").append(String.join(", ", errorMsgs)); |
| | | } |
| | | |
| | | |
| | | if (result.length() == 0) { |
| | | return "导入失败"; |
| | | } |
| | | |
| | | |
| | | return result.toString(); |
| | | } |
| | | } |
| | |
| | | status NUMBER(1) DEFAULT 1, |
| | | create_time DATE DEFAULT SYSDATE, |
| | | update_time DATE DEFAULT SYSDATE, |
| | | create_by VARCHAR2(50 CHAR), |
| | | update_by VARCHAR2(50 CHAR), |
| | | deleted NUMBER(1) DEFAULT 0, |
| | | version NUMBER(10) DEFAULT 1 |
| | | ); |
| | |
| | | status NUMBER(1) DEFAULT 1, |
| | | create_time DATE DEFAULT SYSDATE, |
| | | update_time DATE DEFAULT SYSDATE, |
| | | create_by VARCHAR2(50 CHAR), |
| | | update_by VARCHAR2(50 CHAR), |
| | | deleted NUMBER(1) DEFAULT 0, |
| | | version NUMBER(10) DEFAULT 1 |
| | | ); |
| | |
| | | status NUMBER(1) DEFAULT 1, |
| | | create_time DATE DEFAULT SYSDATE, |
| | | update_time DATE DEFAULT SYSDATE, |
| | | create_by VARCHAR2(50 CHAR), |
| | | update_by VARCHAR2(50 CHAR), |
| | | deleted NUMBER(1) DEFAULT 0, |
| | | version NUMBER(10) DEFAULT 1 |
| | | ); |
| | | |
| | | -- 数据任务表 |
| | | CREATE TABLE data_task ( |
| | | id NUMBER(19) PRIMARY KEY, |
| | | unit_code VARCHAR2(50 CHAR), |
| | | unit_name VARCHAR2(200 CHAR), |
| | | status NUMBER(1) DEFAULT 0, |
| | | task_count NUMBER(10), |
| | | success_count NUMBER(10), |
| | | remark VARCHAR2(1000 CHAR), |
| | | create_time DATE DEFAULT SYSDATE, |
| | | update_time DATE DEFAULT SYSDATE, |
| | | create_by VARCHAR2(50 CHAR), |
| | | update_by VARCHAR2(50 CHAR), |
| | | deleted NUMBER(1) DEFAULT 0, |
| | | version NUMBER(10) DEFAULT 1, |
| | | last_time DATE DEFAULT SYSDATE |
| | | ); |
| | | |
| | | -- 创建序列 |
| | | CREATE SEQUENCE seq_sys_department START WITH 1 INCREMENT BY 1; |
| | | CREATE SEQUENCE seq_sys_user START WITH 1 INCREMENT BY 1; |
| | | CREATE SEQUENCE seq_data_excel START WITH 1 INCREMENT BY 1; |
| | | CREATE SEQUENCE seq_data_task START WITH 1 INCREMENT BY 1; |
| | | |
| | | -- 创建触发器(自动填充ID) |
| | | CREATE OR REPLACE TRIGGER trg_sys_department |
| | |
| | | END; |
| | | / |
| | | |
| | | CREATE OR REPLACE TRIGGER trg_data_task |
| | | BEFORE INSERT ON data_task |
| | | FOR EACH ROW |
| | | BEGIN |
| | | SELECT seq_data_task.NEXTVAL INTO :NEW.id FROM DUAL; |
| | | END; |
| | | / |
| | | |
| | | -- 插入初始化数据 |
| | | INSERT INTO sys_department (dept_code, dept_name, parent_code, sort_order, description, status) VALUES |
| | | ('001', '总公司', '0', 1, '总公司', 1); |
| | |
| | | <result column="status" property="status"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="create_by" property="createBy"/> |
| | | <result column="update_by" property="updateBy"/> |
| | | <result column="deleted" property="deleted"/> |
| | | <result column="version" property="version"/> |
| | | </resultMap> |
| | |
| | | <if test="status != null">status,</if> |
| | | create_time, |
| | | update_time, |
| | | create_by, |
| | | update_by, |
| | | deleted, |
| | | version |
| | | ) VALUES ( |
| | |
| | | <if test="status != null">#{status},</if> |
| | | SYSDATE, |
| | | SYSDATE, |
| | | #{createBy}, |
| | | #{updateBy}, |
| | | 0, |
| | | 1 |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateById" parameterType="com.example.entity.DataExcel"> |
| | | UPDATE data_excel |
| | | SET |
| | | <if test="seqNo != null">seq_no = #{seqNo},</if> |
| | | <if test="sortNo != null">sort_no = #{sortNo},</if> |
| | | <if test="secondaryUnit != null">secondary_unit = #{secondaryUnit},</if> |
| | | <if test="unitCode != null">unit_code = #{unitCode},</if> |
| | | <if test="unitName != null">unit_name = #{unitName},</if> |
| | | <if test="transactionNo != null">transaction_no = #{transactionNo},</if> |
| | | <if test="summary != null">summary = #{summary},</if> |
| | | <if test="amount != null">amount = #{amount},</if> |
| | | <if test="accountingPeriod != null">accounting_period = #{accountingPeriod},</if> |
| | | <if test="voucherNo != null">voucher_no = #{voucherNo},</if> |
| | | <if test="bpContractNo != null">bp_contract_no = #{bpContractNo},</if> |
| | | <if test="contractCenterNo != null">contract_center_no = #{contractCenterNo},</if> |
| | | <if test="bpInvoiceNo != null">bp_invoice_no = #{bpInvoiceNo},</if> |
| | | <if test="gkInvoiceNo != null">gk_invoice_no = #{gkInvoiceNo},</if> |
| | | <if test="businessRelation != null">business_relation = #{businessRelation},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="status != null">status = #{status},</if> |
| | | update_time = SYSDATE |
| | | WHERE id = #{id} AND deleted = 0 |
| | | </update> |
| | | </mapper> |
| | |
| | | <result column="status" property="status"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="create_by" property="createBy"/> |
| | | <result column="update_by" property="updateBy"/> |
| | | <result column="deleted" property="deleted"/> |
| | | <result column="version" property="version"/> |
| | | </resultMap> |
| | |
| | | status, |
| | | create_time, |
| | | update_time, |
| | | create_by, |
| | | update_by, |
| | | deleted, |
| | | version |
| | | ) VALUES ( |
| | |
| | | #{status}, |
| | | SYSDATE, |
| | | SYSDATE, |
| | | #{createBy}, |
| | | #{updateBy}, |
| | | 0, |
| | | 1 |
| | | ) |
| | |
| | | <result column="status" property="status"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="create_by" property="createBy"/> |
| | | <result column="update_by" property="updateBy"/> |
| | | <result column="deleted" property="deleted"/> |
| | | <result column="version" property="version"/> |
| | | <result column="dept_name" property="deptName"/> |
| | |
| | | status, |
| | | create_time, |
| | | update_time, |
| | | create_by, |
| | | update_by, |
| | | deleted, |
| | | version |
| | | ) VALUES ( |
| | |
| | | #{status}, |
| | | SYSDATE, |
| | | SYSDATE, |
| | | #{createBy}, |
| | | #{updateBy}, |
| | | 0, |
| | | 1 |
| | | ) |