瀏覽代碼

用户角色修改

chenjiasheng 3 年之前
父節點
當前提交
679d37a9ca

+ 28 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/FundsManagementEndpoint.java

@ -1,22 +1,33 @@
package com.yihu.jw.base.endpoint.a4endpoint;
import com.yihu.jw.base.service.a3service.MedicineOrderService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/Funds")
@Api(value = "资金管理", description = "资金管理", tags = {"资金管理--对账单"})
public class FundsManagementEndpoint extends EnvelopRestEndpoint {
    @Autowired
    MedicineOrderService medicineOrderService;
    @ApiOperation(value = "对账单")
    @GetMapping("/reconciliation")
    public Envelop reconciliation(@ApiParam(name="belongCommunity",value = "社区编码",required = false)
@ -24,7 +35,21 @@ public class FundsManagementEndpoint extends EnvelopRestEndpoint {
                                  @ApiParam(name = "equNum" ,value = "设备编码" ,required = false)
                                  @RequestParam(value = "equNum",required = false)String equNum,
                                  @ApiParam(name = "startTime" ,value = "开始时间",required = false)
                                  @RequestParam(value = "startTime" ,required = false)Date startTime){
        return null;
                                  @RequestParam(value = "startTime" ,required = false)String startTime,
                                  @ApiParam(name = "endTime",value = "截止时间",required = false)
                                  @RequestParam(value = "endTime",required = false)String endTime,
                                  HttpServletResponse response){
        MixEnvelop expressages = null;
        try {
            expressages = medicineOrderService.getSumAmount(belongCommunity,equNum,startTime,endTime);
            List<Map<String, Object>> list = expressages.getDetailModelList();
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("pushDataList.xls".getBytes("utf-8"), "iso8859-1"));
            OutputStream os = response.getOutputStream();
            medicineOrderService.pushListWrite(os, list);
            return success(expressages);
        } catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 81 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java

@ -13,15 +13,22 @@ import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import jxl.format.VerticalAlignment;
import jxl.write.*;
import org.apache.commons.collections4.IterableUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Boolean;
import java.util.*;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@ -1474,4 +1481,78 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        result.put("msg", jsonObject);
        return result;
    }
    public MixEnvelop getSumAmount(String belongCommunity, String equNum, String startTime, String endTime) {
        List<Map<String,Object>> arrayList=new ArrayList<>();
        List<Map<String,Object>> mapList=new ArrayList<>();
        Iterable <Mediicinedevice> mediicinedevices = deviceDao.findAll();
        List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
        for (Mediicinedevice mediicinedevice:mediicinedeviceList){
            String sql = "SELECT SUM(t.amount) AS sumAmount,\n" +
                    "a.community AS community,\n" +
                    "a.equ_name AS equName,\n" +
                    "COUNT(*) AS count,\n" +
                    "t.shipping_equ AS equNum \n" +
                    "FROM t_mediicine_order AS t,\n" +
                    "t_mediicine_device AS a \n" +
                    "WHERE t.shipping_equ = a.equ_num AND t.sell_state = 1 " +
                    "AND 1=1";
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
                sql += "AND a.belong_community ='"+belongCommunity+"'";
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
                sql += "AND t.shipping_equ = '" + equNum + "'";
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
                sql += "AND t.shipping_time >= "+ startTime  ;
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
                sql += "AND t.shipping_time <= "+ endTime ;
            }
//        sql += "GROUP BY t.shipping_equ";
            sql +="AND t.shipping_equ = '" + mediicinedevice.getEquNum()+"'";
            Map<String,Object> result=new HashMap<>();
            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
            result.put("msg",list);
            mapList.add(result);
        }
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
    }
    public void pushListWrite(OutputStream os, List<Map<String, Object>> list)throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet sheet;
            sheet = wwb.createSheet("sheet", 1);
            String header[] = {"社区", "设备名/设备编号", "历史订单", "总销售额"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            for (Map<String, Object> tmp : list) {
                addCell(sheet, j, 0, tmp.get("community")==null ? "" : tmp.get("community").toString());
                addCell(sheet, j, 1, tmp.get("equName") == null? "" : tmp.get("drugTypeCode").toString()+(tmp.get("equNum")==null?"":tmp.get("equNum")));
                addCell(sheet, j, 2, tmp.get("count") == null ? "" : tmp.get("count").toString());
                addCell(sheet, j, 3, tmp.get("sumAmount") == null ? "" :tmp.get("sumAmount").toString());
                j++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }
}

+ 46 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -890,6 +890,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
     */
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        List<String>roleList=new ArrayList();
   /*     int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
        String realName = null == name ? "" : name;
@ -951,6 +952,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                "\t\t\tusr .username AS \"username\",\n" +
                "\t\t\tusr .update_time AS \"updateTime\",\n" +
                "\t\t\tusr .create_time AS \"createTime\",\n" +
                "\t\t\tusr .role_id AS \"roleId\",\n" +
                "\t\t\tCASE \n" +
                "\t\tWHEN usr .enabled=0 THEN\n" +
                "\t\t\t'已失效'\n" +
@ -959,14 +961,14 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                "\t\tEND  AS \"enabled\",\n" +
                "\t\tusr .mobile AS \"mobile\",\n" +
                "\t\tsaas. NAME AS \"saasName\",\n" +
                "\t\tROLE . NAME AS \"roleName\"\n" +
//                "\t\tROLE . NAME AS \"roleName\"\n" +
                "\tFROM\n" +
                "\t\tbase_user usr,\n" +
                "\t\tbase_saas saas,\n" +
                "\t\tbase_role ROLE\n" +
//                "\t\tbase_role ROLE\n" +
                "\tWHERE\n" +
                "\t\tusr .saas_id = saas. ID\n" +
                "\tAND usr .role_id = ROLE . ID\n" ;
                "\t\tusr .saas_id = saas. ID\n" ;
//                "\tAND usr .role_id = ROLE . ID\n" ;
                if(!realName.equals(null) && !realName.equals("")){
                    finalSql = finalSql + " and usr . NAME LIKE '%"+realName+"%'";
                }
@ -996,6 +998,19 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                        areaDOList = userAreaDao.findAllByUserId(id);
                        map.put("area",areaDOList);
                    }
                    if (map.get("roleId")!=null){
                        if (map.get("roleId").toString().contains(",")){
                            String[] roleIds=map.get("roleId").toString().split(",");
                            for (String role:roleIds){
                                RoleDO roleDO=roleDao.findOne(role);
                                roleList.add(roleDO.getName());
                            }
                        }else {
                            RoleDO roleDO=roleDao.findOne(map.get("roleId").toString());
                            roleList.add(roleDO.getName());
                        }
                        map.put("roleName",roleList);
                    }
                }
            }else {
                String oracleSql="SELECT\n" +
@ -1023,7 +1038,21 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                        areaDOList = userAreaDao.findAllByUserId(id);
                        map.put("area",areaDOList);
                    }
                    if (map.get("roleId")!=null){
                        if (map.get("roleId").toString().contains(",")){
                            String[] roleIds=map.get("roleId").toString().split(",");
                            for (String role:roleIds){
                                RoleDO roleDO=roleDao.findOne(role);
                                roleList.add(roleDO.getName());
                            }
                        }else {
                            RoleDO roleDO=roleDao.findOne(map.get("roleId").toString());
                            roleList.add(roleDO.getName());
                        }
                        map.put("roleName",roleList);
                    }
                }
            }
        }else {
@ -1036,6 +1065,19 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                    areaDOList = userAreaDao.findAllByUserId(id);
                    map.put("area",areaDOList);
                }
                if (map.get("roleId")!=null){
                    if (map.get("roleId").toString().contains(",")){
                        String[] roleIds=map.get("roleId").toString().split(",");
                        for (String role:roleIds){
                            RoleDO roleDO=roleDao.findOne(role);
                            roleList.add(roleDO.getName());
                        }
                    }else {
                        RoleDO roleDO=roleDao.findOne(map.get("roleId").toString());
                        roleList.add(roleDO.getName());
                    }
                    map.put("roleName",roleList);
                }
            }
        }