Przeglądaj źródła

出库保存后可编辑,上下限增加导出,打印调整

WANGJIALIANG 2 lat temu
rodzic
commit
3f8e0aa4e7

+ 100 - 7
src/main/java/cn/hnthyy/thmz/Utils/ExcelUtil.java

@@ -8,10 +8,7 @@ import cn.hnthyy.thmz.entity.his.mz.MzyReqrec;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
 import cn.hnthyy.thmz.entity.thmz.Mzmxsr;
 import cn.hnthyy.thmz.enums.YesNoEnum;
-import cn.hnthyy.thmz.vo.ChargeFeeVo;
-import cn.hnthyy.thmz.vo.MzyReqrecVo;
-import cn.hnthyy.thmz.vo.ReqrecVo;
-import cn.hnthyy.thmz.vo.YpZdBaseVo;
+import cn.hnthyy.thmz.vo.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.poi.hssf.usermodel.HSSFDataFormat;
@@ -113,13 +110,25 @@ public class ExcelUtil {
      *
      * @param request
      * @param response
-     * @param YpZdBaseVos
+     * @param ypZdBaseVos
      */
-    public static void exportExcelForYfInventoryList(HttpServletRequest request, HttpServletResponse response, List<YpZdBaseVo> YpZdBaseVos) {
-        Map<String, Object> data = fomartYfInventoryList(YpZdBaseVos);
+    public static void exportExcelForYfInventoryList(HttpServletRequest request, HttpServletResponse response, List<YpZdBaseVo> ypZdBaseVos) {
+        Map<String, Object> data = fomartYfInventoryList(ypZdBaseVos);
         exportYfInventoryListExcel(request, response, data, YP_YFKCQD_REPORT_COLUMNS_LENGTH, VERSION_2007);
     }
 
+    /**
+     * 将药品上下限对象转换为导出Excel
+     *
+     * @param request
+     * @param response
+     * @param ypBaseBoundVos
+     */
+    public static void exportExcelForYpBaseBound(HttpServletRequest request, HttpServletResponse response, List<YpBaseBoundVo> ypBaseBoundVos) {
+        Map<String, Object> data = fomartYpBaseBoundList(ypBaseBoundVos);
+        exportExcel(request, response, data, YP_YFKCQD_REPORT_COLUMNS_LENGTH, VERSION_2007);
+    }
+
     /**
      * 将门诊收入明细列表对象转换为导出Excel
      *
@@ -228,6 +237,45 @@ public class ExcelUtil {
         }
     }
 
+    /**
+     * 方法名:exportYfInventoryListExcel
+     * 功能:导出Excel
+     */
+    public static byte[] exportYpBaseBoundListExcel(HttpServletRequest request, HttpServletResponse response, Map<String, Object> data, Integer columns, Integer version) {
+        if (data == null) {
+            return null;
+        }
+        log.info("导出解析开始,fileName:{}", data.get(FILE_NAME_KEY));
+        try {
+            //实例化HSSFWorkbook
+            //HSSFWorkbook workbook = new HSSFWorkbook();
+            Workbook workbook = null;
+            if (version.equals(VERSION_2007)) {
+                workbook = new XSSFWorkbook();// 创建 一个excel文档对象
+            } else if (version.equals(VERSION_2003)) {
+                workbook = new HSSFWorkbook();// 创建 一个excel文档对象
+            }
+            //创建一个Excel表单,参数为sheet的名字
+            Sheet sheet = workbook.createSheet(SHEET_NAME);
+            //设置表头
+            setYfInventoryListTitle(workbook, sheet, (List<Map<String, Object>>) data.get(HEAD_KEY), columns);
+            //设置单元格并赋值
+            setYfInventoryListData(workbook, sheet, (List<String[]>) data.get(DATA_KEY), ((List<Map<String, Object>>) data.get(HEAD_KEY)).size());
+            log.info("导出解析成功!");
+            if (request != null && response != null) {
+                //设置浏览器下载
+                setBrowser(request, response, workbook, (String) data.get(FILE_NAME_KEY));
+                return null;
+            } else {
+                // return createFile(workbook,(String) data.get(FILE_NAME_KEY));
+                return createFile(workbook);
+            }
+        } catch (Exception e) {
+            log.info("导出解析失败!错误信息{}", e.getMessage());
+            return null;
+        }
+    }
+
     /**
      * 方法名:setTitle
      * 功能:设置表头
@@ -805,6 +853,51 @@ public class ExcelUtil {
         return data;
     }
 
+    /**
+     * 将上下限清单对象转换为导出Excel  表格内容的格式
+     *
+     * @param ypBaseBoundVos
+     * @return
+     */
+    private static Map<String, Object> fomartYpBaseBoundList(List<YpBaseBoundVo> ypBaseBoundVos) {
+        if (ypBaseBoundVos == null) {
+            return Collections.emptyMap();
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+        Map<String, Object> data = new HashMap<>();
+        data.put(FILE_NAME_KEY, "上下限清单" + simpleDateFormat.format(new Date()) + ".xls");
+        List<Map<String, Object>> heads = new ArrayList<>();
+        Map<String, Object> map0 = new HashMap<>();
+        String[] head0 = {"药品编码", "药品名称", "规格", "库存上限", "库存下限", "药库库存", "制药厂", "7天用量", "14天用量", "30天用量", "60天用量", "预计可用天数", "供应商"};
+        String[] headNum0 = {"0,0,0,0"};
+        map0.put(HEAD_ARR_KEY, head0);
+        map0.put(HEAD_NUM_KEY, headNum0);
+        heads.add(map0);
+        data.put(HEAD_KEY, heads);
+        List<String[]> arr = new ArrayList<>();
+        ypBaseBoundVos.forEach(ypBaseBoundVo -> {
+            if (ypBaseBoundVo != null) {
+                String[] temp = {ypBaseBoundVo.getChargeCode(),
+                        ypBaseBoundVo.getName(),
+                        ypBaseBoundVo.getSpecification(),
+                        String.format("%.2f", ypBaseBoundVo.getMaxStockAmount()==null?0:ypBaseBoundVo.getMaxStockAmount()),
+                        String.format("%.2f", ypBaseBoundVo.getMiniStockAmount()==null?0:ypBaseBoundVo.getMiniStockAmount()),
+                        String.format("%.2f", ypBaseBoundVo.getStockAmount()),
+                        ypBaseBoundVo.getManufactoryName(),
+                        String.format("%.2f", ypBaseBoundVo.getSevenDayDosage()),
+                        String.format("%.2f", ypBaseBoundVo.getFourteenDayDosage()),
+                        String.format("%.2f", ypBaseBoundVo.getThirtyDayDosage()),
+                        String.format("%.2f", ypBaseBoundVo.getSixtyDayDosage()),
+                        String.format("%.2f", ypBaseBoundVo.getAvailableDay()),
+                        ypBaseBoundVo.getZbSupplyerName()
+                };
+                arr.add(temp);
+            }
+        });
+        data.put(DATA_KEY, arr);
+        return data;
+    }
+
 
     /**
      * 将核酸申请对象转换为导出Excel  表格内容的格式

+ 28 - 0
src/main/java/cn/hnthyy/thmz/controller/yf/YfDrugApplyController.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.controller.yf;
 
+import cn.hnthyy.thmz.Utils.ExcelUtil;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.yp.*;
@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -333,6 +335,32 @@ public class YfDrugApplyController {
         }
     }
 
+    /**
+     * 导出上下限清单Excel
+     *
+     * @param groupNo
+     * @return
+     */
+    @RequestMapping(value = "/excelYpBaseBound", method = {RequestMethod.GET})
+    public Map<String, Object> excelYpBaseBound(@RequestParam("chargeCode") String chargeCode, @RequestParam("groupNo") String groupNo,
+                                                @RequestParam("beyondFlag") String beyondFlag, @RequestParam("visibleFlag") String visibleFlag, PageBean pageBean
+                                                , HttpServletRequest request, HttpServletResponse response){
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            List<YpBaseBoundVo> ypBaseBoundVos = yfDrugApplyService.queryYpBaseBoundPage(chargeCode, groupNo, beyondFlag, visibleFlag, pageBean);
+            ExcelUtil.exportExcelForYpBaseBound(request, response, ypBaseBoundVos);
+            resultMap.put("code", 0);
+            resultMap.put("message", "导出成功");
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("导出失败,错误信息{}", e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "导出失败");
+            return resultMap;
+        }
+    }
+
     /**
      * 修改药品上下限
      *

+ 6 - 6
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpInDetlMapper.java

@@ -19,7 +19,7 @@ public interface YpInDetlMapper {
      * @return
      */
     @Select("<script>" +
-            "select manu_code,rtrim(manu_no)manu_no,rtrim(in_docu_no)in_docu_no,in_seri,charge_code,buy_price,avg_price,buy_amt,group_no,serial," +
+            "select manu_code,rtrim(manu_no)manu_no,rtrim(in_docu_no)in_docu_no,in_seri,rtrim(charge_code)charge_code,buy_price,avg_price,buy_amt,group_no,serial," +
             " supply_code,eff_date,current_stock,in_date from yp_in_detl WITH(NOLOCK) " +
             "<where>" +
             "   <if test=\"chargeCode != null and chargeCode != ''\">" +
@@ -134,7 +134,7 @@ public interface YpInDetlMapper {
     @Select("<script>" +
             "SELECT in_date," +
             "       in_seri," +
-            "       charge_code," +
+            "       rtrim(charge_code)charge_code," +
             "       serial," +
             "       pack_retprice," +
             "       buy_price," +
@@ -214,7 +214,7 @@ public interface YpInDetlMapper {
             " from (select ROW_NUMBER() OVER (ORDER BY in_docu_no DESC)AS RowNumber," +
             " in_date, " +
             " in_seri, " +
-            " charge_code, " +
+            " rtrim(charge_code)charge_code, " +
             " serial, " +
             " pack_retprice, " +
             " buy_price, " +
@@ -461,7 +461,7 @@ public interface YpInDetlMapper {
      * @return
      */
     @Select("<script>"+
-            "SELECT in_date,in_seri,charge_code,serial,pack_retprice," +
+            "SELECT in_date,in_seri,rtrim(charge_code)charge_code,serial,pack_retprice," +
             "       buy_price,buy_amt, eff_date, manu_no," +
             "       rept_no,rtrim(in_docu_no)in_docu_no,supply_code,manu_code," +
             "       license_no,purchaser,checker,in_comment," +
@@ -526,7 +526,7 @@ public interface YpInDetlMapper {
      * @return
      */
     @Select("<script>"+
-            "SELECT chargeCode=charge_code," +
+            "SELECT chargeCode=rtrim(charge_code)," +
             "       serial," +
             "       buyAmt = sum(buy_amt),\n" +
             "       packRetpriceSum = sum(buy_amt *convert(decimal(18,4), pack_retprice)),\n" +
@@ -589,7 +589,7 @@ public interface YpInDetlMapper {
      * @return
      */
     @Select("<script>"+
-            "SELECT chargeCode=charge_code," +
+            "SELECT chargeCode=rtrim(charge_code)," +
             "       serial," +
             "       buyAmt = sum(buy_amt),\n" +
             "       packRetpriceSum = sum(buy_amt *convert(decimal(18,4), pack_retprice)),\n" +

+ 4 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpInDetlYfMapper.java

@@ -42,7 +42,7 @@ public interface YpInDetlYfMapper {
             " select top ${rows} *" +
             " from (select ROW_NUMBER() over (order by in_date desc) as RowNumber," +
             " in_date,rept_no,supply_code,in_docu_no,purchaser,confirm_id,confirm_date,acct_id,acct_date,input_id," +
-            "       sys_date,charge_code,serial,pack_retprice,buy_price,buy_amt,stock_amount,eff_date,manu_code,manu_no," +
+            "       sys_date,rtrim(charge_code)charge_code,serial,pack_retprice,buy_price,buy_amt,stock_amount,eff_date,manu_code,manu_no," +
             "       current_stock,fp_date,kl,in_comment,license_no,in_seri,in_type,plan_no" +
             " FROM yp_in_detl_yf a WITH(NOLOCK) where 1=1 " +
             "<when test='ypInDetlYf.beginTime != null'>" +
@@ -94,7 +94,7 @@ public interface YpInDetlYfMapper {
             "       a.acct_id,\n" +
             "       a.acct_date,\n" +
             "       a.sys_date,\n" +
-            "       a.charge_code,\n" +
+            "       rtrim(a.charge_code)charge_code,\n" +
             "       a.serial,\n" +
             "       a.pack_retprice,\n" +
             "       a.buy_price,\n" +
@@ -160,7 +160,7 @@ public interface YpInDetlYfMapper {
     @Select("<script>" +
             "SELECT\n" +
             "  a.in_date,\n" +
-            "  a.charge_code,\n" +
+            "  rtrim(a.charge_code)charge_code,\n" +
             "  a.serial,\n" +
             "  a.in_seri,\n" +
             "  a.current_stock,\n" +
@@ -203,7 +203,7 @@ public interface YpInDetlYfMapper {
     @Select("<script>" +
             "SELECT\n" +
             "  a.in_date,\n" +
-            "  a.charge_code,\n" +
+            "  rtrim(a.charge_code)charge_code,\n" +
             "  a.serial,\n" +
             "  a.in_seri,\n" +
             "  a.current_stock,\n" +

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpInPlanMapper.java

@@ -158,7 +158,7 @@ public interface YpInPlanMapper {
      * @return
      */
     @Select({"<script>",
-            "SELECT plan_date,plan_seri,charge_code,serial,group_no,group_yk,amount,amount_out,drawer,status_flag,draw_no,confirm_id,confirm_date,input_id,sys_date FROM yp_in_plan WITH(NOLOCK) " +
+            "SELECT plan_date,plan_seri,rtrim(charge_code)charge_code,serial,group_no,group_yk,amount,amount_out,drawer,status_flag,draw_no,confirm_id,confirm_date,input_id,sys_date FROM yp_in_plan WITH(NOLOCK) " +
                     "<where>" +
                     "   draw_no = #{drawNo}" +
                     "   <if test=\"chargeCode != null and chargeCode != ''\">" +
@@ -182,7 +182,7 @@ public interface YpInPlanMapper {
     @Update({"<script>",
             "update yp_in_plan ",
             "<trim prefix='set' prefixOverrides=','>",
-            "<when test=\"amountOut != null and amountOut != ''\">",
+            "<when test=\"amountOut != null\">",
             ",amount_out =#{amountOut}",
             "</when>",
             "<when test=\"statusFlag != null and statusFlag != ''\">",

+ 31 - 3
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpOutDetlMapper.java

@@ -119,7 +119,7 @@ public interface YpOutDetlMapper {
     @Select("<script>" +
             "select dept_code,input_id,confirm_flag,confirm_id,confirm_date,out_date,draw_no,eff_date,draw_yf,stock_amount," +
             "       drawer,serial,out_amt,out_seri,pack_retprice,manu_no," +
-            "       fix_price,acct_sign,buy_price,charge_code,group_no_out,group_no,in_draw_no,in_seri,accept_sign,keeper,out_amt as new_out_amt" +
+            "       fix_price,acct_sign,buy_price,rtrim(charge_code)charge_code,group_no_out,group_no,in_draw_no,in_seri,accept_sign,keeper,out_amt as new_out_amt" +
             " from yp_out_detl WITH(NOLOCK)" +
             "<where>" +
             "   <if test=\"drawNo != null and drawNo != ''\">" +
@@ -143,7 +143,7 @@ public interface YpOutDetlMapper {
      */
     @Select("<script>" +
             "select dept_code,input_id,confirm_flag,confirm_id,confirm_date,out_date,draw_no,draw_yf,\n" +
-            "  drawer,serial,sum(out_amt)out_amt,pack_retprice,fix_price,acct_sign,buy_price,charge_code,group_no_out,\n" +
+            "  drawer,serial,sum(out_amt)out_amt,pack_retprice,fix_price,acct_sign,buy_price,rtrim(charge_code)charge_code,group_no_out,\n" +
             "  group_no,accept_sign,keeper" +
             " from yp_out_detl WITH(NOLOCK)" +
             "<where>" +
@@ -169,7 +169,7 @@ public interface YpOutDetlMapper {
      */
     @Select("<script>" +
             "select dept_code,input_id,confirm_flag,confirm_id,confirm_date,out_date,draw_no,draw_yf,in_draw_no,\n" +
-            "  drawer,serial,out_amt,pack_retprice,fix_price,acct_sign,buy_price,charge_code,group_no_out,\n" +
+            "  drawer,serial,out_amt,pack_retprice,fix_price,acct_sign,buy_price,rtrim(charge_code)charge_code,group_no_out,\n" +
             "  group_no,accept_sign,keeper" +
             " from yp_out_detl WITH(NOLOCK)" +
             "<where>" +
@@ -233,6 +233,17 @@ public interface YpOutDetlMapper {
     @Delete("delete from yp_out_detl where draw_yf=#{drawYf,jdbcType=VARCHAR}")
     int deleteByDrawYf(@Param("drawYf") String drawYf);
 
+    /**
+     * 删除出库单药品确认记录
+     *
+     * @param drawNo
+     * @param chargeCode
+     * @param serial
+     * @return
+     */
+    @Delete("delete from yp_out_detl where draw_no=#{drawNo,jdbcType=VARCHAR} and charge_code=#{chargeCode,jdbcType=VARCHAR} and serial=#{serial,jdbcType=VARCHAR}")
+    int deleteYpOutDetl(@Param("drawNo") String drawNo, @Param("chargeCode") String chargeCode, @Param("serial") String serial);
+
     /**
      * 更新出库单信息
      *
@@ -256,11 +267,17 @@ public interface YpOutDetlMapper {
             "<when test='confirmDate!=null'>",
             ",confirm_date =#{confirmDate}",
             "</when>",
+            "<when test='outAmt!=null'>",
+            ",out_amt =#{outAmt}",
+            "</when>",
             "</trim>",
             "<where>" +
             "   <if test=\"drawNo != null and drawNo != ''\">" +
             "        AND draw_no = #{drawNo}" +
             "   </if>" +
+            "   <if test=\"inDrawNo != null and inDrawNo != ''\">" +
+            "        AND in_draw_no = #{inDrawNo}" +
+            "   </if>" +
             "   <if test=\"outSeri != null and outSeri != ''\">" +
             "        AND out_seri = #{outSeri}" +
             "   </if>" +
@@ -270,6 +287,9 @@ public interface YpOutDetlMapper {
             "   <if test=\"serial != null and serial != ''\">" +
             "        AND serial = #{serial}" +
             "   </if>" +
+            "   <if test=\"inSeri != null and inSeri != ''\">" +
+            "        AND in_seri = #{inSeri}" +
+            "   </if>" +
             "</where>" +
             "</script>"})
     int updateYpOutDetl(YpOutDetl ypOutDetl);
@@ -282,6 +302,14 @@ public interface YpOutDetlMapper {
     @Select("select top 1 accept_sign from yp_out_detl WITH(NOLOCK) where draw_no =#{drawNo}")
     int selectAcceptSign(@Param("drawNo") String drawNo);
 
+    /**
+     * 查询出库单对应的请领单
+     * @param drawNo 出库单
+     * @return
+     */
+    @Select("select draw_yf from yp_out_detl where draw_no=#{drawNo} and draw_yf is not null group by draw_yf")
+    String selectDrawYf(@Param("drawNo") String drawNo);
+
     /**
      * 查询可退库的药品
      * @param ypOutDetl

+ 16 - 14
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfDrugApplyServiceImpl.java

@@ -50,21 +50,23 @@ public class YfDrugApplyServiceImpl implements YfDrugApplyService {
         List<YpBaseBoundVo> ypBaseBoundVos = yfDrugApplyMapper.selectYpBaseBoundPage(chargeCode, groupNo, beyondFlag, visibleFlag, pageBean);
         ypBaseBoundVos.forEach(ypBaseBoundVo -> {
             YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypBaseBoundVo.getChargeCode(), ypBaseBoundVo.getSerial());
-            if(StringUtils.isNotBlank(ypZdDict.getManuCode())){
-                String manu = ypZdManufactoryMapper.selectYpZdManufactoryByCode(ypZdDict.getManuCode());
-                ypBaseBoundVo.setManufactoryName(manu);
+            if(ypZdDict != null){
+                if(StringUtils.isNotBlank(ypZdDict.getManuCode())){
+                    String manu = ypZdManufactoryMapper.selectYpZdManufactoryByCode(ypZdDict.getManuCode());
+                    ypBaseBoundVo.setManufactoryName(manu);
+                }
+                if(StringUtils.isNotBlank(ypZdDict.getZbSupplyer())){
+                    String supplyer = ypZdSupplyMapper.selectNameByCode(ypZdDict.getZbSupplyer());
+                    ypBaseBoundVo.setZbSupplyerName(supplyer);
+                }
+                String code = ypBaseBoundVo.getChargeCode();
+                YpBaseBoundVo ypBaseBoundSum = yfDrugApplyMapper.selectSumQuantity(code);
+                ypBaseBoundVo.setSevenDayDosage(ypBaseBoundSum.getSevenDayDosage());
+                ypBaseBoundVo.setThirtyDayDosage(ypBaseBoundSum.getThirtyDayDosage());
+                ypBaseBoundVo.setSixtyDayDosage(ypBaseBoundSum.getSixtyDayDosage());
+                ypBaseBoundVo.setFourteenDayDosage(ypBaseBoundSum.getFourteenDayDosage());
+                ypBaseBoundVo.setAvailableDay(Double.parseDouble(ypBaseBoundVo.getSevenDayDosage()==0?"0":ypBaseBoundVo.getStockAmount()/ypBaseBoundVo.getSevenDayDosage()+""));
             }
-            if(StringUtils.isNotBlank(ypZdDict.getZbSupplyer())){
-                String supplyer = ypZdSupplyMapper.selectNameByCode(ypZdDict.getZbSupplyer());
-                ypBaseBoundVo.setZbSupplyerName(supplyer);
-            }
-            String code = ypBaseBoundVo.getChargeCode();
-            YpBaseBoundVo ypBaseBoundSum = yfDrugApplyMapper.selectSumQuantity(code);
-            ypBaseBoundVo.setSevenDayDosage(ypBaseBoundSum.getSevenDayDosage());
-            ypBaseBoundVo.setThirtyDayDosage(ypBaseBoundSum.getThirtyDayDosage());
-            ypBaseBoundVo.setSixtyDayDosage(ypBaseBoundSum.getSixtyDayDosage());
-            ypBaseBoundVo.setFourteenDayDosage(ypBaseBoundSum.getFourteenDayDosage());
-            ypBaseBoundVo.setAvailableDay(Double.parseDouble(ypBaseBoundVo.getSevenDayDosage()==0?"0":ypBaseBoundVo.getStockAmount()/ypBaseBoundVo.getSevenDayDosage()+""));
         });
         return ypBaseBoundVos;
     }

+ 149 - 99
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpOutDetlServiceImpl.java

@@ -87,6 +87,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
     public List<YpOutDetlVo> queryYpOutDetlDetail(YpOutDetl ypOutDetl) {
         return ypOutDetlMapper.selectYpOutDetlDetail(ypOutDetl);
     }
+
     @Override
     public List<YpOutDetlVo> queryYpOutDetlGroup(YpOutDetl ypOutDetl) {
         return ypOutDetlMapper.selectYpOutDetlGroup(ypOutDetl);
@@ -119,9 +120,6 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
     @Override
     public int saveYpOutDetlList(Map<String, Object> map, String userId) throws MzException {
         List<Map<String, Object>> list = (List) map.get("list");
-        if(StringUtils.isNotBlank(list.get(0).get("drawNo").toString())){
-            ypOutDetlMapper.deleteByDrawYf(list.get(0).get("drawNo").toString());
-        }
         Map<String, Object> nmap = new HashMap<>();//各药品出库数量合计
         Map<String, List<Map<String, Object>>> glist = list.stream().collect(Collectors.groupingBy(e -> e.get("chargeCode").toString()));
         glist.forEach((k, slist) -> {
@@ -129,86 +127,10 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
                     StringUtils.isBlank(e.get("amountOut").toString()) ? 0 : Double.parseDouble(e.get("amountOut").toString())));
             nmap.put(slist.get(0).get("chargeCode").toString(), sumcc.getSum());
         });
-        Integer ykOutNo = ypConfigService.getNo("yk_out_no");
-        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
-        String str = "";
-        if (ykOutNo < 100) {
-            str = "00";
-        } else if (ykOutNo < 1000) {
-            str = "0";
-        }
-        String drawNo = sdf.format(new Date()) + str + ykOutNo;
-        int j = 1;
-
-        Date now = new Date();
-        for (int i = 0; i < list.size(); i++) {
-            Map m = list.get(i);
-            String chargeCode = m.get("chargeCode").toString();
-            String serial = m.get("serial").toString();
-            if (!(i > 0 && chargeCode.equals(list.get(i - 1).get("chargeCode").toString())
-                    && StringUtils.isBlank(m.get("drawNo").toString())) && StringUtils.isNotBlank(m.get("drawNo").toString())) {
-                YpInPlan ypInPlan = new YpInPlan();
-                ypInPlan.setStatusFlag("2");
-                ypInPlan.setChargeCode(chargeCode);
-                ypInPlan.setSerial(serial);
-                ypInPlan.setDrawNo(m.get("drawNo").toString());
-                ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
-                int num = ypInPlanMapper.updateYpInPlan(ypInPlan);
-                if (num <= 0) {
-                    throw new MzException("更新请领单记录异常!");
-                }
-            }
-            if (m.get("amountOut") != null && StringUtils.isNotBlank(m.get("amountOut").toString())) {
-                YpOutDetl ypOutDetl = new YpOutDetl();
-                ypOutDetl.setOutDate(now);
-                ypOutDetl.setOutSeri(j++);
-                ypOutDetl.setInDrawNo((String) m.get("inDocuNo"));
-                ypOutDetl.setInSeri(Integer.parseInt(m.get("inSeri").toString()));
-                ypOutDetl.setManuNo((String) m.get("manuNo"));
-                ypOutDetl.setDrawNo(drawNo);
-                if(StringUtils.isNotBlank(m.get("drawNo").toString())){
-                    YpInPlan inPlan = new YpInPlan();
-                    inPlan.setChargeCode((String) m.get("chargeCode"));
-                    inPlan.setSerial((String) m.get("serial"));
-                    inPlan.setDrawNo(m.get("drawNo").toString());
-                    YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
-                    ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
-                    ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
-                    ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
-                    ypOutDetl.setDrawYf(m.get("drawNo").toString());
-                }else{
-                    ypOutDetl.setGroupNo(map.get("groupNo").toString());
-                    ypOutDetl.setDrawer(userId);
-                    YpZdGroupName ypZdGroupName = new YpZdGroupName();
-                    ypZdGroupName.setDeptCode(map.get("deptCode").toString());
-                    List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameMapper.selectYpZdGroupNameList(ypZdGroupName);
-                    ypOutDetl.setGroupNoOut(ypZdGroupNames.size()>0?ypZdGroupNames.get(0).getGroupNo():null);
-                }
-                ypOutDetl.setDeptCode(map.get("deptCode").toString());
-                ypOutDetl.setChargeCode(chargeCode);
-                ypOutDetl.setSerial(serial);
-                YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(chargeCode, serial);
-                ypOutDetl.setPackRetprice(ypZdDict.getPackRetprice());
-                ypOutDetl.setOutAmt(StringUtils.isBlank(m.get("amountOut").toString()) ? 0 : Double.parseDouble(m.get("amountOut").toString()));
-                ypOutDetl.setKeeper(userId);
-                if(StringUtils.isNotBlank((String) m.get("effDate"))){
-                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-                    try {
-                        ypOutDetl.setEffDate(format.parse((String) m.get("effDate")));
-                    } catch (ParseException e) {
-                        throw new MzException("有效期转换异常!");
-                    }
-                }
-                ypOutDetl.setOutType((String) map.get("outType"));
-                Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypOutDetl.getGroupNo());
-                ypOutDetl.setStockAmount(Double.parseDouble(String.format("%.2f", stockAmount - ypOutDetl.getOutAmt())));
-                ypOutDetl.setBuyPrice(ypZdDict.getBuyPrice());
-                ypOutDetl.setInputId(userId);
-                ypOutDetl.setSysDate(now);
-                ypOutDetl.setAlloPrice(new BigDecimal(0));
-                ypOutDetl.setConfirmFlag("0");
-                ypOutDetlMapper.insertYpOutDetl(ypOutDetl);
-            }
+        if (map.get("editFlag").toString().equals("1")) {//修改
+            editYpOutDetlList(map, nmap);
+        } else {
+            newYpOutDetlList(map, nmap, userId);
         }
         return 0;
     }
@@ -224,7 +146,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
         } else if (ykOutNo < 1000) {
             str = "0";
         }
-        String drawNo = "T"+sdf.format(new Date()) + str + ykOutNo;
+        String drawNo = "T" + sdf.format(new Date()) + str + ykOutNo;
         Date date = new Date();
         for (int i = 0; i < list.size(); i++) {
             Map map = list.get(i);
@@ -238,18 +160,18 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
             ypInDetl.setCurrentStock(newOutAmt);
             ypInDetl.setInSeri(Integer.parseInt(map.get("inSeri").toString()));
             ypInDetl.setInDocuNo(map.get("inDrawNo").toString());
-            if(ypOutDetlMapper.updateYpOutDetl(ypOutDetl) != 1){
+            if (ypOutDetlMapper.updateYpOutDetl(ypOutDetl) != 1) {
                 throw new MzException("更新历史出库单异常!");
             }
-            if(ypInDetlMapper.updateYpInDetl(ypInDetl) != 1){
+            if (ypInDetlMapper.updateYpInDetl(ypInDetl) != 1) {
                 throw new MzException("更新历史入库单异常!");
             }
             Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetlVo.getChargeCode(), ypOutDetlVo.getSerial(), ypOutDetlVo.getGroupNo());
             YpOutDetl insertYpOutDetl = new YpOutDetl();
-            BeanUtils.copyProperties(ypOutDetlVo,insertYpOutDetl);
+            BeanUtils.copyProperties(ypOutDetlVo, insertYpOutDetl);
             insertYpOutDetl.setOutDate(date);
-            insertYpOutDetl.setOutSeri(i+1);
-            insertYpOutDetl.setDrawYf("T"+ypOutDetlVo.getDrawNo());
+            insertYpOutDetl.setOutSeri(i + 1);
+            insertYpOutDetl.setDrawYf("T" + ypOutDetlVo.getDrawNo());
             insertYpOutDetl.setDrawNo(drawNo);
             insertYpOutDetl.setKeeper(userId);
             insertYpOutDetl.setOutType("2");
@@ -262,11 +184,11 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
             insertYpOutDetl.setConfirmDate(date);
             insertYpOutDetl.setConfirmId(userId);
             insertYpOutDetl.setOutAmt(-newOutAmt);
-            if(ypOutDetlMapper.insertYpOutDetl(insertYpOutDetl) == 0){
+            if (ypOutDetlMapper.insertYpOutDetl(insertYpOutDetl) == 0) {
                 throw new MzException("新增出库记录异常!");
             }
-            if(ypBaseMapper.updateYpBaseStock(newOutAmt,newOutAmt*Double.parseDouble(map.get("packRetprice").toString()),
-                    insertYpOutDetl.getChargeCode(),insertYpOutDetl.getSerial(),insertYpOutDetl.getGroupNo()) != 1){
+            if (ypBaseMapper.updateYpBaseStock(newOutAmt, newOutAmt * Double.parseDouble(map.get("packRetprice").toString()),
+                    insertYpOutDetl.getChargeCode(), insertYpOutDetl.getSerial(), insertYpOutDetl.getGroupNo()) != 1) {
                 throw new MzException("更新库存异常!");
             }
         }
@@ -301,7 +223,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
                 ypOutDetl.setConfirmDate(now);
                 ypOutDetl.setDrawNo(ypOutDetlVo.getDrawNo());
                 ypOutDetlMapper.updateYpOutDetl(ypOutDetl);
-                if(StringUtils.isNotBlank(ypOutDetlVo.getDrawYf())){
+                if (StringUtils.isNotBlank(ypOutDetlVo.getDrawYf())) {
                     YpInPlan ypInPlan = new YpInPlan();
                     ypInPlan.setConfirmId(userId);
                     ypInPlan.setConfirmDate(now);
@@ -315,12 +237,12 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
 
     @Override
     public List<YpOutDetlVo> queryYpOutDetlDrugReturnPage(YpOutDetl ypOutDetl) {
-        List<YpOutDetlVo> ypOutDetlVos= new ArrayList<>();
+        List<YpOutDetlVo> ypOutDetlVos = new ArrayList<>();
         List<YpOutDetl> ypOutDetls = ypOutDetlMapper.selectYpOutDetlDrugReturnPage(ypOutDetl);
         for (int i = 0; i < ypOutDetls.size(); i++) {
             YpOutDetl yp = ypOutDetls.get(i);
             YpOutDetlVo ypOutDetlVo = new YpOutDetlVo();
-            BeanUtils.copyProperties(yp,ypOutDetlVo);
+            BeanUtils.copyProperties(yp, ypOutDetlVo);
             YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(yp.getChargeCode(), yp.getSerial());
             ypOutDetlVo.setName(ypZdDict.getName());
             ypOutDetlVo.setSpecification(ypZdDict.getSpecification());
@@ -333,7 +255,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
             String supplyName = ypZdSupplyMapper.selectNameByCode(ypInDetls.get(0).getSupplyCode());
             ypOutDetlVo.setSupplyName(supplyName);
             ypOutDetlVo.setKeeperName(employeeMapper.selectByUserCode(yp.getKeeper()).getEmployeeName());
-            if(StringUtils.isNotBlank(yp.getGroupNoOut())){
+            if (StringUtils.isNotBlank(yp.getGroupNoOut())) {
                 ypOutDetlVo.setGroupNoOutName(ypZdGroupNameMapper.selectByGroupNo(yp.getGroupNoOut()).getGroupName());
             }
             ypOutDetlVo.setOutType(OutTypeEnum.getOutTypeByCode(yp.getOutType()).name);
@@ -353,11 +275,139 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
         for (int i = 0; i < list.size(); i++) {
             Map<String, Object> stringObjectMap = list.get(i);
             YpZdDrugKind drugKind = ypZdDrugKindMapper.selectYpZdDrugKind(stringObjectMap.get("drugKind").toString());
-            stringObjectMap.put("kindName",drugKind.getName());
-            stringObjectMap.put("ypType",drugKind.getYpType());
+            stringObjectMap.put("kindName", drugKind.getName());
+            stringObjectMap.put("ypType", drugKind.getYpType());
             ZdUnitCode deptCode = zdUnitCodeMapper.selectByCode(stringObjectMap.get("deptCode").toString());
-            stringObjectMap.put("deptName",deptCode.getName());
+            stringObjectMap.put("deptName", deptCode.getName());
         }
         return list;
     }
+
+    /**
+     * 编辑出库单
+     *
+     * @param map
+     */
+    private void editYpOutDetlList(Map<String, Object> map, Map<String, Object> nmap) {
+        List<Map<String, Object>> list = (List) map.get("list");
+        YpInPlan ypInPlan = new YpInPlan();
+        String drawYf = ypOutDetlMapper.selectDrawYf(map.get("drawNo").toString());
+        for (int i = 0; i < list.size(); i++) {
+            Map<String, Object> stringObjectMap = list.get(i);
+            YpOutDetl ypOutDetl = new YpOutDetl();
+            ypOutDetl.setDrawNo(stringObjectMap.get("drawNo").toString());
+            ypOutDetl.setInDrawNo(stringObjectMap.get("inDocuNo").toString());
+            ypOutDetl.setChargeCode(stringObjectMap.get("chargeCode").toString());
+            ypOutDetl.setSerial(stringObjectMap.get("serial").toString());
+            ypOutDetl.setInSeri(Integer.parseInt(stringObjectMap.get("inSeri").toString()));
+            ypOutDetl.setOutAmt(Double.parseDouble(stringObjectMap.get("amountOut").toString()));
+            ypOutDetlMapper.updateYpOutDetl(ypOutDetl);
+            if (StringUtils.isNotBlank(drawYf)) {
+                ypInPlan.setDrawNo(drawYf);
+                ypInPlan.setChargeCode(ypOutDetl.getChargeCode());
+                ypInPlan.setSerial(ypOutDetl.getSerial());
+                ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
+                ypInPlanMapper.updateYpInPlan(ypInPlan);
+            }
+        }
+        List<Map<String, Object>> delList = (List) map.get("delList");
+        for (int i = 0; i < delList.size(); i++) {
+            Map<String, Object> data = delList.get(i);
+            ypOutDetlMapper.deleteYpOutDetl(data.get("drawNo").toString(), data.get("chargeCode").toString(), data.get("serial").toString());
+            ypInPlan.setDrawNo(drawYf);
+            ypInPlan.setChargeCode(data.get("chargeCode").toString());
+            ypInPlan.setSerial(data.get("serial").toString());
+            ypInPlan.setAmountOut(0.0);
+            ypInPlanMapper.updateYpInPlan(ypInPlan);
+        }
+    }
+
+    /**
+     * 新增出库单
+     *
+     * @param map
+     */
+    private void newYpOutDetlList(Map<String, Object> map, Map<String, Object> nmap, String userId) throws MzException {
+        List<Map<String, Object>> list = (List) map.get("list");
+        Integer ykOutNo = ypConfigService.getNo("yk_out_no");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        String str = "";
+        if (ykOutNo < 100) {
+            str = "00";
+        } else if (ykOutNo < 1000) {
+            str = "0";
+        }
+        String drawNo = sdf.format(new Date()) + str + ykOutNo;
+        int j = 1;
+        Date now = new Date();
+        for (int i = 0; i < list.size(); i++) {
+            Map m = list.get(i);
+            String chargeCode = m.get("chargeCode").toString();
+            String serial = m.get("serial").toString();
+            if (!(i > 0 && chargeCode.equals(list.get(i - 1).get("chargeCode").toString())
+                    && StringUtils.isBlank(m.get("drawNo").toString())) && StringUtils.isNotBlank(m.get("drawNo").toString())) {
+                YpInPlan ypInPlan = new YpInPlan();
+                ypInPlan.setStatusFlag("2");
+                ypInPlan.setChargeCode(chargeCode);
+                ypInPlan.setSerial(serial);
+                ypInPlan.setDrawNo(m.get("drawNo").toString());
+                ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
+                int num = ypInPlanMapper.updateYpInPlan(ypInPlan);
+                if (num <= 0) {
+                    throw new MzException("更新请领单记录异常!");
+                }
+            }
+            if (m.get("amountOut") != null && StringUtils.isNotBlank(m.get("amountOut").toString())) {
+                YpOutDetl ypOutDetl = new YpOutDetl();
+                ypOutDetl.setOutDate(now);
+                ypOutDetl.setOutSeri(j++);
+                ypOutDetl.setInDrawNo((String) m.get("inDocuNo"));
+                ypOutDetl.setInSeri(Integer.parseInt(m.get("inSeri").toString()));
+                ypOutDetl.setManuNo((String) m.get("manuNo"));
+                ypOutDetl.setDrawNo(drawNo);
+                if (StringUtils.isNotBlank(m.get("drawNo").toString())) {
+                    YpInPlan inPlan = new YpInPlan();
+                    inPlan.setChargeCode((String) m.get("chargeCode"));
+                    inPlan.setSerial((String) m.get("serial"));
+                    inPlan.setDrawNo(m.get("drawNo").toString());
+                    YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
+                    ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
+                    ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
+                    ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
+                    ypOutDetl.setDrawYf(m.get("drawNo").toString());
+                } else {
+                    ypOutDetl.setGroupNo(map.get("groupNo").toString());
+                    ypOutDetl.setDrawer(userId);
+                    YpZdGroupName ypZdGroupName = new YpZdGroupName();
+                    ypZdGroupName.setDeptCode(map.get("deptCode").toString());
+                    List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameMapper.selectYpZdGroupNameList(ypZdGroupName);
+                    ypOutDetl.setGroupNoOut(ypZdGroupNames.size() > 0 ? ypZdGroupNames.get(0).getGroupNo() : null);
+                }
+                ypOutDetl.setDeptCode(map.get("deptCode").toString());
+                ypOutDetl.setChargeCode(chargeCode);
+                ypOutDetl.setSerial(serial);
+                YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(chargeCode, serial);
+                ypOutDetl.setPackRetprice(ypZdDict.getPackRetprice());
+                ypOutDetl.setOutAmt(StringUtils.isBlank(m.get("amountOut").toString()) ? 0 : Double.parseDouble(m.get("amountOut").toString()));
+                ypOutDetl.setKeeper(userId);
+                if (StringUtils.isNotBlank((String) m.get("effDate"))) {
+                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+                    try {
+                        ypOutDetl.setEffDate(format.parse((String) m.get("effDate")));
+                    } catch (ParseException e) {
+                        throw new MzException("有效期转换异常!");
+                    }
+                }
+                ypOutDetl.setOutType((String) map.get("outType"));
+                Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypOutDetl.getGroupNo());
+                ypOutDetl.setStockAmount(Double.parseDouble(String.format("%.2f", stockAmount - ypOutDetl.getOutAmt())));
+                ypOutDetl.setBuyPrice(ypZdDict.getBuyPrice());
+                ypOutDetl.setInputId(userId);
+                ypOutDetl.setSysDate(now);
+                ypOutDetl.setAlloPrice(new BigDecimal(0));
+                ypOutDetl.setConfirmFlag("0");
+                ypOutDetlMapper.insertYpOutDetl(ypOutDetl);
+            }
+        }
+    }
 }

+ 49 - 25
src/main/resources/static/js/yk/drug_delivery.js

@@ -1,6 +1,7 @@
 //@ sourceURL=drug_delivery.js
 var groupNo = window.localStorage["groupYk"];//药房编码
 var outDetlList = [];//出库数据集
+var delDetlList = [];//删除出库数据集
 $(function () {
     init_daterangepicker();
     $('.datetime').datetimepicker({
@@ -43,6 +44,10 @@ $(function () {
                     }
                 }],
             onClickRow: function (row, $element) {
+                if($("#statusLabel").html() === '未审核'){
+                    warningMesageSimaple('出库单已确认,请另起一张新的出库单');
+                    return;
+                }
                 let dataRow = {
                     chargeCode: row['code'],
                     name: row['name'],
@@ -94,7 +99,7 @@ $(function () {
         if(isEmpty($("#deptCode").val())){
             return errorMesageSimaple('领药科室为空!');
         }
-        if (outDetlList == null || outDetlList.length === 0) {
+        if ((outDetlList == null || outDetlList.length === 0) && (delDetlList == null || delDetlList.length === 0)) {
             return errorMesageSimaple('没有可保存数据!');
         }
         var data = $("#tb_table_detailed").jqGrid("getRowData");
@@ -108,11 +113,13 @@ $(function () {
             url: '/saveYpOutDetlList',
             method: 'POST',
             data: JSON.stringify({
+                drawNo: $("#drawNoLabel").html(),
                 list: outDetlList,
+                delList: delDetlList,
                 outType: $("#outType1Search").val(),
                 deptCode: $("#deptCode").val()[0],
-                groupNo:groupNo
-                //drawNo: $("#drawNoLabel").html()
+                groupNo:groupNo,
+                editFlag: ($("#statusLabel").html() === '未审核')?1:0
             })
         }).then((res) => {
             $("#btn_clean").click();
@@ -154,6 +161,7 @@ $(function () {
         $("#tb_table_indetl_detailed").jqGrid('clearGridData');
         $("#tb_table_detailed").jqGrid('clearGridData');
         outDetlList = [];
+        delDetlList = [];
     });
 });
 
@@ -450,27 +458,29 @@ function initInDetlDetailed() {
             root: "data", repeatitems: false
         },
         beforeSubmitCell: function (rowid, cellname, cellvalue, iRow, iCol) {
-            let rowObject = $("#tb_table_indetl_detailed").getRowData(rowid);
-            let amountOut = 0;
-            rowObject.amountOut = cellvalue == '' ? 0 : parseFloat(cellvalue);
-            for (let i = 0; i < outDetlList.length; i++) {
-                let data = outDetlList[i];
-                if (data.inDocuNo === rowObject.inDocuNo && data.chargeCode === rowObject.chargeCode && data.manuNo === rowObject.manuNo) {
-                    outDetlList.splice(i, 1);
-                    break;
-                }
-            }
+            //let rowObject = $("#tb_table_indetl_detailed").getRowData(rowid);
             let rowId = $("#tb_table_detailed").jqGrid("getGridParam", "selrow");
             var rowData = $("#tb_table_detailed").jqGrid('getRowData', rowId);
-            rowObject.drawNo = rowData.drawNo;
-            outDetlList.push(rowObject);
-            //设置总出库量
             var data = $("#tb_table_indetl_detailed").jqGrid("getRowData");
-            for (let i = 0; i < data.length; i++) {
-                if (data[i].amountOut.length > 10) {
+            let amountOut = 0;//总出库量
+            for (let j = 0; j < data.length; j++) {
+                let rowObject = data[j];
+                for (let i = 0; i < outDetlList.length; i++) {
+                    let data = outDetlList[i];
+                    if (data.inDocuNo === rowObject.inDocuNo && data.chargeCode === rowObject.chargeCode && data.manuNo === rowObject.manuNo) {
+                        outDetlList.splice(i, 1);
+                        break;
+                    }
+                }
+                rowObject.drawNo = rowData.drawNo;
+                if(rowid == (j+1)){
+                    rowObject.amountOut = cellvalue == '' ? 0 : parseFloat(cellvalue);
+                }
+                outDetlList.push(rowObject);
+                if (rowObject.amountOut.length > 10) {
                     amountOut += rowObject.amountOut;
                 } else {
-                    amountOut += parseFloat(data[i].amountOut == '' ? 0 : data[i].amountOut)
+                    amountOut += parseFloat(rowObject.amountOut == '' ? 0 : rowObject.amountOut)
                 }
             }
             $("#tb_table_detailed").jqGrid('setCell', rowId, "amountOut", amountOut);
@@ -520,7 +530,7 @@ function initDetailed() {
         sortable: false,
         loadonce: false, //一次加载全部数据到客户端,由客户端进行排序。
         cellsubmit: "remote",
-        colNames: ['请领单号', '药品编码', '药品名称', '规格', '零售价', '请领数量', '出库量', '金额', '基本药物', 'serial'],
+        colNames: ['单号', '药品编码', '药品名称', '规格', '零售价', '请领数量', '出库量', '金额', '基本药物', 'serial'],
         colModel: [
             {name: 'drawNo', index: 'drawNo', align: 'center'},
             {name: 'chargeCode', index: 'chargeCode', align: 'center'},
@@ -555,6 +565,7 @@ function initDetailed() {
             root: "data", repeatitems: false
         },
         onCellSelect: function (rowid, iCol, cellcontent, e) {
+            selectRowId = rowid;
             loadInDetlDetailed($("#tb_table_detailed").getRowData(rowid));
         },
         loadComplete: function (res) { //加载完成(初始加载),回调函数
@@ -587,13 +598,26 @@ function initDetailed() {
             }
         }
     });
+    $("#t_tb_table_detailed").append("<button class='registration-no-color-foot-button' title='删除药品' id='remove'  style='color: red;margin-left: 10px;'><i class='fa fa-trash-o'></i></button>");
     $("#t_tb_table_detailed").append("<input id='drugName' name='drugName' type='text' style='margin-left: 10px;' placeholder='添加药品...'>");
-    //$("#t_tb_table_detailed").append("<button class='registration-no-color-foot-button' title='删除药品' id='remove'  style='color: red;margin-left: 10px;'><i class='fa fa-trash-o'></i></button>");
     $("#remove").on('click', function () {
         if (selectRowId == null) {
-            return errorMesageSimaple('请选择一行进行删除!');
+            return warningMesageSimaple('请选择一行进行删除!');
+        }
+        let selectRowData = $("#tb_table_detailed").jqGrid("getRowData", selectRowId);
+        console.log(selectRowData);
+        if(!isEmpty(selectRowData.drawNo)){
+            delDetlList.push(selectRowData);
+        }
+        for (let i = 0; i < outDetlList.length; i++) {
+            if(outDetlList[i].chargeCode == selectRowData.chargeCode && outDetlList[i].serial == selectRowData.serial){
+                outDetlList.splice(i, 1);
+                break;
+            }
         }
         $("#tb_table_detailed").jqGrid("delRowData", selectRowId);
+        selectRowId = null;
+        console.log(delDetlList);
     });
 }
 
@@ -640,7 +664,7 @@ function setPrintHtml() {
             html += '<td class="xtd" style="text-align: center;">' + data['manuNo'] + '</td>';
             html += '<td class="xtd" style="text-align: left;">' + data['manufactoryName'] + '</td>';
             html += '<td class="xtd" style="text-align: center;">' + format(data['effDate'], "yyyy-MM-dd") + '</td>';
-            html += '<td class="xtd" style="text-align: center;">' + data['stockAmount'] + '</td>';
+            html += '<td class="xtd" style="text-align: center;">' + keepTwoDecimal(data['stockAmount']) + '</td>';
             html += '</tr>';
         }
         $("#base_tr").after(html);
@@ -656,8 +680,8 @@ function setPrintHtml() {
 function print() {
     setDefaultPrint();
     LODOP = getLodop();
-    LODOP.PRINT_INITA(6, 0, "221mm", "93mm", "出库单打印");
-    LODOP.SET_PRINT_PAGESIZE(1, "221mm", "93mm", "");
+    LODOP.PRINT_INITA(6, 0, "226mm", "280mm", "出库单打印");
+    LODOP.SET_PRINT_PAGESIZE(1, "226mm", "280mm", "");
     //设置默认打印机
     LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
     LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小

+ 21 - 0
src/main/resources/static/js/yk/drug_stock_up_down.js

@@ -53,6 +53,10 @@ function resetSearch() {
     $("#visibleFlag").selectpicker('refresh');
 }
 
+$('#export_excel').on('click',function(e){
+    exportExcel();
+});
+
 /**
  * 药品上下限查询列表
  */
@@ -248,4 +252,21 @@ function modifMaxMiniStockAmount(chargeCode, serial, maxStockAmount, miniStockAm
     }).then((res) => {
         successMesage(res);
     })
+}
+
+
+/**
+ * 导出excel
+ */
+function exportExcel() {
+    $("#export_excel").attr("disabled",true);
+    $("#export_excel").html("<span>Loading..</span>");
+    let net = window.open("/thmz/excelYpBaseBound?groupNo=" + groupYk+"&chargeCode="+$("#chargeCode").val()
+        +"&beyondFlag="+($("#beyondFlag").prop('checked') ? 1 : 0)+"&visibleFlag="+$("#visibleFlag").val()
+        +"&pageSize="+$("#tb_table_bound").bootstrapTable("getOptions").totalRows+"&pageIndex=0");
+    net.addEventListener("beforeunload", (e) => {
+        $("#export_excel").html("<i class=\"fa fa-file-excel-o\"></i>");
+        $("#export_excel").attr("disabled",false);
+    });
+    //window.location.href = "/thmz/excelYpBaseBound?groupNo=" + groupYk+"&chargeCode="+$("#chargeCode").val()+"&beyondFlag="+($("#beyondFlag").prop('checked') ? 1 : 0)+"&visibleFlag="+$("#visibleFlag").val();
 }

+ 4 - 4
src/main/resources/static/js/yk/drug_storage.js

@@ -792,8 +792,8 @@ function setPrintHtml() {
 function print() {
     setDefaultPrint();
     LODOP = getLodop();
-    LODOP.PRINT_INITA(6, 0, "221mm", "93mm", "入库单打印");
-    LODOP.SET_PRINT_PAGESIZE(1, "221mm", "93mm", "");
+    LODOP.PRINT_INITA(6, 0, "215mm", "280mm", "入库单打印");
+    LODOP.SET_PRINT_PAGESIZE(1, "215mm", "280mm", "");
     //设置默认打印机
     LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
     LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
@@ -801,6 +801,6 @@ function print() {
     var strStyle = "<style>table,td,th {border-width: 1px;padding-bottom:0px;" +
         "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 13}.xtd{border: 1px solid black;}</style>";
     LODOP.ADD_PRINT_HTM("0mm", "0mm", "RightMargin:0mm", "BottomMargin:0mm", strStyle + document.getElementById("report_table_1").innerHTML);
-    LODOP.PRINT();
-    //LODOP.PREVIEW();
+    //LODOP.PRINT();
+    LODOP.PREVIEW();
 }

+ 3 - 0
src/main/resources/templates/yk/drug_stock_up_down.html

@@ -42,6 +42,9 @@
                         <button type="button" id="btn_reset" class="btn btn-primary"
                                 title="重置" onclick="resetSearch()"><i class="fa fa-rotate-left"></i>
                         </button>
+                        <button type="button" id="export_excel" class="btn btn-primary"
+                                title="导出Excel"><i class="fa fa-file-excel-o"></i>
+                        </button>
                     </div>
                 </form>
             </div>

+ 5 - 5
src/main/resources/templates/yk/drug_storage.html

@@ -81,16 +81,16 @@
                         </tr>
                         <tr id="base_tr">
                             <td class="xtd" style="text-align: center;width: 50px;">编码</td>
-                            <td class="xtd" style="text-align: center;width: 120px;">药品名称</td>
+                            <td class="xtd" style="text-align: center;width: 110px;">药品名称</td>
                             <td class="xtd" style="text-align: center;width: 100px;">规格</td>
                             <td class="xtd" style="text-align: center;width: 50px;">购入量</td>
                             <td class="xtd" style="text-align: center;width: 50px;">购入价</td>
                             <td class="xtd" style="text-align: center;width: 50px;">零售价</td>
-                            <td class="xtd" style="text-align: center;width: 50px;">购入金额</td>
-                            <td class="xtd" style="text-align: center;width: 50px;">零售金额</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">购入金额</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">零售金额</td>
                             <td class="xtd" style="text-align: center;width: 60px;">生产批号</td>
-                            <td class="xtd" style="text-align: center;width: 120px;">生产厂家</td>
-                            <td class="xtd" style="text-align: center;width: 80px;">有效期</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">生产厂家</td>
+                            <td class="xtd" style="text-align: center;width: 70px;">有效期</td>
                         </tr>
                         <tr style="border: transparent !important;"></tr>
                         <tr>