|
@@ -97,6 +97,25 @@ func (c *ScheduleApiController) CoverSch() {
|
97
|
97
|
id_one, _ := c.GetInt64("id_one")
|
98
|
98
|
id_two, _ := c.GetInt64("id_two")
|
99
|
99
|
sch, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_one)
|
|
100
|
+ orgId := c.GetAdminUserInfo().CurrentOrgId
|
|
101
|
+ //针对凤凰医院
|
|
102
|
+ if orgId == 10579 || orgId == 10344 || orgId == 10206 {
|
|
103
|
+ advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
|
|
104
|
+ if len(advice) > 0 {
|
|
105
|
+ service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
|
|
106
|
+ }
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ if orgId == 10206 || orgId == 10344 {
|
|
110
|
+ hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
|
|
111
|
+ project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, orgId)
|
|
112
|
+ if len(hisAdvice) > 0 {
|
|
113
|
+ service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
|
|
114
|
+ }
|
|
115
|
+ if len(project) > 0 {
|
|
116
|
+ service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, orgId)
|
|
117
|
+ }
|
|
118
|
+ }
|
100
|
119
|
sch_two, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_two)
|
101
|
120
|
//order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
|
102
|
121
|
//if order.ID > 0 {
|
|
@@ -714,6 +733,24 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
|
714
|
733
|
}
|
715
|
734
|
|
716
|
735
|
schedule.Status = 0
|
|
736
|
+ //针对凤凰医院
|
|
737
|
+ if adminInfo.CurrentOrgId == 10579 || adminInfo.CurrentOrgId == 10344 || adminInfo.CurrentOrgId == 10206 {
|
|
738
|
+ advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
739
|
+ if len(advice) > 0 {
|
|
740
|
+ service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
741
|
+ }
|
|
742
|
+ }
|
|
743
|
+
|
|
744
|
+ if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
|
|
745
|
+ hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
746
|
+ project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
747
|
+ if len(hisAdvice) > 0 {
|
|
748
|
+ service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
749
|
+ }
|
|
750
|
+ if len(project) > 0 {
|
|
751
|
+ service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
|
|
752
|
+ }
|
|
753
|
+ }
|
717
|
754
|
service.SaveSch(&schedule)
|
718
|
755
|
}
|
719
|
756
|
HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
|
|
@@ -1985,6 +2022,144 @@ func (c *ScheduleApiController) DeleteSchedule() {
|
1985
|
2022
|
|
1986
|
2023
|
schedule.Status = 0
|
1987
|
2024
|
schedule.UpdatedTime = time.Now().Unix()
|
|
2025
|
+
|
|
2026
|
+ //如果使用的是保存出库功能
|
|
2027
|
+ drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
|
|
2028
|
+ //退库
|
|
2029
|
+ if drugOutConfig.IsOpen == 1 {
|
|
2030
|
+ hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
|
|
2031
|
+ for _, item := range hisAdvice {
|
|
2032
|
+ creater := adminINfo.AdminUser.Id
|
|
2033
|
+ err = service.DrugAutoAddCancelInfo(item, creater)
|
|
2034
|
+ if err != nil {
|
|
2035
|
+ err = fmt.Errorf("!:%v", err)
|
|
2036
|
+ return
|
|
2037
|
+ }
|
|
2038
|
+ }
|
|
2039
|
+ //查询是否有出库记录
|
|
2040
|
+ service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
|
|
2041
|
+ }
|
|
2042
|
+
|
|
2043
|
+ //查询该患者当天是否开耗材
|
|
2044
|
+ list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
|
|
2045
|
+ if len(list) > 0 {
|
|
2046
|
+
|
|
2047
|
+ operation_time := time.Now().Unix()
|
|
2048
|
+ creater := c.GetAdminUserInfo().AdminUser.Id
|
|
2049
|
+ //创建退库单
|
|
2050
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
2051
|
+ timeArr := strings.Split(timeStr, "-")
|
|
2052
|
+ total, _ := service.FindAllCancelStockTotal(c.GetAdminUserInfo().CurrentOrgId)
|
|
2053
|
+ total = total + 1
|
|
2054
|
+ orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
|
|
2055
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
|
|
2056
|
+ cancelStock := models.CancelStock{
|
|
2057
|
+ OrderNumber: orderNumber,
|
|
2058
|
+ OperaTime: operation_time,
|
|
2059
|
+ OrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
2060
|
+ Creater: creater,
|
|
2061
|
+ Ctime: time.Now().Unix(),
|
|
2062
|
+ Status: 1,
|
|
2063
|
+ ReturnTime: schedule.ScheduleDate,
|
|
2064
|
+ Type: 1,
|
|
2065
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
2066
|
+ IsCheck: 1,
|
|
2067
|
+ }
|
|
2068
|
+ _, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, c.GetAdminUserInfo().CurrentOrgId)
|
|
2069
|
+ if msgerrkonde == gorm.ErrRecordNotFound {
|
|
2070
|
+ service.AddSigleCancelStock(&cancelStock)
|
|
2071
|
+ }
|
|
2072
|
+ cancel, _ := service.GetLastCancelStockById(c.GetAdminUserInfo().CurrentOrgId)
|
|
2073
|
+ //进行退库操作
|
|
2074
|
+ for _, item := range list {
|
|
2075
|
+ good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
|
|
2076
|
+ manufacturer, _ := service.GetManufactureById(item.Manufacturer)
|
|
2077
|
+ deaerler, _ := service.GetDealerById(item.Dealer)
|
|
2078
|
+ //回退库存
|
|
2079
|
+ service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
|
|
2080
|
+ goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId)
|
|
2081
|
+ var flush_count int64
|
|
2082
|
+ for _, it := range goodList {
|
|
2083
|
+ flush_count += it.StockCount
|
|
2084
|
+ }
|
|
2085
|
+ cancelStockInfo := models.CancelStockInfo{
|
|
2086
|
+ GoodId: item.GoodId,
|
|
2087
|
+ CancelStockId: cancel.ID,
|
|
2088
|
+ GoodTypeId: good.GoodTypeId,
|
|
2089
|
+ Count: item.Count,
|
|
2090
|
+ Price: item.Price,
|
|
2091
|
+ Total: 0,
|
|
2092
|
+ ProductDate: item.ProductDate,
|
|
2093
|
+ ExpiryDate: item.ExpiryDate,
|
|
2094
|
+ Ctime: time.Now().Unix(),
|
|
2095
|
+ Status: 1,
|
|
2096
|
+ OrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
2097
|
+ OrderNumber: cancel.OrderNumber,
|
|
2098
|
+ Type: 0,
|
|
2099
|
+ Dealer: deaerler.DealerName,
|
|
2100
|
+ Manufacturer: manufacturer.ManufacturerName,
|
|
2101
|
+ Number: item.Number,
|
|
2102
|
+ RegisterAccount: "",
|
|
2103
|
+ Remark: "",
|
|
2104
|
+ WarehouseInfoId: item.WarehouseInfotId,
|
|
2105
|
+ PatientId: item.PatientId,
|
|
2106
|
+ RecordDate: item.SysRecordTime,
|
|
2107
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
2108
|
+ IsCheck: 1,
|
|
2109
|
+ }
|
|
2110
|
+
|
|
2111
|
+ service.CreateCancelStockInfoOne(&cancelStockInfo)
|
|
2112
|
+
|
|
2113
|
+ cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
|
|
2114
|
+
|
|
2115
|
+ flow := models.VmStockFlow{
|
|
2116
|
+ WarehousingId: item.WarehouseInfotId,
|
|
2117
|
+ GoodId: item.GoodId,
|
|
2118
|
+ Number: item.Number,
|
|
2119
|
+ LicenseNumber: item.LicenseNumber,
|
|
2120
|
+ Count: item.Count,
|
|
2121
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
2122
|
+ PatientId: item.PatientId,
|
|
2123
|
+ SystemTime: item.SysRecordTime,
|
|
2124
|
+ ConsumableType: 7,
|
|
2125
|
+ IsSys: 0,
|
|
2126
|
+ WarehousingOrder: "",
|
|
2127
|
+ WarehouseOutId: item.WarehouseOutId,
|
|
2128
|
+ WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
|
|
2129
|
+ IsEdit: 0,
|
|
2130
|
+ CancelStockId: cancel.ID,
|
|
2131
|
+ CancelOrderNumber: cancel.OrderNumber,
|
|
2132
|
+ Manufacturer: manufacturer.ID,
|
|
2133
|
+ Dealer: 0,
|
|
2134
|
+ Creator: c.GetAdminUserInfo().CurrentOrgId,
|
|
2135
|
+ UpdateCreator: 0,
|
|
2136
|
+ Status: 1,
|
|
2137
|
+ Ctime: time.Now().Unix(),
|
|
2138
|
+ Mtime: 0,
|
|
2139
|
+ Price: item.Price,
|
|
2140
|
+ WarehousingDetailId: item.WarehouseInfotId,
|
|
2141
|
+ WarehouseOutDetailId: item.ID,
|
|
2142
|
+ CancelOutDetailId: cancelInfo.ID,
|
|
2143
|
+ ProductDate: item.ProductDate,
|
|
2144
|
+ ExpireDate: item.ExpiryDate,
|
|
2145
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
2146
|
+ OverCount: flush_count,
|
|
2147
|
+ }
|
|
2148
|
+ service.CreateStockFlowOne(flow)
|
|
2149
|
+
|
|
2150
|
+ //退库数量增加
|
|
2151
|
+ service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
|
|
2152
|
+ //出库数量减少
|
|
2153
|
+ service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
|
|
2154
|
+
|
|
2155
|
+ //更新库存
|
|
2156
|
+ service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
|
|
2157
|
+
|
|
2158
|
+ //更新基础库库存
|
|
2159
|
+ service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
|
|
2160
|
+ }
|
|
2161
|
+ }
|
|
2162
|
+
|
1988
|
2163
|
err = service.UpdateSchedule(schedule)
|
1989
|
2164
|
|
1990
|
2165
|
//记录日志
|
|
@@ -2023,23 +2198,6 @@ func (c *ScheduleApiController) DeleteSchedule() {
|
2023
|
2198
|
}
|
2024
|
2199
|
}
|
2025
|
2200
|
|
2026
|
|
- //如果使用的是保存出库功能
|
2027
|
|
- drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
|
2028
|
|
- //退库
|
2029
|
|
- if drugOutConfig.IsOpen == 1 {
|
2030
|
|
- hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
|
2031
|
|
- for _, item := range hisAdvice {
|
2032
|
|
- creater := adminINfo.AdminUser.Id
|
2033
|
|
- err = service.DrugAutoAddCancelInfo(item, creater)
|
2034
|
|
- if err != nil {
|
2035
|
|
- err = fmt.Errorf("!:%v", err)
|
2036
|
|
- return
|
2037
|
|
- }
|
2038
|
|
- }
|
2039
|
|
- //查询是否有出库记录
|
2040
|
|
- service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
|
2041
|
|
- }
|
2042
|
|
-
|
2043
|
2201
|
redis := service.RedisClient()
|
2044
|
2202
|
|
2045
|
2203
|
//处方
|