| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZMarry; |
| | | import com.ruoyi.domain.dto.MarryInfoDto; |
| | | import com.ruoyi.service.ZMarryService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/zMarry") |
| | | public class ZMarryController { |
| | | @Slf4j |
| | | public class ZMarryController extends BaseController { |
| | | @Autowired |
| | | private ZMarryService zMarryService; |
| | | |
| | | |
| | | /** |
| | | * 查询当前婚姻状况 |
| | | */ |
| | | @GetMapping("/list") |
| | | public AjaxResult getMarryStatus(){ |
| | | return zMarryService.getNow(); |
| | | } |
| | | |
| | | /** |
| | | * 新增婚姻状况记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:add')") |
| | | @Log(title = "婚姻状况记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody MarryInfoDto marryInfoDto) |
| | | { |
| | | return zMarryService.addInfo(marryInfoDto); |
| | | } |
| | | |
| | | /** |
| | | * 修改婚姻状况记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:edit')") |
| | | @Log(title = "婚姻状况记录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody MarryInfoDto marryInfoDto) |
| | | { |
| | | return zMarryService.updateInfo(marryInfoDto); |
| | | } |
| | | // |
| | | /** |
| | | * 批量删除婚姻状况记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:remove')") |
| | | @Log(title = "婚姻状况记录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping() |
| | | public AjaxResult remove(String id) |
| | | { |
| | | return zMarryService.deleteOld(id); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZfClean; |
| | | import com.ruoyi.service.ZfCleanService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/zfClean") |
| | | public class ZfCleanController { |
| | | @Slf4j |
| | | public class ZfCleanController extends BaseController { |
| | | |
| | | @Resource |
| | | private ZfCleanService zfCleanService; |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult listAll(ZfClean zfClean){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfCleanService.selectDataList(zfClean, pageNum, pageSize); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出保洁收纳记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfClean zfClean) |
| | | { |
| | | List<ZfClean> list = zfCleanService.selectByCondition(zfClean); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | util.exportExcel(response, list, "保洁收纳记录数据"); |
| | | } |
| | | |
| | | /** |
| | | * 导入保洁收纳记录列表 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception |
| | | { |
| | | return zfCleanService.importExcel(file); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取保洁收纳记录详细信息 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) |
| | | { |
| | | return success(zfCleanService.getById(id)); |
| | | } |
| | | // |
| | | /** |
| | | * 新增保洁收纳记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:add')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfClean zfClean) |
| | | { |
| | | return zfCleanService.addData2(zfClean); |
| | | } |
| | | |
| | | /** |
| | | * 修改保洁收纳记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:edit')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfClean zfClean) |
| | | { |
| | | return toAjax(zfCleanService.updateById(zfClean)); |
| | | } |
| | | // |
| | | /** |
| | | * 批量删除保洁收纳记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:remove')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfCleanService.removeByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | public AjaxResult listAll(ZfContact zfContact){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfContactService.selectContactList(zfContact, pageNum, pageSize); |
| | | return zfContactService.selectDataList(zfContact, pageNum, pageSize); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfContact zfContact) |
| | | { |
| | | return toAjax(zfContactService.save(zfContact)); |
| | | return (zfContactService.addData2(zfContact)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfEquipmentService.selectEquipmentList(zfEquipment, pageNum, pageSize); |
| | | return zfEquipmentService.selectDataList(zfEquipment, pageNum, pageSize); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEquipment zfEquipment) |
| | | { |
| | | return toAjax(zfEquipmentService.addEquipment(zfEquipment)); |
| | | return zfEquipmentService.addData2(zfEquipment); |
| | | } |
| | | |
| | | /** |
| | |
| | | public AjaxResult listAll(ZfEvent zfEvent){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfEventService.selectEventList(zfEvent, pageNum, pageSize); |
| | | return zfEventService.selectDataList(zfEvent, pageNum, pageSize); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEvent zfEvent) |
| | | { |
| | | return toAjax(zfEventService.addEvent(zfEvent)); |
| | | return zfEventService.addData2(zfEvent); |
| | | } |
| | | |
| | | /** |
| | |
| | | // int familyNum = family.nextInt(4); |
| | | |
| | | zfCollection = new ZfCollection(); |
| | | zfCollection.setGetTime(simpleDateFormat.parse(l1.get(typeNum))); |
| | | zfCollection.setHappenTime(simpleDateFormat.parse(l1.get(typeNum))); |
| | | zfCollection.setType(l2.get(typeNum)); |
| | | zfCollection.setName(l3.get(typeNum)); |
| | | zfCollection.setSource(l4.get(sourceNum)); |
| | |
| | | zfEconomyService.save(zfEconomy); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | ZfCleanService zfCleanService; |
| | | @Test |
| | | void insertClean() { |
| | | List<Integer> l1 = Arrays.asList(0,1); |
| | | List<String> l2 = Arrays.asList("所有人", "张三"); |
| | | List<String> l3 = Arrays.asList("玻璃窗", "被子"); |
| | | List<String> l4 = Arrays.asList("玻璃水洗", "折好放被袋"); |
| | | List<String> l5 = Arrays.asList("杂物房", "衣柜"); |
| | | List<String> l6 = Arrays.asList("窗户", "收纳柜"); |
| | | List<String> l7 = Arrays.asList("1", "2", "3", "4"); |
| | | List<String> l9 = Arrays.asList("擦玻璃要小心","叠被子要细心"); |
| | | |
| | | ZfClean zfClean=null; |
| | | int count=0; |
| | | int familyNum = 0; |
| | | Random family = new Random(); |
| | | |
| | | for (int i = 0; i < 100; i++) { |
| | | count=i%2; |
| | | familyNum=family.nextInt(4); |
| | | zfClean=new ZfClean(); |
| | | zfClean.setKind(l1.get(count)); |
| | | zfClean.setSuitable(l2.get(count)); |
| | | zfClean.setType(l3.get(count)); |
| | | zfClean.setMethod(l4.get(count)); |
| | | zfClean.setPlace(l5.get(count)); |
| | | zfClean.setLocation(l6.get(count)); |
| | | zfClean.setRemark(l9.get(count)); |
| | | zfClean.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); |
| | | zfClean.setFamilyId(l7.get(familyNum)); |
| | | zfCleanService.save(zfClean); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public static final String PROPERTY_LIST="2007"; |
| | | public static final String COLLECTION_LIST="2018"; |
| | | public static final String ECONOMY_LIST="2023"; |
| | | public static final String EVENT_LIST="2013"; |
| | | public static final String EQUIPMENT_LIST="2017"; |
| | | public static final String CONTACT_LIST="2021"; |
| | | public static final String CLEAN_LIST="2020"; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.io.PipedReader; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-04-23 13:23 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | @TableName("marry_user") |
| | | public class MarryUser implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | private Long myId; |
| | | |
| | | private String name; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date birthday; |
| | | private String address; |
| | | private String workAddress; |
| | | private Integer marryStatus; |
| | | private Integer sex; |
| | | private String nation; |
| | | private String phone; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * |
| | | * </p> |
| | | * |
| | | * @author ojq |
| | | * @since 2023-03-14 |
| | | */ |
| | | @TableName("z_marry") |
| | | @Data |
| | | @ToString |
| | | public class ZMarry implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | /** |
| | | * 本人id |
| | | */ |
| | | private Integer userId; |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 配偶id |
| | | */ |
| | | private Integer spouseId; |
| | | private String spouseId; |
| | | |
| | | /** |
| | | * 结婚时间 |
| | | */ |
| | | private LocalDateTime marryDate; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date marryTime; |
| | | |
| | | /** |
| | | * 生育情况,0:未生育、1:在孕、2:已生育 |
| | | */ |
| | | private Integer bearStatus; |
| | | |
| | | /** |
| | | * 是否领取计划生育服务手册 |
| | | */ |
| | | private Integer isJhsyfwsc; |
| | | private Integer handbookStatus; |
| | | |
| | | /** |
| | | * 领取计划生育服务手册时间 |
| | | */ |
| | | private LocalDateTime getJhsyfwscDate; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date handbookTime; |
| | | |
| | | /** |
| | | * 是否领取独生子女证 |
| | | */ |
| | | private Integer isDsznz; |
| | | private Integer oneBorn; |
| | | |
| | | /** |
| | | * 领取独生子女证时间 |
| | | */ |
| | | private LocalDateTime getDsznzDate; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date oneBornTime; |
| | | |
| | | /** |
| | | * 需声明的情况 |
| | | */ |
| | | private String content; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 记录是否被删除,有个查看过往史的功能 |
| | | */ |
| | | private Integer isDelete; |
| | | private Integer deleteStatus; |
| | | |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Integer userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Integer getSpouseId() { |
| | | return spouseId; |
| | | } |
| | | |
| | | public void setSpouseId(Integer spouseId) { |
| | | this.spouseId = spouseId; |
| | | } |
| | | |
| | | public LocalDateTime getMarryDate() { |
| | | return marryDate; |
| | | } |
| | | |
| | | public void setMarryDate(LocalDateTime marryDate) { |
| | | this.marryDate = marryDate; |
| | | } |
| | | |
| | | public Integer getBearStatus() { |
| | | return bearStatus; |
| | | } |
| | | |
| | | public void setBearStatus(Integer bearStatus) { |
| | | this.bearStatus = bearStatus; |
| | | } |
| | | |
| | | public Integer getIsJhsyfwsc() { |
| | | return isJhsyfwsc; |
| | | } |
| | | |
| | | public void setIsJhsyfwsc(Integer isJhsyfwsc) { |
| | | this.isJhsyfwsc = isJhsyfwsc; |
| | | } |
| | | |
| | | public LocalDateTime getGetJhsyfwscDate() { |
| | | return getJhsyfwscDate; |
| | | } |
| | | |
| | | public void setGetJhsyfwscDate(LocalDateTime getJhsyfwscDate) { |
| | | this.getJhsyfwscDate = getJhsyfwscDate; |
| | | } |
| | | |
| | | public Integer getIsDsznz() { |
| | | return isDsznz; |
| | | } |
| | | |
| | | public void setIsDsznz(Integer isDsznz) { |
| | | this.isDsznz = isDsznz; |
| | | } |
| | | |
| | | public LocalDateTime getGetDsznzDate() { |
| | | return getDsznzDate; |
| | | } |
| | | |
| | | public void setGetDsznzDate(LocalDateTime getDsznzDate) { |
| | | this.getDsznzDate = getDsznzDate; |
| | | } |
| | | |
| | | public String getContent() { |
| | | return content; |
| | | } |
| | | |
| | | public void setContent(String content) { |
| | | this.content = content; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public Integer getIsDelete() { |
| | | return isDelete; |
| | | } |
| | | |
| | | public void setIsDelete(Integer isDelete) { |
| | | this.isDelete = isDelete; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ZMarry{" + |
| | | "id=" + id + |
| | | ", userId=" + userId + |
| | | ", spouseId=" + spouseId + |
| | | ", marryDate=" + marryDate + |
| | | ", bearStatus=" + bearStatus + |
| | | ", isJhsyfwsc=" + isJhsyfwsc + |
| | | ", getJhsyfwscDate=" + getJhsyfwscDate + |
| | | ", isDsznz=" + isDsznz + |
| | | ", getDsznzDate=" + getDsznzDate + |
| | | ", content=" + content + |
| | | ", remark=" + remark + |
| | | ", isDelete=" + isDelete + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @TableName("zf_clean") |
| | | @Data |
| | | public class ZfClean implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | /** |
| | | * 0:保洁,1:收纳 |
| | |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 电子文件路径 |
| | | */ |
| | | private String url; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | @Excel(name="所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getKind() { |
| | | return kind; |
| | | } |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | public void setKind(Integer kind) { |
| | | this.kind = kind; |
| | | } |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createTime; |
| | | |
| | | public String getSuitable() { |
| | | return suitable; |
| | | } |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenStartTime; |
| | | |
| | | public void setSuitable(String suitable) { |
| | | this.suitable = suitable; |
| | | } |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenEndTime; |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | /** |
| | | * 发生时间 |
| | | */ |
| | | @Excel(name = "发生时间", dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date happenTime; |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getMethod() { |
| | | return method; |
| | | } |
| | | |
| | | public void setMethod(String method) { |
| | | this.method = method; |
| | | } |
| | | |
| | | public String getPlace() { |
| | | return place; |
| | | } |
| | | |
| | | public void setPlace(String place) { |
| | | this.place = place; |
| | | } |
| | | |
| | | public String getLocation() { |
| | | return location; |
| | | } |
| | | |
| | | public void setLocation(String location) { |
| | | this.location = location; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ZfClean{" + |
| | | "id=" + id + |
| | | ", kind=" + kind + |
| | | ", suitable=" + suitable + |
| | | ", type=" + type + |
| | | ", method=" + method + |
| | | ", place=" + place + |
| | | ", location=" + location + |
| | | ", remark=" + remark + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Excel(name = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | private String url; |
| | | |
| | | @Excel(name="所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createTime; |
| | | |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenStartTime; |
| | | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenEndTime; |
| | | |
| | | /** |
| | | * 发生时间 |
| | | */ |
| | | @Excel(name = "发生时间", dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date happenTime; |
| | | |
| | | |
| | | } |
| | |
| | | * 时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd") |
| | | private Date createTime; |
| | | |
| | | /** |
| | |
| | | |
| | | private String url; |
| | | |
| | | @Excel(name = "所属家庭编号") |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | |
| | | /** |
| | |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenStartTime; |
| | | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenEndTime; |
| | | |
| | | /** |
| | | * 发生时间 |
| | | */ |
| | | @Excel(name = "发生时间", dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date happenTime; |
| | | |
| | | } |
| | |
| | | private String name; |
| | | |
| | | /** |
| | | * 记录时间 |
| | | * 插入时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd") |
| | | private Date createDate; |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 购买人 |
| | |
| | | /** |
| | | * 家庭id |
| | | */ |
| | | @Excel(name = "家庭id") |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | |
| | | private String url; |
| | |
| | | private Integer status; |
| | | |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenStartTime; |
| | | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Date happenEndTime; |
| | | |
| | | /** |
| | | * 记录时间 |
| | | */ |
| | | @Excel(name = "记录时间", dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date happenTime; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @TableField(exist = false) |
New file |
| | |
| | | package com.ruoyi.domain.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.domain.MarryUser; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-04-23 14:04 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | public class MarryInfoDto implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | //我个人的数据 |
| | | private String id; |
| | | private String name; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date birthday; |
| | | private String address; |
| | | private String workAddress; |
| | | private Integer marryStatus; |
| | | private Integer sex; |
| | | private String nation; |
| | | private String phone; |
| | | |
| | | //配偶的数据 |
| | | private String spouseId; |
| | | private String spouseName; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date spouseBirthday; |
| | | private String spouseAddress; |
| | | private String spouseWorkAddress; |
| | | private Integer spouseMarryStatus; |
| | | private Integer spouseSex; |
| | | private String spouseNation; |
| | | private String spousePhone; |
| | | |
| | | |
| | | |
| | | //生育情况(中间表) |
| | | private Long marryId; |
| | | /** |
| | | * 结婚时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date marryTime; |
| | | |
| | | /** |
| | | * 生育情况,0:未生育、1:在孕、2:已生育 |
| | | */ |
| | | private Integer bearStatus; |
| | | private Integer handbookStatus; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date handbookTime; |
| | | private Integer oneBorn; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date oneBornTime; |
| | | private String content; |
| | | private String remark; |
| | | |
| | | /** |
| | | * 前任信息的List |
| | | */ |
| | | private List<MarryUser> oldSpouseList; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.domain.MarryUser; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-04-23 13:30 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Mapper |
| | | public interface MarryUserMapper extends BaseMapper<MarryUser> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.domain.MarryUser; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-04-23 13:31 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | public interface MarryUserService extends IService<MarryUser> { |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZMarry; |
| | | import com.ruoyi.domain.dto.MarryInfoDto; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface ZMarryService extends IService<ZMarry> { |
| | | |
| | | AjaxResult getNow(); |
| | | |
| | | AjaxResult addInfo(MarryInfoDto marryInfoDto); |
| | | |
| | | AjaxResult updateInfo(MarryInfoDto marryInfoDto); |
| | | AjaxResult deleteOld(String spouseId); |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZfClean; |
| | | import com.ruoyi.domain.ZfClean; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface ZfCleanService extends IService<ZfClean> { |
| | | |
| | | AjaxResult selectDataList(ZfClean zfClean, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfClean> selectByCondition(ZfClean zfClean); |
| | | |
| | | AjaxResult addData(ZfClean zfClean); |
| | | |
| | | AjaxResult addData2(ZfClean zfClean); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZfContact; |
| | | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface ZfContactService extends IService<ZfContact> { |
| | | |
| | | AjaxResult selectContactList(ZfContact zfContact, Integer pageNum, Integer pageSize); |
| | | AjaxResult selectDataList(ZfContact zfContact, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfContact> selectByCondition(ZfContact zfContact); |
| | | |
| | | AjaxResult addData(ZfContact zfContact); |
| | | |
| | | AjaxResult addData2(ZfContact zfContact); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | } |
| | |
| | | */ |
| | | public interface ZfEquipmentService extends IService<ZfEquipment> { |
| | | |
| | | AjaxResult selectEquipmentList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize); |
| | | AjaxResult selectDataList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment); |
| | | |
| | | int addEquipment(ZfEquipment zfEquipment); |
| | | AjaxResult addData(ZfEquipment zfEquipment); |
| | | AjaxResult addData2(ZfEquipment zfEquipment); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | |
| | | */ |
| | | public interface ZfEventService extends IService<ZfEvent> { |
| | | |
| | | AjaxResult selectEventList(ZfEvent zfEvent, Integer pageNum, Integer pageSize); |
| | | AjaxResult selectDataList(ZfEvent zfEvent, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfEvent> selectByCondition(ZfEvent zfEvent); |
| | | |
| | | int addEvent(ZfEvent zfEvent); |
| | | AjaxResult addData(ZfEvent zfEvent); |
| | | |
| | | AjaxResult addData2(ZfEvent zfEvent); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | } |
| | |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | |
| | | // private Date getHappenTime(ZfProperty zfProperty) { |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // String happenTimeStr = format.format(zfProperty.getHappenTime()); |
| | | // |
| | | // Date happenTime = null; |
| | | // try { |
| | | // happenTime = format.parse(happenTimeStr); |
| | | // System.out.println("方法里的:" + happenTime); |
| | | // } catch (ParseException e) { |
| | | // throw new RuntimeException("时间格式转换有误"); |
| | | // } |
| | | // return happenTime; |
| | | // } |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) { |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | |
New file |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.domain.MarryUser; |
| | | import com.ruoyi.mapper.MarryUserMapper; |
| | | import com.ruoyi.service.MarryUserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-04-23 13:31 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public class MarryUserServiceImpl extends ServiceImpl<MarryUserMapper, MarryUser> implements MarryUserService { |
| | | } |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.domain.MarryUser; |
| | | import com.ruoyi.domain.ZMarry; |
| | | import com.ruoyi.domain.dto.MarryInfoDto; |
| | | import com.ruoyi.mapper.ZMarryMapper; |
| | | import com.ruoyi.service.MarryUserService; |
| | | import com.ruoyi.service.ZMarryService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author ojq |
| | |
| | | @Service |
| | | public class ZMarryServiceImpl extends ServiceImpl<ZMarryMapper, ZMarry> implements ZMarryService { |
| | | |
| | | @Resource |
| | | MarryUserService marryUserService; |
| | | |
| | | @Autowired |
| | | ZMarryServiceImpl zMarryService; |
| | | |
| | | @Override |
| | | public AjaxResult getNow() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | //先查询个人信息 |
| | | LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper1 = new LambdaQueryWrapper<>(); |
| | | marryUserLambdaQueryWrapper1.eq(MarryUser::getMyId, userId); |
| | | MarryUser myself = marryUserService.getOne(marryUserLambdaQueryWrapper1); |
| | | |
| | | //再查询中间表信息 |
| | | if (myself == null) { |
| | | throw new RuntimeException("您暂时还未在婚姻表中添加个人信息"); |
| | | } |
| | | LambdaQueryWrapper<ZMarry> zMarryLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zMarryLambdaQueryWrapper.eq(ZMarry::getUserId, myself.getMyId()) |
| | | .eq(ZMarry::getDeleteStatus, 0); |
| | | ZMarry myMarryInfo = getOne(zMarryLambdaQueryWrapper);//只能有一个配偶 |
| | | |
| | | //根据中间表信息查询配偶信息 |
| | | if (myMarryInfo == null) { |
| | | throw new RuntimeException("您暂时还未在婚姻表中添加婚姻信息"); |
| | | } |
| | | String spouseId = myMarryInfo.getSpouseId(); |
| | | LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); |
| | | marryUserLambdaQueryWrapper2.eq(MarryUser::getId, spouseId); |
| | | MarryUser spouse = marryUserService.getOne(marryUserLambdaQueryWrapper2); |
| | | if (spouse == null) { |
| | | throw new RuntimeException("您暂时还未在婚姻表中添加配偶信息"); |
| | | } |
| | | |
| | | //根据中间表信息查询前任信息 |
| | | LambdaQueryWrapper<ZMarry> zMarryOldLQW = new LambdaQueryWrapper<>(); |
| | | zMarryOldLQW.eq(ZMarry::getUserId,myself.getMyId()) |
| | | .eq(ZMarry::getDeleteStatus,1); |
| | | List<ZMarry> oldList = list(zMarryOldLQW); |
| | | |
| | | //前任信息表 |
| | | List<MarryUser> oldSpouseList = new ArrayList<>(); |
| | | for (ZMarry zMarry : oldList) { |
| | | String spouseId1 = zMarry.getSpouseId(); |
| | | MarryUser oldSpouse = marryUserService.getById(spouseId1); |
| | | oldSpouseList.add(oldSpouse); |
| | | } |
| | | |
| | | //统一封装返回 |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("myInfo",myself); |
| | | resultMap.put("spouseInfo",spouse); |
| | | resultMap.put("marryInfo",myMarryInfo); |
| | | resultMap.put("oldSpouseInfo",oldSpouseList); |
| | | |
| | | return AjaxResult.success(resultMap); |
| | | } |
| | | |
| | | @Transactional |
| | | public AjaxResult addInfo(MarryInfoDto marryInfoDto){ |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | String meId= IdUtils.simpleUUID(); |
| | | String spouseId = IdUtils.simpleUUID(); |
| | | |
| | | //添加自己的信息 |
| | | MarryUser myself = new MarryUser(); |
| | | myself.setId(meId); |
| | | myself.setName(marryInfoDto.getName()); |
| | | myself.setBirthday(marryInfoDto.getBirthday()); |
| | | myself.setAddress(marryInfoDto.getAddress()); |
| | | myself.setWorkAddress(marryInfoDto.getWorkAddress()); |
| | | myself.setMarryStatus(marryInfoDto.getMarryStatus()); |
| | | myself.setSex(marryInfoDto.getSex()); |
| | | myself.setMyId(userId); |
| | | myself.setNation(marryInfoDto.getNation()); |
| | | myself.setPhone(marryInfoDto.getPhone()); |
| | | marryUserService.save(myself); |
| | | |
| | | //添加配偶的信息 |
| | | MarryUser spouse = new MarryUser(); |
| | | spouse.setId(spouseId); |
| | | spouse.setName(marryInfoDto.getSpouseName()); |
| | | spouse.setBirthday(marryInfoDto.getSpouseBirthday()); |
| | | spouse.setAddress(marryInfoDto.getSpouseAddress()); |
| | | spouse.setWorkAddress(marryInfoDto.getSpouseWorkAddress()); |
| | | spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); |
| | | spouse.setSex(marryInfoDto.getSpouseSex()); |
| | | spouse.setNation(marryInfoDto.getSpouseNation()); |
| | | spouse.setPhone(marryInfoDto.getSpousePhone()); |
| | | marryUserService.save(spouse); |
| | | |
| | | //添加生育情况(中间表)信息 |
| | | ZMarry zMarry = new ZMarry(); |
| | | zMarry.setUserId(userId); |
| | | zMarry.setSpouseId(spouseId); |
| | | zMarry.setMarryTime(marryInfoDto.getMarryTime()); |
| | | zMarry.setBearStatus(marryInfoDto.getBearStatus()); |
| | | zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); |
| | | zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); |
| | | zMarry.setOneBorn(marryInfoDto.getOneBorn()); |
| | | zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); |
| | | zMarry.setContent(marryInfoDto.getContent()); |
| | | zMarry.setRemark(marryInfoDto.getRemark()); |
| | | zMarry.setDeleteStatus(0); |
| | | zMarryService.save(zMarry); |
| | | |
| | | |
| | | List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); |
| | | |
| | | //添加前任的信息 |
| | | if(oldSpouseList!=null&&oldSpouseList.size()!=0){ |
| | | for (MarryUser marryUser : oldSpouseList) { |
| | | //先添加配偶用户信息 |
| | | String spId = IdUtils.simpleUUID(); |
| | | marryUser.setId(spId); |
| | | marryUserService.save(marryUser); |
| | | |
| | | //再添加中间表信息 |
| | | ZMarry oldMarry = new ZMarry(); |
| | | oldMarry.setUserId(userId); |
| | | oldMarry.setSpouseId(spId); |
| | | oldMarry.setDeleteStatus(1); |
| | | zMarryService.save(oldMarry); |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Transactional |
| | | public AjaxResult updateInfo(MarryInfoDto marryInfoDto){ |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | //更新自己的信息 |
| | | MarryUser myself = new MarryUser(); |
| | | myself.setId(marryInfoDto.getId()); |
| | | myself.setName(marryInfoDto.getName()); |
| | | myself.setBirthday(marryInfoDto.getBirthday()); |
| | | myself.setAddress(marryInfoDto.getAddress()); |
| | | myself.setWorkAddress(marryInfoDto.getWorkAddress()); |
| | | myself.setMarryStatus(marryInfoDto.getMarryStatus()); |
| | | myself.setSex(marryInfoDto.getSex()); |
| | | myself.setNation(marryInfoDto.getNation()); |
| | | myself.setPhone(marryInfoDto.getPhone()); |
| | | marryUserService.updateById(myself); |
| | | |
| | | //更新配偶的信息 |
| | | |
| | | //先查询是更新配偶信息还是换配偶,因为配偶只能有一个 |
| | | //这里暂时用名字来判断吧,如果有重名的人就会有bug |
| | | //先查询 |
| | | String spouseName = marryInfoDto.getSpouseName(); |
| | | MarryUser marry = marryUserService.getById(marryInfoDto.getSpouseId()); |
| | | String marryName = marry.getName(); |
| | | if(!spouseName.equals(marryName)){ |
| | | |
| | | //如果正妻子换人了,就新增而不是修改,同时删除旧纪录 |
| | | //将现在中间表的妻子改成前妻 |
| | | LambdaQueryWrapper<ZMarry> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZMarry::getUserId,userId) |
| | | .eq(ZMarry::getSpouseId,marryInfoDto.getSpouseId()); |
| | | ZMarry one = getOne(lqw); |
| | | one.setDeleteStatus(1); |
| | | zMarryService.updateById(one); |
| | | |
| | | //新增用户信息表 |
| | | String spouseId = IdUtils.simpleUUID(); |
| | | MarryUser spouse = new MarryUser(); |
| | | spouse.setId(spouseId); |
| | | spouse.setName(marryInfoDto.getSpouseName()); |
| | | spouse.setBirthday(marryInfoDto.getSpouseBirthday()); |
| | | spouse.setAddress(marryInfoDto.getSpouseAddress()); |
| | | spouse.setWorkAddress(marryInfoDto.getSpouseWorkAddress()); |
| | | spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); |
| | | spouse.setSex(marryInfoDto.getSpouseSex()); |
| | | spouse.setNation(marryInfoDto.getSpouseNation()); |
| | | spouse.setPhone(marryInfoDto.getSpousePhone()); |
| | | marryUserService.save(spouse); |
| | | |
| | | //新增中间表 |
| | | //添加生育情况(中间表)信息 |
| | | ZMarry zMarry = new ZMarry(); |
| | | zMarry.setUserId(userId); |
| | | zMarry.setSpouseId(spouseId); |
| | | zMarry.setMarryTime(marryInfoDto.getMarryTime()); |
| | | zMarry.setBearStatus(marryInfoDto.getBearStatus()); |
| | | zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); |
| | | zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); |
| | | zMarry.setOneBorn(marryInfoDto.getOneBorn()); |
| | | zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); |
| | | zMarry.setContent(marryInfoDto.getContent()); |
| | | zMarry.setRemark(marryInfoDto.getRemark()); |
| | | zMarry.setDeleteStatus(0); |
| | | zMarryService.save(zMarry); |
| | | |
| | | |
| | | |
| | | }else { |
| | | |
| | | MarryUser spouse = new MarryUser(); |
| | | spouse.setId(marryInfoDto.getSpouseId()); |
| | | spouse.setName(marryInfoDto.getSpouseName()); |
| | | spouse.setBirthday(marryInfoDto.getSpouseBirthday()); |
| | | spouse.setAddress(marryInfoDto.getSpouseAddress()); |
| | | spouse.setWorkAddress(marryInfoDto.getSpouseWorkAddress()); |
| | | spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); |
| | | spouse.setSex(marryInfoDto.getSpouseSex()); |
| | | spouse.setNation(marryInfoDto.getSpouseNation()); |
| | | spouse.setPhone(marryInfoDto.getSpousePhone()); |
| | | marryUserService.updateById(spouse); |
| | | |
| | | //更新生育情况信息 |
| | | ZMarry zMarry = new ZMarry(); |
| | | zMarry.setId(marryInfoDto.getMarryId()); |
| | | zMarry.setMarryTime(marryInfoDto.getMarryTime()); |
| | | zMarry.setBearStatus(marryInfoDto.getBearStatus()); |
| | | zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); |
| | | zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); |
| | | zMarry.setOneBorn(marryInfoDto.getOneBorn()); |
| | | zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); |
| | | zMarry.setContent(marryInfoDto.getContent()); |
| | | zMarry.setRemark(marryInfoDto.getRemark()); |
| | | zMarry.setDeleteStatus(0); |
| | | zMarryService.updateById(zMarry); |
| | | } |
| | | |
| | | //更新前任信息 |
| | | List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); |
| | | if(oldSpouseList!=null&&oldSpouseList.size()!=0){ |
| | | for (MarryUser marryUser : oldSpouseList) { |
| | | //修改用户前任信息 |
| | | marryUserService.updateById(marryUser); |
| | | //中间表不需要修改 |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | public AjaxResult deleteOld(String spouseId){ |
| | | marryUserService.removeById(spouseId); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfClean; |
| | | |
| | | import com.ruoyi.domain.ZfClean; |
| | | import com.ruoyi.mapper.ZfCleanMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCleanService; |
| | | |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.CLEAN_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ZfCleanServiceImpl extends ServiceImpl<ZfCleanMapper, ZfClean> implements ZfCleanService { |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | ZfCleanService zfCleanService; |
| | | |
| | | private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean) { |
| | | LambdaQueryWrapper<ZfClean> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zfClean.getKind() != null, ZfClean::getKind, zfClean.getKind()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getSuitable()), ZfClean::getSuitable, zfClean.getSuitable()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getType()), ZfClean::getType, zfClean.getType()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getMethod()), ZfClean::getMethod, zfClean.getMethod()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getPlace()), ZfClean::getPlace, zfClean.getPlace()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getLocation()), ZfClean::getLocation, zfClean.getLocation()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getRemark()), ZfClean::getRemark, zfClean.getRemark()) |
| | | .eq(zfClean.getHappenTime() != null, ZfClean::getHappenTime, zfClean.getHappenTime()) |
| | | .between(zfClean.getHappenStartTime() != null && zfClean.getHappenEndTime() != null, ZfClean::getHappenTime, zfClean.getHappenStartTime(), zfClean.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfClean::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfClean::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfClean::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(CLEAN_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(CLEAN_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfClean> selectByCondition(ZfClean zfClean) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfClean> lambdaQueryWrapper = buildCondition(zfClean, familyIds, secondFamilyIds); |
| | | List<ZfClean> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | private static List<ZfClean> markOwnData(String familyIds, List<ZfClean> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfClean zfClean, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean, familyIds, secondFamilyAuthority); |
| | | |
| | | Page<ZfClean> zfCleanPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfClean> pageResult = page(zfCleanPage, lqw); |
| | | |
| | | List<ZfClean> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfClean> dtoResult = markOwnData(familyIds, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfClean zfClean) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfClean.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfClean.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfClean)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfClean.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfClean zfClean) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfClean.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfClean.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfClean.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | if (save(zfClean)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | List<ZfClean> propertyList = null; |
| | | try { |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfClean zfClean : propertyList) { |
| | | zfCleanService.addData2(zfClean); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.ZfContact; |
| | | import com.ruoyi.domain.ZfContact; |
| | | import com.ruoyi.mapper.ZfContactMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfContactService; |
| | | import com.ruoyi.service.ZfContactService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.CONTACT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | @Slf4j |
| | | public class ZfContactServiceImpl extends ServiceImpl<ZfContactMapper, ZfContact> implements ZfContactService { |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | @Override |
| | | public AjaxResult selectContactList(ZfContact zfContact, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact); |
| | | Page<ZfContact> ZfContactPage = new Page<>(pageNum,pageSize); |
| | | Page<ZfContact> pageResult = page(ZfContactPage, lqw); |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | @Resource |
| | | ZfContactService zfContactService; |
| | | |
| | | @Override |
| | | public List<ZfContact> selectByCondition(ZfContact zfContact) { |
| | | LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact); |
| | | List<ZfContact> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}",list); |
| | | return list; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact) { |
| | | LambdaQueryWrapper<ZfContact> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getQq()),ZfContact::getQq,zfContact.getQq()); |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getTwitter()),ZfContact::getTwitter,zfContact.getTwitter()); |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getRemark()),ZfContact::getRemark,zfContact.getRemark()); |
| | | lqw.eq(zfContact.getHappenTime() != null, ZfContact::getHappenTime, zfContact.getHappenTime()); |
| | | lqw.between(zfContact.getHappenStartTime() != null && zfContact.getHappenEndTime() != null, ZfContact::getHappenTime, zfContact.getHappenStartTime(), zfContact.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfContact::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfContact::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfContact::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(CONTACT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(CONTACT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfContact> selectByCondition(ZfContact zfContact) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact, familyIds, secondFamilyIds); |
| | | List<ZfContact> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | private static List<ZfContact> markOwnData(String familyIds, List<ZfContact> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfContact zfContact, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact, familyIds, secondFamilyAuthority); |
| | | |
| | | Page<ZfContact> zfContactPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfContact> pageResult = page(zfContactPage, lqw); |
| | | |
| | | List<ZfContact> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfContact> dtoResult = markOwnData(familyIds, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfContact zfContact) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfContact.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfContact.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfContact)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfContact.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfContact zfContact) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfContact.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfContact.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfContact.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | if (save(zfContact)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | List<ZfContact> propertyList = null; |
| | | try { |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfContact zfContact : propertyList) { |
| | | zfContactService.addData2(zfContact); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.mapper.ZfEconomyMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEconomyService; |
| | |
| | | LambdaQueryWrapper<ZfEconomy> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zfEconomy.getType()!=null,ZfEconomy::getType,zfEconomy.getType()); |
| | | lqw.eq(zfEconomy.getKind()!=null,ZfEconomy::getKind,zfEconomy.getKind()); |
| | | lqw.like(zfEconomy.getCreateTime()!=null,ZfEconomy::getCreateTime,zfEconomy.getCreateTime()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getPrice()),ZfEconomy::getPrice,zfEconomy.getPrice()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getUseFor()),ZfEconomy::getUseFor,zfEconomy.getUseFor()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getUsePeople()),ZfEconomy::getUsePeople,zfEconomy.getUsePeople()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getBalance()),ZfEconomy::getBalance,zfEconomy.getBalance()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getRemark()),ZfEconomy::getRemark,zfEconomy.getRemark()); |
| | | lqw.eq(zfEconomy.getHappenTime() != null, ZfEconomy::getHappenTime, zfEconomy.getHappenTime()); |
| | | lqw.between(zfEconomy.getHappenStartTime() != null && zfEconomy.getHappenEndTime() != null, ZfEconomy::getHappenTime, zfEconomy.getHappenStartTime(), zfEconomy.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEconomy::getId); |
| | | lqw.orderByDesc(ZfEconomy::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.mapper.ZfEquipmentMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEquipmentService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.EQUIPMENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | ZfEquipmentService zfEquipmentService; |
| | | @Override |
| | | public List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment) { |
| | | String familyIds = listFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, familyIds); |
| | | List<ZfEquipment> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}", list); |
| | | return list; |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment) { |
| | | LambdaQueryWrapper<ZfEquipment> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getName()), ZfEquipment::getName, zfEquipment.getName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getBuyer()), ZfEquipment::getBuyer, zfEquipment.getBuyer()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getContent()), ZfEquipment::getContent, zfEquipment.getContent()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getLocation()), ZfEquipment::getLocation, zfEquipment.getLocation()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark()); |
| | | lqw.eq(zfEquipment.getHappenTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenTime()); |
| | | lqw.between(zfEquipment.getHappenStartTime() != null && zfEquipment.getHappenEndTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenStartTime(), zfEquipment.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | |
| | | |
| | | //------------------------------------------------------------------------------------------ |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEquipment::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEquipment::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEquipment::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(EQUIPMENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(EQUIPMENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | |
| | | @Override |
| | | public int addEquipment(ZfEquipment zfEquipment) { |
| | | public List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, familyIds, secondFamilyIds); |
| | | List<ZfEquipment> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | private static List<ZfEquipment> markOwnData(String familyIds, List<ZfEquipment> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, familyIds, secondFamilyAuthority); |
| | | |
| | | Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEquipment> pageResult = page(zfEquipmentPage, lqw); |
| | | |
| | | List<ZfEquipment> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfEquipment> dtoResult = markOwnData(familyIds, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfEquipment zfEquipment) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | |
| | | } |
| | | } |
| | | if (flag) { |
| | | boolean save = save(zfEquipment); |
| | | return save ? 1 : 0; |
| | | if (save(zfEquipment)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfEquipment.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfEquipment zfEquipment) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfEquipment.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfEquipment.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfEquipment.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | if (save(zfEquipment)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | |
| | | ExcelUtil<ZfEquipment> util = new ExcelUtil<>(ZfEquipment.class); |
| | | List<ZfEquipment> equipmentList = null; |
| | | List<ZfEquipment> propertyList = null; |
| | | try { |
| | | equipmentList = util.importExcel(file.getInputStream()); |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", equipmentList); |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfEquipment zfEquipment : equipmentList) { |
| | | zfEquipmentService.addEquipment(zfEquipment); |
| | | for (ZfEquipment zfEquipment : propertyList) { |
| | | zfEquipmentService.addData2(zfEquipment); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment) { |
| | | LambdaQueryWrapper<ZfEquipment> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getName()), ZfEquipment::getName, zfEquipment.getName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getBuyer()), ZfEquipment::getBuyer, zfEquipment.getBuyer()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getContent()), ZfEquipment::getContent, zfEquipment.getContent()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getLocation()), ZfEquipment::getLocation, zfEquipment.getLocation()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark()); |
| | | lqw.like(zfEquipment.getCreateDate() != null, ZfEquipment::getCreateDate, zfEquipment.getCreateDate()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment, String familyIds) { |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEquipment::getFamilyId,familyList); |
| | | |
| | | } else { |
| | | lqw.eq(ZfEquipment::getFamilyId, familyIds); |
| | | } |
| | | return lqw; |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | ZInfoUser zInfoUser = zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | return zInfoUser.getFamilyId(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectEquipmentList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, familyIds); |
| | | Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEquipment> pageResult = page(zfEquipmentPage, lqw); |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | | return AjaxResult.success(data); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.mapper.ZfEventMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEventService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.PROPERTY_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZfEventService zfEventService; |
| | | |
| | | private String listFamilyIds() { |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent) { |
| | | LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getAddress()), ZfEvent::getAddress, zfEvent.getAddress()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getPeople()), ZfEvent::getPeople, zfEvent.getPeople()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getTitle()), ZfEvent::getTitle, zfEvent.getTitle()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getRemark()), ZfEvent::getRemark, zfEvent.getRemark()); |
| | | lqw.eq(zfEvent.getHappenTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenTime()); |
| | | lqw.between(zfEvent.getHappenStartTime() != null && zfEvent.getHappenEndTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenStartTime(), zfEvent.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEvent::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEvent::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEvent::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(EVENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(EVENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | ZInfoUser zInfoUser = zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | return zInfoUser.getFamilyId(); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult selectEventList(ZfEvent zfEvent, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent, familyIds); |
| | | |
| | | Page<ZfEvent> ZfEventPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEvent> pageResult = page(ZfEventPage, lqw); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | | return AjaxResult.success(data); |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfEvent> selectByCondition(ZfEvent zfEvent) { |
| | | String familyIds = listFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent, familyIds); |
| | | List<ZfEvent> list = list(lqw); |
| | | log.info("返回的数据为:{}", list); |
| | | return list; |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lambdaQueryWrapper = buildCondition(zfEvent, familyIds, secondFamilyIds); |
| | | List<ZfEvent> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | private static List<ZfEvent> markOwnData(String familyIds, List<ZfEvent> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public int addEvent(ZfEvent zfEvent) { |
| | | public AjaxResult selectDataList(ZfEvent zfEvent, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent, familyIds, secondFamilyAuthority); |
| | | |
| | | Page<ZfEvent> zfEventPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEvent> pageResult = page(zfEventPage, lqw); |
| | | |
| | | List<ZfEvent> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfEvent> dtoResult = markOwnData(familyIds, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfEvent zfEvent) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | |
| | | } |
| | | } |
| | | if (flag) { |
| | | boolean save = save(zfEvent); |
| | | return save ? 1 : 0; |
| | | if (save(zfEvent)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfEvent.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfEvent zfEvent) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfEvent.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfEvent.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfEvent.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | if (save(zfEvent)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | List<ZfEvent> eventList = null; |
| | | List<ZfEvent> propertyList = null; |
| | | try { |
| | | eventList = util.importExcel(file.getInputStream()); |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", eventList); |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfEvent zfEvent : eventList) { |
| | | zfEventService.addEvent(zfEvent); |
| | | for (ZfEvent zfEvent : propertyList) { |
| | | zfEventService.addData2(zfEvent); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent) { |
| | | LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getAddress()), ZfEvent::getAddress, zfEvent.getAddress()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getPeople()), ZfEvent::getPeople, zfEvent.getPeople()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getTitle()), ZfEvent::getTitle, zfEvent.getTitle()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getRemark()), ZfEvent::getRemark, zfEvent.getRemark()); |
| | | lqw.eq(zfEvent.getHappenTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenTime()); |
| | | lqw.between(zfEvent.getHappenStartTime() != null && zfEvent.getHappenEndTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenStartTime(), zfEvent.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent, String familyIds) { |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEvent::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEvent::getFamilyId, familyIds); |
| | | } |
| | | return lqw; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |