zjh
昨天 9597821e57d4bad1ea4e984241f363be956dda8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.ltkj.web.controller.system;
 
import java.security.Security;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.service.ITjCustomerService;
import com.ltkj.hosp.service.ITjOrderService;
import com.ltkj.system.service.ISysUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.core.controller.BaseController;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.system.domain.TjDjdDyjl;
import com.ltkj.system.service.ITjDjdDyjlService;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
 
/**
 * 体检导检单打印记录Controller
 *
 * @author ltkj
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/system/dyjl")
@Api(tags = "B-体检导检单打印记录接口")
@Slf4j
public class TjDjdDyjlController extends BaseController {
    @Autowired
    private ITjDjdDyjlService tjDjdDyjlService;
    @Resource
    private ITjOrderService orderService;
    @Resource
    private ITjCustomerService customerService;
    @Autowired
    private ISysUserService userService;
 
/**
 * 查询体检导检单打印记录列表
 */
@PreAuthorize("@ss.hasPermi('system:dyjl:list')")
@GetMapping("/list")
    public TableDataInfo list(TjDjdDyjl tjDjdDyjl) {
        startPage();
        List<TjDjdDyjl> list = tjDjdDyjlService.selectTjDjdDyjlList(tjDjdDyjl);
        return getDataTable(list);
    }
 
    /**
     * 导出体检导检单打印记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dyjl:export')")
    @Log(title = "体检导检单打印记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TjDjdDyjl tjDjdDyjl) {
        List<TjDjdDyjl> list = tjDjdDyjlService.selectTjDjdDyjlList(tjDjdDyjl);
        ExcelUtil<TjDjdDyjl> util = new ExcelUtil<TjDjdDyjl>(TjDjdDyjl. class);
        util.exportExcel(response, list, "体检导检单打印记录数据");
    }
 
    /**
     * 获取体检导检单打印记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dyjl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tjDjdDyjlService.selectTjDjdDyjlById(id));
    }
 
    /**
     * 新增体检导检单打印记录
     */
    @PreAuthorize("@ss.hasPermi('system:dyjl:add')")
    @Log(title = "体检导检单打印记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TjDjdDyjl tjDjdDyjl) {
        return toAjax(tjDjdDyjlService.insertTjDjdDyjl(tjDjdDyjl));
    }
 
    /**
     * 修改体检导检单打印记录
     */
    @PreAuthorize("@ss.hasPermi('system:dyjl:edit')")
    @Log(title = "体检导检单打印记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TjDjdDyjl tjDjdDyjl) {
        return toAjax(tjDjdDyjlService.updateTjDjdDyjl(tjDjdDyjl));
    }
 
    /**
     * 删除体检导检单打印记录
     */
    @PreAuthorize("@ss.hasPermi('system:dyjl:remove')")
    @Log(title = "体检导检单打印记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tjDjdDyjlService.deleteTjDjdDyjlByIds(ids));
    }
 
 
    @PostMapping("/saveGjddyjl")
    public AjaxResult saveGjddyjl(@RequestBody JSONObject json) {
 
        log.info("===================记录打印====================");
        log.info(json.toJSONString());
 
        String tjNumber = json.getString("tjNumber");
        String dqdlr = json.getString("dqdlr");
        SysUser user = userService.getById(dqdlr);
 
        TjOrder order = orderService.getOrderByTjNum(tjNumber);
        if(null !=order){
            TjCustomer customer = customerService.getById(order.getUserId());
//            String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
            Date date=new Date();
            LambdaQueryWrapper<TjDjdDyjl>wq=new LambdaQueryWrapper<>();
            wq.eq(TjDjdDyjl::getTjNum,tjNumber);
            wq.eq(TjDjdDyjl::getDylx,"0");
            TjDjdDyjl dyjl = tjDjdDyjlService.getOne(wq);
            if(null !=dyjl){
                Long dycs = dyjl.getDycs();
                dycs+=1;
                dyjl.setDycs(dycs);
                dyjl.setDysj(date);
                dyjl.setCreateBy(user.getNickName());
                dyjl.setUpdateTime(date);
                tjDjdDyjlService.updateById(dyjl);
                return AjaxResult.success();
            }
            TjDjdDyjl djdDyjl=new TjDjdDyjl();
            djdDyjl.setTjNum(tjNumber);
            djdDyjl.setDylx("0");
            djdDyjl.setCardId(order.getCardId());
            djdDyjl.setHzxm(customer.getCusName());
            djdDyjl.setCreateBy(user.getNickName());
            djdDyjl.setCreateTime(date);
            djdDyjl.setDysj(date);
            tjDjdDyjlService.save(djdDyjl);
            return AjaxResult.success();
 
        }
        return AjaxResult.error();
    }
 
    @PostMapping("/saveBlGjddyjl")
    public AjaxResult saveBlGjddyjl(@RequestBody JSONObject json) {
 
        log.info("===================记录打印====================");
        log.info(json.toJSONString());
 
        String tjNumber = json.getString("tjNumber");
        String dqdlr = json.getString("dqdlr");
        SysUser user = userService.getById(dqdlr);
 
        TjOrder order = orderService.getOrderByTjNum(tjNumber);
        if(null !=order){
            TjCustomer customer = customerService.getById(order.getUserId());
//            String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
            Date date=new Date();
            LambdaQueryWrapper<TjDjdDyjl>wq=new LambdaQueryWrapper<>();
            wq.eq(TjDjdDyjl::getTjNum,tjNumber);
            wq.eq(TjDjdDyjl::getDylx,"1");
            TjDjdDyjl dyjl = tjDjdDyjlService.getOne(wq);
            if(null !=dyjl){
                Long dycs = dyjl.getDycs();
                dycs+=1;
                dyjl.setDycs(dycs);
                dyjl.setDysj(date);
                dyjl.setCreateBy(user.getNickName());
                dyjl.setUpdateTime(date);
                tjDjdDyjlService.updateById(dyjl);
                return AjaxResult.success();
            }
            TjDjdDyjl djdDyjl=new TjDjdDyjl();
            djdDyjl.setTjNum(tjNumber);
            djdDyjl.setDylx("1");
            djdDyjl.setCardId(order.getCardId());
            djdDyjl.setHzxm(customer.getCusName());
            djdDyjl.setCreateBy(user.getNickName());
            djdDyjl.setCreateTime(date);
            djdDyjl.setDysj(date);
            tjDjdDyjlService.save(djdDyjl);
            return AjaxResult.success();
 
        }
        return AjaxResult.error();
    }
}