晏有为
2024-05-23 10de56ca16261e6a4eec49dfd32f0a6b232f7baf
Merge branch 'master' of http://114.132.189.42:9002/r/center-lims-after
已修改53个文件
已删除2个文件
已添加10个文件
1527 ■■■■■ 文件已修改
cnas-server/src/main/java/com/yuanchu/mom/controller/DepartmentController.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/controller/StandardMethodController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/mapper/DepartmentLimsMapper.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/mapper/DepartmentMapper.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/mapper/StandardMethodMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/pojo/Department.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/pojo/DepartmentLims.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/DepartmentLimsService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/DepartmentService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/StandardMethodService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/impl/DepartmentLimsServiceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/impl/DepartmentServiceImpl.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/impl/StandardMethodServiceImpl.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/resources/mapper/DepartmentLimsMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/resources/mapper/DepartmentMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/resources/mapper/DeviceMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/config/OpenFifer.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/config/Swagger3.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderPlanController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/InsUnPassController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/ReportController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTemplateController.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/WarehouseController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/mapper/StandardProductListMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/pojo/InsUnPass.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/pojo/StandardProductList.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/StandardTreeService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java 94 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardTreeServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/StandardProductListMapper.xml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/StandardTemplateMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/StandardTreeMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/static/report-template.docx 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/main/resources/application-dev.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/main/resources/application-prod.yml 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/test/java/com/yuanchu/mom/SystemRunApplicationTest.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/controller/CompaniesController.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/controller/PostController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/controller/SimpleController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/controller/UserController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/dto/Custom.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/dto/PersonDto.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/dto/UserPageDto.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/mapper/DepartmentsMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/pojo/AuthApi.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/pojo/Departments.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/pojo/Person.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/pojo/User.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/service/UserService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/java/com/yuanchu/mom/util/HeaderToken.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/resources/mapper/DepartmentsMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user-server/src/main/resources/mapper/UserMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/controller/DepartmentController.java
@@ -1,23 +1,19 @@
package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.dto.UserDto;
import com.yuanchu.mom.pojo.Department;
import com.yuanchu.mom.pojo.DepartmentLims;
import com.yuanchu.mom.service.DepartmentLimsService;
import com.yuanchu.mom.service.DepartmentService;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
 * <p>
 * éƒ¨é—¨æ˜Žç»† å‰ç«¯æŽ§åˆ¶å™¨
 * ç»„织架构明细 å‰ç«¯æŽ§åˆ¶å™¨
 * </p>
 *
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
@@ -29,32 +25,47 @@
@RequestMapping("/department")
public class DepartmentController {
    DepartmentService departmentService;
    @ValueClassify("人员明细")
    @ApiOperation(value = "添加部门")
    private DepartmentService departmentService;
    private DepartmentLimsService departmentLimsService;
    @ValueClassify("用户管理")
    @ApiOperation(value = "添加组织架构")
    @PostMapping("/addDepartment")
    public Result addDepartment(@RequestBody Department department) {
        return Result.success(departmentService.addDepartment(department));
    }
    @ApiOperation(value = "获取部门树")
    @ApiOperation(value = "获取组织架构树")
    @GetMapping("/selectDepartment")
    @ValueClassify("人员明细")
    @ValueClassify("用户管理")
    public Result selectDepartment() {
        return Result.success(departmentService.selectDepartment());
    }
    @ValueClassify("人员明细")
    @ApiOperation(value = "删除部门")
    @ValueClassify("用户管理")
    @ApiOperation(value = "删除组织架构")
    @PostMapping("/delDepartment")
    public Result delDepartment(Integer id) {
        return Result.success(departmentService.delDepartment(id));
    }
    @ValueAuth
    @ApiOperation(value = "根据选择的树展示相关的人员")
    @PostMapping("/showUserById")
    public Result showUserById(@RequestBody Map<String, Object> data) throws Exception {
        Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class);
        UserDto user = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), UserDto.class);
        return Result.success(departmentService.showUserById(page, user));
    @ValueClassify("人员明细")
    @ApiOperation(value = "获取组织架构树")
    @GetMapping("/selectDepartmentLim")
    public Result selectDepartmentLim() {
        return Result.success(departmentLimsService.selectDepartment());
    }
    @ValueClassify("人员明细")
    @ApiOperation(value = "添加组织架构")
    @PostMapping("/addDepartmentLims")
    public Result addDepartmentLims(@RequestBody DepartmentLims department) {
        return Result.success(departmentLimsService.addDepartment(department));
    }
    @ValueClassify("人员明细")
    @ApiOperation(value = "删除组织架构")
    @PostMapping("/delDepartmentLims")
    public Result delDepartmentLims(Integer id) {
        return Result.success(departmentLimsService.delDepartment(id));
    }
}
cnas-server/src/main/java/com/yuanchu/mom/controller/StandardMethodController.java
@@ -11,10 +11,12 @@
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Map;
@Api("标准方法")
@Api(tags = "标准方法")
@RestController
@RequestMapping("/standardMethod")
@AllArgsConstructor
@@ -55,4 +57,12 @@
    public Result<?> upStandardMethod(@RequestBody StandardMethod standardMethod) {
        return Result.success(standardMethodService.upStandardMethod(standardMethod));
    }
    @ValueClassify("实验室的检测能力档案")
    @ApiOperation(value = "导入标准明细")
    @PostMapping("/importStandardDetails")
    public Result<?> importStandardDetails(@RequestPart("file") MultipartFile file) throws IOException {
        standardMethodService.inputExcel(file);
        return Result.success();
    }
}
cnas-server/src/main/java/com/yuanchu/mom/mapper/DepartmentLimsMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.pojo.DepartmentLims;
import java.util.List;
/**
* @author z1292
* @description é’ˆå¯¹è¡¨ã€department_lims(部门明细)】的数据库操作Mapper
* @createDate 2024-05-22 14:08:17
* @Entity com.yuanchu.mom.pojo.DepartmentLims
*/
public interface DepartmentLimsMapper extends BaseMapper<DepartmentLims> {
    //获取部门树
    List<DepartmentDto> selectDepartment();
    //根据部门id,查询他的所有子类id
    List<Integer> selectSonById(Integer id);
}
cnas-server/src/main/java/com/yuanchu/mom/mapper/DepartmentMapper.java
@@ -1,12 +1,8 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.dto.UserDto;
import com.yuanchu.mom.mybatis_config.MyBaseMapper;
import com.yuanchu.mom.pojo.Department;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -18,15 +14,11 @@
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
 * @since 2024-04-15 04:01:48
 */
public interface DepartmentMapper extends BaseMapper<Department> {
public interface DepartmentMapper extends MyBaseMapper<Department> {
    //获取部门树
    List<DepartmentDto> selectDepartment();
    //根据选择的树展示相关的人员
    IPage<UserDto> showUserById(@Param("page") IPage<UserDto> page, @Param("ids") List<String> ids, @Param("ew") QueryWrapper<UserDto> ew);
    //根据部门id,查询他的所有子类id
    List<Integer> selectSonById(Integer id);
cnas-server/src/main/java/com/yuanchu/mom/mapper/StandardMethodMapper.java
@@ -3,9 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.mybatis_config.MyBaseMapper;
import com.yuanchu.mom.pojo.StandardMethod;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuanchu.mom.pojo.StructureItemParameter;
/**
* @author Administrator
@@ -13,7 +12,7 @@
* @createDate 2024-03-03 19:21:41
* @Entity com.yuanchu.mom.pojo.StandardMethod
*/
public interface StandardMethodMapper extends BaseMapper<StandardMethod> {
public interface StandardMethodMapper extends MyBaseMapper<StandardMethod> {
    IPage<StandardMethod> selectStandardMethodList(Page page, QueryWrapper<StandardMethod> ew);
cnas-server/src/main/java/com/yuanchu/mom/pojo/Department.java
@@ -4,12 +4,13 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
@@ -35,13 +36,17 @@
    @ApiModelProperty("父级id")
    private Integer fatherId;
    @TableField(fill = FieldFill.INSERT)
    private Integer createUser;
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateUser;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    private String companyId;
}
cnas-server/src/main/java/com/yuanchu/mom/pojo/DepartmentLims.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
package com.yuanchu.mom.pojo;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * éƒ¨é—¨æ˜Žç»†
 * @TableName department_lims
 */
@TableName(value ="department_lims")
@Data
public class DepartmentLims implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("父级id")
    private Integer fatherId;
    @TableField(fill = FieldFill.INSERT)
    private Integer createUser;
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateUser;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}
cnas-server/src/main/java/com/yuanchu/mom/service/DepartmentLimsService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.pojo.DepartmentLims;
import java.util.List;
/**
* @author z1292
* @description é’ˆå¯¹è¡¨ã€department_lims(部门明细)】的数据库操作Service
* @createDate 2024-05-22 14:08:17
*/
public interface DepartmentLimsService extends IService<DepartmentLims> {
    //添加部门
    int addDepartment(DepartmentLims departmentLims);
    //获取部门树
    List<DepartmentDto> selectDepartment();
    //删除部门
    boolean delDepartment(Integer id);
}
cnas-server/src/main/java/com/yuanchu/mom/service/DepartmentService.java
@@ -1,14 +1,10 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.dto.UserDto;
import com.yuanchu.mom.pojo.Department;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.pojo.User;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.pojo.Department;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -28,7 +24,4 @@
    //删除部门
    boolean delDepartment(Integer id);
    //根据选择的树展示相关的人员
    Map<String, Object> showUserById(Page page, UserDto user);
}
cnas-server/src/main/java/com/yuanchu/mom/service/StandardMethodService.java
@@ -1,10 +1,11 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.StandardMethod;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.pojo.StructureItemParameter;
import com.yuanchu.mom.pojo.StandardMethod;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -25,4 +26,5 @@
    int upStandardMethod(StandardMethod standardMethod);
    void inputExcel(MultipartFile file) throws IOException;
}
cnas-server/src/main/java/com/yuanchu/mom/service/impl/DepartmentLimsServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,86 @@
package com.yuanchu.mom.service.impl;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.mapper.DepartmentLimsMapper;
import com.yuanchu.mom.pojo.DepartmentLims;
import com.yuanchu.mom.service.DepartmentLimsService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author z1292
* @description é’ˆå¯¹è¡¨ã€department_lims(部门明细)】的数据库操作Service实现
* @createDate 2024-05-22 14:08:17
*/
@Service
@AllArgsConstructor
public class DepartmentLimsServiceImpl extends ServiceImpl<DepartmentLimsMapper, DepartmentLims>
    implements DepartmentLimsService{
    DepartmentLimsMapper departmentMapper;
    @Override
    public int addDepartment(DepartmentLims department) {
        departmentMapper.insert(department);
        return department.getId();
    }
    //获取部门树
    @Override
    public List<DepartmentDto> selectDepartment() {
        List<DepartmentDto> departments = departmentMapper.selectDepartment();
        //获取父节点
        List<DepartmentDto> collect = departments.stream().filter(m -> m.getFatherId() == null).peek(
                (m) -> m.setChildren(getChildren(m, departments))
        ).collect(Collectors.toList());
        return collect;
    }
    /**
     * é€’归查询子节点
     * @param root  æ ¹èŠ‚ç‚¹
     * @param all   æ‰€æœ‰èŠ‚ç‚¹
     * @return æ ¹èŠ‚ç‚¹ä¿¡æ¯
     */
    private List<DepartmentDto> getChildren(DepartmentDto root, List<DepartmentDto> all) {
        return all.stream().filter(m -> Objects.equals(m.getFatherId(), root.getId())).peek(
                (m) -> m.setChildren(getChildren(m, all))
        ).collect(Collectors.toList());
    }
    //删除部门
    @Override
    public boolean delDepartment(Integer id) {
        //判断是否有子类,直到没有为止
        List<DepartmentLims> department = getDepartment(id);
        return removeBatchByIds(department);
    }
    //判断是否有子类,直到没有为止
    public List<DepartmentLims> getDepartment(Integer id) {
        List<DepartmentLims> list = new ArrayList<>();
        DepartmentLims depart = baseMapper.selectById(id);
        list.add(depart);
        List<DepartmentLims> departments = baseMapper.selectList(Wrappers.<DepartmentLims>lambdaQuery().eq(DepartmentLims::getFatherId, id));
        if (ObjectUtils.isNotEmpty(departments)) {
            list.addAll(departments);
            for (DepartmentLims department : departments) {
                list.addAll(getDepartment(department.getId()));
            }
        }
        return list;
    }
}
cnas-server/src/main/java/com/yuanchu/mom/service/impl/DepartmentServiceImpl.java
@@ -2,30 +2,19 @@
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.common.PrintChina;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.dto.UserDto;
import com.yuanchu.mom.dto.UserPageDto;
import com.yuanchu.mom.pojo.Department;
import com.yuanchu.mom.mapper.DepartmentMapper;
import com.yuanchu.mom.pojo.Device;
import com.yuanchu.mom.pojo.User;
import com.yuanchu.mom.service.DepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.utils.QueryWrappers;
import com.yuanchu.mom.dto.DepartmentDto;
import com.yuanchu.mom.mapper.DepartmentMapper;
import com.yuanchu.mom.pojo.Department;
import com.yuanchu.mom.service.DepartmentService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Wrapper;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -43,6 +32,8 @@
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
    DepartmentMapper departmentMapper;
    //添加部门
@@ -82,23 +73,6 @@
        List<Department> department = getDepartment(id);
        return removeBatchByIds(department);
    }
    //根据选择的树展示相关的人员
    @Override
    public Map<String, Object> showUserById(Page page, UserDto user) {
        //根据部门id,查询他的所有子类id
        List<Integer> list = departmentMapper.selectSonById(Integer.parseInt(user.getDepartId()));
        List<String> ids = list.stream()
                .map(Object::toString)
                //.collect(Collectors.joining(","));
                .collect(Collectors.toList());
        log.info(ids+"\n");
        Map<String, Object> map = new HashMap<>();
        map.put("head", PrintChina.printChina(UserDto.class));
        map.put("body", departmentMapper.showUserById(page, ids, QueryWrappers.queryWrappers(user)));
        return map;
    }
    //判断是否有子类,直到没有为止
    public List<Department> getDepartment(Integer id) {
cnas-server/src/main/java/com/yuanchu/mom/service/impl/StandardMethodServiceImpl.java
@@ -1,5 +1,8 @@
package com.yuanchu.mom.service.impl;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -11,10 +14,11 @@
import com.yuanchu.mom.utils.QueryWrappers;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.*;
/**
* @author Administrator
@@ -42,7 +46,7 @@
    @Override
    public List<StandardMethod> selectStandardMethods() {
        return standardMethodMapper.selectList(Wrappers.<StandardMethod>lambdaQuery().select(StandardMethod::getId,StandardMethod::getCode,StandardMethod::getName));
        return standardMethodMapper.selectList(Wrappers.<StandardMethod>lambdaQuery().select(StandardMethod::getId,StandardMethod::getCode,StandardMethod::getName).ne(StandardMethod::getId, 0));
    }
    @Override
@@ -62,6 +66,132 @@
        int i = standardMethodMapper.updateById(standardMethod);
        return i;
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void inputExcel(MultipartFile file) throws IOException {
        // å­˜å‚¨æ£€æµ‹å¯¹è±¡List
        List<Object> structureTestObjectIdList = new ArrayList<>();
        List<StandardMethod> result = new ArrayList<>();
        ExcelUtil.readBySax(file.getInputStream(), 0, (i, l, list) -> {
            // åŽ»é™¤ç¬¬ä¸€è¡Œè¡¨å¤´
            if (l == 0) {
                return;
            }
            // å­˜å‚¨å”¯ä¸€æ£€æµ‹å¯¹è±¡
            if (!structureTestObjectIdList.contains(list.get(2))) {
                structureTestObjectIdList.add(list.get(2));
            }
            StandardMethod standardMethod = formatData(list);
            result.add(standardMethod);
        });
        addStructureTest(structureTestObjectIdList, result);
    }
    // æ ¼å¼åŒ–数据
    public StandardMethod formatData(List<Object> list) {
        StandardMethod standardMethod = new StandardMethod();
        standardMethod.setField(list.get(1).toString());
        // é€ æ ¼å¼
        List<List<Object>> structureTestObjectId = new ArrayList<>();
        if (ObjectUtils.isEmpty(list.get(3))){
            structureTestObjectId.add(Arrays.asList(list.get(2)));
        } else {
            structureTestObjectId.add(Arrays.asList(list.get(2), list.get(3)));
        }
        standardMethod.setStructureTestObjectId(JSONUtil.toJsonStr(structureTestObjectId));
        standardMethod.setCode(list.get(4).toString());
        standardMethod.setName(list.get(5).toString());
        standardMethod.setNameEn(list.get(6).toString());
        if (!Objects.equals(list.get(7), null)) {
            standardMethod.setRemark(list.get(7).toString());
        }
        standardMethod.setQualificationId(list.get(8).toString());
        if (ObjectUtils.isNotEmpty(list.get(9))) {
            if (list.get(9).equals("是")) {
                standardMethod.setIsProduct(1);
            } else if (list.get(9).equals("否")) {
                standardMethod.setIsProduct(0);
            }
        }
        if (ObjectUtils.isNotEmpty(list.get(10))) {
            if (list.get(10).equals("是")) {
                standardMethod.setIsUse(1);
            } else if (list.get(9).equals("否")) {
                standardMethod.setIsUse(0);
            }
        }
        return standardMethod;
    }
    // æ–°å¢žæ•°æ®
    public void addStructureTest(List<Object> structureTestObjectIdList, List<StandardMethod> standardMethodList) {
        List<StandardMethod> updateList = new ArrayList<>();
        List<Integer> deleteListId = new ArrayList<>();
        List<StandardMethod> addList = new ArrayList<>();
        if (!structureTestObjectIdList.isEmpty()) {
            // å¾ªçޝexcel里面的分组
            structureTestObjectIdList.forEach(j -> {
                // ä»¥excel中的组名查询数据库中的分组
                List<StandardMethod> standardMethods = baseMapper.selectList(Wrappers.<StandardMethod>lambdaQuery()
                        .like(StandardMethod::getStructureTestObjectId, "\"" + j + "\""));
                // å°†ç»“果循环匹配
                for (int i = 0; i < standardMethods.size(); i++) {
                    boolean isExistence = false;
                    for (int i1 = 0; i1 < standardMethodList.size(); i1++) {
                        // æ›´æ–°
                        if (standardMethods.get(i).getStructureTestObjectId().equals(standardMethodList.get(i1).getStructureTestObjectId())
                                && standardMethods.get(i).getCode().equals(standardMethodList.get(i1).getCode())
                                && standardMethods.get(i).getField().equals(standardMethodList.get(i1).getField())) {
                            // ç»™excel数据赋值id做更新
                            standardMethodList.get(i1).setId(standardMethods.get(i).getId());
                            // æ›´æ–°
                            updateList.add(standardMethodList.get(i1));
                            isExistence = true;
                            break;
                        }
                    }
                    // åˆ é™¤
                    if (!isExistence) {
                        deleteListId.add(standardMethods.get(i).getId());
                    }
                }
                for (int i = 0; i < standardMethodList.size(); i++) {
                    if (standardMethodList.get(i).getStructureTestObjectId().contains("\"" + j + "\"")) {
                        boolean isExistence = false;
                        for (int i1 = 0; i1 < standardMethods.size(); i1++) {
                            if (standardMethods.get(i1).getStructureTestObjectId().equals(standardMethodList.get(i).getStructureTestObjectId())
                                    && standardMethods.get(i1).getCode().equals(standardMethodList.get(i).getCode())
                                    && standardMethods.get(i1).getField().equals(standardMethodList.get(i).getField())) {
                                isExistence = true;
                                break;
                            }
                        }
                        // æ–°å¢ž
                        if (!isExistence) {
                            addList.add(standardMethodList.get(i));
                        }
                    }
                }
            });
        }
        if (!addList.isEmpty()) {
            // æ–°å¢ž
            baseMapper.insertBatchSomeColumn(addList);
        }
        if (!deleteListId.isEmpty()) {
            // åˆ é™¤
            baseMapper.deleteBatchIds(deleteListId);
        }
        if (!updateList.isEmpty()) {
            // æ›´æ–°
            updateList.forEach(i -> {
                baseMapper.updateById(i);
            });
        }
    }
}
cnas-server/src/main/resources/mapper/DepartmentLimsMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
<?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.yuanchu.mom.mapper.DepartmentLimsMapper">
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.DepartmentLims">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
            <result property="fatherId" column="father_id" jdbcType="INTEGER"/>
            <result property="createUser" column="create_user" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <select id="selectDepartment" resultType="com.yuanchu.mom.dto.DepartmentDto">
        SELECT id, name, father_id
        FROM department_lims
    </select>
    <select id="selectSonById" resultType="java.lang.Integer">
        SELECT au.id
        FROM (SELECT * FROM department_lims WHERE father_id IS NOT NULL) au,
             (SELECT @father_id := #{id}) pd
        WHERE FIND_IN_SET(father_id, @father_id) > 0
                  AND @father_id := concat(@father_id, ',', id)
        UNION
        SELECT id
        FROM department_lims
        WHERE id = #{id}
        ORDER BY id
    </select>
</mapper>
cnas-server/src/main/resources/mapper/DepartmentMapper.xml
@@ -6,17 +6,6 @@
        FROM department
    </select>
    <select id="showUserById" resultType="com.yuanchu.mom.dto.UserDto">
        select * from (select id, name, age, email, phone,depart_id
        from user where state=1 and SUBSTRING_INDEX(depart_id, ',', -1) in
        <foreach collection="ids" item="id" separator="," open="(" close=")">
            #{id}
        </foreach> ) a
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="selectSonById" resultType="java.lang.Integer">
        SELECT au.id
        FROM (SELECT * FROM department WHERE father_id IS NOT NULL) au,
cnas-server/src/main/resources/mapper/DeviceMapper.xml
@@ -93,12 +93,11 @@
    <select id="selectDeviceParameterPage" resultType="com.yuanchu.mom.dto.DeviceDto">
        select * from(
        SELECT
        d.*, u.name equipmentManagerUser, l.laboratory_name laboratoryName, i.inspection_item insProductItem
        d.*, u.name equipmentManagerUser, l.laboratory_name laboratoryName
        FROM
        device d
        left join `user` u on u.id = d.equipment_manager
        left join laboratory l on l.id = d.subordinate_departments_id
        left join ins_product i on i.id = d.ins_product_ids
        ) a
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
framework/src/main/java/com/yuanchu/mom/config/OpenFifer.java
@@ -1,16 +1,12 @@
package com.yuanchu.mom.config;
import cn.hutool.log.Log;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@@ -63,8 +59,8 @@
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(fiferConfig).addPathPatterns("/**");
//        registry.addInterceptor(powerConfig).addPathPatterns("/**");
        registry.addInterceptor(fiferConfig).addPathPatterns("/**");
        registry.addInterceptor(powerConfig).addPathPatterns("/**");
        registry.addInterceptor(logConfig).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
framework/src/main/java/com/yuanchu/mom/config/Swagger3.java
@@ -34,15 +34,15 @@
        // ç”¨ApiInfoBuilder进行定制
        return new ApiInfoBuilder()
                // è®¾ç½®æ ‡é¢˜
                .title("OMS")
                .title("LIMS")
                // æè¿°
                .description("OMS系统")
                .description("实验室管理系统")
                // ä½œè€…信息
                .contact(new Contact("鵷雏", null, null))
                .contact(new Contact("鵷雏网络科技", null, null))
                // ç‰ˆæœ¬
                .version("版本号:V1.0")
                .version("版本号:V1.0")
                //协议
                .license("The Apache License")
                .license("商业项目")
                //协议url
                .licenseUrl("http://www.baidu.com")
                .build();
framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java
@@ -1,7 +1,6 @@
package com.yuanchu.mom.utils;
import com.yuanchu.mom.mapper.SystemLogMapper;
import lombok.Builder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java
@@ -31,7 +31,7 @@
@RestController
@AllArgsConstructor
@RequestMapping("/insOrder")
@Api("检验单模块")
@Api(tags="检验单模块")
public class InsOrderController {
    private InsOrderService insOrderService;
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderPlanController.java
@@ -23,7 +23,7 @@
 */
@RestController
@RequestMapping("/insOrderPlan")
@Api("/检验任务")
@Api(tags = "检验任务")
@AllArgsConstructor
public class InsOrderPlanController {
inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java
@@ -4,7 +4,6 @@
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.dto.ReportPageDto;
import com.yuanchu.mom.exception.ErrorException;
@@ -30,8 +29,7 @@
@RestController
@RequestMapping("/insReport")
//@AllArgsConstructor
@Api("检验报告")
@Api(tags = "检验报告")
public class InsReportController {
    @Resource
@@ -49,9 +47,9 @@
        return Result.success(insReportService.pageInsReport(page, reportPageDto));
    }
    @ValueClassify("报告编制")
    @ApiOperation(value = "报告上传")
    @PostMapping("/inReport")
    @ValueAuth
    public Result inReport(MultipartFile file, Integer id) {
        String urlString;
        String pathName;
inspect-server/src/main/java/com/yuanchu/mom/controller/InsUnPassController.java
@@ -23,7 +23,7 @@
 */
@RestController
@RequestMapping("/unPass")
@Api("/不合格管理")
@Api(tags = "不合格管理")
@AllArgsConstructor
public class InsUnPassController {
    @Resource
inspect-server/src/main/java/com/yuanchu/mom/controller/ReportController.java
@@ -16,7 +16,7 @@
@RestController
@AllArgsConstructor
@RequestMapping("/report")
@Api("报表模块")
@Api(tags = "报表模块")
public class ReportController {
    private ReportService reportService;
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTemplateController.java
@@ -17,7 +17,7 @@
@RequestMapping("/StandardTemplate")
@RestController
@AllArgsConstructor
@Api("原始记录模板")
@Api(tags = "原始记录模板")
public class StandardTemplateController {
    private StandardTemplateService standardTemplateService;
@@ -62,4 +62,11 @@
        return Result.success(standardTemplateService.getStandTempThingById(id));
    }
    @ApiOperation(value = "编辑模板编制")
    @GetMapping("/getEditTemplatePreparation")
    @ValueClassify("标准库")
    public Result<?> getEditTemplatePreparation(@RequestParam("id") Integer id) {
        StandardTemplate byId = standardTemplateService.getById(id);
        return Result.success("OK", byId.getThing());
    }
}
inspect-server/src/main/java/com/yuanchu/mom/controller/StandardTreeController.java
@@ -11,13 +11,19 @@
import com.yuanchu.mom.service.StandardProductListService;
import com.yuanchu.mom.service.StandardTreeService;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/standardTree")
@Api(tags="标准库")
public class StandardTreeController {
    private StandardTreeService standardTreeService;
@@ -103,6 +109,20 @@
        return Result.success(standardProductListService.selectStandardProductListByMethodId(id, tree, page));
    }
    @ApiOperation(value = "批量编辑查询检验项目")
    @PostMapping("/selectStandardProductByMethodId")
    @ValueAuth
    public Result selectStandardProductByMethodId(Integer id, String tree, Integer page,String laboratory,String item,String items){
        return Result.success(standardProductListService.selectStandardProductByMethodId(id, tree, page, laboratory, item, items));
    }
    @ApiOperation(value = "批量编辑查询所有检验项目和检验子项枚举")
    @PostMapping("/selectStandardProductEnumByMethodId")
    @ValueAuth
    public Result selectStandardProductEnumByMethodId(Integer id, String tree){
        return Result.success(standardProductListService.selectStandardProductEnumByMethodId(id, tree));
    }
    @ApiOperation(value = "获取标准树下标准方法枚举")
    @GetMapping("/selectStandardMethodEnum")
    @ValueAuth
@@ -117,4 +137,14 @@
        return Result.success(standardTreeService.getStandardTree2());
    }
    @ValueClassify("标准库")
    @ApiOperation(value = "批量修改项目内容")
    @PostMapping("/upStandardProducts")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "standardProductList",dataTypeClass = StandardProductList.class),
            @ApiImplicitParam(name = "ids",dataTypeClass = Integer.class)
    })
    public Result upStandardProducts(@RequestBody Map<String, Object> product){
        return Result.success(standardTreeService.upStandardProducts(product));
    }
}
inspect-server/src/main/java/com/yuanchu/mom/controller/WarehouseController.java
@@ -16,7 +16,7 @@
@RequestMapping("/warehouse")
@RestController
@AllArgsConstructor
@Api("样品仓库")
@Api(tags = "样品管理")
public class WarehouseController {
    private WarehouseService warehouseService;
inspect-server/src/main/java/com/yuanchu/mom/mapper/StandardProductListMapper.java
@@ -1,5 +1,6 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanchu.mom.pojo.StandardProductList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -11,6 +12,8 @@
*/
public interface StandardProductListMapper extends BaseMapper<StandardProductList> {
    IPage<StandardProductList> standardProductListIPage(Integer id, String tree, IPage<StandardProductList> iPage, String laboratory, String item, String items);
}
inspect-server/src/main/java/com/yuanchu/mom/pojo/InsUnPass.java
@@ -61,7 +61,7 @@
    /**
     * ç”¨æˆ·å
     */
    @ValueTableShow(value = 9, name = "用户名")
    @ValueTableShow(value = 9, name = "检验人")
    private String name;
    @TableField(fill = FieldFill.INSERT)
inspect-server/src/main/java/com/yuanchu/mom/pojo/StandardProductList.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -18,8 +20,9 @@
    /**
     * ä¸»é”®id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;
    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    /**
     * æ£€éªŒé¡¹
@@ -177,4 +180,6 @@
    private String dic;
    private String tree;
    private Integer structureItemParameterId;
}
inspect-server/src/main/java/com/yuanchu/mom/service/StandardProductListService.java
@@ -1,6 +1,7 @@
package com.yuanchu.mom.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.pojo.InsSample;
import com.yuanchu.mom.pojo.StandardProductList;
@@ -23,4 +24,8 @@
    Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page);
    IPage<StandardProductList> selectStandardProductByMethodId(Integer id, String tree, Integer page, String laboratory, String item, String items);
    Map<String, List<?>> selectStandardProductEnumByMethodId(Integer id, String tree);
}
inspect-server/src/main/java/com/yuanchu/mom/service/StandardTreeService.java
@@ -6,6 +6,7 @@
import com.yuanchu.mom.pojo.StandardTree;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
@@ -24,4 +25,6 @@
    List<SampleTypeDto> getStandardTree2();
    int upStandardProducts(Map<String, Object> product);
}
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -410,8 +410,6 @@
                                    delRSet.add(jo1.get("r") + "");
                                }
                            }
                        } else {
                            if ("参数".equals(v.get("v"))) delSet.add(jo1.get("c") + "");
                        }
                    }
                    for (int i = 0; i < temp.size(); i++) {
@@ -504,7 +502,6 @@
                        }
                        Style style = new Style();
                        style.setFontFamily(v.get("ff") == null ? "微软雅黑" : v.get("ff") + "");
//                        style.setFontSize(v.get("fs")==null?14:Integer.parseInt(v.get("fs")+""));
                        if (!((v.get("fc") + "").indexOf("rgb") > -1)) {
                            style.setColor(v.get("fc") == null ? "000000" : (v.get("fc") + "").replace("#", ""));
                        } else {
@@ -512,13 +509,10 @@
                        }
                        textRenderData.setStyle(style);
                        text.add(textRenderData);
                        if (i == temp.size() - 1) {
                            TextRenderData[] text2 = text.toArray(new TextRenderData[0]);
                            rowRenderData = Rows.of(text2).rowAtleastHeight(1).center().create();
                            rows.add(rowRenderData);
                            text = new ArrayList<>();
                        }
                    }
                    TextRenderData[] text2 = text.toArray(new TextRenderData[0]);
                    rowRenderData = Rows.of(text2).rowAtleastHeight(1).center().create();
                    rows.add(rowRenderData);
                    TableRenderData tableRenderData = new TableRenderData();
                    tableRenderData.setRows(rows);
                    TableStyle tableStyle = new TableStyle();
@@ -594,6 +588,9 @@
            }catch (Exception e){
                throw new ErrorException("找不到检验人的签名");
            }
            if(signatureUrl == null || "".equals(signatureUrl)){
                throw new ErrorException("找不到检验人的签名");
            }
            XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
                    new HashMap<String, Object>() {{
                        put("order", insOrder);
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -12,6 +12,7 @@
import com.yuanchu.mom.dto.SampleOrderDto;
import com.yuanchu.mom.dto.SampleProductDto;
import com.yuanchu.mom.dto.SampleProductDto2;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.*;
import com.yuanchu.mom.pojo.*;
import com.yuanchu.mom.service.InsOrderService;
@@ -81,7 +82,11 @@
        for (InsProduct insProduct : insProducts) {
            InsOrderState insOrderState = new InsOrderState();
            insOrderState.setInsOrderId(orderId);
            insOrderState.setLaboratory(insProduct.getSonLaboratory());
            try {
                insOrderState.setLaboratory(insProduct.getSonLaboratory());
            }catch (NullPointerException e){
                throw new ErrorException("该检验单有未维护实验室的检验项目");
            }
            insOrderState.setInsState(0);
            insOrderStateMapper.insert(insOrderState);
        }
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
@@ -171,8 +171,9 @@
            String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory();
            sealUrl = insReportMapper.getLaboratoryByName(laboratory);
        }catch (Exception e){
            throw new ErrorException("找不到报告章印");
            throw new ErrorException("找不到报告专用章");
        }
        if(sealUrl==null) throw new ErrorException("找不到报告专用章");
        //系统生成报告地址
        String url = insReport.getUrl();
        //手动上传报告地址
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -2,7 +2,10 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.mapper.StandardProductListMapper;
@@ -52,6 +55,9 @@
    public List<StandardProductList> selectStandardProductList(InsSample insSample) {
        String[] models = insSample.getModel().split("-(?=[^-]*$)");//拆分最后一个【-】
        List<StandardProductList> list = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, insSample.getStandardMethodListId()).eq(StandardProductList::getState, 1).eq(StandardProductList::getModel, models[0]));
        if (list.size() == 0) {
            list = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, insSample.getStandardMethodListId()).eq(StandardProductList::getState, 1));
        }
        list = list.stream().filter(a -> {
            try {
                if (a.getSection() != null && !Objects.equals(a.getSection(), "")) {
@@ -61,7 +67,7 @@
                    List<String> manHours = JSON.parseArray(a.getManHour(), String.class);
                    List<String> prices = JSON.parseArray(a.getPrice(), String.class);
                    boolean isIf = false;
                    for (int i = 0;i<sections.size();i++){
                    for (int i = 0; i < sections.size(); i++) {
                        if (sections.get(i).contains("&")) {
                            String[] split = sections.get(i).split("&");
                            isIf = new BigDecimal(models[1]).compareTo(new BigDecimal(split[0])) > -1 && new BigDecimal(models[1]).compareTo(new BigDecimal(split[1])) < 1;
@@ -81,7 +87,7 @@
                            String param = sections.get(i).replace("=", "");
                            isIf = new BigDecimal(models[1]).compareTo(new BigDecimal(param)) == 0;
                        }
                        if(isIf) {
                        if (isIf) {
                            a.setSection(sections.get(i));
                            a.setAsk(asks.get(i));
                            a.setTell(tells.get(i));
@@ -106,14 +112,29 @@
        List<StandardProductList> list = new ArrayList<>();
        if (trees.length == 3) {
            List<StandardTree> treeList = standardTreeMapper.selectList(Wrappers.<StandardTree>lambdaQuery().eq(StandardTree::getLaboratory, trees[1]).eq(StandardTree::getSampleType, trees[2]));
            if (treeList.size() == 0) {
                StandardTree standardTree = new StandardTree();
                standardTree.setFactory(trees[0]);
                standardTree.setLaboratory(trees[1]);
                standardTree.setSampleType(trees[2]);
                treeList.add(standardTree);
            }
            for (StandardTree standardTree : treeList) {
                String str = tree+" - "+standardTree.getSample()+" - "+standardTree.getModel();
                String str = tree + " - " + standardTree.getSample() + " - " + standardTree.getModel();
                list.addAll(standardTreeMapper.selectStandardProductListByTree3("\"" + trees[2] + "\"", standardTree.getSample(), standardTree.getModel(), str));
            }
        } else if (trees.length == 4){
        } else if (trees.length == 4) {
            List<StandardTree> treeList = standardTreeMapper.selectList(Wrappers.<StandardTree>lambdaQuery().eq(StandardTree::getLaboratory, trees[1]).eq(StandardTree::getSampleType, trees[2]).eq(StandardTree::getSample, trees[3]));
            if (treeList.size() == 0) {
                StandardTree standardTree = new StandardTree();
                standardTree.setFactory(trees[0]);
                standardTree.setLaboratory(trees[1]);
                standardTree.setSampleType(trees[2]);
                standardTree.setSample(trees[2]);
                treeList.add(standardTree);
            }
            for (StandardTree standardTree : treeList) {
                String str = tree+" - "+standardTree.getModel();
                String str = tree + " - " + standardTree.getModel();
                list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", standardTree.getSample(), standardTree.getModel(), str));
                list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", standardTree.getSample(), standardTree.getModel(), str));
            }
@@ -121,42 +142,53 @@
            list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", trees[3], trees[4], tree));
            list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", trees[3], trees[4], tree));
        }
        for (StandardProductList productList : list) {
            productList.setId(IdWorker.getId());
        }
        List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, id).like(StandardProductList::getTree, tree));
        for (StandardProductList sp : standardProductLists) {
            for (StandardProductList pl : list) {
                if (Objects.equals(sp.getInspectionItem(), pl.getInspectionItem())
                        && Objects.equals(sp.getInspectionItemSubclass(), pl.getInspectionItemSubclass())
                        && Objects.equals(sp.getModel(), pl.getModel())) {
                        && Objects.equals(sp.getInspectionItemSubclass() == null ? "" : sp.getInspectionItemSubclass(), pl.getInspectionItemSubclass() == null ? "" : pl.getInspectionItemSubclass())
                        && Objects.equals(sp.getModel(), pl.getModel())
                        && Objects.equals(sp.getStructureItemParameterId(), pl.getStructureItemParameterId())) {
                    pl.setId(sp.getId());
                    pl.setState(id==0?1:sp.getState());
                    if (sp.getState() != null && !sp.getState().equals("")) {
                        pl.setState(sp.getState());
                    } else {
                        pl.setState(id == 0 ? 1 : 0);
                    }
                    pl.setMethodS(sp.getMethodS());
                    if(sp.getAsk()!=null&&!sp.getAsk().equals("")){
                    if (sp.getAsk() != null && !sp.getAsk().equals("")) {
                        pl.setAsk(sp.getAsk());
                    }
                    if(sp.getTell()!=null&&!sp.getTell().equals("")){
                    if (sp.getTell() != null && !sp.getTell().equals("")) {
                        pl.setTell(sp.getTell());
                    }
                    if(sp.getPrice()!=null&&!sp.getPrice().equals("")){
                    if (sp.getPrice() != null && !sp.getPrice().equals("")) {
                        pl.setPrice(sp.getPrice());
                    }
                    if(sp.getManHour()!=null&&!sp.getManHour().equals("")){
                    if (sp.getManHour() != null && !sp.getManHour().equals("")) {
                        pl.setManHour(sp.getManHour());
                    }
                    if(sp.getSection()!=null&&!sp.getSection().equals("")){
                    if (sp.getSection() != null && !sp.getSection().equals("")) {
                        pl.setSection(sp.getSection());
                    }
                    if(sp.getTemplateId()!=null&&!sp.getTemplateId().equals("")){
                    if (sp.getTemplateId() != null && !sp.getTemplateId().equals("")) {
                        pl.setTemplateId(sp.getTemplateId());
                    }
                    if(sp.getTree() != null && !sp.getTree().equals("")){
                        pl.setTree(sp.getTree());
                    }
                    break;
                }
            }
        }
        if(page == 1){
        if (page == 1) {
            Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
            CompletableFuture.supplyAsync(() -> {
                standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id).like(StandardProductList::getTree, tree));
                standardProductListService2.saveBatch(list.stream().map(a->{
                standardProductListService2.saveBatch(list.stream().map(a -> {
                    a.setFactory(trees[0]);
                    a.setLaboratory(trees[1]);
                    a.setSampleType(trees[2]);
@@ -174,13 +206,37 @@
        }
        Map<String, Object> map = new HashMap<>();
        try {
            map.put("productList", list.subList((page - 1)*50, page * 50));
        }catch (IndexOutOfBoundsException e){
            map.put("productList", list.subList((page - 1)*50, list.size()));
            map.put("productList", list.subList((page - 1) * 50, page * 50));
        } catch (IndexOutOfBoundsException e) {
            map.put("productList", list.subList((page - 1) * 50, list.size()));
        }
        map.put("total", list.size());
        return map;
    }
    @Override
    public IPage<StandardProductList> selectStandardProductByMethodId(Integer id, String tree, Integer page, String laboratory, String item, String items) {
        IPage<StandardProductList> iPage = new Page<>();
        iPage.setSize(100);
        iPage.setCurrent(page);
        return standardProductListMapper.standardProductListIPage(id, tree, iPage, laboratory, item, items);
    }
    @Override
    public Map<String, List<?>> selectStandardProductEnumByMethodId(Integer id, String tree) {
        HashMap<String, List<?>> map = new HashMap<>();
        map.put("item", standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery()
                .eq(StandardProductList::getStandardMethodListId, id)
                .like(StandardProductList::getTree, tree)
                .select(StandardProductList::getInspectionItem)
                .groupBy(StandardProductList::getInspectionItem)));
        map.put("items", standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery()
                .eq(StandardProductList::getStandardMethodListId, id)
                .like(StandardProductList::getTree, tree)
                .select(StandardProductList::getInspectionItemSubclass)
                .groupBy(StandardProductList::getInspectionItemSubclass)));
        return map;
    }
}
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardTreeServiceImpl.java
@@ -19,6 +19,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * @author Administrator
@@ -109,6 +110,14 @@
        return standardTreeMapper.getStandardTree2();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int upStandardProducts(Map<String, Object> product) {
        List<Integer> ids = JSON.parseArray(JSON.toJSONString(product.get("ids")));
        StandardProductList productList = JSON.parseObject(JSON.toJSONString(product.get("standardProductList")), StandardProductList.class);
        standardProductListMapper.update(productList, Wrappers.<StandardProductList>lambdaUpdate().in(StandardProductList::getId, ids));
        return 1;
    }
}
inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -159,6 +159,7 @@
        inspection_item from (select *,GROUP_CONCAT(inspection_item
        SEPARATOR ',') inspection_item2  from ins_product where state = 1 GROUP BY ins_sample_id,man_hour_group) b GROUP
        BY b.ins_sample_id) c ON c.ins_sample_id = isa.id
        where (i.state = 1 or i.state = 3 or i.state = 4)
        ) a
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
inspect-server/src/main/resources/mapper/StandardProductListMapper.xml
@@ -16,10 +16,8 @@
            <result property="manHourGroup" column="man_hour_group" jdbcType="VARCHAR"/>
            <result property="inspectionItemType" column="inspection_item_type" jdbcType="VARCHAR"/>
            <result property="inspectionValueType" column="inspection_value_type" jdbcType="VARCHAR"/>
            <result property="deviceGroup" column="device_group" jdbcType="VARCHAR"/>
            <result property="checkoutNumber" column="checkout_number" jdbcType="INTEGER"/>
            <result property="section" column="section" jdbcType="VARCHAR"/>
            <result property="valueType" column="value_type" jdbcType="VARCHAR"/>
            <result property="method" column="method" jdbcType="VARCHAR"/>
            <result property="manDay" column="man_day" jdbcType="INTEGER"/>
            <result property="bsm" column="bsm" jdbcType="VARCHAR"/>
@@ -31,14 +29,18 @@
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,inspection_item,inspection_item_classify,
        inspection_item_subclass,laboratory,unit,
        price,man_hour,man_hour_group,
        inspection_item_type,inspection_value_type,device_group,
        checkout_number,section,value_type,
        method,man_day,bsm,
        ask,standard_method_list_id,create_user,
        update_user,create_time,update_time
    </sql>
    <select id="standardProductListIPage" resultType="com.yuanchu.mom.pojo.StandardProductList">
        select * from `center-lims`.standard_product_list
        where standard_method_list_id = #{id}
        and tree like concat('%',#{tree},'%')
        <if test="laboratory != ''">
            and son_laboratory = #{laboratory}
        </if>
        <if test="item != ''">
            and inspection_item = #{item}
        </if>
        <if test="items != ''">
            and inspection_item_subclass = #{items}
        </if>
    </select>
</mapper>
inspect-server/src/main/resources/mapper/StandardTemplateMapper.xml
@@ -17,7 +17,7 @@
    <select id="selectStandardTemplatePageList" resultType="com.yuanchu.mom.pojo.StandardTemplate">
        select * from (
        select st.id, st.name, remark, thing, u2.name create_user_name, u3.name update_user_name, st.create_time, st.update_time
        select st.id, st.name, remark, u2.name create_user_name, u3.name update_user_name, st.create_time, st.update_time
        from standard_template st
        left join user u2 on u2.id = st.create_user
        left join user u3 on u3.id = st.update_user
inspect-server/src/main/resources/mapper/StandardTreeMapper.xml
@@ -157,7 +157,8 @@
               0 state,
               #{model} model,
               #{sample} sample,
               #{trees} tree
               #{trees} tree,
               id structure_item_parameter_id
        from structure_item_parameter
        where (
                      sample is NULL
@@ -193,7 +194,8 @@
               0 state,
               #{model} model,
               #{sample} sample,
               #{trees} tree
               #{trees} tree,
               id structure_item_parameter_id
        from structure_item_parameter
        where sample LIKE CONCAT('%[', #{tree}, ']%')
    </select>
@@ -233,7 +235,8 @@
               0 state,
               #{model} model,
               #{sample} sample,
               #{trees} tree
               #{trees} tree,
               id structure_item_parameter_id
        from structure_item_parameter
        where (
                      sample is NULL
inspect-server/src/main/resources/static/report-template.docx
Binary files differ
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -19,6 +19,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -100,7 +101,7 @@
        List<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYearPage(time, userName, laboratory);
        mapIPage.getRecords().forEach(i -> {
            String[] shiftTimes = i.getShiftTime().split(";");
            int totalAttendance = 0;
            double totalAttendance = 0;
            List<Map<String, Object>> map = new ArrayList<>();
            // åˆ†å‰²æ—¥æœŸ
            for (String shiftTime : shiftTimes) {
@@ -111,19 +112,29 @@
                        i.getMonthlyAttendance().put(enums.getLabel(), 0);
                    }
                    if (enums.getValue().equals(shiftTimeAndShift[1])) {
                        Integer num = (Integer) i.getMonthlyAttendance().get(enums.getLabel());
                        i.getMonthlyAttendance().put(enums.getLabel(), num += 1);
                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(enums.getLabel()).toString());
                        i.getMonthlyAttendance().put(enums.getLabel(), bigDecimal.add(new BigDecimal("1")));
                    }
                    // åŠï¼Œå¦å¤–半天算给早
                    if (shiftTimeAndShift[1].equals("5") && enums.getValue().equals("0")) {
                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(enums.getLabel()).toString());
                        i.getMonthlyAttendance().put(enums.getLabel(), bigDecimal.add(new BigDecimal("0.5")));
                    }
                }
                if (shiftTimeAndShift[1].equals("1") || shiftTimeAndShift[1].equals("2") || shiftTimeAndShift[1].equals("0")) {
                // æ—©ï¼Œä¸­ï¼Œå¤œï¼Œå·®
                if (shiftTimeAndShift[1].equals("1") || shiftTimeAndShift[1].equals("2") || shiftTimeAndShift[1].equals("0") || shiftTimeAndShift[1].equals("6")) {
                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
                }
                // åŠ
                if (shiftTimeAndShift[1].equals("5")) {
                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 0.5);
                }
                hashMap.put("id", shiftTimeAndShift[2]);
                hashMap.put("shift", shiftTimeAndShift[1]);
                hashMap.put("time", shiftTimeAndShift[0]);
                map.add(hashMap);
            }
            int totalYearAttendance = 0;
            double totalYearAttendance = 0;
            Map<String, Object> hashMap = new HashMap<>();
            for (Map<String, Object> record : mapYearIPage) {
                if (record.get("user_id").toString().equals(i.getUserId())) {
@@ -132,12 +143,21 @@
                            hashMap.put(enums.getLabel(), 0);
                        }
                        if (enums.getValue().equals(record.get("shift"))) {
                            Integer num = (Integer) hashMap.get(enums.getLabel());
                            hashMap.put(enums.getLabel(), num += 1);
                            BigDecimal num = new BigDecimal(hashMap.get(enums.getLabel()).toString());
                            hashMap.put(enums.getLabel(), num.add(new BigDecimal("1")));
                        }
                        // åŠï¼Œå¦å¤–半天算给早
                        if (record.get("shift").equals("5") && enums.getValue().equals("0")) {
                            BigDecimal bigDecimal = new BigDecimal(hashMap.get(enums.getLabel()).toString());
                            hashMap.put(enums.getLabel(), bigDecimal.add(new BigDecimal("0.5")));
                        }
                    }
                    if (record.get("shift").equals("1") || record.get("shift").equals("2") || record.get("shift").equals("0")) {
                    if (record.get("shift").equals("1") || record.get("shift").equals("2") || record.get("shift").equals("0") || record.get("shift").equals("6")) {
                        hashMap.put("totalAttendance", totalYearAttendance += 1);
                    }
                    // åŠ
                    if (record.get("shift").equals("5")) {
                        hashMap.put("totalAttendance", totalYearAttendance += 0.5);
                    }
                }
            }
@@ -187,11 +207,11 @@
        for (Map<String, Object> map : mapYearList) {
            Map<String, Object> resultMap = new LinkedHashMap<>();
            Map<String, Object> hashMapYear = new LinkedHashMap<>();
            int totalYearAttendance = 0;
            double totalYearAttendance = 0;
            // ä¸€å¹´12个月
            for (int i = 1; i < 13; i++) {
                Map<String, Object> hashMapMonth = new LinkedHashMap<>();
                int totalMonthAttendance = 0;
                double totalMonthAttendance = 0;
                for (Enums enums : shiftType) {
                    if (!hashMapYear.containsKey(enums.getLabel())) {
                        hashMapYear.put(enums.getLabel(), 0);
@@ -202,9 +222,17 @@
                        int count = countOccurrences(charArray, i + ":" + enums.getValue());
                        hashMapMonth.put(enums.getLabel(), count);
                        hashMapYear.put(enums.getLabel(), Integer.parseInt(hashMapYear.get(enums.getLabel()).toString()) + count );
                        if (enums.getValue().equals("0") || enums.getValue().equals("1") || enums.getValue().equals("2")) {
                        if (enums.getValue().equals("0") || enums.getValue().equals("1") || enums.getValue().equals("2") || enums.getValue().equals("6")) {
                            totalMonthAttendance += count;
                            totalYearAttendance += count;
                        }
                        // åŠï¼Œå¦å¤–半天算给早
                        if (enums.getValue().equals("5")) {
                            BigDecimal multiply = new BigDecimal("0.5").multiply(new BigDecimal(count)).setScale(1, BigDecimal.ROUND_CEILING);
                            hashMapMonth.put(shiftType.get(0).getLabel(), new BigDecimal(hashMapMonth.get(shiftType.get(0).getLabel()).toString()).add(multiply));
                            hashMapYear.put(shiftType.get(0).getLabel(), new BigDecimal(hashMapYear.get(shiftType.get(0).getLabel()).toString()).add(multiply));
                            totalMonthAttendance += multiply.doubleValue();
                            totalYearAttendance += multiply.doubleValue();
                        }
                    }
                    // ç©ºæ•°æ®
@@ -245,14 +273,18 @@
            Map<String, Object> year = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("year")), Map.class);
            excelRowList.add(year.get("totalYearAttendance"));
            enums.forEach(j -> {
                excelRowList.add(year.get(j.getLabel()));
                if (!j.getValue().equals("5")) {
                    excelRowList.add(year.get(j.getLabel()));
                }
            });
            Map<String, Map<String, Object>> month = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("month")), Map.class);
            for (int j = 1; j < 13; j++) {
                Object totalMonthAttendance = month.get(j + "").get("totalMonthAttendance");
                excelRowList.add(totalMonthAttendance);
                for (Enums anEnum : enums) {
                    excelRowList.add(month.get(j + "").get(anEnum.getLabel()));
                    if (!anEnum.getValue().equals("5")) {
                        excelRowList.add(month.get(j + "").get(anEnum.getLabel()));
                    }
                }
            }
            data.add(excelRowList);
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
@@ -26,6 +26,7 @@
            </if>
        </where>
        GROUP BY u.id
        order by s.create_time
    </select>
    <select id="performanceShiftYearPage" resultType="map">
@@ -43,6 +44,7 @@
        </if>
        <if test="laboratory != null and laboratory != ''">
        </if>
        order by s.create_time
    </select>
    <select id="performanceShiftYear" resultType="java.util.Map">
@@ -63,7 +65,7 @@
        <if test="laboratory != null and laboratory != ''">
        </if>
        GROUP BY u.id
        order by s.work_time
        order by s.create_time
    </select>
    <select id="performanceShiftYearList" resultType="map">
@@ -84,7 +86,7 @@
        <if test="laboratory != null and laboratory != ''">
        </if>
        GROUP BY u.id
        order by s.work_time
        order by s.create_time
    </select>
    <select id="performanceShiftList" resultMap="performanceShiftPageMap">
@@ -104,5 +106,6 @@
            </if>
        </where>
        GROUP BY u.id
        order by s.create_time
    </select>
</mapper>
system-run/src/main/resources/application-dev.yml
@@ -37,9 +37,8 @@
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
    #url: jdbc:mysql://localhost:3306/center_lims?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
#    url: jdbc:mysql://114.132.189.42:9004/center-lims?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
    url: jdbc:mysql://localhost:3306/center-lims?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
#    url: jdbc:mysql://114.132.189.42:9004/center-lims?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
    username: root
    password: 123456
    druid:
system-run/src/main/resources/application-prod.yml
@@ -54,26 +54,24 @@
      filters: stat,wall,log4j # é…ç½®ç›‘控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      useGlobalDataSourceStat: true #合并多个DruidDatasource的监控数据
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500; #通过connectProperties属性来打开mergesql功能罗慢sQL记录
redis:
  # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突
  database: 0
  # redis服务器地址(默认为loaclhost)
  host: 127.0.0.1
  # redis端口(默认为6379)
  port: 6379
  # redis访问密码(默认为空)
  password: root2022
  # redis连接超时时间(单位毫秒)
  timeout: 20
  # redis连接池配置
  pool:
    # æœ€å¤§å¯ç”¨è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º8,负数表示无限)
    max-active: 8
    # æœ€å¤§ç©ºé—²è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º8,负数表示无限)
    max-idle: 8
    # æœ€å°ç©ºé—²è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º0,该值只有为正数才有用)
    min-idle: 0
    # ä»Žè¿žæŽ¥æ± ä¸­èŽ·å–è¿žæŽ¥æœ€å¤§ç­‰å¾…æ—¶é—´ï¼ˆé»˜è®¤ä¸º-1,单位为毫秒,负数表示无限)
    max-wait: -1
  redis:
    # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突
    database: 0
    # redis服务器地址(默认为loaclhost)
    host: 127.0.0.1
    # redis端口(默认为6379)
    port: 6379
    # redis访问密码(默认为空)
    password: root2022
    # redis连接超时时间(单位毫秒)
    timeout: 20
    # redis连接池配置
    pool:
      # æœ€å¤§å¯ç”¨è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º8,负数表示无限)
      max-active: 8
      # æœ€å¤§ç©ºé—²è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º8,负数表示无限)
      max-idle: 8
      # æœ€å°ç©ºé—²è¿žæŽ¥æ•°ï¼ˆé»˜è®¤ä¸º0,该值只有为正数才有用)
      min-idle: 0
      # ä»Žè¿žæŽ¥æ± ä¸­èŽ·å–è¿žæŽ¥æœ€å¤§ç­‰å¾…æ—¶é—´ï¼ˆé»˜è®¤ä¸º-1,单位为毫秒,负数表示无限)
      max-wait: -1
system-run/src/test/java/com/yuanchu/mom/SystemRunApplicationTest.java
@@ -1,42 +1,14 @@
package com.yuanchu.mom;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.yuanchu.mom.service.PerformanceShiftService;
import com.yuanchu.mom.utils.StyleYearUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@SpringBootTest
class SystemRunApplicationTest {
    @Autowired
    private PerformanceShiftService performanceShiftService;
    private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx";
    @Test
    void  contextLoads() throws Exception {
        Map<Object, Object> data = performanceShiftService.exportToYearExcel("2024-05-01 00:00:00", null, null);
        // è®¾ç½®å•元格样式
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.getContentStyle());
        EasyExcel.write(fileName)
                .head((List<List<String>>) data.get("header"))
                .registerWriteHandler(horizontalCellStyleStrategy)
                .sheet("月度")
                .doWrite((Collection<?>) data.get("data"));
//        String url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?corpid=wwa423654b975441ac&corpsecret=J3fbMJoTn3LmrWDobvS5JpU8N0TvEbGkVl8OhvIsol0";
//        String s = HttpUtil.get(url);
//        System.out.println(s);
//        Map<String, Object> unmarshal = JSONObject.parseObject(s, Map.class);
//        String checkInRecords = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=" + unmarshal.get("access_token");
//        String body = HttpRequest.post(checkInRecords).execute().body();
//        System.out.println(body);
    }
}
user-server/src/main/java/com/yuanchu/mom/controller/CompaniesController.java
@@ -1,37 +1,48 @@
package com.yuanchu.mom.controller;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.pojo.AuthApi;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.dto.PersonDto;
import com.yuanchu.mom.pojo.Company;
import com.yuanchu.mom.service.UserService;
import com.yuanchu.mom.util.HeaderToken;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/companies")
@Api("组织模块")
@Api(tags="用户模块")
public class CompaniesController {
    @Autowired
    private HeaderToken headerToken;
    @ValueAuth
    @ApiOperation(value = "获取组织列表")
    private UserService userService;
    @ValueClassify("用户管理")
    @ApiOperation(value = "获取人事系统组织架构")
    @GetMapping(value = "/selectCompaniesList")
    public Result<List<Company>> selectcompaniesList(){
    public Result<List<Company>> selectCompaniesList() {
        return Result.success(headerToken.companyUrl());
    }
    @ValueAuth
    @ApiOperation("获取人事系统组织下的人员")
    @PostMapping(value = "/selectSimpleList")
    public Result<?> selectSimpleList(String companyId) {
        return Result.success(headerToken.userUrl(companyId));
    }
    @ValueAuth
    @ApiOperation("将人事系统勾选的内容转移到本系统")
    @PostMapping(value = "/addPersonUser")
    public Result<?> addPersonUser(@RequestBody PersonDto personDto) {
        return Result.success(userService.addPersonUser(personDto));
    }
}
user-server/src/main/java/com/yuanchu/mom/controller/PostController.java
ÎļþÒÑɾ³ý
user-server/src/main/java/com/yuanchu/mom/controller/SimpleController.java
ÎļþÒÑɾ³ý
user-server/src/main/java/com/yuanchu/mom/controller/UserController.java
@@ -98,6 +98,16 @@
        UserPageDto user = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), UserPageDto.class);
        return Result.success(userService.selectUserList(page, user));
    }
    @ValueClassify("人员总览")
    @ApiOperation(value = "人员总览")
    @PostMapping("/selectPersonnelOverview")
    public Result selectPersonnelOverview(@RequestBody Map<String, Object> data) throws Exception {
        Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class);
        UserPageDto user = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), UserPageDto.class);
        return Result.success(userService.selectPersonnelOverview(page, user));
    }
    @ValueClassify("用户管理")
    @ApiOperation(value = "修改用户信息")
    @PostMapping("/updateUser")
@@ -171,4 +181,19 @@
    public Result<?> upUserPassword(String oldPassword, String newPassWord){
        return Result.success(userService.upUserPassword(oldPassword, newPassWord));
    }
    @ValueClassify("人员明细")
    @PostMapping("/upUserDepardLimsId")
    @ApiOperation(value = "修改人员明细所在组织架构")
    public Result<?> upUserDepardLimsId(String ids, String id){
        return Result.success(userService.upUserDepardLimsId(ids, id));
    }
    @ValueClassify("人员明细")
    @PostMapping("/delUserDepardLimsId")
    @ApiOperation(value = "删除人员明细所在组织架构")
    public Result<?> delUserDepardLimsId(Integer id){
        return Result.success(userService.delUserDepardLimsId(id));
    }
}
user-server/src/main/java/com/yuanchu/mom/dto/Custom.java
@@ -24,7 +24,7 @@
    @TableId(type = IdType.AUTO)
    private Integer id;
    @ValueTableShow(2)
    @ValueTableShow(value = 2)
    @ApiModelProperty(value = "客户账号")
    private String account;
user-server/src/main/java/com/yuanchu/mom/dto/PersonDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.yuanchu.mom.dto;
import com.yuanchu.mom.pojo.Company;
import com.yuanchu.mom.pojo.Person;
import lombok.Data;
import java.util.List;
@Data
public class PersonDto {
    private List<Person> person;
    private List<Company> company;
}
user-server/src/main/java/com/yuanchu/mom/dto/UserPageDto.java
@@ -12,15 +12,13 @@
@NoArgsConstructor
public class UserPageDto extends User {
    @ValueTableShow(10)
    @ApiModelProperty(value = "创建用户")
    private String createUserName;
    @ValueTableShow(11)
    @ApiModelProperty(value = "更新用户")
    private String updateUserName;
    @ValueTableShow(1)
    @ValueTableShow(3)
    @ApiModelProperty(value = "角色")
    private String roleName;
user-server/src/main/java/com/yuanchu/mom/mapper/DepartmentsMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuanchu.mom.pojo.Departments;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface DepartmentsMapper extends BaseMapper<Departments> {
}
user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java
@@ -16,6 +16,8 @@
    IPage<User> selectUserDtoPageList(IPage<UserPageDto> page, QueryWrapper<UserPageDto> ew);
    IPage<User> selectPersonnelOverview(IPage<UserPageDto> page, QueryWrapper<UserPageDto> ew);
    //获取设备负责人
    List<User> getDeviceManager();
user-server/src/main/java/com/yuanchu/mom/pojo/AuthApi.java
@@ -2,10 +2,43 @@
public class AuthApi {
    public static String companies = "https://ztt-sso.asuncloud.net/api/org/v1/companies";
    /**
     * æµ‹è¯•地址
     * */
//    private String code = "https://ztt-sso.asuncloud.net/oauth2/token";
    /**
     * æ­£å¼åœ°å€
     * */
    public static String code = "https://ztt-sso.chinaztt.cn/oauth2/token";
    public static String post="https://ztt-sso.asuncloud.net/api/org/v1/post?companyId=";
    /**
     * æ²³å£äººäº‹æµ‹è¯•库
     * */
//    private String appId = "8b2f2c7e-2ab9-4718-8193-c0c636dceba8";
//    private String appSecret = "db59b70d28ab1865aafe4008f59d4760";
    /**
     * æ²³å£äººäº‹æ­£å¼åº“
     * */
    public static String appId = "f6f3d70f-3666-4d3d-b9c5-430de3f6007c";
    public static String appSecret = "a18923496542302066b0a7bec993a4e2";
/**
 * è£…备人事测试库
 * */
//    private String appId = "0acf9b63-31e3-45c4-99c1-af1aac88b985";
//    private String appSecret = "7fb7a4026c71619345c31fa12ba31f4f";
    /**
     * è£…备人事正式库
     * */
//    private String appId = "6f5f6a0c-2a01-4ef6-9e75-c8a6f0c2f044";
//    private String appSecret = "89b9c4735b1e5ee9d6a8544b9b38bb03";
    public static String simple="https://ztt-sso.asuncloud.net/api/org/v1/employees/simple?companyId=";
    public static String companies = "https://ztt-connector.chinaztt.cn/api/org/v1/companies";
    public static String simple="https://ztt-connector.chinaztt.cn/api/org/v1/employees/simple?companyId=";
    /**
     * äººå‘˜å¯†ç èŽ·å–
     * */
    public static String password = "https://ztt-connector.chinaztt.cn/api/org/v1/employees/original_pwd/";
}
user-server/src/main/java/com/yuanchu/mom/pojo/Departments.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
package com.yuanchu.mom.pojo;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
 * éƒ¨é—¨æ˜Žç»†
 * </p>
 *
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
 * @since 2024-04-15 04:01:48
 */
@Data
@ApiModel(value = "Department对象", description = "部门明细")
@TableName("department")
public class Departments implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("父级id")
    private Integer fatherId;
    @TableField(fill = FieldFill.INSERT)
    private Integer createUser;
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateUser;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    private String companyId;
}
user-server/src/main/java/com/yuanchu/mom/pojo/Person.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.yuanchu.mom.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class Person {
    private String name;
    //人员编号,全局唯一
    private String employeeID;
//岗位
    private String position;
//岗位编码
    private String positionCode;
//手机号码
    private String phoneNumber;
    //性别 1:男 2:女
    private Integer gender;
    //组织状态 enable:在职 disabled:离职
    private String status;
//所属组织编码
    private String companyId;
//公司邮箱(可用于邮箱系统)
    private String companyEmail;
//入职公司时间
    private String dateOfJoiningTheCompany;
//组织内的部门编码
    private String departmentCode;
    @ApiModelProperty(">1:存在 =0:不存在")
    private Long isLive;
}
user-server/src/main/java/com/yuanchu/mom/pojo/User.java
@@ -24,18 +24,17 @@
    @TableId(type = IdType.AUTO)
    private Integer id;
    @ValueTableShow(1)
    @ValueTableShow(2)
    @ApiModelProperty(value = "账号")
    private String account;
    @ApiModelProperty(value = "密码")
    private String password;
    @ValueTableShow(2)
    @ValueTableShow(1)
    @ApiModelProperty(value = "姓名")
    private String name;
    @ValueTableShow(2)
    @ApiModelProperty(value = "姓名EN")
    private String nameEn;
@@ -43,11 +42,9 @@
    @ApiModelProperty(value = "状态")
    private Integer state;
    @ValueTableShow(4)
    @ApiModelProperty(value = "年龄")
    private Integer age;
    @ValueTableShow(5)
    @ApiModelProperty(value = "邮箱")
    private String email;
@@ -58,24 +55,20 @@
    @ApiModelProperty(value = "部门")
    private String department;
    @ValueTableShow(8)
    @ApiModelProperty(value = "单位")
    private String company;
    @ValueTableShow(14)
    @ApiModelProperty(value = "单位地址")
    private String address;
    @ApiModelProperty(value = "角色主键")
    private Integer roleId;
    @ValueTableShow(9)
    @ApiModelProperty(value = "创建日期")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @ValueTableShow(10)
    @ApiModelProperty(value = "更新日期")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -96,42 +89,20 @@
    /**
     * ç­¾åç…§ç‰‡åœ°å€
     */
    @ValueTableShow(value = 12,name = "签名照片地址")
    private String signatureUrl;
    /**
     * è‡ªèº«ç…§ç‰‡åœ°å€
     */
    @ValueTableShow(value = 13,name = "自身照片地址")
    private String pictureUrl;
    /**
     * ç»„织
     */
//    @ValueTableShow(value = 14,name = "组织")
    @ApiModelProperty(value = "关联的部门id")
    private String departId;
    ////人员编号,全局唯一
//    private String employeeID;
////岗位
//    private String position;
////岗位编码
//    private String positionCode;
////手机号码
//    private String phoneNumber;
//
//    //性别 1:男 2:女
//    private int gender;
//
//    //组织状态 enable:在职 disabled:离职
//    private String status;
////所属组织编码
//    private String companyId;
////公司邮箱(可用于邮箱系统)
//    private String companyEmail;
////入职公司时间
//    private String dateOfJoiningTheCompany;
////组织内的部门编码
//    private String departmentCode;
    @ApiModelProperty(value = "LIMS关联的部门id")
    private String departLimsId;
}
user-server/src/main/java/com/yuanchu/mom/service/UserService.java
@@ -1,10 +1,9 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.dto.PersonDto;
import com.yuanchu.mom.dto.UserPageDto;
import com.yuanchu.mom.pojo.User;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
@@ -18,6 +17,8 @@
    String selectNameById(Integer id);
    Map<String, Object> selectUserList(IPage<UserPageDto> page, UserPageDto user);
    Map<String, Object> selectPersonnelOverview(IPage<UserPageDto> page, UserPageDto user);
    int updateUser(User user);
@@ -34,4 +35,10 @@
    int upUserPassword(String oldPassword, String newPassWord);
    int addPersonUser(PersonDto personDto);
    int upUserDepardLimsId(String ids, String id);
    int delUserDepardLimsId(Integer id);
}
user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java
@@ -1,35 +1,32 @@
package com.yuanchu.mom.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.common.PrintChina;
import com.yuanchu.mom.dto.PersonDto;
import com.yuanchu.mom.dto.UserPageDto;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.DepartmentsMapper;
import com.yuanchu.mom.mapper.UserMapper;
import com.yuanchu.mom.pojo.Departments;
import com.yuanchu.mom.pojo.User;
import com.yuanchu.mom.service.UserService;
import com.yuanchu.mom.utils.Jwt;
import com.yuanchu.mom.util.HeaderToken;
import com.yuanchu.mom.utils.QueryWrappers;
import com.yuanchu.mom.vo.Result;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
@Service
public class UserServiceImp implements UserService {
@@ -37,11 +34,13 @@
    @Resource
    UserMapper userMapper;
    @Resource
    Jwt jwt;
    @Resource
    private GetLook getLook;
    @Resource
    private DepartmentsMapper departmentsMapper;
    @Resource
    private HeaderToken headerToken;
    @Override
    public User selectUserByPwd(String account, String password) {
@@ -69,14 +68,24 @@
    }
    @Override
    public Map<String, Object> selectPersonnelOverview(IPage<UserPageDto> page, UserPageDto user) {
        Map<String, Object> map = new HashMap<>();
        map.put("head", PrintChina.printChina(UserPageDto.class));
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectUserList");
        if (map1.get("look") == 1) user.setCreateUser(map1.get("userId"));
        map.put("body", userMapper.selectPersonnelOverview(page, QueryWrappers.queryWrappers(user)));
        return map;
    }
    @Override
    public int updateUser(User user) {
        user.setDepartId("1,"+user.getDepartId());
        user.setDepartId("1," + user.getDepartId());
        return userMapper.updateById(user);
    }
    @Override
    public int addUser(User user) {
        user.setDepartId("1,"+user.getDepartId());
        user.setDepartId("1");
        return userMapper.insert(user);
    }
@@ -114,4 +123,69 @@
        return userMapper.updateById(user);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int addPersonUser(PersonDto personDto) {
        AtomicReference<String> departId = new AtomicReference<>("");
        AtomicReference<String> companyName = new AtomicReference<>();
        personDto.getCompany().forEach(company -> {
            Departments department = departmentsMapper.selectOne(Wrappers.<Departments>lambdaQuery().eq(Departments::getCompanyId, company.getCompanyId()));
            if (BeanUtil.isEmpty(department)) {
                department = new Departments();
                department.setName(company.getCompanyName());
                department.setCompanyId(company.getCompanyId());
                Departments department2 = departmentsMapper.selectOne(Wrappers.<Departments>lambdaQuery().eq(Departments::getCompanyId, company.getParentCompanyId()));
                if (BeanUtil.isEmpty(department2)) {
                    department.setFatherId(1);
                } else {
                    department.setFatherId(department2.getId());
                }
                departmentsMapper.insert(department);
            }
            departId.set(departId.get() + department.getId() + ",");
            companyName.set(department.getName());
        });
        personDto.getPerson().forEach(person -> {
            User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getAccount, person.getEmployeeID()));
            if (BeanUtil.isEmpty(user)) {
                user = new User();
                user.setName(person.getName());
                user.setNameEn("not write");
                user.setAccount(person.getEmployeeID());
                user.setPhone(person.getPhoneNumber());
                user.setEmail(person.getCompanyEmail());
                user.setIsCustom(person.getCompanyId().equals("SC2463") ? 0 : 1);
                user.setDepartId(departId.get());
//                user.setPassword(DigestUtils.md5DigestAsHex(headerToken.getPassword(person.getEmployeeID()).getBytes()));
                user.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
                user.setCompany(companyName.get());
                user.setAddress("未填写");
                userMapper.insert(user);
            } else {
                user.setName(person.getName());
                user.setPhone(person.getPhoneNumber());
                user.setEmail(person.getCompanyEmail());
                user.setIsCustom(person.getCompanyId().equals("SC2463") ? 0 : 1);
                user.setDepartId(departId.get());
                user.setCompany(companyName.get());
                user.setCreateUser(null);
                user.setCreateTime(null);
                user.setUpdateUser(null);
                user.setUpdateTime(null);
                userMapper.updateById(user);
            }
        });
        return 1;
    }
    @Override
    public int upUserDepardLimsId(String ids, String id) {
        List<Integer> userIds = JSON.parseArray(ids, Integer.class);
        return userMapper.update(null, Wrappers.<User>lambdaUpdate().in(User::getId, userIds).set(User::getDepartLimsId, id).set(User::getUpdateTime, LocalDateTime.now()).set(User::getUpdateUser, getLook.selectPowerByMethodAndUserId(null).get("userId")));
    }
    @Override
    public int delUserDepardLimsId(Integer id) {
        return userMapper.update(null, Wrappers.<User>lambdaUpdate().eq(User::getId, id).set(User::getDepartLimsId, null).set(User::getUpdateTime, LocalDateTime.now()).set(User::getUpdateUser, getLook.selectPowerByMethodAndUserId(null).get("userId")));
    }
}
user-server/src/main/java/com/yuanchu/mom/util/HeaderToken.java
@@ -2,23 +2,25 @@
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.log.Log;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.UserMapper;
import com.yuanchu.mom.pojo.AuthApi;
import com.yuanchu.mom.pojo.Company;
import com.yuanchu.mom.pojo.Post;
import com.yuanchu.mom.pojo.Person;
import com.yuanchu.mom.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
public class HeaderToken {
@@ -26,129 +28,83 @@
    @Resource
    private RedisTemplate redisTemplate;
    public static void main(String[] args) {
        HttpRequest request = HttpRequest.post("https://ztt-sso.asuncloud.net/oauth2/token")
                .header("Content-Type", "application/x-www-form-urlencoded")
                .form("grant_type", "client_credentials")
                .form("client_id", "8b2f2c7e-2ab9-4718-8193-c0c636dceba8")
                .form("client_secret", "db59b70d28ab1865aafe4008f59d4760");
        HttpResponse response = request.execute();
        System.out.println(response.body());
    }
    @Resource
    private UserMapper userMapper;
    public String fetchNewAccessToken() {
        HttpRequest request = HttpRequest.post("https://ztt-sso.asuncloud.net/oauth2/token")
        HttpRequest request = HttpRequest.post(AuthApi.code)
                .header("Content-Type", "application/x-www-form-urlencoded")
                .form("grant_type", "client_credentials")
                .form("client_id", "8b2f2c7e-2ab9-4718-8193-c0c636dceba8")
                .form("client_secret", "db59b70d28ab1865aafe4008f59d4760");
                .form("client_id", AuthApi.appId)
                .form("client_secret", AuthApi.appSecret);
        HttpResponse response = request.execute();
        System.out.println(response.body());
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode jsonNode = null;
        JsonNode jsonNode;
        try {
            jsonNode = objectMapper.readTree(response.body());
            String accessToken = jsonNode.get("access_token").asText();
            redisTemplate.opsForValue().set("access_token",accessToken);
            redisTemplate.expire("access_token", dataTime("access_token"), TimeUnit.SECONDS);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            Log.get().info("获取人事系统token:"+accessToken);
            redisTemplate.opsForValue().set("access_token",accessToken,jsonNode.get("expires_in").asInt() - 60,TimeUnit.SECONDS);
            return accessToken;
        } catch (Exception e) {
            throw new ErrorException(e.getMessage());
        }
        return null;
    }
        private String accessToken ;
    //判断是否过期
    //判断是否存在
    public String getAccessToken() {
        accessToken=(String) redisTemplate.opsForValue().get("access_token");
        if (accessToken == null) {
        String accessToken;
        if (!redisTemplate.hasKey("access_token")) {
            accessToken = fetchNewAccessToken();
        }else{
            accessToken = redisTemplate.opsForValue().get("access_token")+"";
        }
        return accessToken;
    }
    //判断 token æ˜¯å¦å·²å­˜åœ¨
    public String getToken(String token) {
        String o = redisTemplate.opsForValue().get(token).toString();
        if (o != null && !o.isEmpty()) {
            return o;
        }else{
            redisTemplate.expire(token,dataTime("access_token"),TimeUnit.SECONDS);
            String tokens = redisTemplate.opsForValue().get(token).toString();
            return tokens;
        }
        // èŽ·å– token
//        accessToken = fetchNewAccessToken();
//        return accessToken;
    }
    //获取token过期时间
    public Long dataTime(String token){
        Long access_token = redisTemplate.getExpire(token);
        if(access_token != null && access_token >60) {
            redisTemplate.expire(token, access_token - 60 ,TimeUnit.SECONDS);
            return access_token - 60;
        }//就直接调用
        return null;
    }
    //调用
    public List<Company>  companyUrl() {
    public List<Company> companyUrl() {
        String accessToken = getAccessToken();
        String getToken= getToken(accessToken);
        String apiUrl =AuthApi.companies; // æ›¿æ¢ä¸ºå®žé™…çš„API端点URL
        HttpRequest request = HttpRequest.get(apiUrl)
        HttpRequest request = HttpRequest.get(AuthApi.companies)
                .header("Authorization", "Bearer " + accessToken);
        HttpResponse response = request.execute();
        ObjectMapper objectMapper = new ObjectMapper();
        String body = response.body();
        List<Company> companies = null;
        List<Company> companies;
        try {
            companies = objectMapper.readValue(body, new TypeReference<List<Company>>(){});
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            companies = JSON.parseArray(request.execute().body(), Company.class);
        }catch (Exception e){
            throw new ErrorException(e.getMessage());
        }
        return companies;
        return companies.stream().filter(ob->{
            if(ob.getStatus().equals("enabled")) return true;
            return false;
        }).collect(Collectors.toList());
    }
    public List<Post>  postUrl(String companyId) {
    public List<Person> userUrl(String companyId) {
        String accessToken = getAccessToken();
        String token = getToken(accessToken);
        String apiUrl =AuthApi.post+companyId; // æ›¿æ¢ä¸ºå®žé™…çš„API端点URL
        HttpRequest request = HttpRequest.get(apiUrl)
                .header("Authorization", "Bearer " + accessToken);
        HttpResponse response = request.execute();
        ObjectMapper objectMapper = new ObjectMapper();
        String body = response.body();
        List<Post> posts = null;
        try {
            posts=objectMapper.readValue(body, new TypeReference<List<Post>>() {});
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return posts;
    }
    public List<User>  userUrl(String companyId) {
        String accessToken = getAccessToken();
        String token = getToken(accessToken);
        String apiUrl =AuthApi.simple+companyId; // æ›¿æ¢ä¸ºå®žé™…çš„API端点URL
        HttpRequest request = HttpRequest.get(apiUrl)
        HttpRequest request = HttpRequest.get(AuthApi.simple+companyId)
                .header("Authorization", "Bearer " + accessToken)
                .header("Content-Type", "application/form-data");
        HttpResponse response = request.execute();
        ObjectMapper objectMapper = new ObjectMapper();
        String body = response.body();
        List<User> user=null;
        List<Person> person;
        try {
            user= objectMapper.readValue(body,new TypeReference<List<User>>(){});
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            person = JSON.parseArray(request.execute().body(), Person.class);
        }catch (Exception e){
            throw new ErrorException(e.getMessage());
        }
        return user;
        return person.stream().filter(ob->{
            if(Objects.equals(ob.getStatus(), "enabled")) {
                ob.setIsLive(userMapper.selectCount(Wrappers.<User>lambdaQuery().eq(User::getAccount, ob.getEmployeeID())));
                return true;
            }
            return false;
        }).collect(Collectors.toList());
    }
    public String getPassword(String employeeId) {
        String accessToken = getAccessToken();
        HttpRequest request = HttpRequest.get(AuthApi.password + employeeId)
                .header("Authorization", "Bearer " + accessToken);
        System.out.println(AuthApi.password + employeeId);
        System.out.println(request.execute().body());
        return JSON.parseObject(request.execute().body()).get("originalPwd").toString();
    }
}
user-server/src/main/resources/mapper/DepartmentsMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,4 @@
<?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.yuanchu.mom.mapper.DepartmentsMapper">
</mapper>
user-server/src/main/resources/mapper/UserMapper.xml
@@ -6,7 +6,7 @@
        select u1.id, u1.account, u1.name, u1.state, u1.create_time, u1.update_time, u1.create_user, u1.update_user,
        u1.age, u1.email, u1.phone, u1.department, u1.company, u1.address, u1.is_custom, u1.role_id, u2.name
        create_user_name, u3.name update_user_name, r.name role_name,u1.signature_url,u1.picture_url,u1.depart_id,
        u1.name_en
        u1.name_en,u1.depart_lims_id
        from user u1
        left join user u2 on u2.id = u1.create_user
        left join user u3 on u3.id = u1.update_user
@@ -16,6 +16,24 @@
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="selectPersonnelOverview" resultType="com.yuanchu.mom.dto.UserPageDto">
        select * from (
        select u1.id, u1.account, u1.name, u1.state, u1.create_time, u1.update_time, u1.create_user, u1.update_user,
        u1.age, u1.email, u1.phone, u1.department, u1.company, u1.address, u1.is_custom, u1.role_id, u2.name
        create_user_name, u3.name update_user_name, r.name role_name,u1.signature_url,u1.picture_url,u1.depart_id,
        u1.name_en
        from user u1
        left join user u2 on u2.id = u1.create_user
        left join user u3 on u3.id = u1.update_user
        left join role r on u1.role_id = r.id
        where u1.depart_lims_id is not null
        ) a
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="getDeviceManager" resultType="com.yuanchu.mom.dto.UserPageDto">
        select id, name
        from user